From 96807c4c05e1e76b8bbf00d874a28a279e7d2840 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Tue, 1 Sep 2015 19:34:18 +0200 Subject: src: add compat header file definitions This patch restores the original nft_* definitions from the header files to avoid sudden compilation breakage of the existing clients of this library. Then, moving forward the idea is to deprecate the old nft_* symbols anytime soon using __attribute__((deprecated)) from the header files to warn our users that they need to update their code. Signed-off-by: Pablo Neira Ayuso --- include/libnftnl/rule.h | 83 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) (limited to 'include/libnftnl/rule.h') diff --git a/include/libnftnl/rule.h b/include/libnftnl/rule.h index 8aa47ea..c1bfcb6 100644 --- a/include/libnftnl/rule.h +++ b/include/libnftnl/rule.h @@ -91,6 +91,89 @@ struct nftnl_rule *nftnl_rule_list_iter_cur(struct nftnl_rule_list_iter *iter); struct nftnl_rule *nftnl_rule_list_iter_next(struct nftnl_rule_list_iter *iter); void nftnl_rule_list_iter_destroy(struct nftnl_rule_list_iter *iter); +/* + * Compat + */ + +struct nft_rule; +struct nft_rule_expr; + +struct nft_rule *nft_rule_alloc(void); +void nft_rule_free(struct nft_rule *); + +enum { + NFT_RULE_ATTR_FAMILY = 0, + NFT_RULE_ATTR_TABLE, + NFT_RULE_ATTR_CHAIN, + NFT_RULE_ATTR_HANDLE, + NFT_RULE_ATTR_COMPAT_PROTO, + NFT_RULE_ATTR_COMPAT_FLAGS, + NFT_RULE_ATTR_POSITION, + NFT_RULE_ATTR_USERDATA, + __NFT_RULE_ATTR_MAX +}; +#define NFT_RULE_ATTR_MAX (__NFT_RULE_ATTR_MAX - 1) + +void nft_rule_attr_unset(struct nft_rule *r, uint16_t attr); +bool nft_rule_attr_is_set(const struct nft_rule *r, uint16_t attr); +void nft_rule_attr_set(struct nft_rule *r, uint16_t attr, const void *data); +void nft_rule_attr_set_data(struct nft_rule *r, uint16_t attr, + const void *data, uint32_t data_len); +void nft_rule_attr_set_u32(struct nft_rule *r, uint16_t attr, uint32_t val); +void nft_rule_attr_set_u64(struct nft_rule *r, uint16_t attr, uint64_t val); +void nft_rule_attr_set_str(struct nft_rule *r, uint16_t attr, const char *str); + +const void *nft_rule_attr_get(const struct nft_rule *r, uint16_t attr); +const void *nft_rule_attr_get_data(const struct nft_rule *r, uint16_t attr, + uint32_t *data_len); +const char *nft_rule_attr_get_str(const struct nft_rule *r, uint16_t attr); +uint8_t nft_rule_attr_get_u8(const struct nft_rule *r, uint16_t attr); +uint32_t nft_rule_attr_get_u32(const struct nft_rule *r, uint16_t attr); +uint64_t nft_rule_attr_get_u64(const struct nft_rule *r, uint16_t attr); + +void nft_rule_add_expr(struct nft_rule *r, struct nft_rule_expr *expr); + +struct nlmsghdr; + +void nft_rule_nlmsg_build_payload(struct nlmsghdr *nlh, struct nft_rule *t); + +int nft_rule_parse(struct nft_rule *r, enum nft_parse_type type, + const char *data, struct nft_parse_err *err); +int nft_rule_parse_file(struct nft_rule *r, enum nft_parse_type type, + FILE *fp, struct nft_parse_err *err); +int nft_rule_snprintf(char *buf, size_t size, struct nft_rule *t, uint32_t type, uint32_t flags); +int nft_rule_fprintf(FILE *fp, struct nft_rule *r, uint32_t type, uint32_t flags); + +#define nft_rule_nlmsg_build_hdr nft_nlmsg_build_hdr +int nft_rule_nlmsg_parse(const struct nlmsghdr *nlh, struct nft_rule *t); + +int nft_rule_expr_foreach(struct nft_rule *r, + int (*cb)(struct nft_rule_expr *e, void *data), + void *data); + +struct nft_rule_expr_iter; + +struct nft_rule_expr_iter *nft_rule_expr_iter_create(struct nft_rule *r); +struct nft_rule_expr *nft_rule_expr_iter_next(struct nft_rule_expr_iter *iter); +void nft_rule_expr_iter_destroy(struct nft_rule_expr_iter *iter); + +struct nft_rule_list; + +struct nft_rule_list *nft_rule_list_alloc(void); +void nft_rule_list_free(struct nft_rule_list *list); +int nft_rule_list_is_empty(struct nft_rule_list *list); +void nft_rule_list_add(struct nft_rule *r, struct nft_rule_list *list); +void nft_rule_list_add_tail(struct nft_rule *r, struct nft_rule_list *list); +void nft_rule_list_del(struct nft_rule *r); +int nft_rule_list_foreach(struct nft_rule_list *rule_list, int (*cb)(struct nft_rule *t, void *data), void *data); + +struct nft_rule_list_iter; + +struct nft_rule_list_iter *nft_rule_list_iter_create(struct nft_rule_list *l); +struct nft_rule *nft_rule_list_iter_cur(struct nft_rule_list_iter *iter); +struct nft_rule *nft_rule_list_iter_next(struct nft_rule_list_iter *iter); +void nft_rule_list_iter_destroy(struct nft_rule_list_iter *iter); + #ifdef __cplusplus } /* extern "C" */ #endif -- cgit v1.2.3