@@ -56,6 +56,8 @@ uint64_t nft_chain_attr_get_u64(struct nft_chain *c, uint16_t attr);
struct nlmsghdr;
void nft_chain_nlmsg_build_payload(struct nlmsghdr *nlh, const struct nft_chain *t);
+void nft_chain_build_msg(struct nft_chain *c, void *buf, uint16_t msg,
+ unsigned int flags, uint32_t seq);
int nft_chain_parse(struct nft_chain *c, enum nft_parse_type type,
const char *data, struct nft_parse_err *err);
@@ -53,6 +53,8 @@ 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);
+void nft_rule_build_msg(struct nft_rule *r, void *buf, uint16_t msg,
+ unsigned int flags, uint32_t seq);
int nft_rule_parse(struct nft_rule *r, enum nft_parse_type type,
const char *data, struct nft_parse_err *err);
@@ -44,6 +44,8 @@ struct nlmsghdr;
#define nft_set_nlmsg_build_hdr nft_nlmsg_build_hdr
void nft_set_nlmsg_build_payload(struct nlmsghdr *nlh, struct nft_set *s);
+void nft_set_build_msg(struct nft_set *s, void *buf, uint16_t msg,
+ unsigned int flags, uint32_t seq);
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);
@@ -104,6 +106,8 @@ bool nft_set_elem_attr_is_set(const struct nft_set_elem *s, uint16_t attr);
#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);
+void nft_set_elems_build_msg(struct nft_set *s, void *buf, uint16_t msg,
+ unsigned int flags, uint32_t seq);
int nft_set_elem_parse(struct nft_set_elem *e, enum nft_parse_type type,
const char *data, struct nft_parse_err *err);
@@ -45,6 +45,8 @@ const char *nft_table_attr_get_str(struct nft_table *t, uint16_t attr);
struct nlmsghdr;
void nft_table_nlmsg_build_payload(struct nlmsghdr *nlh, const struct nft_table *t);
+void nft_table_build_msg(struct nft_table *t, void *buf, uint16_t msg,
+ unsigned int flags, uint32_t seq);
int nft_table_parse(struct nft_table *t, enum nft_parse_type type,
const char *data, struct nft_parse_err *err);
@@ -372,6 +372,17 @@ void nft_chain_nlmsg_build_payload(struct nlmsghdr *nlh, const struct nft_chain
}
EXPORT_SYMBOL(nft_chain_nlmsg_build_payload);
+void nft_chain_build_msg(struct nft_chain *c, void *buf, uint16_t msg,
+ unsigned int flags, uint32_t seq)
+{
+ struct nlmsghdr *nlh;
+ uint32_t family = nft_chain_attr_get_u32(c, NFT_CHAIN_ATTR_FAMILY);
+
+ nlh = nft_chain_nlmsg_build_hdr(buf, msg, family, flags, seq);
+ nft_chain_nlmsg_build_payload(nlh, c);
+}
+EXPORT_SYMBOL(nft_chain_build_msg);
+
static int nft_chain_parse_attr_cb(const struct nlattr *attr, void *data)
{
const struct nlattr **tb = data;
@@ -206,3 +206,11 @@ LIBNFTNL_1.1 {
nft_set_attr_set_data;
nft_set_attr_get_data;
} LIBNFTNL_1.0;
+
+LIBNFTNL_1.2 {
+ nft_table_build_msg;
+ nft_chain_build_msg;
+ nft_rule_build_msg;
+ nft_set_build_msg;
+ nft_set_elems_build_msg;
+} LIBNFTNL_1.1;
@@ -315,6 +315,17 @@ void nft_rule_nlmsg_build_payload(struct nlmsghdr *nlh, struct nft_rule *r)
}
EXPORT_SYMBOL(nft_rule_nlmsg_build_payload);
+void nft_rule_build_msg(struct nft_rule *r, void *buf, uint16_t msg,
+ unsigned int flags, uint32_t seq)
+{
+ struct nlmsghdr *nlh;
+ uint32_t family = nft_rule_attr_get_u32(r, NFT_RULE_ATTR_FAMILY);
+
+ nlh = nft_rule_nlmsg_build_hdr(buf, msg, family, flags, seq);
+ nft_rule_nlmsg_build_payload(nlh, r);
+}
+EXPORT_SYMBOL(nft_rule_build_msg);
+
void nft_rule_add_expr(struct nft_rule *r, struct nft_rule_expr *expr)
{
list_add_tail(&expr->head, &r->expr_list);
@@ -245,6 +245,17 @@ void nft_set_nlmsg_build_payload(struct nlmsghdr *nlh, struct nft_set *s)
}
EXPORT_SYMBOL(nft_set_nlmsg_build_payload);
+void nft_set_build_msg(struct nft_set *s, void *buf, uint16_t msg,
+ unsigned int flags, uint32_t seq)
+{
+ struct nlmsghdr *nlh;
+ uint32_t family = nft_set_attr_get_u32(s, NFT_SET_ATTR_FAMILY);
+
+ nlh = nft_set_nlmsg_build_hdr(buf, msg, family, flags, seq);
+ nft_set_nlmsg_build_payload(nlh, s);
+}
+EXPORT_SYMBOL(nft_set_build_msg);
+
static int nft_set_parse_attr_cb(const struct nlattr *attr, void *data)
{
const struct nlattr **tb = data;
@@ -220,6 +220,17 @@ void nft_set_elems_nlmsg_build_payload(struct nlmsghdr *nlh, struct nft_set *s)
}
EXPORT_SYMBOL(nft_set_elems_nlmsg_build_payload);
+void nft_set_elems_build_msg(struct nft_set *s, void *buf, uint16_t msg,
+ unsigned int flags, uint32_t seq)
+{
+ struct nlmsghdr *nlh;
+ uint32_t family = nft_set_attr_get_u32(s, NFT_SET_ATTR_FAMILY);
+
+ nlh = nft_set_nlmsg_build_hdr(buf, msg, family, flags, seq);
+ nft_set_elems_nlmsg_build_payload(nlh, s);
+}
+EXPORT_SYMBOL(nft_set_elems_build_msg);
+
static int nft_set_elem_parse_attr_cb(const struct nlattr *attr, void *data)
{
const struct nlattr **tb = data;
@@ -196,6 +196,17 @@ void nft_table_nlmsg_build_payload(struct nlmsghdr *nlh, const struct nft_table
}
EXPORT_SYMBOL(nft_table_nlmsg_build_payload);
+void nft_table_build_msg(struct nft_table *t, void *buf, uint16_t msg,
+ unsigned int flags, uint32_t seq)
+{
+ struct nlmsghdr *nlh;
+ uint32_t family = nft_table_attr_get_u32(t, NFT_TABLE_ATTR_FAMILY);
+
+ nlh = nft_table_nlmsg_build_hdr(buf, msg, family, flags, seq);
+ nft_table_nlmsg_build_payload(nlh, t);
+}
+EXPORT_SYMBOL(nft_table_build_msg);
+
static int nft_table_parse_attr_cb(const struct nlattr *attr, void *data)
{
const struct nlattr **tb = data;
These functions are likely to be used by all userspace programs to interact with the nftables kernel subsystem. Lets put in the library. Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com> --- include/libnftnl/chain.h | 2 ++ include/libnftnl/rule.h | 2 ++ include/libnftnl/set.h | 4 ++++ include/libnftnl/table.h | 2 ++ src/chain.c | 11 +++++++++++ src/libnftnl.map | 8 ++++++++ src/rule.c | 11 +++++++++++ src/set.c | 11 +++++++++++ src/set_elem.c | 11 +++++++++++ src/table.c | 11 +++++++++++ 10 files changed, 73 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html