|
Lines 120-125
Link Here
|
| 120 |
.notifier_call = handle_netdev_event, |
120 |
.notifier_call = handle_netdev_event, |
| 121 |
}; |
121 |
}; |
| 122 |
|
122 |
|
|
|
123 |
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31) |
| 124 |
static const struct net_device_ops vpn_netdev_ops = { |
| 125 |
.ndo_start_xmit = interceptor_tx, |
| 126 |
.ndo_get_stats = interceptor_stats, |
| 127 |
.ndo_do_ioctl = interceptor_ioctl, |
| 128 |
}; |
| 129 |
#endif |
| 130 |
|
| 123 |
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22) |
131 |
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22) |
| 124 |
static int |
132 |
static int |
| 125 |
#else |
133 |
#else |
|
Lines 128-137
Link Here
|
| 128 |
interceptor_init(struct net_device *dev) |
136 |
interceptor_init(struct net_device *dev) |
| 129 |
{ |
137 |
{ |
| 130 |
ether_setup(dev); |
138 |
ether_setup(dev); |
| 131 |
|
139 |
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31) |
|
|
140 |
dev->netdev_ops = &vpn_netdev_ops; |
| 141 |
#else |
| 132 |
dev->hard_start_xmit = interceptor_tx; |
142 |
dev->hard_start_xmit = interceptor_tx; |
| 133 |
dev->get_stats = interceptor_stats; |
143 |
dev->get_stats = interceptor_stats; |
| 134 |
dev->do_ioctl = interceptor_ioctl; |
144 |
dev->do_ioctl = interceptor_ioctl; |
|
|
145 |
#endif |
| 135 |
|
146 |
|
| 136 |
dev->mtu = ETH_DATA_LEN-MTU_REDUCTION; |
147 |
dev->mtu = ETH_DATA_LEN-MTU_REDUCTION; |
| 137 |
kernel_memcpy(dev->dev_addr, interceptor_eth_addr,ETH_ALEN); |
148 |
kernel_memcpy(dev->dev_addr, interceptor_eth_addr,ETH_ALEN); |
|
Lines 268-275
Link Here
|
| 268 |
Bindings[i].original_mtu = dev->mtu; |
279 |
Bindings[i].original_mtu = dev->mtu; |
| 269 |
|
280 |
|
| 270 |
/*replace the original send function with our send function */ |
281 |
/*replace the original send function with our send function */ |
|
|
282 |
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31) |
| 283 |
Bindings[i].InjectSend = dev->netdev_ops->ndo_start_xmit; |
| 284 |
dev->netdev_ops->ndo_start_xmit = replacement_dev_xmit; |
| 285 |
#else |
| 271 |
Bindings[i].InjectSend = dev->hard_start_xmit; |
286 |
Bindings[i].InjectSend = dev->hard_start_xmit; |
| 272 |
dev->hard_start_xmit = replacement_dev_xmit; |
287 |
dev->hard_start_xmit = replacement_dev_xmit; |
|
|
288 |
#endif |
| 273 |
|
289 |
|
| 274 |
/*copy in the ip packet handler function and packet type struct */ |
290 |
/*copy in the ip packet handler function and packet type struct */ |
| 275 |
Bindings[i].InjectReceive = original_ip_handler.orig_handler_func; |
291 |
Bindings[i].InjectReceive = original_ip_handler.orig_handler_func; |
|
Lines 291-297
Link Here
|
| 291 |
if (b) |
307 |
if (b) |
| 292 |
{ |
308 |
{ |
| 293 |
rc = 0; |
309 |
rc = 0; |
|
|
310 |
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31) |
| 311 |
dev->netdev_ops->ndo_start_xmit = b->InjectSend; |
| 312 |
#else |
| 294 |
dev->hard_start_xmit = b->InjectSend; |
313 |
dev->hard_start_xmit = b->InjectSend; |
|
|
314 |
#endif |
| 295 |
kernel_memset(b, 0, sizeof(BINDING)); |
315 |
kernel_memset(b, 0, sizeof(BINDING)); |
| 296 |
} |
316 |
} |
| 297 |
else |
317 |
else |