]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * | |
3 | * Generic internet FLOW. | |
4 | * | |
5 | */ | |
6 | ||
7 | #ifndef _NET_FLOW_H | |
8 | #define _NET_FLOW_H | |
9 | ||
10 | #include <linux/in6.h> | |
11 | #include <asm/atomic.h> | |
12 | ||
806566cc DM |
13 | struct flowi_common { |
14 | int flowic_oif; | |
15 | int flowic_iif; | |
16 | __u32 flowic_mark; | |
17 | __u8 flowic_tos; | |
18 | __u8 flowic_scope; | |
19 | __u8 flowic_proto; | |
20 | __u8 flowic_flags; | |
fbef0a40 DM |
21 | #define FLOWI_FLAG_ANYSRC 0x01 |
22 | #define FLOWI_FLAG_PRECOW_METRICS 0x02 | |
23 | #define FLOWI_FLAG_CAN_SLEEP 0x04 | |
806566cc DM |
24 | __u32 flowic_secid; |
25 | }; | |
26 | ||
08704bcb DM |
27 | union flowi_uli { |
28 | struct { | |
29 | __be16 sport; | |
30 | __be16 dport; | |
31 | } ports; | |
32 | ||
33 | struct { | |
34 | __u8 type; | |
35 | __u8 code; | |
36 | } icmpt; | |
37 | ||
38 | struct { | |
39 | __le16 sport; | |
40 | __le16 dport; | |
41 | } dnports; | |
42 | ||
43 | __be32 spi; | |
44 | __be32 gre_key; | |
45 | ||
46 | struct { | |
47 | __u8 type; | |
48 | } mht; | |
49 | }; | |
50 | ||
56bb8059 DM |
51 | struct flowi4 { |
52 | struct flowi_common __fl_common; | |
22bd5b9b DM |
53 | #define flowi4_oif __fl_common.flowic_oif |
54 | #define flowi4_iif __fl_common.flowic_iif | |
55 | #define flowi4_mark __fl_common.flowic_mark | |
56 | #define flowi4_tos __fl_common.flowic_tos | |
57 | #define flowi4_scope __fl_common.flowic_scope | |
58 | #define flowi4_proto __fl_common.flowic_proto | |
59 | #define flowi4_flags __fl_common.flowic_flags | |
60 | #define flowi4_secid __fl_common.flowic_secid | |
56bb8059 DM |
61 | __be32 daddr; |
62 | __be32 saddr; | |
63 | union flowi_uli uli; | |
9cce96df DM |
64 | #define fl4_sport uli.ports.sport |
65 | #define fl4_dport uli.ports.dport | |
66 | #define fl4_icmp_type uli.icmpt.type | |
67 | #define fl4_icmp_code uli.icmpt.code | |
68 | #define fl4_ipsec_spi uli.spi | |
69 | #define fl4_mh_type uli.mht.type | |
70 | #define fl4_gre_key uli.gre_key | |
56bb8059 DM |
71 | }; |
72 | ||
73 | struct flowi6 { | |
806566cc | 74 | struct flowi_common __fl_common; |
2032656e DM |
75 | #define flowi6_oif __fl_common.flowic_oif |
76 | #define flowi6_iif __fl_common.flowic_iif | |
77 | #define flowi6_mark __fl_common.flowic_mark | |
78 | #define flowi6_tos __fl_common.flowic_tos | |
79 | #define flowi6_scope __fl_common.flowic_scope | |
80 | #define flowi6_proto __fl_common.flowic_proto | |
81 | #define flowi6_flags __fl_common.flowic_flags | |
82 | #define flowi6_secid __fl_common.flowic_secid | |
56bb8059 DM |
83 | struct in6_addr daddr; |
84 | struct in6_addr saddr; | |
85 | __be32 flowlabel; | |
86 | union flowi_uli uli; | |
87 | }; | |
1da177e4 | 88 | |
56bb8059 DM |
89 | struct flowidn { |
90 | struct flowi_common __fl_common; | |
91 | __le16 daddr; | |
92 | __le16 saddr; | |
93 | union flowi_uli uli; | |
94 | }; | |
95 | ||
96 | struct flowi { | |
1da177e4 | 97 | union { |
56bb8059 DM |
98 | struct flowi_common __fl_common; |
99 | struct flowi4 ip4; | |
100 | struct flowi6 ip6; | |
101 | struct flowidn dn; | |
102 | } u; | |
103 | #define flowi_oif u.__fl_common.flowic_oif | |
104 | #define flowi_iif u.__fl_common.flowic_iif | |
105 | #define flowi_mark u.__fl_common.flowic_mark | |
106 | #define flowi_tos u.__fl_common.flowic_tos | |
107 | #define flowi_scope u.__fl_common.flowic_scope | |
108 | #define flowi_proto u.__fl_common.flowic_proto | |
109 | #define flowi_flags u.__fl_common.flowic_flags | |
110 | #define flowi_secid u.__fl_common.flowic_secid | |
56bb8059 DM |
111 | #define fld_scope flowi_scope |
112 | ||
113 | #define fld_dst u.dn.daddr | |
114 | #define fld_src u.dn.saddr | |
115 | #define fl6_dst u.ip6.daddr | |
116 | #define fl6_src u.ip6.saddr | |
117 | #define fl6_flowlabel u.ip6.flowlabel | |
56bb8059 DM |
118 | #define fl6_sport u.ip6.uli.ports.sport |
119 | #define fl6_dport u.ip6.uli.ports.dport | |
120 | #define fl6_icmp_type u.ip6.uli.icmpt.type | |
121 | #define fl6_icmp_code u.ip6.uli.icmpt.code | |
122 | #define fl6_ipsec_spi u.ip6.uli.spi | |
123 | #define fl6_mh_type u.ip6.uli.mht.type | |
124 | #define fl6_gre_key u.ip6.uli.gre_key | |
1da177e4 LT |
125 | } __attribute__((__aligned__(BITS_PER_LONG/8))); |
126 | ||
59b1a94c DM |
127 | static inline struct flowi *flowi4_to_flowi(struct flowi4 *fl4) |
128 | { | |
129 | return container_of(fl4, struct flowi, u.ip4); | |
130 | } | |
131 | ||
132 | static inline struct flowi *flowi6_to_flowi(struct flowi6 *fl6) | |
133 | { | |
134 | return container_of(fl6, struct flowi, u.ip6); | |
135 | } | |
136 | ||
137 | static inline struct flowi *flowidn_to_flowi(struct flowidn *fldn) | |
138 | { | |
139 | return container_of(fldn, struct flowi, u.dn); | |
140 | } | |
141 | ||
1da177e4 LT |
142 | #define FLOW_DIR_IN 0 |
143 | #define FLOW_DIR_OUT 1 | |
144 | #define FLOW_DIR_FWD 2 | |
145 | ||
52479b62 | 146 | struct net; |
df71837d | 147 | struct sock; |
fe1a5f03 TT |
148 | struct flow_cache_ops; |
149 | ||
150 | struct flow_cache_object { | |
151 | const struct flow_cache_ops *ops; | |
152 | }; | |
153 | ||
154 | struct flow_cache_ops { | |
155 | struct flow_cache_object *(*get)(struct flow_cache_object *); | |
156 | int (*check)(struct flow_cache_object *); | |
157 | void (*delete)(struct flow_cache_object *); | |
158 | }; | |
159 | ||
160 | typedef struct flow_cache_object *(*flow_resolve_t)( | |
dee9f4bc | 161 | struct net *net, const struct flowi *key, u16 family, |
fe1a5f03 TT |
162 | u8 dir, struct flow_cache_object *oldobj, void *ctx); |
163 | ||
164 | extern struct flow_cache_object *flow_cache_lookup( | |
dee9f4bc | 165 | struct net *net, const struct flowi *key, u16 family, |
fe1a5f03 | 166 | u8 dir, flow_resolve_t resolver, void *ctx); |
1da177e4 | 167 | |
1da177e4 LT |
168 | extern void flow_cache_flush(void); |
169 | extern atomic_t flow_cache_genid; | |
170 | ||
171 | #endif |