142
144
enum ipset_cmd_flags {
143
145
IPSET_FLAG_BIT_EXIST = 0,
144
146
IPSET_FLAG_EXIST = (1 << IPSET_FLAG_BIT_EXIST),
147
IPSET_FLAG_BIT_LIST_SETNAME = 1,
148
IPSET_FLAG_LIST_SETNAME = (1 << IPSET_FLAG_BIT_LIST_SETNAME),
149
IPSET_FLAG_BIT_LIST_HEADER = 2,
150
IPSET_FLAG_LIST_HEADER = (1 << IPSET_FLAG_BIT_LIST_HEADER),
147
153
/* Flags at CADT attribute level */
148
154
enum ipset_cadt_flags {
149
155
IPSET_FLAG_BIT_BEFORE = 0,
150
156
IPSET_FLAG_BEFORE = (1 << IPSET_FLAG_BIT_BEFORE),
157
IPSET_FLAG_BIT_PHYSDEV = 1,
158
IPSET_FLAG_PHYSDEV = (1 << IPSET_FLAG_BIT_PHYSDEV),
153
161
/* Commands with settype-specific attributes */
206
215
IPSET_TYPE_IP2 = (1 << IPSET_TYPE_IP2_FLAG),
207
216
IPSET_TYPE_NAME_FLAG = 4,
208
217
IPSET_TYPE_NAME = (1 << IPSET_TYPE_NAME_FLAG),
218
IPSET_TYPE_IFACE_FLAG = 5,
219
IPSET_TYPE_IFACE = (1 << IPSET_TYPE_IFACE_FLAG),
209
220
/* Strictly speaking not a feature, but a flag for dumping:
210
221
* this settype must be dumped last */
211
222
IPSET_DUMP_LAST_FLAG = 7,
217
typedef int (*ipset_adtfn)(struct ip_set *set, void *value, u32 timeout);
228
typedef int (*ipset_adtfn)(struct ip_set *set, void *value,
229
u32 timeout, u32 flags);
231
/* Kernel API function options */
232
struct ip_set_adt_opt {
233
u8 family; /* Actual protocol family */
234
u8 dim; /* Dimension of match/target */
235
u8 flags; /* Direction and negation flags */
236
u32 cmdflags; /* Command-like flags */
237
u32 timeout; /* Timeout value */
219
240
/* Set type, variant-specific part */
220
241
struct ip_set_type_variant {
223
244
* zero for no match/success to add/delete
224
245
* positive for matching element */
225
246
int (*kadt)(struct ip_set *set, const struct sk_buff * skb,
226
enum ipset_adt adt, u8 pf, u8 dim, u8 flags);
247
const struct xt_action_param *par,
248
enum ipset_adt adt, const struct ip_set_adt_opt *opt);
228
250
/* Userspace: test/add/del entries
229
251
* returns negative error code,
230
252
* zero for no match/success to add/delete
231
253
* positive for matching element */
232
254
int (*uadt)(struct ip_set *set, struct nlattr *tb[],
233
enum ipset_adt adt, u32 *lineno, u32 flags);
255
enum ipset_adt adt, u32 *lineno, u32 flags, bool retried);
235
257
/* Low level add/del/test functions */
236
258
ipset_adtfn adt[IPSET_ADT_MAX];
269
291
/* Supported family: may be AF_UNSPEC for both AF_INET/AF_INET6 */
294
u8 revision_min, revision_max;
275
297
int (*create)(struct ip_set *set, struct nlattr *tb[], u32 flags);
307
331
/* register and unregister set references */
308
332
extern ip_set_id_t ip_set_get_byname(const char *name, struct ip_set **set);
309
333
extern void ip_set_put_byindex(ip_set_id_t index);
310
extern const char * ip_set_name_byindex(ip_set_id_t index);
334
extern const char *ip_set_name_byindex(ip_set_id_t index);
311
335
extern ip_set_id_t ip_set_nfnl_get(const char *name);
312
336
extern ip_set_id_t ip_set_nfnl_get_byindex(ip_set_id_t index);
313
337
extern void ip_set_nfnl_put(ip_set_id_t index);
315
339
/* API for iptables set match, and SET target */
316
341
extern int ip_set_add(ip_set_id_t id, const struct sk_buff *skb,
317
u8 family, u8 dim, u8 flags);
342
const struct xt_action_param *par,
343
const struct ip_set_adt_opt *opt);
318
344
extern int ip_set_del(ip_set_id_t id, const struct sk_buff *skb,
319
u8 family, u8 dim, u8 flags);
345
const struct xt_action_param *par,
346
const struct ip_set_adt_opt *opt);
320
347
extern int ip_set_test(ip_set_id_t id, const struct sk_buff *skb,
321
u8 family, u8 dim, u8 flags);
348
const struct xt_action_param *par,
349
const struct ip_set_adt_opt *opt);
323
351
/* Utility functions */
324
extern void * ip_set_alloc(size_t size);
352
extern void *ip_set_alloc(size_t size);
325
353
extern void ip_set_free(void *members);
326
354
extern int ip_set_get_ipaddr4(struct nlattr *nla, __be32 *ipaddr);
327
355
extern int ip_set_get_ipaddr6(struct nlattr *nla, union nf_inet_addr *ipaddr);