linux/net/core/flow_dissector.c
<<
on v14./spa 14./form 14.a on v14 href="../linux+v3.7.3/net/core/flow_dissector.c">on v14.img src="../.static/gfx/right.png" alt=">>">on./spa on.spa class="lxr_search">on v ="+search" method="post" onsubmit="return do_search(this);">on v14.input typ hidden" nam navtarget" ion> ">on v14.input typ text" nam search" id search">on v14.buttopttyp submit">Searchon v14Prefs 14./a>on./spa v14 4./div v14 4.form ac > ="ajax+*" method="post" onsubmit="return false;">on.input typ hidden" nam ajax_lookup" id ajax_lookup" ion> ">o v14 4./form o v14 4.div class="headingbottom">
.div id file_contents"
4 41./a>#include <linux/skbuff.h./a>>
4 42./a>#include <linux/export.h./a>>
4 43./a>#include <linux/ip.h./a>>
4 44./a>#include <linux/ipv6.h./a>>
4 45./a>#include <linux/if_vlan.h./a>>
4 46./a>#include <net/ip.h./a>>
4 47./a>#include <net/ipv6.h./a>>
4 48./a>#include <linux/if_tunnel.h./a>>
4 49./a>#include <linux/if_pppox.h./a>>
4 .10"a>#include <linux/ppp_defs.h./a>>
4 11./a>#include <net/flow_keys.h./a>>
4 12./a>
4 13./a>.spa
 class="comment">/* copy saddr & daddr, possibly using 64bit load/store./spa
  4 14./a>.spa
 class="comment"> * Equiionent to : v14 4flow->src = iph->saddr;./spa
  4 15./a>.spa
 class="comment"> *                      flow->dst = iph->daddr;./spa
  4 16./a>.spa
 class="comment"> */./spa
  4 17./a>static void4.a href="+code=iph_to_flow_copy_addrs" class="sref">iph_to_flow_copy_addrs./a>(struct4.a href="+code=flow_keys" class="sref">flow_keys./a> *.a href="+code=flow" class="sref">flow./a>, const struct4.a href="+code=iphdr" class="sref">iphdr./a> *.a href="+code=iph" class="sref">iph./a>) 4 18./a>{ 4 19./a>        .a href="+code=BUILD_BUG_ON" class="sref">BUILD_BUG_ON./a>(.a href="+code=offsetof" class="sref">offsetof./a>(.a href="+code=typ
of" class="sref">typ
of./a>(*.a href="+code=flow" class="sref">flow./a>), .a href="+code=dst" class="sref">dst./a>) !=
4 20./a>                     .a href="+code=offsetof" class="sref">offsetof./a>(.a href="+code=typ
of" class="sref">typ
of./a>(*.a href="+code=flow" class="sref">flow./a>), .a href="+code=src" class="sref">src./a>) + siz
of(.a href="+code=flow" class="sref">flow./a>->.a href="+code=src" class="sref">src./a>));
4 21./a>        .a href="+code=memcpy" class="sref">memcpy./a>(&.a href="+code=flow" class="sref">flow./a>->.a href="+code=src" class="sref">src./a>, &.a href="+code=iph" class="sref">iph./a>->.a href="+code=saddr" class="sref">saddr./a>, siz
of(.a href="+code=flow" class="sref">flow./a>->.a href="+code=src" class="sref">src./a>) + siz
of(.a href="+code=flow" class="sref">flow./a>->.a href="+code=dst" class="sref">dst./a>));
4 22./a>}
4 23./a>
4 24./a>.a href="+code=bool" class="sref">bool./a> .a href="+code=skb_flow_dissect" class="sref">skb_flow_dissect./a>(const struct4.a href="+code=sk_buff" class="sref">sk_buff./a> *.a href="+code=skb" class="sref">skb./a>, struct4.a href="+code=flow_keys" class="sref">flow_keys./a> *.a href="+code=flow" class="sref">flow./a>) 4 25./a>{ 4 26./a>        int4.a href="+code=poff" class="sref">poff./a>, .a href="+code=nhoff" class="sref">nhoff./a> = .a href="+code=skb_network_offset" class="sref">skb_network_offset./a>(.a href="+code=skb" class="sref">skb./a>);
4 27./a>        .a href="+code=u8" class="sref">u8./a> .a href="+code=ip_proto" class="sref">ip_proto./a>;
4 28./a>        .a href="+code=__be16" class="sref">__be16./a> .a href="+code=proto" class="sref">proto./a> = .a href="+code=skb" class="sref">skb./a>->.a href="+code=protocol" class="sref">protocol./a>;
4 29./a>
4 30./a>        .a href="+code=memset" class="sref">memset./a>(.a href="+code=flow" class="sref">flow./a>, 0, siz
of(*.a href="+code=flow" class="sref">flow./a>));
4 31./a>
4 32./a>.a href="+code=again" class="sref">again./a>:
4 33./a>        switch (.a href="+code=proto" class="sref">proto./a>) { 4 34./a>        case .a href="+code=__constant_htons" class="sref">__constant_htons./a>(.a href="+code=ETH_P_IP" class="sref">ETH_P_IP./a>): { 4 35./a>                const struct4.a href="+code=iphdr" class="sref">iphdr./a> *.a href="+code=iph" class="sref">iph./a>;
4 36./a>                struct4.a href="+code=iphdr" class="sref">iphdr./a> .a href="+code=_iph" class="sref">_iph./a>;
4 37./a>.a href="+code=ip" class="sref">ip./a>:
4 38./a>                .a href="+code=iph" class="sref">iph./a> = .a href="+code=skb_header_pointer" class="sref">skb_header_pointer./a>(.a href="+code=skb" class="sref">skb./a>, .a href="+code=nhoff" class="sref">nhoff./a>, siz
of(.a href="+code=_iph" class="sref">_iph./a>), &.a href="+code=_iph" class="sref">_iph./a>);
4 39./a>                if (!.a href="+code=iph" class="sref">iph./a>) 4 40./a>                        return .a href="+code=false" class="sref">false./a>;
4 41./a>
4 42./a>                if (.a href="+code=ip_is_fragment" class="sref">ip_is_fragment./a>(.a href="+code=iph" class="sref">iph./a>)) 4 43./a>                        .a href="+code=ip_proto" class="sref">ip_proto./a> = 0;
4 44./a>                else
4 45./a>                        .a href="+code=ip_proto" class="sref">ip_proto./a> = .a href="+code=iph" class="sref">iph./a>->.a href="+code=protocol" class="sref">protocol./a>;
4 46./a>                .a href="+code=iph_to_flow_copy_addrs" class="sref">iph_to_flow_copy_addrs./a>(.a href="+code=flow" class="sref">flow./a>, .a href="+code=iph" class="sref">iph./a>);
4 47./a>                .a href="+code=nhoff" class="sref">nhoff./a> += .a href="+code=iph" class="sref">iph./a>->.a href="+code=ihl" class="sref">ihl./a> * 4;
4 48./a>                break;
4 49./a>        }
4 50./a>        case .a href="+code=__constant_htons" class="sref">__constant_htons./a>(.a href="+code=ETH_P_IPV6" class="sref">ETH_P_IPV6./a>): { 4 51./a>                const struct4.a href="+code=ipv6hdr" class="sref">ipv6hdr./a> *.a href="+code=iph" class="sref">iph./a>;
4 52./a>                struct4.a href="+code=ipv6hdr" class="sref">ipv6hdr./a> .a href="+code=_iph" class="sref">_iph./a>;
4 53./a>.a href="+code=ipv6" class="sref">ipv6./a>:
4 54./a>                .a href="+code=iph" class="sref">iph./a> = .a href="+code=skb_header_pointer" class="sref">skb_header_pointer./a>(.a href="+code=skb" class="sref">skb./a>, .a href="+code=nhoff" class="sref">nhoff./a>, siz
of(.a href="+code=_iph" class="sref">_iph./a>), &.a href="+code=_iph" class="sref">_iph./a>);
4 55./a>                if (!.a href="+code=iph" class="sref">iph./a>) 4 56./a>                        return .a href="+code=false" class="sref">false./a>;
4 57./a>
4 58./a>                .a href="+code=ip_proto" class="sref">ip_proto./a> = .a href="+code=iph" class="sref">iph./a>->.a href="+code=nexthdr" class="sref">nexthdr./a>;
4 59./a>                .a href="+code=flow" class="sref">flow./a>->.a href="+code=src" class="sref">src./a> = (.a href="+code=__force" class="sref">__force./a> .a href="+code=__be32" class="sref">__be32./a>).a href="+code=ipv6_addr_hash" class="sref">ipv6_addr_hash./a>(&.a href="+code=iph" class="sref">iph./a>->.a href="+code=saddr" class="sref">saddr./a>);
4 60./a>                .a href="+code=flow" class="sref">flow./a>->.a href="+code=dst" class="sref">dst./a> = (.a href="+code=__force" class="sref">__force./a> .a href="+code=__be32" class="sref">__be32./a>).a href="+code=ipv6_addr_hash" class="sref">ipv6_addr_hash./a>(&.a href="+code=iph" class="sref">iph./a>->.a href="+code=daddr" class="sref">daddr./a>);
4 61./a>                .a href="+code=nhoff" class="sref">nhoff./a> += siz
of(struct4.a href="+code=ipv6hdr" class="sref">ipv6hdr./a>);
4 62./a>                break;
4 63./a>        }
4 64./a>        case .a href="+code=__constant_htons" class="sref">__constant_htons./a>(.a href="+code=ETH_P_8021Q" class="sref">ETH_P_8021Q./a>): { 4 65./a>                const struct4.a href="+code=vlan_hdr" class="sref">vlan_hdr./a> *.a href="+code=vlan" class="sref">vlan./a>;
4 66./a>                struct4.a href="+code=vlan_hdr" class="sref">vlan_hdr./a> .a href="+code=_vlan" class="sref">_vlan./a>;
4 67./a>
4 68./a>                .a href="+code=vlan" class="sref">vlan./a> = .a href="+code=skb_header_pointer" class="sref">skb_header_pointer./a>(.a href="+code=skb" class="sref">skb./a>, .a href="+code=nhoff" class="sref">nhoff./a>, siz
of(.a href="+code=_vlan" class="sref">_vlan./a>), &.a href="+code=_vlan" class="sref">_vlan./a>);
4 69./a>                if (!.a href="+code=vlan" class="sref">vlan./a>) 4 70./a>                        return .a href="+code=false" class="sref">false./a>;
4 71./a>
4 72./a>                .a href="+code=proto" class="sref">proto./a> = .a href="+code=vlan" class="sref">vlan./a>->.a href="+code=h_vlan_encapsulated_proto" class="sref">h_vlan_encapsulated_proto./a>;
4 73./a>                .a href="+code=nhoff" class="sref">nhoff./a> += siz
of(*.a href="+code=vlan" class="sref">vlan./a>);
4 74./a>                goto .a href="+code=again" class="sref">again./a>;
4 75./a>        }
4 76./a>        case .a href="+code=__constant_htons" class="sref">__constant_htons./a>(.a href="+code=ETH_P_PPP_SES" class="sref">ETH_P_PPP_SES./a>): { 4 77./a>                struct4{ 4 78./a>                        struct4.a href="+code=pppoe_hdr" class="sref">pppoe_hdr./a> .a href="+code=hdr" class="sref">hdr./a>;
4 79./a>                        .a href="+code=__be16" class="sref">__be16./a> .a href="+code=proto" class="sref">proto./a>;
4 80./a>                } *.a href="+code=hdr" class="sref">hdr./a>, .a href="+code=_hdr" class="sref">_hdr./a>;
4 81./a>                .a href="+code=hdr" class="sref">hdr./a> = .a href="+code=skb_header_pointer" class="sref">skb_header_pointer./a>(.a href="+code=skb" class="sref">skb./a>, .a href="+code=nhoff" class="sref">nhoff./a>, siz
of(.a href="+code=_hdr" class="sref">_hdr./a>), &.a href="+code=_hdr" class="sref">_hdr./a>);
4 82./a>                if (!.a href="+code=hdr" class="sref">hdr./a>) 4 83./a>                        return .a href="+code=false" class="sref">false./a>;
4 84./a>                .a href="+code=proto" class="sref">proto./a> = .a href="+code=hdr" class="sref">hdr./a>->.a href="+code=proto" class="sref">proto./a>;
4 85./a>                .a href="+code=nhoff" class="sref">nhoff./a> += .a href="+code=PPPOE_SES_HLEN" class="sref">PPPOE_SES_HLEN./a>;
4 86./a>                switch (.a href="+code=proto" class="sref">proto./a>) { 4 87./a>                case .a href="+code=__constant_htons" class="sref">__constant_htons./a>(.a href="+code=PPP_IP" class="sref">PPP_IP./a>): 4 88./a>                        goto .a href="+code=ip" class="sref">ip./a>;
4 89./a>                case .a href="+code=__constant_htons" class="sref">__constant_htons./a>(.a href="+code=PPP_IPV6" class="sref">PPP_IPV6./a>): 4 90./a>                        goto .a href="+code=ipv6" class="sref">ipv6./a>;
4 91./a>                default: 4 92./a>                        return .a href="+code=false" class="sref">false./a>;
4 93./a>                }
4 94./a>        }
4 95./a>        default: 4 96./a>                return .a href="+code=false" class="sref">false./a>;
4 97./a>        }
4 98./a>
4 99./a>        switch (.a href="+code=ip_proto" class="sref">ip_proto./a>) { 4100./a>        case .a href="+code=IPPROTO_GRE" class="sref">IPPROTO_GRE./a>: { 4101./a>                struct4.a href="+code=gre_hdr" class="sref">gre_hdr./a> { 4102./a>                        .a href="+code=__be16" class="sref">__be16./a> .a href="+code=flags" class="sref">flags./a>;
4103./a>                        .a href="+code=__be16" class="sref">__be16./a> .a href="+code=proto" class="sref">proto./a>;
4104./a>                } *.a href="+code=hdr" class="sref">hdr./a>, .a href="+code=_hdr" class="sref">_hdr./a>;
4105./a>
4106./a>                .a href="+code=hdr" class="sref">hdr./a> = .a href="+code=skb_header_pointer" class="sref">skb_header_pointer./a>(.a href="+code=skb" class="sref">skb./a>, .a href="+code=nhoff" class="sref">nhoff./a>, siz
of(.a href="+code=_hdr" class="sref">_hdr./a>), &.a href="+code=_hdr" class="sref">_hdr./a>);
4107./a>                if (!.a href="+code=hdr" class="sref">hdr./a>) 4108./a>                        return .a href="+code=false" class="sref">false./a>;
4109./a>                .spa
 class="comment">/*./spa
  41.10"a>.spa
 class="comment">                 * Only look inside GRE if vers/optzero and no./spa
  4111./a>.spa
 class="comment">                 * routing./spa
  4112./a>.spa
 class="comment">                 */./spa
  4113./a>                if (!(.a href="+code=hdr" class="sref">hdr./a>->.a href="+code=flags" class="sref">flags./a> & (.a href="+code=GRE_VERSION" class="sref">GRE_VERSION./a>|.a href="+code=GRE_ROUTING" class="sref">GRE_ROUTING./a>))) { 4114./a>                        .a href="+code=proto" class="sref">proto./a> = .a href="+code=hdr" class="sref">hdr./a>->.a href="+code=proto" class="sref">proto./a>;
4115./a>                        .a href="+code=nhoff" class="sref">nhoff./a> += 4;
4116./a>                        if (.a href="+code=hdr" class="sref">hdr./a>->.a href="+code=flags" class="sref">flags./a> & .a href="+code=GRE_CSUM" class="sref">GRE_CSUM./a>) 4117./a>                                .a href="+code=nhoff" class="sref">nhoff./a> += 4;
4118./a>                        if (.a href="+code=hdr" class="sref">hdr./a>->.a href="+code=flags" class="sref">flags./a> & .a href="+code=GRE_KEY" class="sref">GRE_KEY./a>) 4119./a>                                .a href="+code=nhoff" class="sref">nhoff./a> += 4;
4120./a>                        if (.a href="+code=hdr" class="sref">hdr./a>->.a href="+code=flags" class="sref">flags./a> & .a href="+code=GRE_SEQ" class="sref">GRE_SEQ./a>) 4121./a>                                .a href="+code=nhoff" class="sref">nhoff./a> += 4;
4122./a>                        goto .a href="+code=again" class="sref">again./a>;
4123./a>                }
4124./a>                break;
4125./a>        }
4126./a>        case .a href="+code=IPPROTO_IPIP" class="sref">IPPROTO_IPIP./a>:
4127./a>                goto .a href="+code=again" class="sref">again./a>;
4128./a>        default: 4129./a>                break;
4130./a>        }
4131./a>
4132./a>        .a href="+code=flow" class="sref">flow./a>->.a href="+code=ip_proto" class="sref">ip_proto./a> = .a href="+code=ip_proto" class="sref">ip_proto./a>;
4133./a>        .a href="+code=poff" class="sref">poff./a> = .a href="+code=proto_ports_offset" class="sref">proto_ports_offset./a>(.a href="+code=ip_proto" class="sref">ip_proto./a>);
4134./a>        if (.a href="+code=poff" class="sref">poff./a> >= 0) { 4135./a>                .a href="+code=__be32" class="sref">__be32./a> *.a href="+code=ports" class="sref">ports./a>, .a href="+code=_ports" class="sref">_ports./a>;
4136./a>
4137./a>                .a href="+code=nhoff" class="sref">nhoff./a> += .a href="+code=poff" class="sref">poff./a>;
4138./a>                .a href="+code=ports" class="sref">ports./a> = .a href="+code=skb_header_pointer" class="sref">skb_header_pointer./a>(.a href="+code=skb" class="sref">skb./a>, .a href="+code=nhoff" class="sref">nhoff./a>, siz
of(.a href="+code=_ports" class="sref">_ports./a>), &.a href="+code=_ports" class="sref">_ports./a>);
4139./a>                if (.a href="+code=ports" class="sref">ports./a>) 4140./a>                        .a href="+code=flow" class="sref">flow./a>->.a href="+code=ports" class="sref">ports./a> = *.a href="+code=ports" class="sref">ports./a>;
4141./a>        }
4142./a>
4143./a>        return .a href="+code=true" class="sref">true./a>;
4144./a>}
4145./a>.a href="+code=EXPORT_SYMBOL" class="sref">EXPORT_SYMBOL./a>(.a href="+code=skb_flow_dissect" class="sref">skb_flow_dissect./a>);
4146./a>
The original LXR software by the .a href="http://sourceforge.net/projects/lxr">LXR community./a>, this experimental vers/optby .a href="mailto:lxr@linux.no">lxr@linux.no./a>. ./div .div class="subfooter"> lxr.linux.no kindly hostedtby .a href="http://www.redpill-linpro.no">Redpill Linpro AS./a>, provider of Linux consulting and opera > s services since 1995. ./div ./body ./html