00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "packet_out.h"
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 extern struct route_table_entry *g_my_entry;
00037 extern u_int32_t g_my_ip;
00038 extern u_int32_t g_broadcast_ip;
00039 extern struct nf_hook_ops output_filter;
00040
00041 #ifdef AODV_MULTICAST
00042 static u_int16_t temp_id=0;
00043 #endif
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053 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 *))
00054 {
00055 struct iphdr *ip;
00056 struct route_table_entry *tmp_route;
00057 struct net_device *dev;
00058
00059
00060
00061 ip = (*skb)->nh.iph;
00062 dev = (*skb)->dev;
00063
00064 #ifdef AODV_MULTICAST
00065 if(hooknum==NF_IP_LOCAL_OUT)
00066 {
00067 if ( (multicast_test(ip->daddr)) && (ip->id==0) && (ip->ttl!=0))
00068 {
00069 temp_id++;
00070 ip->id=htons(temp_id);
00071 ip->check = 0;
00072
00073
00074 ip->check = ip_fast_csum((unsigned char *) ip, ip->ihl);
00075 }
00076 }
00077 #endif
00078
00079
00080 #ifdef AODV_MULTICAST
00081 if (multicast_test(ip->daddr) || (ip->daddr==g_broadcast_ip) )
00082 #else
00083 if (ip->daddr==g_broadcast_ip)
00084 #endif
00085 {
00086 monitor.bytes=(*skb)->len + monitor.bytes;
00087 monitor.packets++;
00088 return NF_ACCEPT;
00089 }
00090
00091
00092 tmp_route=find_route_table_entry(ip->daddr);
00093
00094
00095 #ifdef AODV_GATEWAY
00096 if (adhoc_subnet_test(ip->daddr) &&( (tmp_route==NULL) || !(tmp_route->route_valid)))
00097 #else
00098 if ( (tmp_route==NULL) || !(tmp_route->route_valid))
00099 #endif
00100 {
00101 printk("Generating a RREQ for: %s\n",inet_ntoa(ip->daddr));
00102 gen_rreq(g_my_ip,ip->daddr);
00103 return NF_QUEUE;
00104 }
00105
00106 if ((tmp_route!=NULL) && (tmp_route->route_valid))
00107 tmp_route->lifetime = MAX(tmp_route->lifetime,getcurrtime() + ACTIVE_ROUTE_TIMEOUT);
00108
00109 monitor.bytes=(*skb)->len + monitor.bytes;
00110 monitor.packets++;
00111 return NF_ACCEPT;
00112 }
00113