| 1 |
#ifndef _OBJ_OPS_H_ |
| 2 |
#define _OBJ_OPS_H_ |
| 3 |
|
| 4 |
#include <stdint.h> |
| 5 |
#include <libnftnl/object.h> /* For NFTNL_CTTIMEOUT_ARRAY_MAX. */ |
| 6 |
#include "internal.h" |
| 7 |
|
| 8 |
struct nlattr; |
| 9 |
struct nlmsghdr; |
| 10 |
struct nftnl_obj; |
| 11 |
|
| 12 |
struct nftnl_obj { |
| 13 |
struct list_head head; |
| 14 |
struct obj_ops *ops; |
| 15 |
|
| 16 |
const char *table; |
| 17 |
const char *name; |
| 18 |
|
| 19 |
uint32_t family; |
| 20 |
uint32_t use; |
| 21 |
|
| 22 |
uint32_t flags; |
| 23 |
uint64_t handle; |
| 24 |
|
| 25 |
struct { |
| 26 |
void *data; |
| 27 |
uint32_t len; |
| 28 |
} user; |
| 29 |
|
| 30 |
union { |
| 31 |
struct nftnl_obj_counter { |
| 32 |
uint64_t pkts; |
| 33 |
uint64_t bytes; |
| 34 |
} counter; |
| 35 |
struct nftnl_obj_quota { |
| 36 |
uint64_t bytes; |
| 37 |
uint64_t consumed; |
| 38 |
uint32_t flags; |
| 39 |
} quota; |
| 40 |
struct nftnl_obj_ct_helper { |
| 41 |
uint16_t l3proto; |
| 42 |
uint8_t l4proto; |
| 43 |
char name[16]; |
| 44 |
} ct_helper; |
| 45 |
struct nftnl_obj_ct_timeout { |
| 46 |
uint16_t l3proto; |
| 47 |
uint8_t l4proto; |
| 48 |
uint32_t timeout[NFTNL_CTTIMEOUT_ARRAY_MAX]; |
| 49 |
} ct_timeout; |
| 50 |
struct nftnl_obj_ct_expect { |
| 51 |
uint16_t l3proto; |
| 52 |
uint16_t dport; |
| 53 |
uint8_t l4proto; |
| 54 |
uint8_t size; |
| 55 |
uint32_t timeout; |
| 56 |
} ct_expect; |
| 57 |
struct nftnl_obj_limit { |
| 58 |
uint64_t rate; |
| 59 |
uint64_t unit; |
| 60 |
uint32_t burst; |
| 61 |
uint32_t type; |
| 62 |
uint32_t flags; |
| 63 |
} limit; |
| 64 |
struct nftnl_obj_synproxy { |
| 65 |
uint16_t mss; |
| 66 |
uint8_t wscale; |
| 67 |
uint32_t flags; |
| 68 |
} synproxy; |
| 69 |
struct nftnl_obj_tunnel { |
| 70 |
uint32_t id; |
| 71 |
uint32_t src_v4; |
| 72 |
uint32_t dst_v4; |
| 73 |
struct in6_addr src_v6; |
| 74 |
struct in6_addr dst_v6; |
| 75 |
uint16_t sport; |
| 76 |
uint16_t dport; |
| 77 |
uint32_t flowlabel; |
| 78 |
uint32_t tun_flags; |
| 79 |
uint8_t tun_tos; |
| 80 |
uint8_t tun_ttl; |
| 81 |
struct nftnl_tunnel_opts *tun_opts; |
| 82 |
} tunnel; |
| 83 |
struct nftnl_obj_secmark { |
| 84 |
char ctx[NFT_SECMARK_CTX_MAXLEN]; |
| 85 |
} secmark; |
| 86 |
} data; |
| 87 |
}; |
| 88 |
|
| 89 |
struct obj_ops { |
| 90 |
const char *name; |
| 91 |
uint32_t type; |
| 92 |
size_t alloc_len; |
| 93 |
int nftnl_max_attr; |
| 94 |
struct attr_policy *attr_policy; |
| 95 |
int (*set)(struct nftnl_obj *e, uint16_t type, const void *data, uint32_t data_len); |
| 96 |
const void *(*get)(const struct nftnl_obj *e, uint16_t type, uint32_t *data_len); |
| 97 |
int (*parse)(struct nftnl_obj *e, struct nlattr *attr); |
| 98 |
void (*build)(struct nlmsghdr *nlh, const struct nftnl_obj *e); |
| 99 |
int (*output)(char *buf, size_t len, uint32_t flags, const struct nftnl_obj *e); |
| 100 |
}; |
| 101 |
|
| 102 |
extern struct obj_ops obj_ops_counter; |
| 103 |
extern struct obj_ops obj_ops_quota; |
| 104 |
extern struct obj_ops obj_ops_ct_helper; |
| 105 |
extern struct obj_ops obj_ops_ct_timeout; |
| 106 |
extern struct obj_ops obj_ops_ct_expect; |
| 107 |
extern struct obj_ops obj_ops_limit; |
| 108 |
extern struct obj_ops obj_ops_synproxy; |
| 109 |
extern struct obj_ops obj_ops_tunnel; |
| 110 |
extern struct obj_ops obj_ops_secmark; |
| 111 |
|
| 112 |
#define nftnl_obj_data(obj) (void *)&obj->data |
| 113 |
|
| 114 |
#endif |