📄 packet_out.c
字号:
/* Kernel AODV v2.0National Institute of Standards and Technology Luke Klein-Berndt----------------------------------------------------- Version 2.0 new features: * Updated to AODV draft version 11 * Managed internet gatewaying * Monitor wireles signal strength * Many bug fixes!-----------------------------------------------------Originally based upon MadHoc code. I am notsure how much of it is left anymore, but MadHocproved to be a great starting point.MadHoc was written by - Fredrik Lilieblad,Oskar Mattsson, Petra Nylund, Dan Ouchterlonyand Anders Roxenhag Mail: mad-hoc@flyinglinux.netThis software is Open Source under the GNU General Public Licence.*/#include "packet_out.h"/**************************************************** packet_out----------------------------------------------------All packets going out of the computer getintercepted by netfilter and passed to thisfunction.****************************************************/extern u_int32_t g_my_ip;extern u_int32_t g_broadcast_ip;extern struct nf_hook_ops output_filter;/**************************************************** output_handler----------------------------------------------------Looks at all the packets leaving the computer****************************************************/unsigned int output_handler( unsigned int hooknum,struct sk_buff **skb,const struct net_device *in, const struct net_device *out, int (*okfn)(struct sk_buff *)){ struct iphdr *ip; struct route_table_entry *tmp_route; struct net_device *dev; // get some useful pointers ip = (*skb)->nh.iph; dev = (*skb)->dev;#ifdef TRACE printk("PACKET_OUT: entered\n");#endif if (ip->daddr==g_broadcast_ip) {#ifdef TRACE printk("PACKET_OUT: Broadcast Packet - exit\n");#endif return NF_ACCEPT; } if (adhoc_subnet_test(ip->daddr)) { //Try to get a route to the destination tmp_route=find_route_table_entry(ip->daddr); //If the there is no route or it is marked for deletion if ((tmp_route==NULL) || !(tmp_route->route_valid)) { //if it is a broadcast message //it is a unknown route time to find a new one#ifdef MESSAGES printk("PACKET_OUT: Couldn't find a route to: %s, sending out a RREQ!\n",inet_ntoa(ip->daddr));#endif gen_rreq(g_my_ip,ip->daddr);#ifdef TRACE printk("PACKET_OUT: Tried to find route exited\n");#endif return NF_QUEUE; } else { tmp_route->lifetime = MAX(tmp_route->lifetime,getcurrtime() + ACTIVE_ROUTE_TIMEOUT); #ifdef TRACE printk("PACKET_OUT: Have route updated timer -exited \n"); #endif return NF_ACCEPT; } } else return NF_ACCEPT;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -