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; | |
53 | __be32 daddr; | |
54 | __be32 saddr; | |
55 | union flowi_uli uli; | |
56 | }; | |
57 | ||
58 | struct flowi6 { | |
806566cc | 59 | struct flowi_common __fl_common; |
56bb8059 DM |
60 | struct in6_addr daddr; |
61 | struct in6_addr saddr; | |
62 | __be32 flowlabel; | |
63 | union flowi_uli uli; | |
64 | }; | |
1da177e4 | 65 | |
56bb8059 DM |
66 | struct flowidn { |
67 | struct flowi_common __fl_common; | |
68 | __le16 daddr; | |
69 | __le16 saddr; | |
70 | union flowi_uli uli; | |
71 | }; | |
72 | ||
73 | struct flowi { | |
1da177e4 | 74 | union { |
56bb8059 DM |
75 | struct flowi_common __fl_common; |
76 | struct flowi4 ip4; | |
77 | struct flowi6 ip6; | |
78 | struct flowidn dn; | |
79 | } u; | |
80 | #define flowi_oif u.__fl_common.flowic_oif | |
81 | #define flowi_iif u.__fl_common.flowic_iif | |
82 | #define flowi_mark u.__fl_common.flowic_mark | |
83 | #define flowi_tos u.__fl_common.flowic_tos | |
84 | #define flowi_scope u.__fl_common.flowic_scope | |
85 | #define flowi_proto u.__fl_common.flowic_proto | |
86 | #define flowi_flags u.__fl_common.flowic_flags | |
87 | #define flowi_secid u.__fl_common.flowic_secid | |
1d28f42c DM |
88 | #define fl4_tos flowi_tos |
89 | #define fl4_scope flowi_scope | |
56bb8059 DM |
90 | #define fld_scope flowi_scope |
91 | ||
92 | #define fld_dst u.dn.daddr | |
93 | #define fld_src u.dn.saddr | |
94 | #define fl6_dst u.ip6.daddr | |
95 | #define fl6_src u.ip6.saddr | |
96 | #define fl6_flowlabel u.ip6.flowlabel | |
97 | #define fl4_dst u.ip4.daddr | |
98 | #define fl4_src u.ip4.saddr | |
99 | #define fl4_sport u.ip4.uli.ports.sport | |
100 | #define fl4_dport u.ip4.uli.ports.dport | |
101 | #define fl4_icmp_type u.ip4.uli.icmpt.type | |
102 | #define fl4_icmp_code u.ip4.uli.icmpt.code | |
103 | #define fl4_ipsec_spi u.ip4.uli.spi | |
104 | #define fl4_mh_type u.ip4.uli.mht.type | |
105 | #define fl4_gre_key u.ip4.uli.gre_key | |
106 | #define fl6_sport u.ip6.uli.ports.sport | |
107 | #define fl6_dport u.ip6.uli.ports.dport | |
108 | #define fl6_icmp_type u.ip6.uli.icmpt.type | |
109 | #define fl6_icmp_code u.ip6.uli.icmpt.code | |
110 | #define fl6_ipsec_spi u.ip6.uli.spi | |
111 | #define fl6_mh_type u.ip6.uli.mht.type | |
112 | #define fl6_gre_key u.ip6.uli.gre_key | |
1da177e4 LT |
113 | } __attribute__((__aligned__(BITS_PER_LONG/8))); |
114 | ||
59b1a94c DM |
115 | static inline struct flowi *flowi4_to_flowi(struct flowi4 *fl4) |
116 | { | |
117 | return container_of(fl4, struct flowi, u.ip4); | |
118 | } | |
119 | ||
120 | static inline struct flowi *flowi6_to_flowi(struct flowi6 *fl6) | |
121 | { | |
122 | return container_of(fl6, struct flowi, u.ip6); | |
123 | } | |
124 | ||
125 | static inline struct flowi *flowidn_to_flowi(struct flowidn *fldn) | |
126 | { | |
127 | return container_of(fldn, struct flowi, u.dn); | |
128 | } | |
129 | ||
1da177e4 LT |
130 | #define FLOW_DIR_IN 0 |
131 | #define FLOW_DIR_OUT 1 | |
132 | #define FLOW_DIR_FWD 2 | |
133 | ||
52479b62 | 134 | struct net; |
df71837d | 135 | struct sock; |
fe1a5f03 TT |
136 | struct flow_cache_ops; |
137 | ||
138 | struct flow_cache_object { | |
139 | const struct flow_cache_ops *ops; | |
140 | }; | |
141 | ||
142 | struct flow_cache_ops { | |
143 | struct flow_cache_object *(*get)(struct flow_cache_object *); | |
144 | int (*check)(struct flow_cache_object *); | |
145 | void (*delete)(struct flow_cache_object *); | |
146 | }; | |
147 | ||
148 | typedef struct flow_cache_object *(*flow_resolve_t)( | |
dee9f4bc | 149 | struct net *net, const struct flowi *key, u16 family, |
fe1a5f03 TT |
150 | u8 dir, struct flow_cache_object *oldobj, void *ctx); |
151 | ||
152 | extern struct flow_cache_object *flow_cache_lookup( | |
dee9f4bc | 153 | struct net *net, const struct flowi *key, u16 family, |
fe1a5f03 | 154 | u8 dir, flow_resolve_t resolver, void *ctx); |
1da177e4 | 155 | |
1da177e4 LT |
156 | extern void flow_cache_flush(void); |
157 | extern atomic_t flow_cache_genid; | |
158 | ||
159 | #endif |