From 206d98a54305a1178c7d9c5e234699813f8c6f5a Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Mon, 7 Sep 2015 17:56:47 +0200 Subject: src: rename nftnl_rule_expr to nftnl_expr Use a shorter name for this, morever this can be used from sets so the _rule_ is misleading. Signed-off-by: Pablo Neira Ayuso --- src/expr/bitwise.c | 58 +++++++++++++++++++-------------------- src/expr/byteorder.c | 66 ++++++++++++++++++++++----------------------- src/expr/cmp.c | 54 ++++++++++++++++++------------------- src/expr/counter.c | 54 ++++++++++++++++++------------------- src/expr/ct.c | 56 +++++++++++++++++++------------------- src/expr/dynset.c | 76 ++++++++++++++++++++++++++-------------------------- src/expr/exthdr.c | 62 +++++++++++++++++++++--------------------- src/expr/immediate.c | 52 +++++++++++++++++------------------ src/expr/limit.c | 54 ++++++++++++++++++------------------- src/expr/log.c | 74 +++++++++++++++++++++++++------------------------- src/expr/lookup.c | 58 +++++++++++++++++++-------------------- src/expr/masq.c | 50 +++++++++++++++++----------------- src/expr/match.c | 48 ++++++++++++++++----------------- src/expr/meta.c | 58 +++++++++++++++++++-------------------- src/expr/nat.c | 74 +++++++++++++++++++++++++------------------------- src/expr/payload.c | 56 +++++++++++++++++++------------------- src/expr/queue.c | 60 ++++++++++++++++++++--------------------- src/expr/redir.c | 64 +++++++++++++++++++++---------------------- src/expr/reject.c | 54 ++++++++++++++++++------------------- src/expr/target.c | 44 +++++++++++++++--------------- 20 files changed, 586 insertions(+), 586 deletions(-) (limited to 'src/expr') diff --git a/src/expr/bitwise.c b/src/expr/bitwise.c index 331fd20..a18aad5 100644 --- a/src/expr/bitwise.c +++ b/src/expr/bitwise.c @@ -30,7 +30,7 @@ struct nftnl_expr_bitwise { }; static int -nftnl_rule_expr_bitwise_set(struct nftnl_rule_expr *e, uint16_t type, +nftnl_expr_bitwise_set(struct nftnl_expr *e, uint16_t type, const void *data, uint32_t data_len) { struct nftnl_expr_bitwise *bitwise = nftnl_expr_data(e); @@ -60,7 +60,7 @@ nftnl_rule_expr_bitwise_set(struct nftnl_rule_expr *e, uint16_t type, } static const void * -nftnl_rule_expr_bitwise_get(const struct nftnl_rule_expr *e, uint16_t type, +nftnl_expr_bitwise_get(const struct nftnl_expr *e, uint16_t type, uint32_t *data_len) { struct nftnl_expr_bitwise *bitwise = nftnl_expr_data(e); @@ -85,7 +85,7 @@ nftnl_rule_expr_bitwise_get(const struct nftnl_rule_expr *e, uint16_t type, return NULL; } -static int nftnl_rule_expr_bitwise_cb(const struct nlattr *attr, void *data) +static int nftnl_expr_bitwise_cb(const struct nlattr *attr, void *data) { const struct nlattr **tb = data; int type = mnl_attr_get_type(attr); @@ -112,7 +112,7 @@ static int nftnl_rule_expr_bitwise_cb(const struct nlattr *attr, void *data) } static void -nftnl_rule_expr_bitwise_build(struct nlmsghdr *nlh, struct nftnl_rule_expr *e) +nftnl_expr_bitwise_build(struct nlmsghdr *nlh, struct nftnl_expr *e) { struct nftnl_expr_bitwise *bitwise = nftnl_expr_data(e); @@ -141,13 +141,13 @@ nftnl_rule_expr_bitwise_build(struct nlmsghdr *nlh, struct nftnl_rule_expr *e) } static int -nftnl_rule_expr_bitwise_parse(struct nftnl_rule_expr *e, struct nlattr *attr) +nftnl_expr_bitwise_parse(struct nftnl_expr *e, struct nlattr *attr) { struct nftnl_expr_bitwise *bitwise = nftnl_expr_data(e); struct nlattr *tb[NFTA_BITWISE_MAX+1] = {}; int ret = 0; - if (mnl_attr_parse_nested(attr, nftnl_rule_expr_bitwise_cb, tb) < 0) + if (mnl_attr_parse_nested(attr, nftnl_expr_bitwise_cb, tb) < 0) return -1; if (tb[NFTA_BITWISE_SREG]) { @@ -175,7 +175,7 @@ nftnl_rule_expr_bitwise_parse(struct nftnl_rule_expr *e, struct nlattr *attr) } static int -nftnl_rule_expr_bitwise_json_parse(struct nftnl_rule_expr *e, json_t *root, +nftnl_expr_bitwise_json_parse(struct nftnl_expr *e, json_t *root, struct nftnl_parse_err *err) { #ifdef JSON_PARSING @@ -183,13 +183,13 @@ nftnl_rule_expr_bitwise_json_parse(struct nftnl_rule_expr *e, json_t *root, uint32_t reg, len; if (nftnl_jansson_parse_reg(root, "sreg", NFTNL_TYPE_U32, ®, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_BITWISE_SREG, reg); + nftnl_expr_set_u32(e, NFTNL_EXPR_BITWISE_SREG, reg); if (nftnl_jansson_parse_reg(root, "dreg", NFTNL_TYPE_U32, ®, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_BITWISE_DREG, reg); + nftnl_expr_set_u32(e, NFTNL_EXPR_BITWISE_DREG, reg); if (nftnl_jansson_parse_val(root, "len", NFTNL_TYPE_U32, &len, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_BITWISE_LEN, len); + nftnl_expr_set_u32(e, NFTNL_EXPR_BITWISE_LEN, len); if (nftnl_jansson_data_reg_parse(root, "mask", &bitwise->mask, err) == DATA_VALUE) @@ -210,7 +210,7 @@ nftnl_rule_expr_bitwise_json_parse(struct nftnl_rule_expr *e, json_t *root, } static int -nftnl_rule_expr_bitwise_xml_parse(struct nftnl_rule_expr *e, mxml_node_t *tree, +nftnl_expr_bitwise_xml_parse(struct nftnl_expr *e, mxml_node_t *tree, struct nftnl_parse_err *err) { #ifdef XML_PARSING @@ -219,15 +219,15 @@ nftnl_rule_expr_bitwise_xml_parse(struct nftnl_rule_expr *e, mxml_node_t *tree, if (nftnl_mxml_reg_parse(tree, "sreg", &sreg, MXML_DESCEND_FIRST, NFTNL_XML_MAND, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_BITWISE_SREG, sreg); + nftnl_expr_set_u32(e, NFTNL_EXPR_BITWISE_SREG, sreg); if (nftnl_mxml_reg_parse(tree, "dreg", &dreg, MXML_DESCEND_FIRST, NFTNL_XML_MAND, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_BITWISE_DREG, dreg); + nftnl_expr_set_u32(e, NFTNL_EXPR_BITWISE_DREG, dreg); if (nftnl_mxml_num_parse(tree, "len", MXML_DESCEND_FIRST, BASE_DEC, &len, NFTNL_TYPE_U32, NFTNL_XML_MAND, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_BITWISE_LEN, len); + nftnl_expr_set_u32(e, NFTNL_EXPR_BITWISE_LEN, len); if (nftnl_mxml_data_reg_parse(tree, "mask", &bitwise->mask, NFTNL_XML_MAND, err) == DATA_VALUE) @@ -250,8 +250,8 @@ nftnl_rule_expr_bitwise_xml_parse(struct nftnl_rule_expr *e, mxml_node_t *tree, #endif } -static int nftnl_rule_expr_bitwise_export(char *buf, size_t size, - struct nftnl_rule_expr *e, int type) +static int nftnl_expr_bitwise_export(char *buf, size_t size, + struct nftnl_expr *e, int type) { struct nftnl_expr_bitwise *bitwise = nftnl_expr_data(e); NFTNL_BUF_INIT(b, buf, size); @@ -270,8 +270,8 @@ static int nftnl_rule_expr_bitwise_export(char *buf, size_t size, return nftnl_buf_done(&b); } -static int nftnl_rule_expr_bitwise_snprintf_default(char *buf, size_t size, - struct nftnl_rule_expr *e) +static int nftnl_expr_bitwise_snprintf_default(char *buf, size_t size, + struct nftnl_expr *e) { struct nftnl_expr_bitwise *bitwise = nftnl_expr_data(e); int len = size, offset = 0, ret; @@ -295,15 +295,15 @@ static int nftnl_rule_expr_bitwise_snprintf_default(char *buf, size_t size, } static int -nftnl_rule_expr_bitwise_snprintf(char *buf, size_t size, uint32_t type, - uint32_t flags, struct nftnl_rule_expr *e) +nftnl_expr_bitwise_snprintf(char *buf, size_t size, uint32_t type, + uint32_t flags, struct nftnl_expr *e) { switch (type) { case NFTNL_OUTPUT_DEFAULT: - return nftnl_rule_expr_bitwise_snprintf_default(buf, size, e); + return nftnl_expr_bitwise_snprintf_default(buf, size, e); case NFTNL_OUTPUT_XML: case NFTNL_OUTPUT_JSON: - return nftnl_rule_expr_bitwise_export(buf, size, e, type); + return nftnl_expr_bitwise_export(buf, size, e, type); default: break; } @@ -314,11 +314,11 @@ struct expr_ops expr_ops_bitwise = { .name = "bitwise", .alloc_len = sizeof(struct nftnl_expr_bitwise), .max_attr = NFTA_BITWISE_MAX, - .set = nftnl_rule_expr_bitwise_set, - .get = nftnl_rule_expr_bitwise_get, - .parse = nftnl_rule_expr_bitwise_parse, - .build = nftnl_rule_expr_bitwise_build, - .snprintf = nftnl_rule_expr_bitwise_snprintf, - .xml_parse = nftnl_rule_expr_bitwise_xml_parse, - .json_parse = nftnl_rule_expr_bitwise_json_parse, + .set = nftnl_expr_bitwise_set, + .get = nftnl_expr_bitwise_get, + .parse = nftnl_expr_bitwise_parse, + .build = nftnl_expr_bitwise_build, + .snprintf = nftnl_expr_bitwise_snprintf, + .xml_parse = nftnl_expr_bitwise_xml_parse, + .json_parse = nftnl_expr_bitwise_json_parse, }; diff --git a/src/expr/byteorder.c b/src/expr/byteorder.c index c37e56d..f16bbf7 100644 --- a/src/expr/byteorder.c +++ b/src/expr/byteorder.c @@ -30,7 +30,7 @@ struct nftnl_expr_byteorder { }; static int -nftnl_rule_expr_byteorder_set(struct nftnl_rule_expr *e, uint16_t type, +nftnl_expr_byteorder_set(struct nftnl_expr *e, uint16_t type, const void *data, uint32_t data_len) { struct nftnl_expr_byteorder *byteorder = nftnl_expr_data(e); @@ -58,7 +58,7 @@ nftnl_rule_expr_byteorder_set(struct nftnl_rule_expr *e, uint16_t type, } static const void * -nftnl_rule_expr_byteorder_get(const struct nftnl_rule_expr *e, uint16_t type, +nftnl_expr_byteorder_get(const struct nftnl_expr *e, uint16_t type, uint32_t *data_len) { struct nftnl_expr_byteorder *byteorder = nftnl_expr_data(e); @@ -83,7 +83,7 @@ nftnl_rule_expr_byteorder_get(const struct nftnl_rule_expr *e, uint16_t type, return NULL; } -static int nftnl_rule_expr_byteorder_cb(const struct nlattr *attr, void *data) +static int nftnl_expr_byteorder_cb(const struct nlattr *attr, void *data) { const struct nlattr **tb = data; int type = mnl_attr_get_type(attr); @@ -107,7 +107,7 @@ static int nftnl_rule_expr_byteorder_cb(const struct nlattr *attr, void *data) } static void -nftnl_rule_expr_byteorder_build(struct nlmsghdr *nlh, struct nftnl_rule_expr *e) +nftnl_expr_byteorder_build(struct nlmsghdr *nlh, struct nftnl_expr *e) { struct nftnl_expr_byteorder *byteorder = nftnl_expr_data(e); @@ -134,13 +134,13 @@ nftnl_rule_expr_byteorder_build(struct nlmsghdr *nlh, struct nftnl_rule_expr *e) } static int -nftnl_rule_expr_byteorder_parse(struct nftnl_rule_expr *e, struct nlattr *attr) +nftnl_expr_byteorder_parse(struct nftnl_expr *e, struct nlattr *attr) { struct nftnl_expr_byteorder *byteorder = nftnl_expr_data(e); struct nlattr *tb[NFTA_BYTEORDER_MAX+1] = {}; int ret = 0; - if (mnl_attr_parse_nested(attr, nftnl_rule_expr_byteorder_cb, tb) < 0) + if (mnl_attr_parse_nested(attr, nftnl_expr_byteorder_cb, tb) < 0) return -1; if (tb[NFTA_BYTEORDER_SREG]) { @@ -198,7 +198,7 @@ static inline int nftnl_str2ntoh(const char *op) } static int -nftnl_rule_expr_byteorder_json_parse(struct nftnl_rule_expr *e, json_t *root, +nftnl_expr_byteorder_json_parse(struct nftnl_expr *e, json_t *root, struct nftnl_parse_err *err) { #ifdef JSON_PARSING @@ -207,10 +207,10 @@ nftnl_rule_expr_byteorder_json_parse(struct nftnl_rule_expr *e, json_t *root, int ntoh; if (nftnl_jansson_parse_reg(root, "sreg", NFTNL_TYPE_U32, &sreg, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_BYTEORDER_SREG, sreg); + nftnl_expr_set_u32(e, NFTNL_EXPR_BYTEORDER_SREG, sreg); if (nftnl_jansson_parse_reg(root, "dreg", NFTNL_TYPE_U32, &dreg, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_BYTEORDER_DREG, dreg); + nftnl_expr_set_u32(e, NFTNL_EXPR_BYTEORDER_DREG, dreg); op = nftnl_jansson_parse_str(root, "op", err); if (op != NULL) { @@ -218,14 +218,14 @@ nftnl_rule_expr_byteorder_json_parse(struct nftnl_rule_expr *e, json_t *root, if (ntoh < 0) return -1; - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_BYTEORDER_OP, ntoh); + nftnl_expr_set_u32(e, NFTNL_EXPR_BYTEORDER_OP, ntoh); } if (nftnl_jansson_parse_val(root, "len", NFTNL_TYPE_U32, &len, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_BYTEORDER_LEN, len); + nftnl_expr_set_u32(e, NFTNL_EXPR_BYTEORDER_LEN, len); if (nftnl_jansson_parse_val(root, "size", NFTNL_TYPE_U32, &size, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_BYTEORDER_SIZE, size); + nftnl_expr_set_u32(e, NFTNL_EXPR_BYTEORDER_SIZE, size); return 0; #else @@ -235,7 +235,7 @@ nftnl_rule_expr_byteorder_json_parse(struct nftnl_rule_expr *e, json_t *root, } static int -nftnl_rule_expr_byteorder_xml_parse(struct nftnl_rule_expr *e, mxml_node_t *tree, +nftnl_expr_byteorder_xml_parse(struct nftnl_expr *e, mxml_node_t *tree, struct nftnl_parse_err *err) { #ifdef XML_PARSING @@ -245,11 +245,11 @@ nftnl_rule_expr_byteorder_xml_parse(struct nftnl_rule_expr *e, mxml_node_t *tree if (nftnl_mxml_reg_parse(tree, "sreg", &sreg, MXML_DESCEND_FIRST, NFTNL_XML_MAND, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_BYTEORDER_SREG, sreg); + nftnl_expr_set_u32(e, NFTNL_EXPR_BYTEORDER_SREG, sreg); if (nftnl_mxml_reg_parse(tree, "dreg", &dreg, MXML_DESCEND, NFTNL_XML_MAND, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_BYTEORDER_DREG, dreg); + nftnl_expr_set_u32(e, NFTNL_EXPR_BYTEORDER_DREG, dreg); op = nftnl_mxml_str_parse(tree, "op", MXML_DESCEND_FIRST, NFTNL_XML_MAND, err); @@ -258,16 +258,16 @@ nftnl_rule_expr_byteorder_xml_parse(struct nftnl_rule_expr *e, mxml_node_t *tree if (ntoh < 0) return -1; - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_BYTEORDER_OP, ntoh); + nftnl_expr_set_u32(e, NFTNL_EXPR_BYTEORDER_OP, ntoh); } if (nftnl_mxml_num_parse(tree, "len", MXML_DESCEND_FIRST, BASE_DEC, &len, NFTNL_TYPE_U32, NFTNL_XML_MAND, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_BYTEORDER_LEN, len); + nftnl_expr_set_u32(e, NFTNL_EXPR_BYTEORDER_LEN, len); if (nftnl_mxml_num_parse(tree, "size", MXML_DESCEND_FIRST, BASE_DEC, &size, NFTNL_TYPE_U32, NFTNL_XML_MAND, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_BYTEORDER_SIZE, size); + nftnl_expr_set_u32(e, NFTNL_EXPR_BYTEORDER_SIZE, size); return 0; #else @@ -276,8 +276,8 @@ nftnl_rule_expr_byteorder_xml_parse(struct nftnl_rule_expr *e, mxml_node_t *tree #endif } -static int nftnl_rule_expr_byteorder_export(char *buf, size_t size, - struct nftnl_rule_expr *e, int type) +static int nftnl_expr_byteorder_export(char *buf, size_t size, + struct nftnl_expr *e, int type) { struct nftnl_expr_byteorder *byteorder = nftnl_expr_data(e); NFTNL_BUF_INIT(b, buf, size); @@ -296,8 +296,8 @@ static int nftnl_rule_expr_byteorder_export(char *buf, size_t size, return nftnl_buf_done(&b); } -static int nftnl_rule_expr_byteorder_snprintf_default(char *buf, size_t size, - struct nftnl_rule_expr *e) +static int nftnl_expr_byteorder_snprintf_default(char *buf, size_t size, + struct nftnl_expr *e) { struct nftnl_expr_byteorder *byteorder = nftnl_expr_data(e); int len = size, offset = 0, ret; @@ -311,15 +311,15 @@ static int nftnl_rule_expr_byteorder_snprintf_default(char *buf, size_t size, } static int -nftnl_rule_expr_byteorder_snprintf(char *buf, size_t size, uint32_t type, - uint32_t flags, struct nftnl_rule_expr *e) +nftnl_expr_byteorder_snprintf(char *buf, size_t size, uint32_t type, + uint32_t flags, struct nftnl_expr *e) { switch (type) { case NFTNL_OUTPUT_DEFAULT: - return nftnl_rule_expr_byteorder_snprintf_default(buf, size, e); + return nftnl_expr_byteorder_snprintf_default(buf, size, e); case NFTNL_OUTPUT_XML: case NFTNL_OUTPUT_JSON: - return nftnl_rule_expr_byteorder_export(buf, size, e, type); + return nftnl_expr_byteorder_export(buf, size, e, type); default: break; } @@ -330,11 +330,11 @@ struct expr_ops expr_ops_byteorder = { .name = "byteorder", .alloc_len = sizeof(struct nftnl_expr_byteorder), .max_attr = NFTA_BYTEORDER_MAX, - .set = nftnl_rule_expr_byteorder_set, - .get = nftnl_rule_expr_byteorder_get, - .parse = nftnl_rule_expr_byteorder_parse, - .build = nftnl_rule_expr_byteorder_build, - .snprintf = nftnl_rule_expr_byteorder_snprintf, - .xml_parse = nftnl_rule_expr_byteorder_xml_parse, - .json_parse = nftnl_rule_expr_byteorder_json_parse, + .set = nftnl_expr_byteorder_set, + .get = nftnl_expr_byteorder_get, + .parse = nftnl_expr_byteorder_parse, + .build = nftnl_expr_byteorder_build, + .snprintf = nftnl_expr_byteorder_snprintf, + .xml_parse = nftnl_expr_byteorder_xml_parse, + .json_parse = nftnl_expr_byteorder_json_parse, }; diff --git a/src/expr/cmp.c b/src/expr/cmp.c index 83b9afc..4125689 100644 --- a/src/expr/cmp.c +++ b/src/expr/cmp.c @@ -29,7 +29,7 @@ struct nftnl_expr_cmp { }; static int -nftnl_rule_expr_cmp_set(struct nftnl_rule_expr *e, uint16_t type, +nftnl_expr_cmp_set(struct nftnl_expr *e, uint16_t type, const void *data, uint32_t data_len) { struct nftnl_expr_cmp *cmp = nftnl_expr_data(e); @@ -52,7 +52,7 @@ nftnl_rule_expr_cmp_set(struct nftnl_rule_expr *e, uint16_t type, } static const void * -nftnl_rule_expr_cmp_get(const struct nftnl_rule_expr *e, uint16_t type, +nftnl_expr_cmp_get(const struct nftnl_expr *e, uint16_t type, uint32_t *data_len) { struct nftnl_expr_cmp *cmp = nftnl_expr_data(e); @@ -71,7 +71,7 @@ nftnl_rule_expr_cmp_get(const struct nftnl_rule_expr *e, uint16_t type, return NULL; } -static int nftnl_rule_expr_cmp_cb(const struct nlattr *attr, void *data) +static int nftnl_expr_cmp_cb(const struct nlattr *attr, void *data) { const struct nlattr **tb = data; int type = mnl_attr_get_type(attr); @@ -96,7 +96,7 @@ static int nftnl_rule_expr_cmp_cb(const struct nlattr *attr, void *data) } static void -nftnl_rule_expr_cmp_build(struct nlmsghdr *nlh, struct nftnl_rule_expr *e) +nftnl_expr_cmp_build(struct nlmsghdr *nlh, struct nftnl_expr *e) { struct nftnl_expr_cmp *cmp = nftnl_expr_data(e); @@ -114,13 +114,13 @@ nftnl_rule_expr_cmp_build(struct nlmsghdr *nlh, struct nftnl_rule_expr *e) } static int -nftnl_rule_expr_cmp_parse(struct nftnl_rule_expr *e, struct nlattr *attr) +nftnl_expr_cmp_parse(struct nftnl_expr *e, struct nlattr *attr) { struct nftnl_expr_cmp *cmp = nftnl_expr_data(e); struct nlattr *tb[NFTA_CMP_MAX+1] = {}; int ret = 0; - if (mnl_attr_parse_nested(attr, nftnl_rule_expr_cmp_cb, tb) < 0) + if (mnl_attr_parse_nested(attr, nftnl_expr_cmp_cb, tb) < 0) return -1; if (tb[NFTA_CMP_SREG]) { @@ -176,7 +176,7 @@ static inline int nftnl_str2cmp(const char *op) } } -static int nftnl_rule_expr_cmp_json_parse(struct nftnl_rule_expr *e, json_t *root, +static int nftnl_expr_cmp_json_parse(struct nftnl_expr *e, json_t *root, struct nftnl_parse_err *err) { #ifdef JSON_PARSING @@ -187,7 +187,7 @@ static int nftnl_rule_expr_cmp_json_parse(struct nftnl_rule_expr *e, json_t *roo if (nftnl_jansson_parse_val(root, "sreg", NFTNL_TYPE_U32, &uval32, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_CMP_SREG, uval32); + nftnl_expr_set_u32(e, NFTNL_EXPR_CMP_SREG, uval32); op = nftnl_jansson_parse_str(root, "op", err); if (op != NULL) { @@ -195,7 +195,7 @@ static int nftnl_rule_expr_cmp_json_parse(struct nftnl_rule_expr *e, json_t *roo if (base < 0) return -1; - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_CMP_OP, base); + nftnl_expr_set_u32(e, NFTNL_EXPR_CMP_OP, base); } if (nftnl_jansson_data_reg_parse(root, "data", @@ -209,7 +209,7 @@ static int nftnl_rule_expr_cmp_json_parse(struct nftnl_rule_expr *e, json_t *roo #endif } -static int nftnl_rule_expr_cmp_xml_parse(struct nftnl_rule_expr *e, mxml_node_t *tree, +static int nftnl_expr_cmp_xml_parse(struct nftnl_expr *e, mxml_node_t *tree, struct nftnl_parse_err *err) { #ifdef XML_PARSING @@ -220,7 +220,7 @@ static int nftnl_rule_expr_cmp_xml_parse(struct nftnl_rule_expr *e, mxml_node_t if (nftnl_mxml_reg_parse(tree, "sreg", &sreg, MXML_DESCEND_FIRST, NFTNL_XML_MAND, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_CMP_SREG, sreg); + nftnl_expr_set_u32(e, NFTNL_EXPR_CMP_SREG, sreg); op = nftnl_mxml_str_parse(tree, "op", MXML_DESCEND_FIRST, NFTNL_XML_MAND, err); @@ -229,7 +229,7 @@ static int nftnl_rule_expr_cmp_xml_parse(struct nftnl_rule_expr *e, mxml_node_t if (op_value < 0) return -1; - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_CMP_OP, op_value); + nftnl_expr_set_u32(e, NFTNL_EXPR_CMP_OP, op_value); } if (nftnl_mxml_data_reg_parse(tree, "data", @@ -244,8 +244,8 @@ static int nftnl_rule_expr_cmp_xml_parse(struct nftnl_rule_expr *e, mxml_node_t #endif } -static int nftnl_rule_expr_cmp_export(char *buf, size_t size, - struct nftnl_rule_expr *e, int type) +static int nftnl_expr_cmp_export(char *buf, size_t size, + struct nftnl_expr *e, int type) { struct nftnl_expr_cmp *cmp = nftnl_expr_data(e); NFTNL_BUF_INIT(b, buf, size); @@ -260,8 +260,8 @@ static int nftnl_rule_expr_cmp_export(char *buf, size_t size, return nftnl_buf_done(&b); } -static int nftnl_rule_expr_cmp_snprintf_default(char *buf, size_t size, - struct nftnl_rule_expr *e) +static int nftnl_expr_cmp_snprintf_default(char *buf, size_t size, + struct nftnl_expr *e) { struct nftnl_expr_cmp *cmp = nftnl_expr_data(e); int len = size, offset = 0, ret; @@ -278,15 +278,15 @@ static int nftnl_rule_expr_cmp_snprintf_default(char *buf, size_t size, } static int -nftnl_rule_expr_cmp_snprintf(char *buf, size_t size, uint32_t type, - uint32_t flags, struct nftnl_rule_expr *e) +nftnl_expr_cmp_snprintf(char *buf, size_t size, uint32_t type, + uint32_t flags, struct nftnl_expr *e) { switch (type) { case NFTNL_OUTPUT_DEFAULT: - return nftnl_rule_expr_cmp_snprintf_default(buf, size, e); + return nftnl_expr_cmp_snprintf_default(buf, size, e); case NFTNL_OUTPUT_XML: case NFTNL_OUTPUT_JSON: - return nftnl_rule_expr_cmp_export(buf, size, e, type); + return nftnl_expr_cmp_export(buf, size, e, type); default: break; } @@ -297,11 +297,11 @@ struct expr_ops expr_ops_cmp = { .name = "cmp", .alloc_len = sizeof(struct nftnl_expr_cmp), .max_attr = NFTA_CMP_MAX, - .set = nftnl_rule_expr_cmp_set, - .get = nftnl_rule_expr_cmp_get, - .parse = nftnl_rule_expr_cmp_parse, - .build = nftnl_rule_expr_cmp_build, - .snprintf = nftnl_rule_expr_cmp_snprintf, - .xml_parse = nftnl_rule_expr_cmp_xml_parse, - .json_parse = nftnl_rule_expr_cmp_json_parse, + .set = nftnl_expr_cmp_set, + .get = nftnl_expr_cmp_get, + .parse = nftnl_expr_cmp_parse, + .build = nftnl_expr_cmp_build, + .snprintf = nftnl_expr_cmp_snprintf, + .xml_parse = nftnl_expr_cmp_xml_parse, + .json_parse = nftnl_expr_cmp_json_parse, }; diff --git a/src/expr/counter.c b/src/expr/counter.c index b5a9644..4b5fb3f 100644 --- a/src/expr/counter.c +++ b/src/expr/counter.c @@ -28,7 +28,7 @@ struct nftnl_expr_counter { }; static int -nftnl_rule_expr_counter_set(struct nftnl_rule_expr *e, uint16_t type, +nftnl_expr_counter_set(struct nftnl_expr *e, uint16_t type, const void *data, uint32_t data_len) { struct nftnl_expr_counter *ctr = nftnl_expr_data(e); @@ -47,7 +47,7 @@ nftnl_rule_expr_counter_set(struct nftnl_rule_expr *e, uint16_t type, } static const void * -nftnl_rule_expr_counter_get(const struct nftnl_rule_expr *e, uint16_t type, +nftnl_expr_counter_get(const struct nftnl_expr *e, uint16_t type, uint32_t *data_len) { struct nftnl_expr_counter *ctr = nftnl_expr_data(e); @@ -63,7 +63,7 @@ nftnl_rule_expr_counter_get(const struct nftnl_rule_expr *e, uint16_t type, return NULL; } -static int nftnl_rule_expr_counter_cb(const struct nlattr *attr, void *data) +static int nftnl_expr_counter_cb(const struct nlattr *attr, void *data) { const struct nlattr **tb = data; int type = mnl_attr_get_type(attr); @@ -84,7 +84,7 @@ static int nftnl_rule_expr_counter_cb(const struct nlattr *attr, void *data) } static void -nftnl_rule_expr_counter_build(struct nlmsghdr *nlh, struct nftnl_rule_expr *e) +nftnl_expr_counter_build(struct nlmsghdr *nlh, struct nftnl_expr *e) { struct nftnl_expr_counter *ctr = nftnl_expr_data(e); @@ -95,12 +95,12 @@ nftnl_rule_expr_counter_build(struct nlmsghdr *nlh, struct nftnl_rule_expr *e) } static int -nftnl_rule_expr_counter_parse(struct nftnl_rule_expr *e, struct nlattr *attr) +nftnl_expr_counter_parse(struct nftnl_expr *e, struct nlattr *attr) { struct nftnl_expr_counter *ctr = nftnl_expr_data(e); struct nlattr *tb[NFTA_COUNTER_MAX+1] = {}; - if (mnl_attr_parse_nested(attr, nftnl_rule_expr_counter_cb, tb) < 0) + if (mnl_attr_parse_nested(attr, nftnl_expr_counter_cb, tb) < 0) return -1; if (tb[NFTA_COUNTER_BYTES]) { @@ -116,7 +116,7 @@ nftnl_rule_expr_counter_parse(struct nftnl_rule_expr *e, struct nlattr *attr) } static int -nftnl_rule_expr_counter_json_parse(struct nftnl_rule_expr *e, json_t *root, +nftnl_expr_counter_json_parse(struct nftnl_expr *e, json_t *root, struct nftnl_parse_err *err) { #ifdef JSON_PARSING @@ -124,11 +124,11 @@ nftnl_rule_expr_counter_json_parse(struct nftnl_rule_expr *e, json_t *root, if (nftnl_jansson_parse_val(root, "pkts", NFTNL_TYPE_U64, &uval64, err) == 0) - nftnl_rule_expr_set_u64(e, NFTNL_EXPR_CTR_PACKETS, uval64); + nftnl_expr_set_u64(e, NFTNL_EXPR_CTR_PACKETS, uval64); if (nftnl_jansson_parse_val(root, "bytes", NFTNL_TYPE_U64, &uval64, err) == 0) - nftnl_rule_expr_set_u64(e, NFTNL_EXPR_CTR_BYTES, uval64); + nftnl_expr_set_u64(e, NFTNL_EXPR_CTR_BYTES, uval64); return 0; #else @@ -138,7 +138,7 @@ nftnl_rule_expr_counter_json_parse(struct nftnl_rule_expr *e, json_t *root, } static int -nftnl_rule_expr_counter_xml_parse(struct nftnl_rule_expr *e, mxml_node_t *tree, +nftnl_expr_counter_xml_parse(struct nftnl_expr *e, mxml_node_t *tree, struct nftnl_parse_err *err) { #ifdef XML_PARSING @@ -146,11 +146,11 @@ nftnl_rule_expr_counter_xml_parse(struct nftnl_rule_expr *e, mxml_node_t *tree, if (nftnl_mxml_num_parse(tree, "pkts", MXML_DESCEND_FIRST, BASE_DEC, &pkts, NFTNL_TYPE_U64, NFTNL_XML_MAND, err) == 0) - nftnl_rule_expr_set_u64(e, NFTNL_EXPR_CTR_PACKETS, pkts); + nftnl_expr_set_u64(e, NFTNL_EXPR_CTR_PACKETS, pkts); if (nftnl_mxml_num_parse(tree, "bytes", MXML_DESCEND_FIRST, BASE_DEC, &bytes, NFTNL_TYPE_U64, NFTNL_XML_MAND, err) == 0) - nftnl_rule_expr_set_u64(e, NFTNL_EXPR_CTR_BYTES, bytes); + nftnl_expr_set_u64(e, NFTNL_EXPR_CTR_BYTES, bytes); return 0; #else @@ -159,8 +159,8 @@ nftnl_rule_expr_counter_xml_parse(struct nftnl_rule_expr *e, mxml_node_t *tree, #endif } -static int nftnl_rule_expr_counter_export(char *buf, size_t size, - struct nftnl_rule_expr *e, int type) +static int nftnl_expr_counter_export(char *buf, size_t size, + struct nftnl_expr *e, int type) { struct nftnl_expr_counter *ctr = nftnl_expr_data(e); NFTNL_BUF_INIT(b, buf, size); @@ -173,8 +173,8 @@ static int nftnl_rule_expr_counter_export(char *buf, size_t size, return nftnl_buf_done(&b); } -static int nftnl_rule_expr_counter_snprintf_default(char *buf, size_t len, - struct nftnl_rule_expr *e) +static int nftnl_expr_counter_snprintf_default(char *buf, size_t len, + struct nftnl_expr *e) { struct nftnl_expr_counter *ctr = nftnl_expr_data(e); @@ -182,16 +182,16 @@ static int nftnl_rule_expr_counter_snprintf_default(char *buf, size_t len, ctr->pkts, ctr->bytes); } -static int nftnl_rule_expr_counter_snprintf(char *buf, size_t len, uint32_t type, +static int nftnl_expr_counter_snprintf(char *buf, size_t len, uint32_t type, uint32_t flags, - struct nftnl_rule_expr *e) + struct nftnl_expr *e) { switch (type) { case NFTNL_OUTPUT_DEFAULT: - return nftnl_rule_expr_counter_snprintf_default(buf, len, e); + return nftnl_expr_counter_snprintf_default(buf, len, e); case NFTNL_OUTPUT_XML: case NFTNL_OUTPUT_JSON: - return nftnl_rule_expr_counter_export(buf, len, e, type); + return nftnl_expr_counter_export(buf, len, e, type); default: break; } @@ -202,11 +202,11 @@ struct expr_ops expr_ops_counter = { .name = "counter", .alloc_len = sizeof(struct nftnl_expr_counter), .max_attr = NFTA_COUNTER_MAX, - .set = nftnl_rule_expr_counter_set, - .get = nftnl_rule_expr_counter_get, - .parse = nftnl_rule_expr_counter_parse, - .build = nftnl_rule_expr_counter_build, - .snprintf = nftnl_rule_expr_counter_snprintf, - .xml_parse = nftnl_rule_expr_counter_xml_parse, - .json_parse = nftnl_rule_expr_counter_json_parse, + .set = nftnl_expr_counter_set, + .get = nftnl_expr_counter_get, + .parse = nftnl_expr_counter_parse, + .build = nftnl_expr_counter_build, + .snprintf = nftnl_expr_counter_snprintf, + .xml_parse = nftnl_expr_counter_xml_parse, + .json_parse = nftnl_expr_counter_json_parse, }; diff --git a/src/expr/ct.c b/src/expr/ct.c index 73ae33a..584dffe 100644 --- a/src/expr/ct.c +++ b/src/expr/ct.c @@ -36,7 +36,7 @@ struct nftnl_expr_ct { #endif static int -nftnl_rule_expr_ct_set(struct nftnl_rule_expr *e, uint16_t type, +nftnl_expr_ct_set(struct nftnl_expr *e, uint16_t type, const void *data, uint32_t data_len) { struct nftnl_expr_ct *ct = nftnl_expr_data(e); @@ -61,7 +61,7 @@ nftnl_rule_expr_ct_set(struct nftnl_rule_expr *e, uint16_t type, } static const void * -nftnl_rule_expr_ct_get(const struct nftnl_rule_expr *e, uint16_t type, +nftnl_expr_ct_get(const struct nftnl_expr *e, uint16_t type, uint32_t *data_len) { struct nftnl_expr_ct *ct = nftnl_expr_data(e); @@ -83,7 +83,7 @@ nftnl_rule_expr_ct_get(const struct nftnl_rule_expr *e, uint16_t type, return NULL; } -static int nftnl_rule_expr_ct_cb(const struct nlattr *attr, void *data) +static int nftnl_expr_ct_cb(const struct nlattr *attr, void *data) { const struct nlattr **tb = data; int type = mnl_attr_get_type(attr); @@ -109,7 +109,7 @@ static int nftnl_rule_expr_ct_cb(const struct nlattr *attr, void *data) } static void -nftnl_rule_expr_ct_build(struct nlmsghdr *nlh, struct nftnl_rule_expr *e) +nftnl_expr_ct_build(struct nlmsghdr *nlh, struct nftnl_expr *e) { struct nftnl_expr_ct *ct = nftnl_expr_data(e); @@ -124,12 +124,12 @@ nftnl_rule_expr_ct_build(struct nlmsghdr *nlh, struct nftnl_rule_expr *e) } static int -nftnl_rule_expr_ct_parse(struct nftnl_rule_expr *e, struct nlattr *attr) +nftnl_expr_ct_parse(struct nftnl_expr *e, struct nlattr *attr) { struct nftnl_expr_ct *ct = nftnl_expr_data(e); struct nlattr *tb[NFTA_CT_MAX+1] = {}; - if (mnl_attr_parse_nested(attr, nftnl_rule_expr_ct_cb, tb) < 0) + if (mnl_attr_parse_nested(attr, nftnl_expr_ct_cb, tb) < 0) return -1; if (tb[NFTA_CT_KEY]) { @@ -216,7 +216,7 @@ static inline int str2ctdir(const char *str, uint8_t *ctdir) return -1; } -static int nftnl_rule_expr_ct_json_parse(struct nftnl_rule_expr *e, json_t *root, +static int nftnl_expr_ct_json_parse(struct nftnl_expr *e, json_t *root, struct nftnl_parse_err *err) { #ifdef JSON_PARSING @@ -226,10 +226,10 @@ static int nftnl_rule_expr_ct_json_parse(struct nftnl_rule_expr *e, json_t *root int key; if (nftnl_jansson_parse_reg(root, "dreg", NFTNL_TYPE_U32, ®, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_CT_DREG, reg); + nftnl_expr_set_u32(e, NFTNL_EXPR_CT_DREG, reg); if (nftnl_jansson_parse_reg(root, "sreg", NFTNL_TYPE_U32, ®, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_CT_SREG, reg); + nftnl_expr_set_u32(e, NFTNL_EXPR_CT_SREG, reg); key_str = nftnl_jansson_parse_str(root, "key", err); if (key_str != NULL) { @@ -237,7 +237,7 @@ static int nftnl_rule_expr_ct_json_parse(struct nftnl_rule_expr *e, json_t *root if (key < 0) return -1; - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_CT_KEY, key); + nftnl_expr_set_u32(e, NFTNL_EXPR_CT_KEY, key); } dir_str = nftnl_jansson_parse_str(root, "dir", err); @@ -247,7 +247,7 @@ static int nftnl_rule_expr_ct_json_parse(struct nftnl_rule_expr *e, json_t *root err->error = NFTNL_PARSE_EBADTYPE; goto err; } - nftnl_rule_expr_set_u8(e, NFTNL_EXPR_CT_DIR, dir); + nftnl_expr_set_u8(e, NFTNL_EXPR_CT_DIR, dir); } return 0; @@ -261,7 +261,7 @@ err: } -static int nftnl_rule_expr_ct_xml_parse(struct nftnl_rule_expr *e, mxml_node_t *tree, +static int nftnl_expr_ct_xml_parse(struct nftnl_expr *e, mxml_node_t *tree, struct nftnl_parse_err *err) { #ifdef XML_PARSING @@ -272,11 +272,11 @@ static int nftnl_rule_expr_ct_xml_parse(struct nftnl_rule_expr *e, mxml_node_t * if (nftnl_mxml_reg_parse(tree, "dreg", &dreg, MXML_DESCEND_FIRST, NFTNL_XML_OPT, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_CT_DREG, dreg); + nftnl_expr_set_u32(e, NFTNL_EXPR_CT_DREG, dreg); if (nftnl_mxml_reg_parse(tree, "sreg", &sreg, MXML_DESCEND_FIRST, NFTNL_XML_OPT, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_CT_SREG, sreg); + nftnl_expr_set_u32(e, NFTNL_EXPR_CT_SREG, sreg); key_str = nftnl_mxml_str_parse(tree, "key", MXML_DESCEND_FIRST, NFTNL_XML_MAND, err); @@ -285,7 +285,7 @@ static int nftnl_rule_expr_ct_xml_parse(struct nftnl_rule_expr *e, mxml_node_t * if (key < 0) return -1; - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_CT_KEY, key); + nftnl_expr_set_u32(e, NFTNL_EXPR_CT_KEY, key); } dir_str = nftnl_mxml_str_parse(tree, "dir", MXML_DESCEND_FIRST, NFTNL_XML_OPT, err); @@ -295,7 +295,7 @@ static int nftnl_rule_expr_ct_xml_parse(struct nftnl_rule_expr *e, mxml_node_t * err->error = NFTNL_PARSE_EBADTYPE; goto err; } - nftnl_rule_expr_set_u8(e, NFTNL_EXPR_CT_DIR, dir); + nftnl_expr_set_u8(e, NFTNL_EXPR_CT_DIR, dir); } return 0; @@ -309,7 +309,7 @@ err: } static int -nftnl_expr_ct_export(char *buf, size_t size, struct nftnl_rule_expr *e, int type) +nftnl_expr_ct_export(char *buf, size_t size, struct nftnl_expr *e, int type) { struct nftnl_expr_ct *ct = nftnl_expr_data(e); NFTNL_BUF_INIT(b, buf, size); @@ -327,7 +327,7 @@ nftnl_expr_ct_export(char *buf, size_t size, struct nftnl_rule_expr *e, int type } static int -nftnl_expr_ct_snprintf_default(char *buf, size_t size, struct nftnl_rule_expr *e) +nftnl_expr_ct_snprintf_default(char *buf, size_t size, struct nftnl_expr *e) { int ret, len = size, offset = 0; struct nftnl_expr_ct *ct = nftnl_expr_data(e); @@ -344,7 +344,7 @@ nftnl_expr_ct_snprintf_default(char *buf, size_t size, struct nftnl_rule_expr *e SNPRINTF_BUFFER_SIZE(ret, size, len, offset); } - if (nftnl_rule_expr_is_set(e, NFTNL_EXPR_CT_DIR)) { + if (nftnl_expr_is_set(e, NFTNL_EXPR_CT_DIR)) { ret = snprintf(buf+offset, len, ", dir %s ", ctdir2str(ct->dir)); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); @@ -354,8 +354,8 @@ nftnl_expr_ct_snprintf_default(char *buf, size_t size, struct nftnl_rule_expr *e } static int -nftnl_rule_expr_ct_snprintf(char *buf, size_t len, uint32_t type, - uint32_t flags, struct nftnl_rule_expr *e) +nftnl_expr_ct_snprintf(char *buf, size_t len, uint32_t type, + uint32_t flags, struct nftnl_expr *e) { switch (type) { case NFTNL_OUTPUT_DEFAULT: @@ -373,11 +373,11 @@ struct expr_ops expr_ops_ct = { .name = "ct", .alloc_len = sizeof(struct nftnl_expr_ct), .max_attr = NFTA_CT_MAX, - .set = nftnl_rule_expr_ct_set, - .get = nftnl_rule_expr_ct_get, - .parse = nftnl_rule_expr_ct_parse, - .build = nftnl_rule_expr_ct_build, - .snprintf = nftnl_rule_expr_ct_snprintf, - .xml_parse = nftnl_rule_expr_ct_xml_parse, - .json_parse = nftnl_rule_expr_ct_json_parse, + .set = nftnl_expr_ct_set, + .get = nftnl_expr_ct_get, + .parse = nftnl_expr_ct_parse, + .build = nftnl_expr_ct_build, + .snprintf = nftnl_expr_ct_snprintf, + .xml_parse = nftnl_expr_ct_xml_parse, + .json_parse = nftnl_expr_ct_json_parse, }; diff --git a/src/expr/dynset.c b/src/expr/dynset.c index ffb3882..ec8f2d3 100644 --- a/src/expr/dynset.c +++ b/src/expr/dynset.c @@ -31,13 +31,13 @@ struct nftnl_expr_dynset { enum nft_registers sreg_data; enum nft_dynset_ops op; uint64_t timeout; - struct nftnl_rule_expr *expr; + struct nftnl_expr *expr; char set_name[IFNAMSIZ]; uint32_t set_id; }; static int -nftnl_rule_expr_dynset_set(struct nftnl_rule_expr *e, uint16_t type, +nftnl_expr_dynset_set(struct nftnl_expr *e, uint16_t type, const void *data, uint32_t data_len) { struct nftnl_expr_dynset *dynset = nftnl_expr_data(e); @@ -72,7 +72,7 @@ nftnl_rule_expr_dynset_set(struct nftnl_rule_expr *e, uint16_t type, } static const void * -nftnl_rule_expr_dynset_get(const struct nftnl_rule_expr *e, uint16_t type, +nftnl_expr_dynset_get(const struct nftnl_expr *e, uint16_t type, uint32_t *data_len) { struct nftnl_expr_dynset *dynset = nftnl_expr_data(e); @@ -100,7 +100,7 @@ nftnl_rule_expr_dynset_get(const struct nftnl_rule_expr *e, uint16_t type, return NULL; } -static int nftnl_rule_expr_dynset_cb(const struct nlattr *attr, void *data) +static int nftnl_expr_dynset_cb(const struct nlattr *attr, void *data) { const struct nlattr **tb = data; int type = mnl_attr_get_type(attr); @@ -135,7 +135,7 @@ static int nftnl_rule_expr_dynset_cb(const struct nlattr *attr, void *data) } static void -nftnl_rule_expr_dynset_build(struct nlmsghdr *nlh, struct nftnl_rule_expr *e) +nftnl_expr_dynset_build(struct nlmsghdr *nlh, struct nftnl_expr *e) { struct nftnl_expr_dynset *dynset = nftnl_expr_data(e); struct nlattr *nest; @@ -154,19 +154,19 @@ nftnl_rule_expr_dynset_build(struct nlmsghdr *nlh, struct nftnl_rule_expr *e) mnl_attr_put_u32(nlh, NFTA_DYNSET_SET_ID, htonl(dynset->set_id)); if (e->flags & (1 << NFTNL_EXPR_DYNSET_EXPR)) { nest = mnl_attr_nest_start(nlh, NFTA_DYNSET_EXPR); - nftnl_rule_expr_build_payload(nlh, dynset->expr); + nftnl_expr_build_payload(nlh, dynset->expr); mnl_attr_nest_end(nlh, nest); } } static int -nftnl_rule_expr_dynset_parse(struct nftnl_rule_expr *e, struct nlattr *attr) +nftnl_expr_dynset_parse(struct nftnl_expr *e, struct nlattr *attr) { struct nftnl_expr_dynset *dynset = nftnl_expr_data(e); struct nlattr *tb[NFTA_SET_MAX+1] = {}; int ret = 0; - if (mnl_attr_parse_nested(attr, nftnl_rule_expr_dynset_cb, tb) < 0) + if (mnl_attr_parse_nested(attr, nftnl_expr_dynset_cb, tb) < 0) return -1; if (tb[NFTA_DYNSET_SREG_KEY]) { @@ -195,7 +195,7 @@ nftnl_rule_expr_dynset_parse(struct nftnl_rule_expr *e, struct nlattr *attr) } if (tb[NFTA_DYNSET_EXPR]) { e->flags |= (1 << NFTNL_EXPR_DYNSET_EXPR); - dynset->expr = nftnl_rule_expr_parse(tb[NFTA_DYNSET_EXPR]); + dynset->expr = nftnl_expr_parse(tb[NFTA_DYNSET_EXPR]); if (dynset->expr == NULL) return -1; } @@ -204,7 +204,7 @@ nftnl_rule_expr_dynset_parse(struct nftnl_rule_expr *e, struct nlattr *attr) } static int -nftnl_rule_expr_dynset_json_parse(struct nftnl_rule_expr *e, json_t *root, +nftnl_expr_dynset_json_parse(struct nftnl_expr *e, json_t *root, struct nftnl_parse_err *err) { #ifdef JSON_PARSING @@ -214,23 +214,23 @@ nftnl_rule_expr_dynset_json_parse(struct nftnl_rule_expr *e, json_t *root, set_name = nftnl_jansson_parse_str(root, "set", err); if (set_name != NULL) - nftnl_rule_expr_set_str(e, NFTNL_EXPR_DYNSET_SET_NAME, set_name); + nftnl_expr_set_str(e, NFTNL_EXPR_DYNSET_SET_NAME, set_name); if (nftnl_jansson_parse_reg(root, "sreg_key", NFTNL_TYPE_U32, &uval32, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_DYNSET_SREG_KEY, uval32); + nftnl_expr_set_u32(e, NFTNL_EXPR_DYNSET_SREG_KEY, uval32); if (nftnl_jansson_parse_reg(root, "sreg_data", NFTNL_TYPE_U32, &uval32, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_DYNSET_SREG_DATA, uval32); + nftnl_expr_set_u32(e, NFTNL_EXPR_DYNSET_SREG_DATA, uval32); if (nftnl_jansson_parse_val(root, "op", NFTNL_TYPE_U32, &uval32, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_DYNSET_OP, uval32); + nftnl_expr_set_u32(e, NFTNL_EXPR_DYNSET_OP, uval32); if (nftnl_jansson_parse_val(root, "timeout", NFTNL_TYPE_U64, &uval64, err) == 0) - nftnl_rule_expr_set_u64(e, NFTNL_EXPR_DYNSET_TIMEOUT, uval64); + nftnl_expr_set_u64(e, NFTNL_EXPR_DYNSET_TIMEOUT, uval64); return 0; #else @@ -240,7 +240,7 @@ nftnl_rule_expr_dynset_json_parse(struct nftnl_rule_expr *e, json_t *root, } static int -nftnl_rule_expr_dynset_xml_parse(struct nftnl_rule_expr *e, mxml_node_t *tree, +nftnl_expr_dynset_xml_parse(struct nftnl_expr *e, mxml_node_t *tree, struct nftnl_parse_err *err) { #ifdef XML_PARSING @@ -251,23 +251,23 @@ nftnl_rule_expr_dynset_xml_parse(struct nftnl_rule_expr *e, mxml_node_t *tree, set_name = nftnl_mxml_str_parse(tree, "set", MXML_DESCEND_FIRST, NFTNL_XML_MAND, err); if (set_name != NULL) - nftnl_rule_expr_set_str(e, NFTNL_EXPR_DYNSET_SET_NAME, set_name); + nftnl_expr_set_str(e, NFTNL_EXPR_DYNSET_SET_NAME, set_name); if (nftnl_mxml_reg_parse(tree, "sreg_key", &uval32, MXML_DESCEND, NFTNL_XML_MAND, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_DYNSET_SREG_KEY, uval32); + nftnl_expr_set_u32(e, NFTNL_EXPR_DYNSET_SREG_KEY, uval32); if (nftnl_mxml_reg_parse(tree, "sreg_data", &uval32, MXML_DESCEND, NFTNL_XML_MAND, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_DYNSET_SREG_DATA, uval32); + nftnl_expr_set_u32(e, NFTNL_EXPR_DYNSET_SREG_DATA, uval32); if (nftnl_mxml_num_parse(tree, "op", MXML_DESCEND_FIRST, BASE_DEC, &uval32, NFTNL_TYPE_U32, NFTNL_XML_MAND, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_DYNSET_OP, uval32); + nftnl_expr_set_u32(e, NFTNL_EXPR_DYNSET_OP, uval32); if (nftnl_mxml_num_parse(tree, "timeout", MXML_DESCEND_FIRST, BASE_DEC, &uval64, NFTNL_TYPE_U64, NFTNL_XML_MAND, err) == 0) - nftnl_rule_expr_set_u64(e, NFTNL_EXPR_DYNSET_TIMEOUT, uval64); + nftnl_expr_set_u64(e, NFTNL_EXPR_DYNSET_TIMEOUT, uval64); return 0; #else @@ -277,8 +277,8 @@ nftnl_rule_expr_dynset_xml_parse(struct nftnl_rule_expr *e, mxml_node_t *tree, } static int -nftnl_rule_expr_dynset_export(char *buf, size_t size, - struct nftnl_rule_expr *e, int type) +nftnl_expr_dynset_export(char *buf, size_t size, + struct nftnl_expr *e, int type) { struct nftnl_expr_dynset *dynset = nftnl_expr_data(e); NFTNL_BUF_INIT(b, buf, size); @@ -306,11 +306,11 @@ static const char *op2str(enum nft_dynset_ops op) } static int -nftnl_rule_expr_dynset_snprintf_default(char *buf, size_t size, - struct nftnl_rule_expr *e) +nftnl_expr_dynset_snprintf_default(char *buf, size_t size, + struct nftnl_expr *e) { struct nftnl_expr_dynset *dynset = nftnl_expr_data(e); - struct nftnl_rule_expr *expr; + struct nftnl_expr *expr; int len = size, offset = 0, ret; ret = snprintf(buf, len, "%s reg_key %u set %s ", @@ -332,7 +332,7 @@ nftnl_rule_expr_dynset_snprintf_default(char *buf, size_t size, expr->ops->name); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); - ret = nftnl_rule_expr_snprintf(buf+offset, len, expr, + ret = nftnl_expr_snprintf(buf+offset, len, expr, NFTNL_OUTPUT_DEFAULT, NFTNL_OF_EVENT_ANY); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); @@ -345,16 +345,16 @@ nftnl_rule_expr_dynset_snprintf_default(char *buf, size_t size, } static int -nftnl_rule_expr_dynset_snprintf(char *buf, size_t size, uint32_t type, - uint32_t flags, struct nftnl_rule_expr *e) +nftnl_expr_dynset_snprintf(char *buf, size_t size, uint32_t type, + uint32_t flags, struct nftnl_expr *e) { switch (type) { case NFTNL_OUTPUT_DEFAULT: - return nftnl_rule_expr_dynset_snprintf_default(buf, size, e); + return nftnl_expr_dynset_snprintf_default(buf, size, e); case NFTNL_OUTPUT_XML: case NFTNL_OUTPUT_JSON: - return nftnl_rule_expr_dynset_export(buf, size, e, type); + return nftnl_expr_dynset_export(buf, size, e, type); default: break; } @@ -365,11 +365,11 @@ struct expr_ops expr_ops_dynset = { .name = "dynset", .alloc_len = sizeof(struct nftnl_expr_dynset), .max_attr = NFTA_DYNSET_MAX, - .set = nftnl_rule_expr_dynset_set, - .get = nftnl_rule_expr_dynset_get, - .parse = nftnl_rule_expr_dynset_parse, - .build = nftnl_rule_expr_dynset_build, - .snprintf = nftnl_rule_expr_dynset_snprintf, - .xml_parse = nftnl_rule_expr_dynset_xml_parse, - .json_parse = nftnl_rule_expr_dynset_json_parse, + .set = nftnl_expr_dynset_set, + .get = nftnl_expr_dynset_get, + .parse = nftnl_expr_dynset_parse, + .build = nftnl_expr_dynset_build, + .snprintf = nftnl_expr_dynset_snprintf, + .xml_parse = nftnl_expr_dynset_xml_parse, + .json_parse = nftnl_expr_dynset_json_parse, }; diff --git a/src/expr/exthdr.c b/src/expr/exthdr.c index 0187f96..2e9b0b0 100644 --- a/src/expr/exthdr.c +++ b/src/expr/exthdr.c @@ -36,7 +36,7 @@ struct nftnl_expr_exthdr { }; static int -nftnl_rule_expr_exthdr_set(struct nftnl_rule_expr *e, uint16_t type, +nftnl_expr_exthdr_set(struct nftnl_expr *e, uint16_t type, const void *data, uint32_t data_len) { struct nftnl_expr_exthdr *exthdr = nftnl_expr_data(e); @@ -61,7 +61,7 @@ nftnl_rule_expr_exthdr_set(struct nftnl_rule_expr *e, uint16_t type, } static const void * -nftnl_rule_expr_exthdr_get(const struct nftnl_rule_expr *e, uint16_t type, +nftnl_expr_exthdr_get(const struct nftnl_expr *e, uint16_t type, uint32_t *data_len) { struct nftnl_expr_exthdr *exthdr = nftnl_expr_data(e); @@ -83,7 +83,7 @@ nftnl_rule_expr_exthdr_get(const struct nftnl_rule_expr *e, uint16_t type, return NULL; } -static int nftnl_rule_expr_exthdr_cb(const struct nlattr *attr, void *data) +static int nftnl_expr_exthdr_cb(const struct nlattr *attr, void *data) { const struct nlattr **tb = data; int type = mnl_attr_get_type(attr); @@ -109,7 +109,7 @@ static int nftnl_rule_expr_exthdr_cb(const struct nlattr *attr, void *data) } static void -nftnl_rule_expr_exthdr_build(struct nlmsghdr *nlh, struct nftnl_rule_expr *e) +nftnl_expr_exthdr_build(struct nlmsghdr *nlh, struct nftnl_expr *e) { struct nftnl_expr_exthdr *exthdr = nftnl_expr_data(e); @@ -124,12 +124,12 @@ nftnl_rule_expr_exthdr_build(struct nlmsghdr *nlh, struct nftnl_rule_expr *e) } static int -nftnl_rule_expr_exthdr_parse(struct nftnl_rule_expr *e, struct nlattr *attr) +nftnl_expr_exthdr_parse(struct nftnl_expr *e, struct nlattr *attr) { struct nftnl_expr_exthdr *exthdr = nftnl_expr_data(e); struct nlattr *tb[NFTA_EXTHDR_MAX+1] = {}; - if (mnl_attr_parse_nested(attr, nftnl_rule_expr_exthdr_cb, tb) < 0) + if (mnl_attr_parse_nested(attr, nftnl_expr_exthdr_cb, tb) < 0) return -1; if (tb[NFTA_EXTHDR_DREG]) { @@ -187,7 +187,7 @@ static inline int str2exthdr_type(const char *str) } static int -nftnl_rule_expr_exthdr_json_parse(struct nftnl_rule_expr *e, json_t *root, +nftnl_expr_exthdr_json_parse(struct nftnl_expr *e, json_t *root, struct nftnl_parse_err *err) { #ifdef JSON_PARSING @@ -197,22 +197,22 @@ nftnl_rule_expr_exthdr_json_parse(struct nftnl_rule_expr *e, json_t *root, if (nftnl_jansson_parse_reg(root, "dreg", NFTNL_TYPE_U32, &uval32, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_EXTHDR_DREG, uval32); + nftnl_expr_set_u32(e, NFTNL_EXPR_EXTHDR_DREG, uval32); exthdr_type = nftnl_jansson_parse_str(root, "exthdr_type", err); if (exthdr_type != NULL) { type = str2exthdr_type(exthdr_type); if (type < 0) return -1; - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_EXTHDR_TYPE, type); + nftnl_expr_set_u32(e, NFTNL_EXPR_EXTHDR_TYPE, type); } if (nftnl_jansson_parse_val(root, "offset", NFTNL_TYPE_U32, &uval32, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_EXTHDR_OFFSET, uval32); + nftnl_expr_set_u32(e, NFTNL_EXPR_EXTHDR_OFFSET, uval32); if (nftnl_jansson_parse_val(root, "len", NFTNL_TYPE_U32, &uval32, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_EXTHDR_LEN, uval32); + nftnl_expr_set_u32(e, NFTNL_EXPR_EXTHDR_LEN, uval32); return 0; #else @@ -222,7 +222,7 @@ nftnl_rule_expr_exthdr_json_parse(struct nftnl_rule_expr *e, json_t *root, } static int -nftnl_rule_expr_exthdr_xml_parse(struct nftnl_rule_expr *e, mxml_node_t *tree, +nftnl_expr_exthdr_xml_parse(struct nftnl_expr *e, mxml_node_t *tree, struct nftnl_parse_err *err) { #ifdef XML_PARSING @@ -232,7 +232,7 @@ nftnl_rule_expr_exthdr_xml_parse(struct nftnl_rule_expr *e, mxml_node_t *tree, if (nftnl_mxml_reg_parse(tree, "dreg", &dreg, MXML_DESCEND_FIRST, NFTNL_XML_MAND, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_EXTHDR_DREG, dreg); + nftnl_expr_set_u32(e, NFTNL_EXPR_EXTHDR_DREG, dreg); exthdr_type = nftnl_mxml_str_parse(tree, "exthdr_type", MXML_DESCEND_FIRST, NFTNL_XML_MAND, err); @@ -240,18 +240,18 @@ nftnl_rule_expr_exthdr_xml_parse(struct nftnl_rule_expr *e, mxml_node_t *tree, type = str2exthdr_type(exthdr_type); if (type < 0) return -1; - nftnl_rule_expr_set_u8(e, NFTNL_EXPR_EXTHDR_TYPE, type); + nftnl_expr_set_u8(e, NFTNL_EXPR_EXTHDR_TYPE, type); } /* Get and set */ if (nftnl_mxml_num_parse(tree, "offset", MXML_DESCEND_FIRST, BASE_DEC, &offset, NFTNL_TYPE_U32, NFTNL_XML_MAND, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_EXTHDR_OFFSET, offset); + nftnl_expr_set_u32(e, NFTNL_EXPR_EXTHDR_OFFSET, offset); /* Get and set */ if (nftnl_mxml_num_parse(tree, "len", MXML_DESCEND_FIRST, BASE_DEC, &len, NFTNL_TYPE_U32, NFTNL_XML_MAND, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_EXTHDR_LEN, len); + nftnl_expr_set_u32(e, NFTNL_EXPR_EXTHDR_LEN, len); return 0; #else @@ -260,8 +260,8 @@ nftnl_rule_expr_exthdr_xml_parse(struct nftnl_rule_expr *e, mxml_node_t *tree, #endif } -static int nftnl_rule_expr_exthdr_export(char *buf, size_t len, - struct nftnl_rule_expr *e, int type) +static int nftnl_expr_exthdr_export(char *buf, size_t len, + struct nftnl_expr *e, int type) { struct nftnl_expr_exthdr *exthdr = nftnl_expr_data(e); NFTNL_BUF_INIT(b, buf, len); @@ -278,8 +278,8 @@ static int nftnl_rule_expr_exthdr_export(char *buf, size_t len, return nftnl_buf_done(&b); } -static int nftnl_rule_expr_exthdr_snprintf_default(char *buf, size_t len, - struct nftnl_rule_expr *e) +static int nftnl_expr_exthdr_snprintf_default(char *buf, size_t len, + struct nftnl_expr *e) { struct nftnl_expr_exthdr *exthdr = nftnl_expr_data(e); @@ -289,15 +289,15 @@ static int nftnl_rule_expr_exthdr_snprintf_default(char *buf, size_t len, } static int -nftnl_rule_expr_exthdr_snprintf(char *buf, size_t len, uint32_t type, - uint32_t flags, struct nftnl_rule_expr *e) +nftnl_expr_exthdr_snprintf(char *buf, size_t len, uint32_t type, + uint32_t flags, struct nftnl_expr *e) { switch (type) { case NFTNL_OUTPUT_DEFAULT: - return nftnl_rule_expr_exthdr_snprintf_default(buf, len, e); + return nftnl_expr_exthdr_snprintf_default(buf, len, e); case NFTNL_OUTPUT_XML: case NFTNL_OUTPUT_JSON: - return nftnl_rule_expr_exthdr_export(buf, len, e, type); + return nftnl_expr_exthdr_export(buf, len, e, type); default: break; } @@ -308,11 +308,11 @@ struct expr_ops expr_ops_exthdr = { .name = "exthdr", .alloc_len = sizeof(struct nftnl_expr_exthdr), .max_attr = NFTA_EXTHDR_MAX, - .set = nftnl_rule_expr_exthdr_set, - .get = nftnl_rule_expr_exthdr_get, - .parse = nftnl_rule_expr_exthdr_parse, - .build = nftnl_rule_expr_exthdr_build, - .snprintf = nftnl_rule_expr_exthdr_snprintf, - .xml_parse = nftnl_rule_expr_exthdr_xml_parse, - .json_parse = nftnl_rule_expr_exthdr_json_parse, + .set = nftnl_expr_exthdr_set, + .get = nftnl_expr_exthdr_get, + .parse = nftnl_expr_exthdr_parse, + .build = nftnl_expr_exthdr_build, + .snprintf = nftnl_expr_exthdr_snprintf, + .xml_parse = nftnl_expr_exthdr_xml_parse, + .json_parse = nftnl_expr_exthdr_json_parse, }; diff --git a/src/expr/immediate.c b/src/expr/immediate.c index 4f3960a..c2fb9ad 100644 --- a/src/expr/immediate.c +++ b/src/expr/immediate.c @@ -26,7 +26,7 @@ struct nftnl_expr_immediate { }; static int -nftnl_rule_expr_immediate_set(struct nftnl_rule_expr *e, uint16_t type, +nftnl_expr_immediate_set(struct nftnl_expr *e, uint16_t type, const void *data, uint32_t data_len) { struct nftnl_expr_immediate *imm = nftnl_expr_data(e); @@ -55,7 +55,7 @@ nftnl_rule_expr_immediate_set(struct nftnl_rule_expr *e, uint16_t type, } static const void * -nftnl_rule_expr_immediate_get(const struct nftnl_rule_expr *e, uint16_t type, +nftnl_expr_immediate_get(const struct nftnl_expr *e, uint16_t type, uint32_t *data_len) { struct nftnl_expr_immediate *imm = nftnl_expr_data(e); @@ -77,7 +77,7 @@ nftnl_rule_expr_immediate_get(const struct nftnl_rule_expr *e, uint16_t type, return NULL; } -static int nftnl_rule_expr_immediate_cb(const struct nlattr *attr, void *data) +static int nftnl_expr_immediate_cb(const struct nlattr *attr, void *data) { const struct nlattr **tb = data; int type = mnl_attr_get_type(attr); @@ -101,7 +101,7 @@ static int nftnl_rule_expr_immediate_cb(const struct nlattr *attr, void *data) } static void -nftnl_rule_expr_immediate_build(struct nlmsghdr *nlh, struct nftnl_rule_expr *e) +nftnl_expr_immediate_build(struct nlmsghdr *nlh, struct nftnl_expr *e) { struct nftnl_expr_immediate *imm = nftnl_expr_data(e); @@ -131,13 +131,13 @@ nftnl_rule_expr_immediate_build(struct nlmsghdr *nlh, struct nftnl_rule_expr *e) } static int -nftnl_rule_expr_immediate_parse(struct nftnl_rule_expr *e, struct nlattr *attr) +nftnl_expr_immediate_parse(struct nftnl_expr *e, struct nlattr *attr) { struct nftnl_expr_immediate *imm = nftnl_expr_data(e); struct nlattr *tb[NFTA_IMMEDIATE_MAX+1] = {}; int ret = 0; - if (mnl_attr_parse_nested(attr, nftnl_rule_expr_immediate_cb, tb) < 0) + if (mnl_attr_parse_nested(attr, nftnl_expr_immediate_cb, tb) < 0) return -1; if (tb[NFTA_IMMEDIATE_DREG]) { @@ -172,7 +172,7 @@ nftnl_rule_expr_immediate_parse(struct nftnl_rule_expr *e, struct nlattr *attr) } static int -nftnl_rule_expr_immediate_json_parse(struct nftnl_rule_expr *e, json_t *root, +nftnl_expr_immediate_json_parse(struct nftnl_expr *e, json_t *root, struct nftnl_parse_err *err) { #ifdef JSON_PARSING @@ -181,7 +181,7 @@ nftnl_rule_expr_immediate_json_parse(struct nftnl_rule_expr *e, json_t *root, uint32_t reg; if (nftnl_jansson_parse_reg(root, "dreg", NFTNL_TYPE_U32, ®, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_IMM_DREG, reg); + nftnl_expr_set_u32(e, NFTNL_EXPR_IMM_DREG, reg); datareg_type = nftnl_jansson_data_reg_parse(root, "data", &imm->data, err); @@ -208,7 +208,7 @@ nftnl_rule_expr_immediate_json_parse(struct nftnl_rule_expr *e, json_t *root, } static int -nftnl_rule_expr_immediate_xml_parse(struct nftnl_rule_expr *e, mxml_node_t *tree, +nftnl_expr_immediate_xml_parse(struct nftnl_expr *e, mxml_node_t *tree, struct nftnl_parse_err *err) { #ifdef XML_PARSING @@ -218,7 +218,7 @@ nftnl_rule_expr_immediate_xml_parse(struct nftnl_rule_expr *e, mxml_node_t *tree if (nftnl_mxml_reg_parse(tree, "dreg", ®, MXML_DESCEND_FIRST, NFTNL_XML_MAND, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_IMM_DREG, reg); + nftnl_expr_set_u32(e, NFTNL_EXPR_IMM_DREG, reg); datareg_type = nftnl_mxml_data_reg_parse(tree, "data", &imm->data, NFTNL_XML_MAND, err); @@ -246,7 +246,7 @@ nftnl_rule_expr_immediate_xml_parse(struct nftnl_rule_expr *e, mxml_node_t *tree } static int -nftnl_rule_expr_immediate_export(char *buf, size_t size, struct nftnl_rule_expr *e, +nftnl_expr_immediate_export(char *buf, size_t size, struct nftnl_expr *e, int type) { struct nftnl_expr_immediate *imm = nftnl_expr_data(e); @@ -265,8 +265,8 @@ nftnl_rule_expr_immediate_export(char *buf, size_t size, struct nftnl_rule_expr } static int -nftnl_rule_expr_immediate_snprintf_default(char *buf, size_t len, - struct nftnl_rule_expr *e, uint32_t flags) +nftnl_expr_immediate_snprintf_default(char *buf, size_t len, + struct nftnl_expr *e, uint32_t flags) { int size = len, offset = 0, ret; struct nftnl_expr_immediate *imm = nftnl_expr_data(e); @@ -294,22 +294,22 @@ nftnl_rule_expr_immediate_snprintf_default(char *buf, size_t len, } static int -nftnl_rule_expr_immediate_snprintf(char *buf, size_t len, uint32_t type, - uint32_t flags, struct nftnl_rule_expr *e) +nftnl_expr_immediate_snprintf(char *buf, size_t len, uint32_t type, + uint32_t flags, struct nftnl_expr *e) { switch(type) { case NFTNL_OUTPUT_DEFAULT: - return nftnl_rule_expr_immediate_snprintf_default(buf, len, e, flags); + return nftnl_expr_immediate_snprintf_default(buf, len, e, flags); case NFTNL_OUTPUT_XML: case NFTNL_OUTPUT_JSON: - return nftnl_rule_expr_immediate_export(buf, len, e, type); + return nftnl_expr_immediate_export(buf, len, e, type); default: break; } return -1; } -static void nftnl_rule_expr_immediate_free(struct nftnl_rule_expr *e) +static void nftnl_expr_immediate_free(struct nftnl_expr *e) { struct nftnl_expr_immediate *imm = nftnl_expr_data(e); @@ -321,12 +321,12 @@ struct expr_ops expr_ops_immediate = { .name = "immediate", .alloc_len = sizeof(struct nftnl_expr_immediate), .max_attr = NFTA_IMMEDIATE_MAX, - .free = nftnl_rule_expr_immediate_free, - .set = nftnl_rule_expr_immediate_set, - .get = nftnl_rule_expr_immediate_get, - .parse = nftnl_rule_expr_immediate_parse, - .build = nftnl_rule_expr_immediate_build, - .snprintf = nftnl_rule_expr_immediate_snprintf, - .xml_parse = nftnl_rule_expr_immediate_xml_parse, - .json_parse = nftnl_rule_expr_immediate_json_parse, + .free = nftnl_expr_immediate_free, + .set = nftnl_expr_immediate_set, + .get = nftnl_expr_immediate_get, + .parse = nftnl_expr_immediate_parse, + .build = nftnl_expr_immediate_build, + .snprintf = nftnl_expr_immediate_snprintf, + .xml_parse = nftnl_expr_immediate_xml_parse, + .json_parse = nftnl_expr_immediate_json_parse, }; diff --git a/src/expr/limit.c b/src/expr/limit.c index b323c5c..e84745d 100644 --- a/src/expr/limit.c +++ b/src/expr/limit.c @@ -28,7 +28,7 @@ struct nftnl_expr_limit { }; static int -nftnl_rule_expr_limit_set(struct nftnl_rule_expr *e, uint16_t type, +nftnl_expr_limit_set(struct nftnl_expr *e, uint16_t type, const void *data, uint32_t data_len) { struct nftnl_expr_limit *limit = nftnl_expr_data(e); @@ -47,7 +47,7 @@ nftnl_rule_expr_limit_set(struct nftnl_rule_expr *e, uint16_t type, } static const void * -nftnl_rule_expr_limit_get(const struct nftnl_rule_expr *e, uint16_t type, +nftnl_expr_limit_get(const struct nftnl_expr *e, uint16_t type, uint32_t *data_len) { struct nftnl_expr_limit *limit = nftnl_expr_data(e); @@ -63,7 +63,7 @@ nftnl_rule_expr_limit_get(const struct nftnl_rule_expr *e, uint16_t type, return NULL; } -static int nftnl_rule_expr_limit_cb(const struct nlattr *attr, void *data) +static int nftnl_expr_limit_cb(const struct nlattr *attr, void *data) { const struct nlattr **tb = data; int type = mnl_attr_get_type(attr); @@ -84,7 +84,7 @@ static int nftnl_rule_expr_limit_cb(const struct nlattr *attr, void *data) } static void -nftnl_rule_expr_limit_build(struct nlmsghdr *nlh, struct nftnl_rule_expr *e) +nftnl_expr_limit_build(struct nlmsghdr *nlh, struct nftnl_expr *e) { struct nftnl_expr_limit *limit = nftnl_expr_data(e); @@ -95,12 +95,12 @@ nftnl_rule_expr_limit_build(struct nlmsghdr *nlh, struct nftnl_rule_expr *e) } static int -nftnl_rule_expr_limit_parse(struct nftnl_rule_expr *e, struct nlattr *attr) +nftnl_expr_limit_parse(struct nftnl_expr *e, struct nlattr *attr) { struct nftnl_expr_limit *limit = nftnl_expr_data(e); struct nlattr *tb[NFTA_LIMIT_MAX+1] = {}; - if (mnl_attr_parse_nested(attr, nftnl_rule_expr_limit_cb, tb) < 0) + if (mnl_attr_parse_nested(attr, nftnl_expr_limit_cb, tb) < 0) return -1; if (tb[NFTA_LIMIT_RATE]) { @@ -115,17 +115,17 @@ nftnl_rule_expr_limit_parse(struct nftnl_rule_expr *e, struct nlattr *attr) return 0; } -static int nftnl_rule_expr_limit_json_parse(struct nftnl_rule_expr *e, json_t *root, +static int nftnl_expr_limit_json_parse(struct nftnl_expr *e, json_t *root, struct nftnl_parse_err *err) { #ifdef JSON_PARSING uint64_t uval64; if (nftnl_jansson_parse_val(root, "rate", NFTNL_TYPE_U64, &uval64, err) == 0) - nftnl_rule_expr_set_u64(e, NFTNL_EXPR_LIMIT_RATE, uval64); + nftnl_expr_set_u64(e, NFTNL_EXPR_LIMIT_RATE, uval64); if (nftnl_jansson_parse_val(root, "unit", NFTNL_TYPE_U64, &uval64, err) == 0) - nftnl_rule_expr_set_u64(e, NFTNL_EXPR_LIMIT_UNIT, uval64); + nftnl_expr_set_u64(e, NFTNL_EXPR_LIMIT_UNIT, uval64); return 0; #else @@ -134,7 +134,7 @@ static int nftnl_rule_expr_limit_json_parse(struct nftnl_rule_expr *e, json_t *r #endif } -static int nftnl_rule_expr_limit_xml_parse(struct nftnl_rule_expr *e, +static int nftnl_expr_limit_xml_parse(struct nftnl_expr *e, mxml_node_t *tree, struct nftnl_parse_err *err) { @@ -143,11 +143,11 @@ static int nftnl_rule_expr_limit_xml_parse(struct nftnl_rule_expr *e, if (nftnl_mxml_num_parse(tree, "rate", MXML_DESCEND_FIRST, BASE_DEC, &rate, NFTNL_TYPE_U64, NFTNL_XML_MAND, err) == 0) - nftnl_rule_expr_set_u64(e, NFTNL_EXPR_LIMIT_RATE, rate); + nftnl_expr_set_u64(e, NFTNL_EXPR_LIMIT_RATE, rate); if (nftnl_mxml_num_parse(tree, "unit", MXML_DESCEND_FIRST, BASE_DEC, &unit, NFTNL_TYPE_U64, NFTNL_XML_MAND, err) == 0) - nftnl_rule_expr_set_u64(e, NFTNL_EXPR_LIMIT_UNIT, unit); + nftnl_expr_set_u64(e, NFTNL_EXPR_LIMIT_UNIT, unit); return 0; #else @@ -168,8 +168,8 @@ static const char *get_unit(uint64_t u) return "error"; } -static int nftnl_rule_expr_limit_export(char *buf, size_t size, - struct nftnl_rule_expr *e, int type) +static int nftnl_expr_limit_export(char *buf, size_t size, + struct nftnl_expr *e, int type) { struct nftnl_expr_limit *limit = nftnl_expr_data(e); NFTNL_BUF_INIT(b, buf, size); @@ -182,8 +182,8 @@ static int nftnl_rule_expr_limit_export(char *buf, size_t size, return nftnl_buf_done(&b); } -static int nftnl_rule_expr_limit_snprintf_default(char *buf, size_t len, - struct nftnl_rule_expr *e) +static int nftnl_expr_limit_snprintf_default(char *buf, size_t len, + struct nftnl_expr *e) { struct nftnl_expr_limit *limit = nftnl_expr_data(e); @@ -192,16 +192,16 @@ static int nftnl_rule_expr_limit_snprintf_default(char *buf, size_t len, } static int -nftnl_rule_expr_limit_snprintf(char *buf, size_t len, uint32_t type, - uint32_t flags, struct nftnl_rule_expr *e) +nftnl_expr_limit_snprintf(char *buf, size_t len, uint32_t type, + uint32_t flags, struct nftnl_expr *e) { switch(type) { case NFTNL_OUTPUT_DEFAULT: - return nftnl_rule_expr_limit_snprintf_default(buf, len, e); + return nftnl_expr_limit_snprintf_default(buf, len, e); case NFTNL_OUTPUT_XML: case NFTNL_OUTPUT_JSON: - return nftnl_rule_expr_limit_export(buf, len, e, type); + return nftnl_expr_limit_export(buf, len, e, type); default: break; } @@ -212,11 +212,11 @@ struct expr_ops expr_ops_limit = { .name = "limit", .alloc_len = sizeof(struct nftnl_expr_limit), .max_attr = NFTA_LIMIT_MAX, - .set = nftnl_rule_expr_limit_set, - .get = nftnl_rule_expr_limit_get, - .parse = nftnl_rule_expr_limit_parse, - .build = nftnl_rule_expr_limit_build, - .snprintf = nftnl_rule_expr_limit_snprintf, - .xml_parse = nftnl_rule_expr_limit_xml_parse, - .json_parse = nftnl_rule_expr_limit_json_parse, + .set = nftnl_expr_limit_set, + .get = nftnl_expr_limit_get, + .parse = nftnl_expr_limit_parse, + .build = nftnl_expr_limit_build, + .snprintf = nftnl_expr_limit_snprintf, + .xml_parse = nftnl_expr_limit_xml_parse, + .json_parse = nftnl_expr_limit_json_parse, }; diff --git a/src/expr/log.c b/src/expr/log.c index 2f1f705..f615d8e 100644 --- a/src/expr/log.c +++ b/src/expr/log.c @@ -30,7 +30,7 @@ struct nftnl_expr_log { const char *prefix; }; -static int nftnl_rule_expr_log_set(struct nftnl_rule_expr *e, uint16_t type, +static int nftnl_expr_log_set(struct nftnl_expr *e, uint16_t type, const void *data, uint32_t data_len) { struct nftnl_expr_log *log = nftnl_expr_data(e); @@ -64,7 +64,7 @@ static int nftnl_rule_expr_log_set(struct nftnl_rule_expr *e, uint16_t type, } static const void * -nftnl_rule_expr_log_get(const struct nftnl_rule_expr *e, uint16_t type, +nftnl_expr_log_get(const struct nftnl_expr *e, uint16_t type, uint32_t *data_len) { struct nftnl_expr_log *log = nftnl_expr_data(e); @@ -92,7 +92,7 @@ nftnl_rule_expr_log_get(const struct nftnl_rule_expr *e, uint16_t type, return NULL; } -static int nftnl_rule_expr_log_cb(const struct nlattr *attr, void *data) +static int nftnl_expr_log_cb(const struct nlattr *attr, void *data) { const struct nlattr **tb = data; int type = mnl_attr_get_type(attr); @@ -123,7 +123,7 @@ static int nftnl_rule_expr_log_cb(const struct nlattr *attr, void *data) } static void -nftnl_rule_expr_log_build(struct nlmsghdr *nlh, struct nftnl_rule_expr *e) +nftnl_expr_log_build(struct nlmsghdr *nlh, struct nftnl_expr *e) { struct nftnl_expr_log *log = nftnl_expr_data(e); @@ -142,12 +142,12 @@ nftnl_rule_expr_log_build(struct nlmsghdr *nlh, struct nftnl_rule_expr *e) } static int -nftnl_rule_expr_log_parse(struct nftnl_rule_expr *e, struct nlattr *attr) +nftnl_expr_log_parse(struct nftnl_expr *e, struct nlattr *attr) { struct nftnl_expr_log *log = nftnl_expr_data(e); struct nlattr *tb[NFTA_LOG_MAX+1] = {}; - if (mnl_attr_parse_nested(attr, nftnl_rule_expr_log_cb, tb) < 0) + if (mnl_attr_parse_nested(attr, nftnl_expr_log_cb, tb) < 0) return -1; if (tb[NFTA_LOG_PREFIX]) { @@ -181,7 +181,7 @@ nftnl_rule_expr_log_parse(struct nftnl_rule_expr *e, struct nlattr *attr) return 0; } -static int nftnl_rule_expr_log_json_parse(struct nftnl_rule_expr *e, json_t *root, +static int nftnl_expr_log_json_parse(struct nftnl_expr *e, json_t *root, struct nftnl_parse_err *err) { #ifdef JSON_PARSING @@ -191,27 +191,27 @@ static int nftnl_rule_expr_log_json_parse(struct nftnl_rule_expr *e, json_t *roo prefix = nftnl_jansson_parse_str(root, "prefix", err); if (prefix != NULL) - nftnl_rule_expr_set_str(e, NFTNL_EXPR_LOG_PREFIX, prefix); + nftnl_expr_set_str(e, NFTNL_EXPR_LOG_PREFIX, prefix); if (nftnl_jansson_parse_val(root, "group", NFTNL_TYPE_U16, &group, err) == 0) - nftnl_rule_expr_set_u16(e, NFTNL_EXPR_LOG_GROUP, group); + nftnl_expr_set_u16(e, NFTNL_EXPR_LOG_GROUP, group); if (nftnl_jansson_parse_val(root, "snaplen", NFTNL_TYPE_U32, &snaplen, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_LOG_SNAPLEN, snaplen); + nftnl_expr_set_u32(e, NFTNL_EXPR_LOG_SNAPLEN, snaplen); if (nftnl_jansson_parse_val(root, "qthreshold", NFTNL_TYPE_U16, &qthreshold, err) == 0) - nftnl_rule_expr_set_u16(e, NFTNL_EXPR_LOG_QTHRESHOLD, qthreshold); + nftnl_expr_set_u16(e, NFTNL_EXPR_LOG_QTHRESHOLD, qthreshold); if (nftnl_jansson_parse_val(root, "level", NFTNL_TYPE_U32, &level, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_LOG_LEVEL, level); + nftnl_expr_set_u32(e, NFTNL_EXPR_LOG_LEVEL, level); if (nftnl_jansson_parse_val(root, "flags", NFTNL_TYPE_U32, &flags, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_LOG_FLAGS, flags); + nftnl_expr_set_u32(e, NFTNL_EXPR_LOG_FLAGS, flags); return 0; #else @@ -220,7 +220,7 @@ static int nftnl_rule_expr_log_json_parse(struct nftnl_rule_expr *e, json_t *roo #endif } -static int nftnl_rule_expr_log_xml_parse(struct nftnl_rule_expr *e, +static int nftnl_expr_log_xml_parse(struct nftnl_expr *e, mxml_node_t *tree, struct nftnl_parse_err *err) { @@ -232,30 +232,30 @@ static int nftnl_rule_expr_log_xml_parse(struct nftnl_rule_expr *e, prefix = nftnl_mxml_str_parse(tree, "prefix", MXML_DESCEND_FIRST, NFTNL_XML_MAND, err); if (prefix != NULL) - nftnl_rule_expr_set_str(e, NFTNL_EXPR_LOG_PREFIX, prefix); + nftnl_expr_set_str(e, NFTNL_EXPR_LOG_PREFIX, prefix); if (nftnl_mxml_num_parse(tree, "group", MXML_DESCEND_FIRST, BASE_DEC, &group, NFTNL_TYPE_U16, NFTNL_XML_MAND, err) == 0) - nftnl_rule_expr_set_u16(e, NFTNL_EXPR_LOG_GROUP, group); + nftnl_expr_set_u16(e, NFTNL_EXPR_LOG_GROUP, group); if (nftnl_mxml_num_parse(tree, "snaplen", MXML_DESCEND_FIRST, BASE_DEC, &snaplen, NFTNL_TYPE_U32, NFTNL_XML_MAND, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_LOG_SNAPLEN, snaplen); + nftnl_expr_set_u32(e, NFTNL_EXPR_LOG_SNAPLEN, snaplen); if (nftnl_mxml_num_parse(tree, "qthreshold", MXML_DESCEND_FIRST, BASE_DEC, &qthreshold, NFTNL_TYPE_U16, NFTNL_XML_MAND, err) == 0) - nftnl_rule_expr_set_u16(e, NFTNL_EXPR_LOG_QTHRESHOLD, qthreshold); + nftnl_expr_set_u16(e, NFTNL_EXPR_LOG_QTHRESHOLD, qthreshold); if (nftnl_mxml_num_parse(tree, "level", MXML_DESCEND_FIRST, BASE_DEC, &level, NFTNL_TYPE_U16, NFTNL_XML_MAND, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_LOG_LEVEL, level); + nftnl_expr_set_u32(e, NFTNL_EXPR_LOG_LEVEL, level); if (nftnl_mxml_num_parse(tree, "flags", MXML_DESCEND_FIRST, BASE_DEC, &flags, NFTNL_TYPE_U16, NFTNL_XML_MAND, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_LOG_FLAGS, flags); + nftnl_expr_set_u32(e, NFTNL_EXPR_LOG_FLAGS, flags); return 0; #else @@ -264,8 +264,8 @@ static int nftnl_rule_expr_log_xml_parse(struct nftnl_rule_expr *e, #endif } -static int nftnl_rule_expr_log_snprintf_default(char *buf, size_t size, - struct nftnl_rule_expr *e) +static int nftnl_expr_log_snprintf_default(char *buf, size_t size, + struct nftnl_expr *e) { struct nftnl_expr_log *log = nftnl_expr_data(e); int ret, offset = 0, len = size; @@ -287,8 +287,8 @@ static int nftnl_rule_expr_log_snprintf_default(char *buf, size_t size, return offset; } -static int nftnl_rule_expr_log_export(char *buf, size_t size, - struct nftnl_rule_expr *e, int type) +static int nftnl_expr_log_export(char *buf, size_t size, + struct nftnl_expr *e, int type) { struct nftnl_expr_log *log = nftnl_expr_data(e); NFTNL_BUF_INIT(b, buf, size); @@ -310,22 +310,22 @@ static int nftnl_rule_expr_log_export(char *buf, size_t size, } static int -nftnl_rule_expr_log_snprintf(char *buf, size_t len, uint32_t type, - uint32_t flags, struct nftnl_rule_expr *e) +nftnl_expr_log_snprintf(char *buf, size_t len, uint32_t type, + uint32_t flags, struct nftnl_expr *e) { switch(type) { case NFTNL_OUTPUT_DEFAULT: - return nftnl_rule_expr_log_snprintf_default(buf, len, e); + return nftnl_expr_log_snprintf_default(buf, len, e); case NFTNL_OUTPUT_XML: case NFTNL_OUTPUT_JSON: - return nftnl_rule_expr_log_export(buf, len, e, type); + return nftnl_expr_log_export(buf, len, e, type); default: break; } return -1; } -static void nftnl_rule_expr_log_free(struct nftnl_rule_expr *e) +static void nftnl_expr_log_free(struct nftnl_expr *e) { struct nftnl_expr_log *log = nftnl_expr_data(e); @@ -336,12 +336,12 @@ struct expr_ops expr_ops_log = { .name = "log", .alloc_len = sizeof(struct nftnl_expr_log), .max_attr = NFTA_LOG_MAX, - .free = nftnl_rule_expr_log_free, - .set = nftnl_rule_expr_log_set, - .get = nftnl_rule_expr_log_get, - .parse = nftnl_rule_expr_log_parse, - .build = nftnl_rule_expr_log_build, - .snprintf = nftnl_rule_expr_log_snprintf, - .xml_parse = nftnl_rule_expr_log_xml_parse, - .json_parse = nftnl_rule_expr_log_json_parse, + .free = nftnl_expr_log_free, + .set = nftnl_expr_log_set, + .get = nftnl_expr_log_get, + .parse = nftnl_expr_log_parse, + .build = nftnl_expr_log_build, + .snprintf = nftnl_expr_log_snprintf, + .xml_parse = nftnl_expr_log_xml_parse, + .json_parse = nftnl_expr_log_json_parse, }; diff --git a/src/expr/lookup.c b/src/expr/lookup.c index 98ac1ad..d911cb6 100644 --- a/src/expr/lookup.c +++ b/src/expr/lookup.c @@ -33,7 +33,7 @@ struct nftnl_expr_lookup { }; static int -nftnl_rule_expr_lookup_set(struct nftnl_rule_expr *e, uint16_t type, +nftnl_expr_lookup_set(struct nftnl_expr *e, uint16_t type, const void *data, uint32_t data_len) { struct nftnl_expr_lookup *lookup = nftnl_expr_data(e); @@ -59,7 +59,7 @@ nftnl_rule_expr_lookup_set(struct nftnl_rule_expr *e, uint16_t type, } static const void * -nftnl_rule_expr_lookup_get(const struct nftnl_rule_expr *e, uint16_t type, +nftnl_expr_lookup_get(const struct nftnl_expr *e, uint16_t type, uint32_t *data_len) { struct nftnl_expr_lookup *lookup = nftnl_expr_data(e); @@ -79,7 +79,7 @@ nftnl_rule_expr_lookup_get(const struct nftnl_rule_expr *e, uint16_t type, return NULL; } -static int nftnl_rule_expr_lookup_cb(const struct nlattr *attr, void *data) +static int nftnl_expr_lookup_cb(const struct nlattr *attr, void *data) { const struct nlattr **tb = data; int type = mnl_attr_get_type(attr); @@ -105,7 +105,7 @@ static int nftnl_rule_expr_lookup_cb(const struct nlattr *attr, void *data) } static void -nftnl_rule_expr_lookup_build(struct nlmsghdr *nlh, struct nftnl_rule_expr *e) +nftnl_expr_lookup_build(struct nlmsghdr *nlh, struct nftnl_expr *e) { struct nftnl_expr_lookup *lookup = nftnl_expr_data(e); @@ -122,13 +122,13 @@ nftnl_rule_expr_lookup_build(struct nlmsghdr *nlh, struct nftnl_rule_expr *e) } static int -nftnl_rule_expr_lookup_parse(struct nftnl_rule_expr *e, struct nlattr *attr) +nftnl_expr_lookup_parse(struct nftnl_expr *e, struct nlattr *attr) { struct nftnl_expr_lookup *lookup = nftnl_expr_data(e); struct nlattr *tb[NFTA_LOOKUP_MAX+1] = {}; int ret = 0; - if (mnl_attr_parse_nested(attr, nftnl_rule_expr_lookup_cb, tb) < 0) + if (mnl_attr_parse_nested(attr, nftnl_expr_lookup_cb, tb) < 0) return -1; if (tb[NFTA_LOOKUP_SREG]) { @@ -153,7 +153,7 @@ nftnl_rule_expr_lookup_parse(struct nftnl_rule_expr *e, struct nlattr *attr) } static int -nftnl_rule_expr_lookup_json_parse(struct nftnl_rule_expr *e, json_t *root, +nftnl_expr_lookup_json_parse(struct nftnl_expr *e, json_t *root, struct nftnl_parse_err *err) { #ifdef JSON_PARSING @@ -162,13 +162,13 @@ nftnl_rule_expr_lookup_json_parse(struct nftnl_rule_expr *e, json_t *root, set_name = nftnl_jansson_parse_str(root, "set", err); if (set_name != NULL) - nftnl_rule_expr_set_str(e, NFTNL_EXPR_LOOKUP_SET, set_name); + nftnl_expr_set_str(e, NFTNL_EXPR_LOOKUP_SET, set_name); if (nftnl_jansson_parse_reg(root, "sreg", NFTNL_TYPE_U32, &sreg, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_LOOKUP_SREG, sreg); + nftnl_expr_set_u32(e, NFTNL_EXPR_LOOKUP_SREG, sreg); if (nftnl_jansson_parse_reg(root, "dreg", NFTNL_TYPE_U32, &dreg, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_LOOKUP_DREG, dreg); + nftnl_expr_set_u32(e, NFTNL_EXPR_LOOKUP_DREG, dreg); return 0; #else @@ -178,7 +178,7 @@ nftnl_rule_expr_lookup_json_parse(struct nftnl_rule_expr *e, json_t *root, } static int -nftnl_rule_expr_lookup_xml_parse(struct nftnl_rule_expr *e, mxml_node_t *tree, +nftnl_expr_lookup_xml_parse(struct nftnl_expr *e, mxml_node_t *tree, struct nftnl_parse_err *err) { #ifdef XML_PARSING @@ -188,15 +188,15 @@ nftnl_rule_expr_lookup_xml_parse(struct nftnl_rule_expr *e, mxml_node_t *tree, set_name = nftnl_mxml_str_parse(tree, "set", MXML_DESCEND_FIRST, NFTNL_XML_MAND, err); if (set_name != NULL) - nftnl_rule_expr_set_str(e, NFTNL_EXPR_LOOKUP_SET, set_name); + nftnl_expr_set_str(e, NFTNL_EXPR_LOOKUP_SET, set_name); if (nftnl_mxml_reg_parse(tree, "sreg", &sreg, MXML_DESCEND, NFTNL_XML_MAND, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_LOOKUP_SREG, sreg); + nftnl_expr_set_u32(e, NFTNL_EXPR_LOOKUP_SREG, sreg); if (nftnl_mxml_reg_parse(tree, "dreg", &dreg, MXML_DESCEND, NFTNL_XML_OPT, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_LOOKUP_DREG, dreg); + nftnl_expr_set_u32(e, NFTNL_EXPR_LOOKUP_DREG, dreg); return 0; #else @@ -206,8 +206,8 @@ nftnl_rule_expr_lookup_xml_parse(struct nftnl_rule_expr *e, mxml_node_t *tree, } static int -nftnl_rule_expr_lookup_export(char *buf, size_t size, - struct nftnl_rule_expr *e, int type) +nftnl_expr_lookup_export(char *buf, size_t size, + struct nftnl_expr *e, int type) { struct nftnl_expr_lookup *l = nftnl_expr_data(e); NFTNL_BUF_INIT(b, buf, size); @@ -223,8 +223,8 @@ nftnl_rule_expr_lookup_export(char *buf, size_t size, } static int -nftnl_rule_expr_lookup_snprintf_default(char *buf, size_t size, - struct nftnl_rule_expr *e) +nftnl_expr_lookup_snprintf_default(char *buf, size_t size, + struct nftnl_expr *e) { int len = size, offset = 0, ret; struct nftnl_expr_lookup *l = nftnl_expr_data(e); @@ -242,16 +242,16 @@ nftnl_rule_expr_lookup_snprintf_default(char *buf, size_t size, } static int -nftnl_rule_expr_lookup_snprintf(char *buf, size_t size, uint32_t type, - uint32_t flags, struct nftnl_rule_expr *e) +nftnl_expr_lookup_snprintf(char *buf, size_t size, uint32_t type, + uint32_t flags, struct nftnl_expr *e) { switch(type) { case NFTNL_OUTPUT_DEFAULT: - return nftnl_rule_expr_lookup_snprintf_default(buf, size, e); + return nftnl_expr_lookup_snprintf_default(buf, size, e); case NFTNL_OUTPUT_XML: case NFTNL_OUTPUT_JSON: - return nftnl_rule_expr_lookup_export(buf, size, e, type); + return nftnl_expr_lookup_export(buf, size, e, type); default: break; } @@ -262,11 +262,11 @@ struct expr_ops expr_ops_lookup = { .name = "lookup", .alloc_len = sizeof(struct nftnl_expr_lookup), .max_attr = NFTA_LOOKUP_MAX, - .set = nftnl_rule_expr_lookup_set, - .get = nftnl_rule_expr_lookup_get, - .parse = nftnl_rule_expr_lookup_parse, - .build = nftnl_rule_expr_lookup_build, - .snprintf = nftnl_rule_expr_lookup_snprintf, - .xml_parse = nftnl_rule_expr_lookup_xml_parse, - .json_parse = nftnl_rule_expr_lookup_json_parse, + .set = nftnl_expr_lookup_set, + .get = nftnl_expr_lookup_get, + .parse = nftnl_expr_lookup_parse, + .build = nftnl_expr_lookup_build, + .snprintf = nftnl_expr_lookup_snprintf, + .xml_parse = nftnl_expr_lookup_xml_parse, + .json_parse = nftnl_expr_lookup_json_parse, }; diff --git a/src/expr/masq.c b/src/expr/masq.c index ee49151..01512b4 100644 --- a/src/expr/masq.c +++ b/src/expr/masq.c @@ -25,7 +25,7 @@ struct nftnl_expr_masq { }; static int -nftnl_rule_expr_masq_set(struct nftnl_rule_expr *e, uint16_t type, +nftnl_expr_masq_set(struct nftnl_expr *e, uint16_t type, const void *data, uint32_t data_len) { struct nftnl_expr_masq *masq = nftnl_expr_data(e); @@ -41,7 +41,7 @@ nftnl_rule_expr_masq_set(struct nftnl_rule_expr *e, uint16_t type, } static const void * -nftnl_rule_expr_masq_get(const struct nftnl_rule_expr *e, uint16_t type, +nftnl_expr_masq_get(const struct nftnl_expr *e, uint16_t type, uint32_t *data_len) { struct nftnl_expr_masq *masq = nftnl_expr_data(e); @@ -54,7 +54,7 @@ nftnl_rule_expr_masq_get(const struct nftnl_rule_expr *e, uint16_t type, return NULL; } -static int nftnl_rule_expr_masq_cb(const struct nlattr *attr, void *data) +static int nftnl_expr_masq_cb(const struct nlattr *attr, void *data) { const struct nlattr **tb = data; int type = mnl_attr_get_type(attr); @@ -74,7 +74,7 @@ static int nftnl_rule_expr_masq_cb(const struct nlattr *attr, void *data) } static void -nftnl_rule_expr_masq_build(struct nlmsghdr *nlh, struct nftnl_rule_expr *e) +nftnl_expr_masq_build(struct nlmsghdr *nlh, struct nftnl_expr *e) { struct nftnl_expr_masq *masq = nftnl_expr_data(e); @@ -83,12 +83,12 @@ nftnl_rule_expr_masq_build(struct nlmsghdr *nlh, struct nftnl_rule_expr *e) } static int -nftnl_rule_expr_masq_parse(struct nftnl_rule_expr *e, struct nlattr *attr) +nftnl_expr_masq_parse(struct nftnl_expr *e, struct nlattr *attr) { struct nftnl_expr_masq *masq = nftnl_expr_data(e); struct nlattr *tb[NFTA_MASQ_MAX+1] = {}; - if (mnl_attr_parse_nested(attr, nftnl_rule_expr_masq_cb, tb) < 0) + if (mnl_attr_parse_nested(attr, nftnl_expr_masq_cb, tb) < 0) return -1; if (tb[NFTA_MASQ_FLAGS]) { @@ -100,7 +100,7 @@ nftnl_rule_expr_masq_parse(struct nftnl_rule_expr *e, struct nlattr *attr) } static int -nftnl_rule_expr_masq_json_parse(struct nftnl_rule_expr *e, json_t *root, +nftnl_expr_masq_json_parse(struct nftnl_expr *e, json_t *root, struct nftnl_parse_err *err) { #ifdef JSON_PARSING @@ -108,7 +108,7 @@ nftnl_rule_expr_masq_json_parse(struct nftnl_rule_expr *e, json_t *root, if (nftnl_jansson_parse_val(root, "flags", NFTNL_TYPE_U32, &flags, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_MASQ_FLAGS, flags); + nftnl_expr_set_u32(e, NFTNL_EXPR_MASQ_FLAGS, flags); return 0; #else @@ -118,7 +118,7 @@ nftnl_rule_expr_masq_json_parse(struct nftnl_rule_expr *e, json_t *root, } static int -nftnl_rule_expr_masq_xml_parse(struct nftnl_rule_expr *e, mxml_node_t *tree, +nftnl_expr_masq_xml_parse(struct nftnl_expr *e, mxml_node_t *tree, struct nftnl_parse_err *err) { #ifdef XML_PARSING @@ -126,7 +126,7 @@ nftnl_rule_expr_masq_xml_parse(struct nftnl_rule_expr *e, mxml_node_t *tree, if (nftnl_mxml_num_parse(tree, "flags", MXML_DESCEND_FIRST, BASE_DEC, &flags, NFTNL_TYPE_U32, NFTNL_XML_MAND, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_MASQ_FLAGS, flags); + nftnl_expr_set_u32(e, NFTNL_EXPR_MASQ_FLAGS, flags); return 0; #else @@ -134,8 +134,8 @@ nftnl_rule_expr_masq_xml_parse(struct nftnl_rule_expr *e, mxml_node_t *tree, return -1; #endif } -static int nftnl_rule_expr_masq_export(char *buf, size_t size, - struct nftnl_rule_expr *e, int type) +static int nftnl_expr_masq_export(char *buf, size_t size, + struct nftnl_expr *e, int type) { struct nftnl_expr_masq *masq = nftnl_expr_data(e); NFTNL_BUF_INIT(b, buf, size); @@ -146,8 +146,8 @@ static int nftnl_rule_expr_masq_export(char *buf, size_t size, return nftnl_buf_done(&b); } -static int nftnl_rule_expr_masq_snprintf_default(char *buf, size_t len, - struct nftnl_rule_expr *e) +static int nftnl_expr_masq_snprintf_default(char *buf, size_t len, + struct nftnl_expr *e) { struct nftnl_expr_masq *masq = nftnl_expr_data(e); @@ -157,15 +157,15 @@ static int nftnl_rule_expr_masq_snprintf_default(char *buf, size_t len, return 0; } -static int nftnl_rule_expr_masq_snprintf(char *buf, size_t len, uint32_t type, - uint32_t flags, struct nftnl_rule_expr *e) +static int nftnl_expr_masq_snprintf(char *buf, size_t len, uint32_t type, + uint32_t flags, struct nftnl_expr *e) { switch (type) { case NFTNL_OUTPUT_DEFAULT: - return nftnl_rule_expr_masq_snprintf_default(buf, len, e); + return nftnl_expr_masq_snprintf_default(buf, len, e); case NFTNL_OUTPUT_XML: case NFTNL_OUTPUT_JSON: - return nftnl_rule_expr_masq_export(buf, len, e, type); + return nftnl_expr_masq_export(buf, len, e, type); default: break; } @@ -176,11 +176,11 @@ struct expr_ops expr_ops_masq = { .name = "masq", .alloc_len = sizeof(struct nftnl_expr_masq), .max_attr = NFTA_MASQ_MAX, - .set = nftnl_rule_expr_masq_set, - .get = nftnl_rule_expr_masq_get, - .parse = nftnl_rule_expr_masq_parse, - .build = nftnl_rule_expr_masq_build, - .snprintf = nftnl_rule_expr_masq_snprintf, - .xml_parse = nftnl_rule_expr_masq_xml_parse, - .json_parse = nftnl_rule_expr_masq_json_parse, + .set = nftnl_expr_masq_set, + .get = nftnl_expr_masq_get, + .parse = nftnl_expr_masq_parse, + .build = nftnl_expr_masq_build, + .snprintf = nftnl_expr_masq_snprintf, + .xml_parse = nftnl_expr_masq_xml_parse, + .json_parse = nftnl_expr_masq_json_parse, }; diff --git a/src/expr/match.c b/src/expr/match.c index 1a550cc..ddecb43 100644 --- a/src/expr/match.c +++ b/src/expr/match.c @@ -35,7 +35,7 @@ struct nftnl_expr_match { }; static int -nftnl_rule_expr_match_set(struct nftnl_rule_expr *e, uint16_t type, +nftnl_expr_match_set(struct nftnl_expr *e, uint16_t type, const void *data, uint32_t data_len) { struct nftnl_expr_match *mt = nftnl_expr_data(e); @@ -62,7 +62,7 @@ nftnl_rule_expr_match_set(struct nftnl_rule_expr *e, uint16_t type, } static const void * -nftnl_rule_expr_match_get(const struct nftnl_rule_expr *e, uint16_t type, +nftnl_expr_match_get(const struct nftnl_expr *e, uint16_t type, uint32_t *data_len) { struct nftnl_expr_match *mt = nftnl_expr_data(e); @@ -81,7 +81,7 @@ nftnl_rule_expr_match_get(const struct nftnl_rule_expr *e, uint16_t type, return NULL; } -static int nftnl_rule_expr_match_cb(const struct nlattr *attr, void *data) +static int nftnl_expr_match_cb(const struct nlattr *attr, void *data) { const struct nlattr **tb = data; int type = mnl_attr_get_type(attr); @@ -109,7 +109,7 @@ static int nftnl_rule_expr_match_cb(const struct nlattr *attr, void *data) } static void -nftnl_rule_expr_match_build(struct nlmsghdr *nlh, struct nftnl_rule_expr *e) +nftnl_expr_match_build(struct nlmsghdr *nlh, struct nftnl_expr *e) { struct nftnl_expr_match *mt = nftnl_expr_data(e); @@ -121,12 +121,12 @@ nftnl_rule_expr_match_build(struct nlmsghdr *nlh, struct nftnl_rule_expr *e) mnl_attr_put(nlh, NFTA_MATCH_INFO, mt->data_len, mt->data); } -static int nftnl_rule_expr_match_parse(struct nftnl_rule_expr *e, struct nlattr *attr) +static int nftnl_expr_match_parse(struct nftnl_expr *e, struct nlattr *attr) { struct nftnl_expr_match *match = nftnl_expr_data(e); struct nlattr *tb[NFTA_MATCH_MAX+1] = {}; - if (mnl_attr_parse_nested(attr, nftnl_rule_expr_match_cb, tb) < 0) + if (mnl_attr_parse_nested(attr, nftnl_expr_match_cb, tb) < 0) return -1; if (tb[NFTA_MATCH_NAME]) { @@ -164,7 +164,7 @@ static int nftnl_rule_expr_match_parse(struct nftnl_rule_expr *e, struct nlattr return 0; } -static int nftnl_rule_expr_match_json_parse(struct nftnl_rule_expr *e, json_t *root, +static int nftnl_expr_match_json_parse(struct nftnl_expr *e, json_t *root, struct nftnl_parse_err *err) { #ifdef JSON_PARSING @@ -172,7 +172,7 @@ static int nftnl_rule_expr_match_json_parse(struct nftnl_rule_expr *e, json_t *r name = nftnl_jansson_parse_str(root, "name", err); if (name != NULL) - nftnl_rule_expr_set_str(e, NFTNL_EXPR_MT_NAME, name); + nftnl_expr_set_str(e, NFTNL_EXPR_MT_NAME, name); return 0; #else @@ -182,7 +182,7 @@ static int nftnl_rule_expr_match_json_parse(struct nftnl_rule_expr *e, json_t *r } -static int nftnl_rule_expr_match_xml_parse(struct nftnl_rule_expr *e, mxml_node_t *tree, +static int nftnl_expr_match_xml_parse(struct nftnl_expr *e, mxml_node_t *tree, struct nftnl_parse_err *err) { #ifdef XML_PARSING @@ -191,7 +191,7 @@ static int nftnl_rule_expr_match_xml_parse(struct nftnl_rule_expr *e, mxml_node_ name = nftnl_mxml_str_parse(tree, "name", MXML_DESCEND_FIRST, NFTNL_XML_MAND, err); if (name != NULL) - nftnl_rule_expr_set_str(e, NFTNL_EXPR_MT_NAME, name); + nftnl_expr_set_str(e, NFTNL_EXPR_MT_NAME, name); /* mt->info is ignored until other solution is reached */ @@ -202,8 +202,8 @@ static int nftnl_rule_expr_match_xml_parse(struct nftnl_rule_expr *e, mxml_node_ #endif } -static int nftnl_rule_expr_match_export(char *buf, size_t size, - struct nftnl_rule_expr *e, int type) +static int nftnl_expr_match_export(char *buf, size_t size, + struct nftnl_expr *e, int type) { struct nftnl_expr_match *mt = nftnl_expr_data(e); NFTNL_BUF_INIT(b, buf, size); @@ -215,8 +215,8 @@ static int nftnl_rule_expr_match_export(char *buf, size_t size, } static int -nftnl_rule_expr_match_snprintf(char *buf, size_t len, uint32_t type, - uint32_t flags, struct nftnl_rule_expr *e) +nftnl_expr_match_snprintf(char *buf, size_t len, uint32_t type, + uint32_t flags, struct nftnl_expr *e) { struct nftnl_expr_match *match = nftnl_expr_data(e); @@ -226,14 +226,14 @@ nftnl_rule_expr_match_snprintf(char *buf, size_t len, uint32_t type, match->name, match->rev); case NFTNL_OUTPUT_XML: case NFTNL_OUTPUT_JSON: - return nftnl_rule_expr_match_export(buf, len, e, type); + return nftnl_expr_match_export(buf, len, e, type); default: break; } return -1; } -static void nftnl_rule_expr_match_free(struct nftnl_rule_expr *e) +static void nftnl_expr_match_free(struct nftnl_expr *e) { struct nftnl_expr_match *match = nftnl_expr_data(e); @@ -244,12 +244,12 @@ struct expr_ops expr_ops_match = { .name = "match", .alloc_len = sizeof(struct nftnl_expr_match), .max_attr = NFTA_MATCH_MAX, - .free = nftnl_rule_expr_match_free, - .set = nftnl_rule_expr_match_set, - .get = nftnl_rule_expr_match_get, - .parse = nftnl_rule_expr_match_parse, - .build = nftnl_rule_expr_match_build, - .snprintf = nftnl_rule_expr_match_snprintf, - .xml_parse = nftnl_rule_expr_match_xml_parse, - .json_parse = nftnl_rule_expr_match_json_parse, + .free = nftnl_expr_match_free, + .set = nftnl_expr_match_set, + .get = nftnl_expr_match_get, + .parse = nftnl_expr_match_parse, + .build = nftnl_expr_match_build, + .snprintf = nftnl_expr_match_snprintf, + .xml_parse = nftnl_expr_match_xml_parse, + .json_parse = nftnl_expr_match_json_parse, }; diff --git a/src/expr/meta.c b/src/expr/meta.c index 98f7588..546b225 100644 --- a/src/expr/meta.c +++ b/src/expr/meta.c @@ -32,7 +32,7 @@ struct nftnl_expr_meta { }; static int -nftnl_rule_expr_meta_set(struct nftnl_rule_expr *e, uint16_t type, +nftnl_expr_meta_set(struct nftnl_expr *e, uint16_t type, const void *data, uint32_t data_len) { struct nftnl_expr_meta *meta = nftnl_expr_data(e); @@ -54,7 +54,7 @@ nftnl_rule_expr_meta_set(struct nftnl_rule_expr *e, uint16_t type, } static const void * -nftnl_rule_expr_meta_get(const struct nftnl_rule_expr *e, uint16_t type, +nftnl_expr_meta_get(const struct nftnl_expr *e, uint16_t type, uint32_t *data_len) { struct nftnl_expr_meta *meta = nftnl_expr_data(e); @@ -73,7 +73,7 @@ nftnl_rule_expr_meta_get(const struct nftnl_rule_expr *e, uint16_t type, return NULL; } -static int nftnl_rule_expr_meta_cb(const struct nlattr *attr, void *data) +static int nftnl_expr_meta_cb(const struct nlattr *attr, void *data) { const struct nlattr **tb = data; int type = mnl_attr_get_type(attr); @@ -95,7 +95,7 @@ static int nftnl_rule_expr_meta_cb(const struct nlattr *attr, void *data) } static void -nftnl_rule_expr_meta_build(struct nlmsghdr *nlh, struct nftnl_rule_expr *e) +nftnl_expr_meta_build(struct nlmsghdr *nlh, struct nftnl_expr *e) { struct nftnl_expr_meta *meta = nftnl_expr_data(e); @@ -108,12 +108,12 @@ nftnl_rule_expr_meta_build(struct nlmsghdr *nlh, struct nftnl_rule_expr *e) } static int -nftnl_rule_expr_meta_parse(struct nftnl_rule_expr *e, struct nlattr *attr) +nftnl_expr_meta_parse(struct nftnl_expr *e, struct nlattr *attr) { struct nftnl_expr_meta *meta = nftnl_expr_data(e); struct nlattr *tb[NFTA_META_MAX+1] = {}; - if (mnl_attr_parse_nested(attr, nftnl_rule_expr_meta_cb, tb) < 0) + if (mnl_attr_parse_nested(attr, nftnl_expr_meta_cb, tb) < 0) return -1; if (tb[NFTA_META_KEY]) { @@ -180,7 +180,7 @@ static inline int str2meta_key(const char *str) return -1; } -static int nftnl_rule_expr_meta_json_parse(struct nftnl_rule_expr *e, json_t *root, +static int nftnl_expr_meta_json_parse(struct nftnl_expr *e, json_t *root, struct nftnl_parse_err *err) { #ifdef JSON_PARSING @@ -192,19 +192,19 @@ static int nftnl_rule_expr_meta_json_parse(struct nftnl_rule_expr *e, json_t *ro if (key_str != NULL) { key = str2meta_key(key_str); if (key >= 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_META_KEY, key); + nftnl_expr_set_u32(e, NFTNL_EXPR_META_KEY, key); } if (nftnl_jansson_node_exist(root, "dreg")) { if (nftnl_jansson_parse_reg(root, "dreg", NFTNL_TYPE_U32, ®, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_META_DREG, reg); + nftnl_expr_set_u32(e, NFTNL_EXPR_META_DREG, reg); } if (nftnl_jansson_node_exist(root, "sreg")) { if (nftnl_jansson_parse_reg(root, "sreg", NFTNL_TYPE_U32, ®, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_META_SREG, reg); + nftnl_expr_set_u32(e, NFTNL_EXPR_META_SREG, reg); } return 0; @@ -215,7 +215,7 @@ static int nftnl_rule_expr_meta_json_parse(struct nftnl_rule_expr *e, json_t *ro } -static int nftnl_rule_expr_meta_xml_parse(struct nftnl_rule_expr *e, mxml_node_t *tree, +static int nftnl_expr_meta_xml_parse(struct nftnl_expr *e, mxml_node_t *tree, struct nftnl_parse_err *err) { #ifdef XML_PARSING @@ -228,16 +228,16 @@ static int nftnl_rule_expr_meta_xml_parse(struct nftnl_rule_expr *e, mxml_node_t if (key_str != NULL) { key = str2meta_key(key_str); if (key >= 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_META_KEY, key); + nftnl_expr_set_u32(e, NFTNL_EXPR_META_KEY, key); } if (nftnl_mxml_reg_parse(tree, "dreg", &dreg, MXML_DESCEND_FIRST, NFTNL_XML_OPT, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_META_DREG, dreg); + nftnl_expr_set_u32(e, NFTNL_EXPR_META_DREG, dreg); if (nftnl_mxml_reg_parse(tree, "sreg", &sreg, MXML_DESCEND_FIRST, NFTNL_XML_OPT, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_META_SREG, sreg); + nftnl_expr_set_u32(e, NFTNL_EXPR_META_SREG, sreg); return 0; #else @@ -247,8 +247,8 @@ static int nftnl_rule_expr_meta_xml_parse(struct nftnl_rule_expr *e, mxml_node_t } static int -nftnl_rule_expr_meta_snprintf_default(char *buf, size_t len, - struct nftnl_rule_expr *e) +nftnl_expr_meta_snprintf_default(char *buf, size_t len, + struct nftnl_expr *e) { struct nftnl_expr_meta *meta = nftnl_expr_data(e); @@ -263,8 +263,8 @@ nftnl_rule_expr_meta_snprintf_default(char *buf, size_t len, return 0; } -static int nftnl_rule_expr_meta_export(char *buf, size_t size, - struct nftnl_rule_expr *e, int type) +static int nftnl_expr_meta_export(char *buf, size_t size, + struct nftnl_expr *e, int type) { struct nftnl_expr_meta *meta = nftnl_expr_data(e); NFTNL_BUF_INIT(b, buf, size); @@ -280,15 +280,15 @@ static int nftnl_rule_expr_meta_export(char *buf, size_t size, } static int -nftnl_rule_expr_meta_snprintf(char *buf, size_t len, uint32_t type, - uint32_t flags, struct nftnl_rule_expr *e) +nftnl_expr_meta_snprintf(char *buf, size_t len, uint32_t type, + uint32_t flags, struct nftnl_expr *e) { switch (type) { case NFTNL_OUTPUT_DEFAULT: - return nftnl_rule_expr_meta_snprintf_default(buf, len, e); + return nftnl_expr_meta_snprintf_default(buf, len, e); case NFTNL_OUTPUT_XML: case NFTNL_OUTPUT_JSON: - return nftnl_rule_expr_meta_export(buf, len, e, type); + return nftnl_expr_meta_export(buf, len, e, type); default: break; } @@ -299,11 +299,11 @@ struct expr_ops expr_ops_meta = { .name = "meta", .alloc_len = sizeof(struct nftnl_expr_meta), .max_attr = NFTA_META_MAX, - .set = nftnl_rule_expr_meta_set, - .get = nftnl_rule_expr_meta_get, - .parse = nftnl_rule_expr_meta_parse, - .build = nftnl_rule_expr_meta_build, - .snprintf = nftnl_rule_expr_meta_snprintf, - .xml_parse = nftnl_rule_expr_meta_xml_parse, - .json_parse = nftnl_rule_expr_meta_json_parse, + .set = nftnl_expr_meta_set, + .get = nftnl_expr_meta_get, + .parse = nftnl_expr_meta_parse, + .build = nftnl_expr_meta_build, + .snprintf = nftnl_expr_meta_snprintf, + .xml_parse = nftnl_expr_meta_xml_parse, + .json_parse = nftnl_expr_meta_json_parse, }; diff --git a/src/expr/nat.c b/src/expr/nat.c index 3b61344..421983f 100644 --- a/src/expr/nat.c +++ b/src/expr/nat.c @@ -35,7 +35,7 @@ struct nftnl_expr_nat { }; static int -nftnl_rule_expr_nat_set(struct nftnl_rule_expr *e, uint16_t type, +nftnl_expr_nat_set(struct nftnl_expr *e, uint16_t type, const void *data, uint32_t data_len) { struct nftnl_expr_nat *nat = nftnl_expr_data(e); @@ -70,7 +70,7 @@ nftnl_rule_expr_nat_set(struct nftnl_rule_expr *e, uint16_t type, } static const void * -nftnl_rule_expr_nat_get(const struct nftnl_rule_expr *e, uint16_t type, +nftnl_expr_nat_get(const struct nftnl_expr *e, uint16_t type, uint32_t *data_len) { struct nftnl_expr_nat *nat = nftnl_expr_data(e); @@ -101,7 +101,7 @@ nftnl_rule_expr_nat_get(const struct nftnl_rule_expr *e, uint16_t type, return NULL; } -static int nftnl_rule_expr_nat_cb(const struct nlattr *attr, void *data) +static int nftnl_expr_nat_cb(const struct nlattr *attr, void *data) { const struct nlattr **tb = data; int type = mnl_attr_get_type(attr); @@ -127,12 +127,12 @@ static int nftnl_rule_expr_nat_cb(const struct nlattr *attr, void *data) } static int -nftnl_rule_expr_nat_parse(struct nftnl_rule_expr *e, struct nlattr *attr) +nftnl_expr_nat_parse(struct nftnl_expr *e, struct nlattr *attr) { struct nftnl_expr_nat *nat = nftnl_expr_data(e); struct nlattr *tb[NFTA_NAT_MAX+1] = {}; - if (mnl_attr_parse_nested(attr, nftnl_rule_expr_nat_cb, tb) < 0) + if (mnl_attr_parse_nested(attr, nftnl_expr_nat_cb, tb) < 0) return -1; if (tb[NFTA_NAT_TYPE]) { @@ -172,7 +172,7 @@ nftnl_rule_expr_nat_parse(struct nftnl_rule_expr *e, struct nlattr *attr) } static void -nftnl_rule_expr_nat_build(struct nlmsghdr *nlh, struct nftnl_rule_expr *e) +nftnl_expr_nat_build(struct nlmsghdr *nlh, struct nftnl_expr *e) { struct nftnl_expr_nat *nat = nftnl_expr_data(e); @@ -220,7 +220,7 @@ static inline int nftnl_str2nat(const char *nat) } } -static int nftnl_rule_expr_nat_json_parse(struct nftnl_rule_expr *e, json_t *root, +static int nftnl_expr_nat_json_parse(struct nftnl_expr *e, json_t *root, struct nftnl_parse_err *err) { #ifdef JSON_PARSING @@ -236,7 +236,7 @@ static int nftnl_rule_expr_nat_json_parse(struct nftnl_rule_expr *e, json_t *roo if (val32 < 0) return -1; - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_NAT_TYPE, val32); + nftnl_expr_set_u32(e, NFTNL_EXPR_NAT_TYPE, val32); family_str = nftnl_jansson_parse_str(root, "family", err); if (family_str == NULL) @@ -246,27 +246,27 @@ static int nftnl_rule_expr_nat_json_parse(struct nftnl_rule_expr *e, json_t *roo if (val32 < 0) return -1; - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_NAT_FAMILY, val32); + nftnl_expr_set_u32(e, NFTNL_EXPR_NAT_FAMILY, val32); if (nftnl_jansson_parse_reg(root, "sreg_addr_min", NFTNL_TYPE_U32, ®, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_NAT_REG_ADDR_MIN, reg); + nftnl_expr_set_u32(e, NFTNL_EXPR_NAT_REG_ADDR_MIN, reg); if (nftnl_jansson_parse_reg(root, "sreg_addr_max", NFTNL_TYPE_U32, ®, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_NAT_REG_ADDR_MAX, reg); + nftnl_expr_set_u32(e, NFTNL_EXPR_NAT_REG_ADDR_MAX, reg); if (nftnl_jansson_parse_reg(root, "sreg_proto_min", NFTNL_TYPE_U32, ®, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_NAT_REG_PROTO_MIN, reg); + nftnl_expr_set_u32(e, NFTNL_EXPR_NAT_REG_PROTO_MIN, reg); if (nftnl_jansson_parse_reg(root, "sreg_proto_max", NFTNL_TYPE_U32, ®, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_NAT_REG_PROTO_MAX, reg); + nftnl_expr_set_u32(e, NFTNL_EXPR_NAT_REG_PROTO_MAX, reg); if (nftnl_jansson_parse_val(root, "flags", NFTNL_TYPE_U32, &flags, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_NAT_FLAGS, flags); + nftnl_expr_set_u32(e, NFTNL_EXPR_NAT_FLAGS, flags); return 0; #else @@ -275,7 +275,7 @@ static int nftnl_rule_expr_nat_json_parse(struct nftnl_rule_expr *e, json_t *roo #endif } -static int nftnl_rule_expr_nat_xml_parse(struct nftnl_rule_expr *e, mxml_node_t *tree, +static int nftnl_expr_nat_xml_parse(struct nftnl_expr *e, mxml_node_t *tree, struct nftnl_parse_err *err) { #ifdef XML_PARSING @@ -292,7 +292,7 @@ static int nftnl_rule_expr_nat_xml_parse(struct nftnl_rule_expr *e, mxml_node_t nat_type_value = nftnl_str2nat(nat_type); if (nat_type_value < 0) return -1; - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_NAT_TYPE, nat_type_value); + nftnl_expr_set_u32(e, NFTNL_EXPR_NAT_TYPE, nat_type_value); family = nftnl_mxml_family_parse(tree, "family", MXML_DESCEND_FIRST, NFTNL_XML_MAND, err); @@ -300,27 +300,27 @@ static int nftnl_rule_expr_nat_xml_parse(struct nftnl_rule_expr *e, mxml_node_t mxmlDelete(tree); return -1; } - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_NAT_FAMILY, family); + nftnl_expr_set_u32(e, NFTNL_EXPR_NAT_FAMILY, family); if (nftnl_mxml_reg_parse(tree, "sreg_addr_min", ®_addr_min, MXML_DESCEND, NFTNL_XML_MAND, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_NAT_REG_ADDR_MIN, reg_addr_min); + nftnl_expr_set_u32(e, NFTNL_EXPR_NAT_REG_ADDR_MIN, reg_addr_min); if (nftnl_mxml_reg_parse(tree, "sreg_addr_max", ®_addr_max, MXML_DESCEND, NFTNL_XML_MAND, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_NAT_REG_ADDR_MAX, reg_addr_max); + nftnl_expr_set_u32(e, NFTNL_EXPR_NAT_REG_ADDR_MAX, reg_addr_max); if (nftnl_mxml_reg_parse(tree, "sreg_proto_min", ®_proto_min, MXML_DESCEND, NFTNL_XML_MAND, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_NAT_REG_PROTO_MIN, reg_proto_min); + nftnl_expr_set_u32(e, NFTNL_EXPR_NAT_REG_PROTO_MIN, reg_proto_min); if (nftnl_mxml_reg_parse(tree, "sreg_proto_max", ®_proto_max, MXML_DESCEND, NFTNL_XML_MAND, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_NAT_REG_PROTO_MAX, reg_proto_max); + nftnl_expr_set_u32(e, NFTNL_EXPR_NAT_REG_PROTO_MAX, reg_proto_max); if (nftnl_mxml_num_parse(tree, "flags", MXML_DESCEND, BASE_DEC, &flags, NFTNL_TYPE_U32, NFTNL_XML_MAND, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_NAT_FLAGS, flags); + nftnl_expr_set_u32(e, NFTNL_EXPR_NAT_FLAGS, flags); return 0; #else @@ -329,8 +329,8 @@ static int nftnl_rule_expr_nat_xml_parse(struct nftnl_rule_expr *e, mxml_node_t #endif } -static int nftnl_rule_expr_nat_export(char *buf, size_t size, - struct nftnl_rule_expr *e, int type) +static int nftnl_expr_nat_export(char *buf, size_t size, + struct nftnl_expr *e, int type) { struct nftnl_expr_nat *nat = nftnl_expr_data(e); NFTNL_BUF_INIT(b, buf, size); @@ -354,8 +354,8 @@ static int nftnl_rule_expr_nat_export(char *buf, size_t size, } static int -nftnl_rule_expr_nat_snprintf_default(char *buf, size_t size, - struct nftnl_rule_expr *e) +nftnl_expr_nat_snprintf_default(char *buf, size_t size, + struct nftnl_expr *e) { struct nftnl_expr_nat *nat = nftnl_expr_data(e); int len = size, offset = 0, ret = 0; @@ -389,15 +389,15 @@ nftnl_rule_expr_nat_snprintf_default(char *buf, size_t size, } static int -nftnl_rule_expr_nat_snprintf(char *buf, size_t size, uint32_t type, - uint32_t flags, struct nftnl_rule_expr *e) +nftnl_expr_nat_snprintf(char *buf, size_t size, uint32_t type, + uint32_t flags, struct nftnl_expr *e) { switch (type) { case NFTNL_OUTPUT_DEFAULT: - return nftnl_rule_expr_nat_snprintf_default(buf, size, e); + return nftnl_expr_nat_snprintf_default(buf, size, e); case NFTNL_OUTPUT_XML: case NFTNL_OUTPUT_JSON: - return nftnl_rule_expr_nat_export(buf, size, e, type); + return nftnl_expr_nat_export(buf, size, e, type); default: break; } @@ -408,11 +408,11 @@ struct expr_ops expr_ops_nat = { .name = "nat", .alloc_len = sizeof(struct nftnl_expr_nat), .max_attr = NFTA_NAT_MAX, - .set = nftnl_rule_expr_nat_set, - .get = nftnl_rule_expr_nat_get, - .parse = nftnl_rule_expr_nat_parse, - .build = nftnl_rule_expr_nat_build, - .snprintf = nftnl_rule_expr_nat_snprintf, - .xml_parse = nftnl_rule_expr_nat_xml_parse, - .json_parse = nftnl_rule_expr_nat_json_parse, + .set = nftnl_expr_nat_set, + .get = nftnl_expr_nat_get, + .parse = nftnl_expr_nat_parse, + .build = nftnl_expr_nat_build, + .snprintf = nftnl_expr_nat_snprintf, + .xml_parse = nftnl_expr_nat_xml_parse, + .json_parse = nftnl_expr_nat_json_parse, }; diff --git a/src/expr/payload.c b/src/expr/payload.c index eda96f7..be10663 100644 --- a/src/expr/payload.c +++ b/src/expr/payload.c @@ -32,7 +32,7 @@ struct nftnl_expr_payload { }; static int -nftnl_rule_expr_payload_set(struct nftnl_rule_expr *e, uint16_t type, +nftnl_expr_payload_set(struct nftnl_expr *e, uint16_t type, const void *data, uint32_t data_len) { struct nftnl_expr_payload *payload = nftnl_expr_data(e); @@ -57,7 +57,7 @@ nftnl_rule_expr_payload_set(struct nftnl_rule_expr *e, uint16_t type, } static const void * -nftnl_rule_expr_payload_get(const struct nftnl_rule_expr *e, uint16_t type, +nftnl_expr_payload_get(const struct nftnl_expr *e, uint16_t type, uint32_t *data_len) { struct nftnl_expr_payload *payload = nftnl_expr_data(e); @@ -79,7 +79,7 @@ nftnl_rule_expr_payload_get(const struct nftnl_rule_expr *e, uint16_t type, return NULL; } -static int nftnl_rule_expr_payload_cb(const struct nlattr *attr, void *data) +static int nftnl_expr_payload_cb(const struct nlattr *attr, void *data) { const struct nlattr **tb = data; int type = mnl_attr_get_type(attr); @@ -102,7 +102,7 @@ static int nftnl_rule_expr_payload_cb(const struct nlattr *attr, void *data) } static void -nftnl_rule_expr_payload_build(struct nlmsghdr *nlh, struct nftnl_rule_expr *e) +nftnl_expr_payload_build(struct nlmsghdr *nlh, struct nftnl_expr *e) { struct nftnl_expr_payload *payload = nftnl_expr_data(e); @@ -117,12 +117,12 @@ nftnl_rule_expr_payload_build(struct nlmsghdr *nlh, struct nftnl_rule_expr *e) } static int -nftnl_rule_expr_payload_parse(struct nftnl_rule_expr *e, struct nlattr *attr) +nftnl_expr_payload_parse(struct nftnl_expr *e, struct nlattr *attr) { struct nftnl_expr_payload *payload = nftnl_expr_data(e); struct nlattr *tb[NFTA_PAYLOAD_MAX+1] = {}; - if (mnl_attr_parse_nested(attr, nftnl_rule_expr_payload_cb, tb) < 0) + if (mnl_attr_parse_nested(attr, nftnl_expr_payload_cb, tb) < 0) return -1; if (tb[NFTA_PAYLOAD_DREG]) { @@ -174,7 +174,7 @@ static inline int nftnl_str2base(const char *base) } static int -nftnl_rule_expr_payload_json_parse(struct nftnl_rule_expr *e, json_t *root, +nftnl_expr_payload_json_parse(struct nftnl_expr *e, json_t *root, struct nftnl_parse_err *err) { #ifdef JSON_PARSING @@ -183,7 +183,7 @@ nftnl_rule_expr_payload_json_parse(struct nftnl_rule_expr *e, json_t *root, int base; if (nftnl_jansson_parse_reg(root, "dreg", NFTNL_TYPE_U32, ®, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_PAYLOAD_DREG, reg); + nftnl_expr_set_u32(e, NFTNL_EXPR_PAYLOAD_DREG, reg); base_str = nftnl_jansson_parse_str(root, "base", err); if (base_str != NULL) { @@ -191,15 +191,15 @@ nftnl_rule_expr_payload_json_parse(struct nftnl_rule_expr *e, json_t *root, if (base < 0) return -1; - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_PAYLOAD_BASE, base); + nftnl_expr_set_u32(e, NFTNL_EXPR_PAYLOAD_BASE, base); } if (nftnl_jansson_parse_val(root, "offset", NFTNL_TYPE_U32, &uval32, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_PAYLOAD_OFFSET, uval32); + nftnl_expr_set_u32(e, NFTNL_EXPR_PAYLOAD_OFFSET, uval32); if (nftnl_jansson_parse_val(root, "len", NFTNL_TYPE_U32, &uval32, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_PAYLOAD_LEN, uval32); + nftnl_expr_set_u32(e, NFTNL_EXPR_PAYLOAD_LEN, uval32); return 0; #else @@ -209,7 +209,7 @@ nftnl_rule_expr_payload_json_parse(struct nftnl_rule_expr *e, json_t *root, } static int -nftnl_rule_expr_payload_xml_parse(struct nftnl_rule_expr *e, mxml_node_t *tree, +nftnl_expr_payload_xml_parse(struct nftnl_expr *e, mxml_node_t *tree, struct nftnl_parse_err *err) { #ifdef XML_PARSING @@ -219,7 +219,7 @@ nftnl_rule_expr_payload_xml_parse(struct nftnl_rule_expr *e, mxml_node_t *tree, if (nftnl_mxml_reg_parse(tree, "dreg", &dreg, MXML_DESCEND_FIRST, NFTNL_XML_MAND, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_PAYLOAD_DREG, dreg); + nftnl_expr_set_u32(e, NFTNL_EXPR_PAYLOAD_DREG, dreg); base_str = nftnl_mxml_str_parse(tree, "base", MXML_DESCEND_FIRST, NFTNL_XML_MAND, err); @@ -228,17 +228,17 @@ nftnl_rule_expr_payload_xml_parse(struct nftnl_rule_expr *e, mxml_node_t *tree, if (base < 0) return -1; - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_PAYLOAD_BASE, base); + nftnl_expr_set_u32(e, NFTNL_EXPR_PAYLOAD_BASE, base); } if (nftnl_mxml_num_parse(tree, "offset", MXML_DESCEND_FIRST, BASE_DEC, &offset, NFTNL_TYPE_U32, NFTNL_XML_MAND, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_PAYLOAD_OFFSET, offset); + nftnl_expr_set_u32(e, NFTNL_EXPR_PAYLOAD_OFFSET, offset); if (nftnl_mxml_num_parse(tree, "len", MXML_DESCEND_FIRST, BASE_DEC, &len, NFTNL_TYPE_U32, NFTNL_XML_MAND, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_PAYLOAD_LEN, len); + nftnl_expr_set_u32(e, NFTNL_EXPR_PAYLOAD_LEN, len); return 0; #else @@ -247,8 +247,8 @@ nftnl_rule_expr_payload_xml_parse(struct nftnl_rule_expr *e, mxml_node_t *tree, #endif } -static int nftnl_rule_expr_payload_export(char *buf, size_t size, uint32_t flags, - struct nftnl_rule_expr *e, int type) +static int nftnl_expr_payload_export(char *buf, size_t size, uint32_t flags, + struct nftnl_expr *e, int type) { struct nftnl_expr_payload *payload = nftnl_expr_data(e); NFTNL_BUF_INIT(b, buf, size); @@ -266,8 +266,8 @@ static int nftnl_rule_expr_payload_export(char *buf, size_t size, uint32_t flags } static int -nftnl_rule_expr_payload_snprintf(char *buf, size_t len, uint32_t type, - uint32_t flags, struct nftnl_rule_expr *e) +nftnl_expr_payload_snprintf(char *buf, size_t len, uint32_t type, + uint32_t flags, struct nftnl_expr *e) { struct nftnl_expr_payload *payload = nftnl_expr_data(e); @@ -278,7 +278,7 @@ nftnl_rule_expr_payload_snprintf(char *buf, size_t len, uint32_t type, payload->offset, payload->dreg); case NFTNL_OUTPUT_XML: case NFTNL_OUTPUT_JSON: - return nftnl_rule_expr_payload_export(buf, len, flags, e, type); + return nftnl_expr_payload_export(buf, len, flags, e, type); default: break; } @@ -289,11 +289,11 @@ struct expr_ops expr_ops_payload = { .name = "payload", .alloc_len = sizeof(struct nftnl_expr_payload), .max_attr = NFTA_PAYLOAD_MAX, - .set = nftnl_rule_expr_payload_set, - .get = nftnl_rule_expr_payload_get, - .parse = nftnl_rule_expr_payload_parse, - .build = nftnl_rule_expr_payload_build, - .snprintf = nftnl_rule_expr_payload_snprintf, - .xml_parse = nftnl_rule_expr_payload_xml_parse, - .json_parse = nftnl_rule_expr_payload_json_parse, + .set = nftnl_expr_payload_set, + .get = nftnl_expr_payload_get, + .parse = nftnl_expr_payload_parse, + .build = nftnl_expr_payload_build, + .snprintf = nftnl_expr_payload_snprintf, + .xml_parse = nftnl_expr_payload_xml_parse, + .json_parse = nftnl_expr_payload_json_parse, }; diff --git a/src/expr/queue.c b/src/expr/queue.c index e388968..21126ed 100644 --- a/src/expr/queue.c +++ b/src/expr/queue.c @@ -26,7 +26,7 @@ struct nftnl_expr_queue { uint16_t flags; }; -static int nftnl_rule_expr_queue_set(struct nftnl_rule_expr *e, uint16_t type, +static int nftnl_expr_queue_set(struct nftnl_expr *e, uint16_t type, const void *data, uint32_t data_len) { struct nftnl_expr_queue *queue = nftnl_expr_data(e); @@ -48,7 +48,7 @@ static int nftnl_rule_expr_queue_set(struct nftnl_rule_expr *e, uint16_t type, } static const void * -nftnl_rule_expr_queue_get(const struct nftnl_rule_expr *e, uint16_t type, +nftnl_expr_queue_get(const struct nftnl_expr *e, uint16_t type, uint32_t *data_len) { struct nftnl_expr_queue *queue = nftnl_expr_data(e); @@ -67,7 +67,7 @@ nftnl_rule_expr_queue_get(const struct nftnl_rule_expr *e, uint16_t type, return NULL; } -static int nftnl_rule_expr_queue_cb(const struct nlattr *attr, void *data) +static int nftnl_expr_queue_cb(const struct nlattr *attr, void *data) { const struct nlattr **tb = data; int type = mnl_attr_get_type(attr); @@ -89,7 +89,7 @@ static int nftnl_rule_expr_queue_cb(const struct nlattr *attr, void *data) } static void -nftnl_rule_expr_queue_build(struct nlmsghdr *nlh, struct nftnl_rule_expr *e) +nftnl_expr_queue_build(struct nlmsghdr *nlh, struct nftnl_expr *e) { struct nftnl_expr_queue *queue = nftnl_expr_data(e); @@ -102,12 +102,12 @@ nftnl_rule_expr_queue_build(struct nlmsghdr *nlh, struct nftnl_rule_expr *e) } static int -nftnl_rule_expr_queue_parse(struct nftnl_rule_expr *e, struct nlattr *attr) +nftnl_expr_queue_parse(struct nftnl_expr *e, struct nlattr *attr) { struct nftnl_expr_queue *queue = nftnl_expr_data(e); struct nlattr *tb[NFTA_QUEUE_MAX+1] = {}; - if (mnl_attr_parse_nested(attr, nftnl_rule_expr_queue_cb, tb) < 0) + if (mnl_attr_parse_nested(attr, nftnl_expr_queue_cb, tb) < 0) return -1; if (tb[NFTA_QUEUE_NUM]) { @@ -127,7 +127,7 @@ nftnl_rule_expr_queue_parse(struct nftnl_rule_expr *e, struct nlattr *attr) } static int -nftnl_rule_expr_queue_json_parse(struct nftnl_rule_expr *e, json_t *root, +nftnl_expr_queue_json_parse(struct nftnl_expr *e, json_t *root, struct nftnl_parse_err *err) { #ifdef JSON_PARSING @@ -135,14 +135,14 @@ nftnl_rule_expr_queue_json_parse(struct nftnl_rule_expr *e, json_t *root, uint16_t code; if (nftnl_jansson_parse_val(root, "num", NFTNL_TYPE_U16, &type, err) == 0) - nftnl_rule_expr_set_u16(e, NFTNL_EXPR_QUEUE_NUM, type); - nftnl_rule_expr_set_u16(e, NFTNL_EXPR_QUEUE_NUM, type); + nftnl_expr_set_u16(e, NFTNL_EXPR_QUEUE_NUM, type); + nftnl_expr_set_u16(e, NFTNL_EXPR_QUEUE_NUM, type); if (nftnl_jansson_parse_val(root, "total", NFTNL_TYPE_U16, &code, err) == 0) - nftnl_rule_expr_set_u16(e, NFTNL_EXPR_QUEUE_TOTAL, code); + nftnl_expr_set_u16(e, NFTNL_EXPR_QUEUE_TOTAL, code); if (nftnl_jansson_parse_val(root, "flags", NFTNL_TYPE_U16, &code, err) == 0) - nftnl_rule_expr_set_u16(e, NFTNL_EXPR_QUEUE_FLAGS, code); + nftnl_expr_set_u16(e, NFTNL_EXPR_QUEUE_FLAGS, code); return 0; #else @@ -152,7 +152,7 @@ nftnl_rule_expr_queue_json_parse(struct nftnl_rule_expr *e, json_t *root, } static int -nftnl_rule_expr_queue_xml_parse(struct nftnl_rule_expr *e, mxml_node_t *tree, +nftnl_expr_queue_xml_parse(struct nftnl_expr *e, mxml_node_t *tree, struct nftnl_parse_err *err) { #ifdef XML_PARSING @@ -161,17 +161,17 @@ nftnl_rule_expr_queue_xml_parse(struct nftnl_rule_expr *e, mxml_node_t *tree, if (nftnl_mxml_num_parse(tree, "num", MXML_DESCEND_FIRST, BASE_DEC, &queue_num, NFTNL_TYPE_U16, NFTNL_XML_MAND, err) == 0) - nftnl_rule_expr_set_u16(e, NFTNL_EXPR_QUEUE_NUM, queue_num); + nftnl_expr_set_u16(e, NFTNL_EXPR_QUEUE_NUM, queue_num); if (nftnl_mxml_num_parse(tree, "total", MXML_DESCEND_FIRST, BASE_DEC, &queue_total, NFTNL_TYPE_U16, NFTNL_XML_MAND, err) == 0) - nftnl_rule_expr_set_u16(e, NFTNL_EXPR_QUEUE_TOTAL, queue_total); + nftnl_expr_set_u16(e, NFTNL_EXPR_QUEUE_TOTAL, queue_total); if (nftnl_mxml_num_parse(tree, "flags", MXML_DESCEND_FIRST, BASE_DEC, &flags, NFTNL_TYPE_U16, NFTNL_XML_MAND, err) == 0) - nftnl_rule_expr_set_u16(e, NFTNL_EXPR_QUEUE_FLAGS, flags); + nftnl_expr_set_u16(e, NFTNL_EXPR_QUEUE_FLAGS, flags); return 0; #else @@ -180,8 +180,8 @@ nftnl_rule_expr_queue_xml_parse(struct nftnl_rule_expr *e, mxml_node_t *tree, #endif } -static int nftnl_rule_expr_queue_snprintf_default(char *buf, size_t len, - struct nftnl_rule_expr *e) +static int nftnl_expr_queue_snprintf_default(char *buf, size_t len, + struct nftnl_expr *e) { struct nftnl_expr_queue *queue = nftnl_expr_data(e); int ret, size = len, offset = 0; @@ -210,8 +210,8 @@ static int nftnl_rule_expr_queue_snprintf_default(char *buf, size_t len, return offset; } -static int nftnl_rule_expr_queue_export(char *buf, size_t size, - struct nftnl_rule_expr *e, int type) +static int nftnl_expr_queue_export(char *buf, size_t size, + struct nftnl_expr *e, int type) { struct nftnl_expr_queue *queue = nftnl_expr_data(e); NFTNL_BUF_INIT(b, buf, size); @@ -227,16 +227,16 @@ static int nftnl_rule_expr_queue_export(char *buf, size_t size, } static int -nftnl_rule_expr_queue_snprintf(char *buf, size_t len, uint32_t type, - uint32_t flags, struct nftnl_rule_expr *e) +nftnl_expr_queue_snprintf(char *buf, size_t len, uint32_t type, + uint32_t flags, struct nftnl_expr *e) { switch (type) { case NFTNL_OUTPUT_DEFAULT: - return nftnl_rule_expr_queue_snprintf_default(buf, len, e); + return nftnl_expr_queue_snprintf_default(buf, len, e); case NFTNL_OUTPUT_XML: case NFTNL_OUTPUT_JSON: - return nftnl_rule_expr_queue_export(buf, len, e, type); + return nftnl_expr_queue_export(buf, len, e, type); default: break; } @@ -247,11 +247,11 @@ struct expr_ops expr_ops_queue = { .name = "queue", .alloc_len = sizeof(struct nftnl_expr_queue), .max_attr = NFTA_QUEUE_MAX, - .set = nftnl_rule_expr_queue_set, - .get = nftnl_rule_expr_queue_get, - .parse = nftnl_rule_expr_queue_parse, - .build = nftnl_rule_expr_queue_build, - .snprintf = nftnl_rule_expr_queue_snprintf, - .xml_parse = nftnl_rule_expr_queue_xml_parse, - .json_parse = nftnl_rule_expr_queue_json_parse, + .set = nftnl_expr_queue_set, + .get = nftnl_expr_queue_get, + .parse = nftnl_expr_queue_parse, + .build = nftnl_expr_queue_build, + .snprintf = nftnl_expr_queue_snprintf, + .xml_parse = nftnl_expr_queue_xml_parse, + .json_parse = nftnl_expr_queue_json_parse, }; diff --git a/src/expr/redir.c b/src/expr/redir.c index d73730d..b8fb1fe 100644 --- a/src/expr/redir.c +++ b/src/expr/redir.c @@ -27,7 +27,7 @@ struct nftnl_expr_redir { }; static int -nftnl_rule_expr_redir_set(struct nftnl_rule_expr *e, uint16_t type, +nftnl_expr_redir_set(struct nftnl_expr *e, uint16_t type, const void *data, uint32_t data_len) { struct nftnl_expr_redir *redir = nftnl_expr_data(e); @@ -49,7 +49,7 @@ nftnl_rule_expr_redir_set(struct nftnl_rule_expr *e, uint16_t type, } static const void * -nftnl_rule_expr_redir_get(const struct nftnl_rule_expr *e, uint16_t type, +nftnl_expr_redir_get(const struct nftnl_expr *e, uint16_t type, uint32_t *data_len) { struct nftnl_expr_redir *redir = nftnl_expr_data(e); @@ -68,7 +68,7 @@ nftnl_rule_expr_redir_get(const struct nftnl_rule_expr *e, uint16_t type, return NULL; } -static int nftnl_rule_expr_redir_cb(const struct nlattr *attr, void *data) +static int nftnl_expr_redir_cb(const struct nlattr *attr, void *data) { const struct nlattr **tb = data; int type = mnl_attr_get_type(attr); @@ -90,7 +90,7 @@ static int nftnl_rule_expr_redir_cb(const struct nlattr *attr, void *data) } static void -nftnl_rule_expr_redir_build(struct nlmsghdr *nlh, struct nftnl_rule_expr *e) +nftnl_expr_redir_build(struct nlmsghdr *nlh, struct nftnl_expr *e) { struct nftnl_expr_redir *redir = nftnl_expr_data(e); @@ -105,12 +105,12 @@ nftnl_rule_expr_redir_build(struct nlmsghdr *nlh, struct nftnl_rule_expr *e) } static int -nftnl_rule_expr_redir_parse(struct nftnl_rule_expr *e, struct nlattr *attr) +nftnl_expr_redir_parse(struct nftnl_expr *e, struct nlattr *attr) { struct nftnl_expr_redir *redir = nftnl_expr_data(e); struct nlattr *tb[NFTA_REDIR_MAX + 1] = {}; - if (mnl_attr_parse_nested(attr, nftnl_rule_expr_redir_cb, tb) < 0) + if (mnl_attr_parse_nested(attr, nftnl_expr_redir_cb, tb) < 0) return -1; if (tb[NFTA_REDIR_REG_PROTO_MIN]) { @@ -132,7 +132,7 @@ nftnl_rule_expr_redir_parse(struct nftnl_rule_expr *e, struct nlattr *attr) } static int -nftnl_rule_expr_redir_json_parse(struct nftnl_rule_expr *e, json_t *root, +nftnl_expr_redir_json_parse(struct nftnl_expr *e, json_t *root, struct nftnl_parse_err *err) { #ifdef JSON_PARSING @@ -140,15 +140,15 @@ nftnl_rule_expr_redir_json_parse(struct nftnl_rule_expr *e, json_t *root, if (nftnl_jansson_parse_reg(root, "sreg_proto_min", NFTNL_TYPE_U32, ®, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_REDIR_REG_PROTO_MIN, reg); + nftnl_expr_set_u32(e, NFTNL_EXPR_REDIR_REG_PROTO_MIN, reg); if (nftnl_jansson_parse_reg(root, "sreg_proto_max", NFTNL_TYPE_U32, ®, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_REDIR_REG_PROTO_MAX, reg); + nftnl_expr_set_u32(e, NFTNL_EXPR_REDIR_REG_PROTO_MAX, reg); if (nftnl_jansson_parse_val(root, "flags", NFTNL_TYPE_U32, &flags, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_REDIR_FLAGS, flags); + nftnl_expr_set_u32(e, NFTNL_EXPR_REDIR_FLAGS, flags); return 0; #else @@ -158,7 +158,7 @@ nftnl_rule_expr_redir_json_parse(struct nftnl_rule_expr *e, json_t *root, } static int -nftnl_rule_expr_redir_xml_parse(struct nftnl_rule_expr *e, mxml_node_t *tree, +nftnl_expr_redir_xml_parse(struct nftnl_expr *e, mxml_node_t *tree, struct nftnl_parse_err *err) { #ifdef XML_PARSING @@ -166,15 +166,15 @@ nftnl_rule_expr_redir_xml_parse(struct nftnl_rule_expr *e, mxml_node_t *tree, if (nftnl_mxml_reg_parse(tree, "sreg_proto_min", ®, MXML_DESCEND, NFTNL_XML_OPT, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_REDIR_REG_PROTO_MIN, reg); + nftnl_expr_set_u32(e, NFTNL_EXPR_REDIR_REG_PROTO_MIN, reg); if (nftnl_mxml_reg_parse(tree, "sreg_proto_max", ®, MXML_DESCEND, NFTNL_XML_OPT, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_REDIR_REG_PROTO_MAX, reg); + nftnl_expr_set_u32(e, NFTNL_EXPR_REDIR_REG_PROTO_MAX, reg); if (nftnl_mxml_num_parse(tree, "flags", MXML_DESCEND_FIRST, BASE_DEC, &flags, NFTNL_TYPE_U32, NFTNL_XML_OPT, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_REDIR_FLAGS, flags); + nftnl_expr_set_u32(e, NFTNL_EXPR_REDIR_FLAGS, flags); return 0; #else @@ -183,8 +183,8 @@ nftnl_rule_expr_redir_xml_parse(struct nftnl_rule_expr *e, mxml_node_t *tree, #endif } -static int nftnl_rule_expr_redir_export(char *buf, size_t size, - struct nftnl_rule_expr *e, int type) +static int nftnl_expr_redir_export(char *buf, size_t size, + struct nftnl_expr *e, int type) { struct nftnl_expr_redir *redir = nftnl_expr_data(e); NFTNL_BUF_INIT(b, buf, size); @@ -199,25 +199,25 @@ static int nftnl_rule_expr_redir_export(char *buf, size_t size, return nftnl_buf_done(&b); } -static int nftnl_rule_expr_redir_snprintf_default(char *buf, size_t len, - struct nftnl_rule_expr *e) +static int nftnl_expr_redir_snprintf_default(char *buf, size_t len, + struct nftnl_expr *e) { int ret, size = len, offset = 0; struct nftnl_expr_redir *redir = nftnl_expr_data(e); - if (nftnl_rule_expr_is_set(e, NFTNL_EXPR_REDIR_REG_PROTO_MIN)) { + if (nftnl_expr_is_set(e, NFTNL_EXPR_REDIR_REG_PROTO_MIN)) { ret = snprintf(buf + offset, len, "proto_min reg %u ", redir->sreg_proto_min); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); } - if (nftnl_rule_expr_is_set(e, NFTNL_EXPR_REDIR_REG_PROTO_MAX)) { + if (nftnl_expr_is_set(e, NFTNL_EXPR_REDIR_REG_PROTO_MAX)) { ret = snprintf(buf + offset, len, "proto_max reg %u ", redir->sreg_proto_max); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); } - if (nftnl_rule_expr_is_set(e, NFTNL_EXPR_REDIR_FLAGS)) { + if (nftnl_expr_is_set(e, NFTNL_EXPR_REDIR_FLAGS)) { ret = snprintf(buf + offset , len, "flags 0x%x ", redir->flags); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); @@ -227,15 +227,15 @@ static int nftnl_rule_expr_redir_snprintf_default(char *buf, size_t len, } static int -nftnl_rule_expr_redir_snprintf(char *buf, size_t len, uint32_t type, - uint32_t flags, struct nftnl_rule_expr *e) +nftnl_expr_redir_snprintf(char *buf, size_t len, uint32_t type, + uint32_t flags, struct nftnl_expr *e) { switch (type) { case NFTNL_OUTPUT_DEFAULT: - return nftnl_rule_expr_redir_snprintf_default(buf, len, e); + return nftnl_expr_redir_snprintf_default(buf, len, e); case NFTNL_OUTPUT_XML: case NFTNL_OUTPUT_JSON: - return nftnl_rule_expr_redir_export(buf, len, e, type); + return nftnl_expr_redir_export(buf, len, e, type); default: break; } @@ -246,11 +246,11 @@ struct expr_ops expr_ops_redir = { .name = "redir", .alloc_len = sizeof(struct nftnl_expr_redir), .max_attr = NFTA_REDIR_MAX, - .set = nftnl_rule_expr_redir_set, - .get = nftnl_rule_expr_redir_get, - .parse = nftnl_rule_expr_redir_parse, - .build = nftnl_rule_expr_redir_build, - .snprintf = nftnl_rule_expr_redir_snprintf, - .xml_parse = nftnl_rule_expr_redir_xml_parse, - .json_parse = nftnl_rule_expr_redir_json_parse, + .set = nftnl_expr_redir_set, + .get = nftnl_expr_redir_get, + .parse = nftnl_expr_redir_parse, + .build = nftnl_expr_redir_build, + .snprintf = nftnl_expr_redir_snprintf, + .xml_parse = nftnl_expr_redir_xml_parse, + .json_parse = nftnl_expr_redir_json_parse, }; diff --git a/src/expr/reject.c b/src/expr/reject.c index e0bfc71..979817a 100644 --- a/src/expr/reject.c +++ b/src/expr/reject.c @@ -26,7 +26,7 @@ struct nftnl_expr_reject { uint8_t icmp_code; }; -static int nftnl_rule_expr_reject_set(struct nftnl_rule_expr *e, uint16_t type, +static int nftnl_expr_reject_set(struct nftnl_expr *e, uint16_t type, const void *data, uint32_t data_len) { struct nftnl_expr_reject *reject = nftnl_expr_data(e); @@ -45,7 +45,7 @@ static int nftnl_rule_expr_reject_set(struct nftnl_rule_expr *e, uint16_t type, } static const void * -nftnl_rule_expr_reject_get(const struct nftnl_rule_expr *e, uint16_t type, +nftnl_expr_reject_get(const struct nftnl_expr *e, uint16_t type, uint32_t *data_len) { struct nftnl_expr_reject *reject = nftnl_expr_data(e); @@ -61,7 +61,7 @@ nftnl_rule_expr_reject_get(const struct nftnl_rule_expr *e, uint16_t type, return NULL; } -static int nftnl_rule_expr_reject_cb(const struct nlattr *attr, void *data) +static int nftnl_expr_reject_cb(const struct nlattr *attr, void *data) { const struct nlattr **tb = data; int type = mnl_attr_get_type(attr); @@ -85,7 +85,7 @@ static int nftnl_rule_expr_reject_cb(const struct nlattr *attr, void *data) } static void -nftnl_rule_expr_reject_build(struct nlmsghdr *nlh, struct nftnl_rule_expr *e) +nftnl_expr_reject_build(struct nlmsghdr *nlh, struct nftnl_expr *e) { struct nftnl_expr_reject *reject = nftnl_expr_data(e); @@ -96,12 +96,12 @@ nftnl_rule_expr_reject_build(struct nlmsghdr *nlh, struct nftnl_rule_expr *e) } static int -nftnl_rule_expr_reject_parse(struct nftnl_rule_expr *e, struct nlattr *attr) +nftnl_expr_reject_parse(struct nftnl_expr *e, struct nlattr *attr) { struct nftnl_expr_reject *reject = nftnl_expr_data(e); struct nlattr *tb[NFTA_REJECT_MAX+1] = {}; - if (mnl_attr_parse_nested(attr, nftnl_rule_expr_reject_cb, tb) < 0) + if (mnl_attr_parse_nested(attr, nftnl_expr_reject_cb, tb) < 0) return -1; if (tb[NFTA_REJECT_TYPE]) { @@ -117,7 +117,7 @@ nftnl_rule_expr_reject_parse(struct nftnl_rule_expr *e, struct nlattr *attr) } static int -nftnl_rule_expr_reject_json_parse(struct nftnl_rule_expr *e, json_t *root, +nftnl_expr_reject_json_parse(struct nftnl_expr *e, json_t *root, struct nftnl_parse_err *err) { #ifdef JSON_PARSING @@ -125,10 +125,10 @@ nftnl_rule_expr_reject_json_parse(struct nftnl_rule_expr *e, json_t *root, uint8_t code; if (nftnl_jansson_parse_val(root, "type", NFTNL_TYPE_U32, &type, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_REJECT_TYPE, type); + nftnl_expr_set_u32(e, NFTNL_EXPR_REJECT_TYPE, type); if (nftnl_jansson_parse_val(root, "code", NFTNL_TYPE_U8, &code, err) == 0) - nftnl_rule_expr_set_u8(e, NFTNL_EXPR_REJECT_CODE, code); + nftnl_expr_set_u8(e, NFTNL_EXPR_REJECT_CODE, code); return 0; #else @@ -138,7 +138,7 @@ nftnl_rule_expr_reject_json_parse(struct nftnl_rule_expr *e, json_t *root, } static int -nftnl_rule_expr_reject_xml_parse(struct nftnl_rule_expr *e, mxml_node_t *tree, +nftnl_expr_reject_xml_parse(struct nftnl_expr *e, mxml_node_t *tree, struct nftnl_parse_err *err) { #ifdef XML_PARSING @@ -147,11 +147,11 @@ nftnl_rule_expr_reject_xml_parse(struct nftnl_rule_expr *e, mxml_node_t *tree, if (nftnl_mxml_num_parse(tree, "type", MXML_DESCEND_FIRST, BASE_DEC, &type, NFTNL_TYPE_U32, NFTNL_XML_MAND, err) == 0) - nftnl_rule_expr_set_u32(e, NFTNL_EXPR_REJECT_TYPE, type); + nftnl_expr_set_u32(e, NFTNL_EXPR_REJECT_TYPE, type); if (nftnl_mxml_num_parse(tree, "code", MXML_DESCEND_FIRST, BASE_DEC, &code, NFTNL_TYPE_U8, NFTNL_XML_MAND, err) == 0) - nftnl_rule_expr_set_u8(e, NFTNL_EXPR_REJECT_CODE, code); + nftnl_expr_set_u8(e, NFTNL_EXPR_REJECT_CODE, code); return 0; #else @@ -160,8 +160,8 @@ nftnl_rule_expr_reject_xml_parse(struct nftnl_rule_expr *e, mxml_node_t *tree, #endif } -static int nftnl_rule_expr_reject_snprintf_default(char *buf, size_t len, - struct nftnl_rule_expr *e) +static int nftnl_expr_reject_snprintf_default(char *buf, size_t len, + struct nftnl_expr *e) { struct nftnl_expr_reject *reject = nftnl_expr_data(e); @@ -169,8 +169,8 @@ static int nftnl_rule_expr_reject_snprintf_default(char *buf, size_t len, reject->type, reject->icmp_code); } -static int nftnl_rule_expr_reject_export(char *buf, size_t size, - struct nftnl_rule_expr *e, int type) +static int nftnl_expr_reject_export(char *buf, size_t size, + struct nftnl_expr *e, int type) { struct nftnl_expr_reject *reject = nftnl_expr_data(e); NFTNL_BUF_INIT(b, buf, size); @@ -184,15 +184,15 @@ static int nftnl_rule_expr_reject_export(char *buf, size_t size, } static int -nftnl_rule_expr_reject_snprintf(char *buf, size_t len, uint32_t type, - uint32_t flags, struct nftnl_rule_expr *e) +nftnl_expr_reject_snprintf(char *buf, size_t len, uint32_t type, + uint32_t flags, struct nftnl_expr *e) { switch (type) { case NFTNL_OUTPUT_DEFAULT: - return nftnl_rule_expr_reject_snprintf_default(buf, len, e); + return nftnl_expr_reject_snprintf_default(buf, len, e); case NFTNL_OUTPUT_XML: case NFTNL_OUTPUT_JSON: - return nftnl_rule_expr_reject_export(buf, len, e, type); + return nftnl_expr_reject_export(buf, len, e, type); default: break; } @@ -203,11 +203,11 @@ struct expr_ops expr_ops_reject = { .name = "reject", .alloc_len = sizeof(struct nftnl_expr_reject), .max_attr = NFTA_REJECT_MAX, - .set = nftnl_rule_expr_reject_set, - .get = nftnl_rule_expr_reject_get, - .parse = nftnl_rule_expr_reject_parse, - .build = nftnl_rule_expr_reject_build, - .snprintf = nftnl_rule_expr_reject_snprintf, - .xml_parse = nftnl_rule_expr_reject_xml_parse, - .json_parse = nftnl_rule_expr_reject_json_parse, + .set = nftnl_expr_reject_set, + .get = nftnl_expr_reject_get, + .parse = nftnl_expr_reject_parse, + .build = nftnl_expr_reject_build, + .snprintf = nftnl_expr_reject_snprintf, + .xml_parse = nftnl_expr_reject_xml_parse, + .json_parse = nftnl_expr_reject_json_parse, }; diff --git a/src/expr/target.c b/src/expr/target.c index 57d03ea..cbbee60 100644 --- a/src/expr/target.c +++ b/src/expr/target.c @@ -35,7 +35,7 @@ struct nftnl_expr_target { }; static int -nftnl_rule_expr_target_set(struct nftnl_rule_expr *e, uint16_t type, +nftnl_expr_target_set(struct nftnl_expr *e, uint16_t type, const void *data, uint32_t data_len) { struct nftnl_expr_target *tg = nftnl_expr_data(e); @@ -62,7 +62,7 @@ nftnl_rule_expr_target_set(struct nftnl_rule_expr *e, uint16_t type, } static const void * -nftnl_rule_expr_target_get(const struct nftnl_rule_expr *e, uint16_t type, +nftnl_expr_target_get(const struct nftnl_expr *e, uint16_t type, uint32_t *data_len) { struct nftnl_expr_target *tg = nftnl_expr_data(e); @@ -81,7 +81,7 @@ nftnl_rule_expr_target_get(const struct nftnl_rule_expr *e, uint16_t type, return NULL; } -static int nftnl_rule_expr_target_cb(const struct nlattr *attr, void *data) +static int nftnl_expr_target_cb(const struct nlattr *attr, void *data) { const struct nlattr **tb = data; int type = mnl_attr_get_type(attr); @@ -109,7 +109,7 @@ static int nftnl_rule_expr_target_cb(const struct nlattr *attr, void *data) } static void -nftnl_rule_expr_target_build(struct nlmsghdr *nlh, struct nftnl_rule_expr *e) +nftnl_expr_target_build(struct nlmsghdr *nlh, struct nftnl_expr *e) { struct nftnl_expr_target *tg = nftnl_expr_data(e); @@ -121,12 +121,12 @@ nftnl_rule_expr_target_build(struct nlmsghdr *nlh, struct nftnl_rule_expr *e) mnl_attr_put(nlh, NFTA_TARGET_INFO, tg->data_len, tg->data); } -static int nftnl_rule_expr_target_parse(struct nftnl_rule_expr *e, struct nlattr *attr) +static int nftnl_expr_target_parse(struct nftnl_expr *e, struct nlattr *attr) { struct nftnl_expr_target *target = nftnl_expr_data(e); struct nlattr *tb[NFTA_TARGET_MAX+1] = {}; - if (mnl_attr_parse_nested(attr, nftnl_rule_expr_target_cb, tb) < 0) + if (mnl_attr_parse_nested(attr, nftnl_expr_target_cb, tb) < 0) return -1; if (tb[NFTA_TARGET_NAME]) { @@ -165,7 +165,7 @@ static int nftnl_rule_expr_target_parse(struct nftnl_rule_expr *e, struct nlattr } static int -nftnl_rule_expr_target_json_parse(struct nftnl_rule_expr *e, json_t *root, +nftnl_expr_target_json_parse(struct nftnl_expr *e, json_t *root, struct nftnl_parse_err *err) { #ifdef JSON_PARSING @@ -173,7 +173,7 @@ nftnl_rule_expr_target_json_parse(struct nftnl_rule_expr *e, json_t *root, name = nftnl_jansson_parse_str(root, "name", err); if (name != NULL) - nftnl_rule_expr_set_str(e, NFTNL_EXPR_TG_NAME, name); + nftnl_expr_set_str(e, NFTNL_EXPR_TG_NAME, name); return 0; #else @@ -183,7 +183,7 @@ nftnl_rule_expr_target_json_parse(struct nftnl_rule_expr *e, json_t *root, } static int -nftnl_rule_expr_target_xml_parse(struct nftnl_rule_expr *e, mxml_node_t *tree, +nftnl_expr_target_xml_parse(struct nftnl_expr *e, mxml_node_t *tree, struct nftnl_parse_err *err) { #ifdef XML_PARSING @@ -192,7 +192,7 @@ nftnl_rule_expr_target_xml_parse(struct nftnl_rule_expr *e, mxml_node_t *tree, name = nftnl_mxml_str_parse(tree, "name", MXML_DESCEND_FIRST, NFTNL_XML_MAND, err); if (name != NULL) - nftnl_rule_expr_set_str(e, NFTNL_EXPR_TG_NAME, name); + nftnl_expr_set_str(e, NFTNL_EXPR_TG_NAME, name); /* tg->info is ignored until other solution is reached */ @@ -204,7 +204,7 @@ nftnl_rule_expr_target_xml_parse(struct nftnl_rule_expr *e, mxml_node_t *tree, } static int nftnl_rule_exp_target_export(char *buf, size_t size, - struct nftnl_rule_expr *e, int type) + struct nftnl_expr *e, int type) { struct nftnl_expr_target *target = nftnl_expr_data(e); NFTNL_BUF_INIT(b, buf, size); @@ -216,8 +216,8 @@ static int nftnl_rule_exp_target_export(char *buf, size_t size, } static int -nftnl_rule_expr_target_snprintf(char *buf, size_t len, uint32_t type, - uint32_t flags, struct nftnl_rule_expr *e) +nftnl_expr_target_snprintf(char *buf, size_t len, uint32_t type, + uint32_t flags, struct nftnl_expr *e) { struct nftnl_expr_target *target = nftnl_expr_data(e); @@ -234,7 +234,7 @@ nftnl_rule_expr_target_snprintf(char *buf, size_t len, uint32_t type, return -1; } -static void nftnl_rule_expr_target_free(struct nftnl_rule_expr *e) +static void nftnl_expr_target_free(struct nftnl_expr *e) { struct nftnl_expr_target *target = nftnl_expr_data(e); @@ -245,12 +245,12 @@ struct expr_ops expr_ops_target = { .name = "target", .alloc_len = sizeof(struct nftnl_expr_target), .max_attr = NFTA_TARGET_MAX, - .free = nftnl_rule_expr_target_free, - .set = nftnl_rule_expr_target_set, - .get = nftnl_rule_expr_target_get, - .parse = nftnl_rule_expr_target_parse, - .build = nftnl_rule_expr_target_build, - .snprintf = nftnl_rule_expr_target_snprintf, - .xml_parse = nftnl_rule_expr_target_xml_parse, - .json_parse = nftnl_rule_expr_target_json_parse, + .free = nftnl_expr_target_free, + .set = nftnl_expr_target_set, + .get = nftnl_expr_target_get, + .parse = nftnl_expr_target_parse, + .build = nftnl_expr_target_build, + .snprintf = nftnl_expr_target_snprintf, + .xml_parse = nftnl_expr_target_xml_parse, + .json_parse = nftnl_expr_target_json_parse, }; -- cgit v1.2.3