| <div class="dp-highlighter bg_cpp">?<div class="bar">
 <div class="tools">
 [cpp]?<a class="ViewSource" title="view plain" href="http://blog.csdn.net/geekcome/article/details/7492423">view plain<a class="CopyToClipboard" title="copy" href="http://blog.csdn.net/geekcome/article/details/7492423">copy
 
?
??
{??h.iph;???????sock?*raw_sk=NULL;??
????unsigned??flag?=?0;??
?????inet_protocol?*ipprot;??
??
?????is_frag=0;??
?????err;??
??
??
?
??ip_hdr?=?iph;????
?
?
?
??
?????(skb->len<(?iphdr)?||?iph->ihl<5?||?iph->version?!=?4?||??lentot_len)?||?ip_fast_csum((unsigned??*)iph,?iph->ihl)?!=0)??????{??
????????kfree_skb(skb,?FREE_WRITE);??
????}??
?????
??
??
?????((err=ip_fw_chk(iph,dev,ip_fw_blk_chain,ip_fw_blk_policy,?0))!=1)??
????????(err==-1)??
????????kfree_skb(skb,?FREE_WRITE);??
????}??
??
?????
?
??len=ntohs(iph->tot_len);????
?
??
?????(iph->ihl?!=?5)??
????????memset((?*)?&opt,?(opt));??
?????????????0;??
????}??
?????
??
????(iph->frag_off)??
?????????(iph->frag_off?&?0x0020)??
?????????
??
?????????(ntohs(iph->frag_off)?&?0x1fff)??
????}??
?????
?
?
?
?
??
?????(?iph->daddr?!=?skb->dev->pa_addr?&&?(brd?=?ip_chk_addr(iph->daddr))?==?0)??
?????????
??
????????(skb->pkt_type!=PACKET_HOST?||?brd==IS_BROADCAST)??
????????????kfree_skb(skb,FREE_WRITE);??
????????}??
?????????
??
??
??
saddr,iph->daddr);*/??
??
?
??
????????kfree_skb(skb,?FREE_WRITE);??
????}??
??
????(brd==IS_MULTICAST?&&?iph->daddr!=IGMP_ALL_HOSTS?&&?!(dev->flags&IFF_LOOPBACK))??
?????????
??ip_mc_list;????????????
????????????(ip_mc==NULL)??
????????????????kfree_skb(skb,?FREE_WRITE);??
????????????}??multiaddr==iph->daddr)??????????????????;??next;??????????}??
????}??
?????
??
??
??
?????
??
????(is_frag)??
??????????
????????(skb==NULL)??
????????skb->dev?=?dev;??h.iph;??????}??
???????????
?????
??
????skb->ip_hdr?=?iph;??h.raw?+=?iph->ihl*4;????????
?
???????protocol?&?(SOCK_ARRAY_SIZE-1);????????
????((raw_sk=raw_prot.sock_array[hash])!=NULL)??
?????????sock?*sknext=NULL;??
????????raw_sk=get_sock_raw(raw_sk,?hash,??iph->saddr,?iph->daddr);??
????????{??
????????????{??
????????????????sknext=get_sock_raw(raw_sk->next,?iph->saddr,?iph->daddr);??
????????????????????skb1=skb_clone(skb,?GFP_ATOMIC);??
????????????????????;????
????????????????????raw_rcv(raw_sk,?skb1,iph->daddr);??
????????????}??
??????????????
????????}??
??????
h.raw?now?points?at?the?protocol?beyond?the?IP?header.?
??protocol?&?(MAX_INET_PROTOS?-1);???????(ipprot?=?(?inet_protocol?*)inet_protos[hash];ipprot?!=?NULL;ipprot=(?inet_protocol?*)ipprot->next)??
?????????sk_buff?*skb2;??
?????????(ipprot->protocol?!=?iph->protocol)??
????????
?
?
?????????(ipprot->copy?||?raw_sk)??
????????????skb2?=?skb_clone(skb,?GFP_ATOMIC);??
????????????????;??
??????????
????????????skb2?=?skb;??
????????flag?=?1;??
????????????
?
??handler(skb2,?opts_p???&opt?:?0,?iph->daddr,??????????????????(ntohs(iph->tot_len)?-?(iph->ihl?*?4)),??saddr,?ipprot);????
??
?
?
??
????(raw_sk!=NULL)??????daddr);????????(!flag)???????
?????????(brd?!=?IS_BROADCAST?&&?brd!=IS_MULTICAST)??
??
}?? 
3、传输层 如果在IP数据报的首部标明的是使用TCP传输数据,则在上述函数中会调用tcp_rcv函数。该函数的大体处理流程为: (编辑:鹰潭站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |