OSDN Git Service

e4ee761ca8c0140d45a654520e9280ad09466e1d
[uclinux-h8/linux.git] / include / net / flow_dissector.h
1 #ifndef _NET_FLOW_DISSECTOR_H
2 #define _NET_FLOW_DISSECTOR_H
3
4 /* struct flow_keys:
5  *      @src: source ip address in case of IPv4
6  *            For IPv6 it contains 32bit hash of src address
7  *      @dst: destination ip address in case of IPv4
8  *            For IPv6 it contains 32bit hash of dst address
9  *      @ports: port numbers of Transport header
10  *              port16[0]: src port number
11  *              port16[1]: dst port number
12  *      @thoff: Transport header offset
13  *      @n_proto: Network header protocol (eg. IPv4/IPv6)
14  *      @ip_proto: Transport header protocol (eg. TCP/UDP)
15  * All the members, except thoff, are in network byte order.
16  */
17 struct flow_keys {
18         /* (src,dst) must be grouped, in the same way than in IP header */
19         __be32 src;
20         __be32 dst;
21         union {
22                 __be32 ports;
23                 __be16 port16[2];
24         };
25         u16     thoff;
26         __be16  n_proto;
27         u8      ip_proto;
28 };
29
30 bool __skb_flow_dissect(const struct sk_buff *skb, struct flow_keys *flow,
31                         void *data, __be16 proto, int nhoff, int hlen);
32
33 static inline bool skb_flow_dissect(const struct sk_buff *skb,
34                                     struct flow_keys *flow)
35 {
36         return __skb_flow_dissect(skb, flow, NULL, 0, 0, 0);
37 }
38
39 __be32 __skb_flow_get_ports(const struct sk_buff *skb, int thoff, u8 ip_proto,
40                             void *data, int hlen_proto);
41
42 static inline __be32 skb_flow_get_ports(const struct sk_buff *skb,
43                                         int thoff, u8 ip_proto)
44 {
45         return __skb_flow_get_ports(skb, thoff, ip_proto, NULL, 0);
46 }
47
48 u32 flow_hash_from_keys(struct flow_keys *keys);
49 void __skb_get_hash(struct sk_buff *skb);
50 u32 skb_get_poff(const struct sk_buff *skb);
51 u32 __skb_get_poff(const struct sk_buff *skb, void *data,
52                    const struct flow_keys *keys, int hlen);
53
54 /* struct flow_keys_digest:
55  *
56  * This structure is used to hold a digest of the full flow keys. This is a
57  * larger "hash" of a flow to allow definitively matching specific flows where
58  * the 32 bit skb->hash is not large enough. The size is limited to 16 bytes so
59  * that it can by used in CB of skb (see sch_choke for an example).
60  */
61 #define FLOW_KEYS_DIGEST_LEN    16
62 struct flow_keys_digest {
63         u8      data[FLOW_KEYS_DIGEST_LEN];
64 };
65
66 void make_flow_keys_digest(struct flow_keys_digest *digest,
67                            const struct flow_keys *flow);
68
69 #endif