From d7955867a79e8aed8058a2a69953c6005bb9ef5a Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Sun, 24 Nov 2013 21:01:49 +0100 Subject: src: consolidate netlink build header function Add new function nft_nlmsg_build_hdr which consolidates all existing functions to build headers per object. They basically look the same. This patch still provides aliases for consistency in the naming approach. Signed-off-by: Pablo Neira Ayuso --- include/libnftables/chain.h | 2 +- include/libnftables/common.h | 4 ++++ include/libnftables/rule.h | 2 +- include/libnftables/set.h | 4 ++-- include/libnftables/table.h | 2 +- 5 files changed, 9 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/libnftables/chain.h b/include/libnftables/chain.h index fff47d3..8b4eab9 100644 --- a/include/libnftables/chain.h +++ b/include/libnftables/chain.h @@ -55,7 +55,7 @@ int nft_chain_parse(struct nft_chain *c, enum nft_parse_type type, const char *d int nft_chain_snprintf(char *buf, size_t size, struct nft_chain *t, uint32_t type, uint32_t flags); int nft_chain_fprintf(FILE *fp, struct nft_chain *c, uint32_t type, uint32_t flags); -struct nlmsghdr *nft_chain_nlmsg_build_hdr(char *buf, uint16_t cmd, uint16_t family, uint16_t type, uint32_t seq); +#define nft_chain_nlmsg_build_hdr nft_nlmsg_build_hdr int nft_chain_nlmsg_parse(const struct nlmsghdr *nlh, struct nft_chain *t); struct nft_chain_list; diff --git a/include/libnftables/common.h b/include/libnftables/common.h index 2283d72..9cd92b2 100644 --- a/include/libnftables/common.h +++ b/include/libnftables/common.h @@ -13,4 +13,8 @@ enum nft_parse_type { NFT_PARSE_JSON, NFT_PARSE_MAX, }; + +struct nlmsghdr *nft_nlmsg_build_hdr(char *buf, uint16_t cmd, uint16_t family, + uint16_t type, uint32_t seq); + #endif diff --git a/include/libnftables/rule.h b/include/libnftables/rule.h index d1d75e1..86dbc17 100644 --- a/include/libnftables/rule.h +++ b/include/libnftables/rule.h @@ -51,7 +51,7 @@ int nft_rule_parse(struct nft_rule *r, enum nft_parse_type type, const char *dat 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); -struct nlmsghdr *nft_rule_nlmsg_build_hdr(char *buf, uint16_t cmd, uint16_t family, uint16_t type, uint32_t seq); +#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, diff --git a/include/libnftables/set.h b/include/libnftables/set.h index d91bd42..13ac857 100644 --- a/include/libnftables/set.h +++ b/include/libnftables/set.h @@ -36,7 +36,7 @@ uint32_t nft_set_attr_get_u32(struct nft_set *s, uint16_t attr); struct nlmsghdr; -struct nlmsghdr *nft_set_nlmsg_build_hdr(char *buf, uint16_t cmd, uint16_t family, uint16_t type, uint32_t seq); +#define nft_set_nlmsg_build_hdr nft_nlmsg_build_hdr void nft_set_nlmsg_build_payload(struct nlmsghdr *nlh, struct nft_set *s); int nft_set_nlmsg_parse(const struct nlmsghdr *nlh, struct nft_set *s); int nft_set_elems_nlmsg_parse(const struct nlmsghdr *nlh, struct nft_set *s); @@ -92,7 +92,7 @@ uint32_t nft_set_elem_attr_get_u32(struct nft_set_elem *s, uint16_t attr); bool nft_set_elem_attr_is_set(const struct nft_set_elem *s, uint16_t attr); -struct nlmsghdr *nft_set_elem_nlmsg_build_hdr(char *buf, uint16_t cmd, uint16_t family, uint16_t type, uint32_t seq); +#define nft_set_elem_nlmsg_build_hdr nft_nlmsg_build_hdr void nft_set_elems_nlmsg_build_payload(struct nlmsghdr *nlh, struct nft_set *s); void nft_set_elem_nlmsg_build_payload(struct nlmsghdr *nlh, struct nft_set_elem *e); diff --git a/include/libnftables/table.h b/include/libnftables/table.h index 87481e4..be60da9 100644 --- a/include/libnftables/table.h +++ b/include/libnftables/table.h @@ -43,7 +43,7 @@ int nft_table_parse(struct nft_table *t, enum nft_parse_type type, const char *d int nft_table_snprintf(char *buf, size_t size, struct nft_table *t, uint32_t type, uint32_t flags); int nft_table_fprintf(FILE *fp, struct nft_table *t, uint32_t type, uint32_t flags); -struct nlmsghdr *nft_table_nlmsg_build_hdr(char *buf, uint16_t cmd, uint16_t family, uint16_t type, uint32_t seq); +#define nft_table_nlmsg_build_hdr nft_nlmsg_build_hdr int nft_table_nlmsg_parse(const struct nlmsghdr *nlh, struct nft_table *t); struct nft_table_list; -- cgit v1.2.3