summaryrefslogtreecommitdiffstats
path: root/src/table.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/table.c')
-rw-r--r--src/table.c316
1 files changed, 158 insertions, 158 deletions
diff --git a/src/table.c b/src/table.c
index 543ea8d..4adfba8 100644
--- a/src/table.c
+++ b/src/table.c
@@ -26,7 +26,7 @@
#include <libnftnl/table.h>
#include <buffer.h>
-struct nft_table {
+struct nftnl_table {
struct list_head head;
const char *name;
@@ -36,76 +36,76 @@ struct nft_table {
uint32_t flags;
};
-struct nft_table *nft_table_alloc(void)
+struct nftnl_table *nftnl_table_alloc(void)
{
- return calloc(1, sizeof(struct nft_table));
+ return calloc(1, sizeof(struct nftnl_table));
}
EXPORT_SYMBOL(nftnl_table_alloc, nft_table_alloc);
-void nft_table_free(struct nft_table *t)
+void nftnl_table_free(struct nftnl_table *t)
{
- if (t->flags & (1 << NFT_TABLE_ATTR_NAME))
+ if (t->flags & (1 << NFTNL_TABLE_ATTR_NAME))
xfree(t->name);
xfree(t);
}
EXPORT_SYMBOL(nftnl_table_free, nft_table_free);
-bool nft_table_attr_is_set(const struct nft_table *t, uint16_t attr)
+bool nftnl_table_attr_is_set(const struct nftnl_table *t, uint16_t attr)
{
return t->flags & (1 << attr);
}
EXPORT_SYMBOL(nftnl_table_attr_is_set, nft_table_attr_is_set);
-void nft_table_attr_unset(struct nft_table *t, uint16_t attr)
+void nftnl_table_attr_unset(struct nftnl_table *t, uint16_t attr)
{
if (!(t->flags & (1 << attr)))
return;
switch (attr) {
- case NFT_TABLE_ATTR_NAME:
+ case NFTNL_TABLE_ATTR_NAME:
if (t->name) {
xfree(t->name);
t->name = NULL;
}
break;
- case NFT_TABLE_ATTR_FLAGS:
- case NFT_TABLE_ATTR_FAMILY:
+ case NFTNL_TABLE_ATTR_FLAGS:
+ case NFTNL_TABLE_ATTR_FAMILY:
break;
- case NFT_TABLE_ATTR_USE:
+ case NFTNL_TABLE_ATTR_USE:
break;
}
t->flags &= ~(1 << attr);
}
EXPORT_SYMBOL(nftnl_table_attr_unset, nft_table_attr_unset);
-static uint32_t nft_table_attr_validate[NFT_TABLE_ATTR_MAX + 1] = {
- [NFT_TABLE_ATTR_FLAGS] = sizeof(uint32_t),
- [NFT_TABLE_ATTR_FAMILY] = sizeof(uint32_t),
+static uint32_t nftnl_table_attr_validate[NFTNL_TABLE_ATTR_MAX + 1] = {
+ [NFTNL_TABLE_ATTR_FLAGS] = sizeof(uint32_t),
+ [NFTNL_TABLE_ATTR_FAMILY] = sizeof(uint32_t),
};
-void nft_table_attr_set_data(struct nft_table *t, uint16_t attr,
+void nftnl_table_attr_set_data(struct nftnl_table *t, uint16_t attr,
const void *data, uint32_t data_len)
{
- if (attr > NFT_TABLE_ATTR_MAX)
+ if (attr > NFTNL_TABLE_ATTR_MAX)
return;
- nft_assert_validate(data, nft_table_attr_validate, attr, data_len);
+ nftnl_assert_validate(data, nftnl_table_attr_validate, attr, data_len);
switch (attr) {
- case NFT_TABLE_ATTR_NAME:
+ case NFTNL_TABLE_ATTR_NAME:
if (t->name)
xfree(t->name);
t->name = strdup(data);
break;
- case NFT_TABLE_ATTR_FLAGS:
+ case NFTNL_TABLE_ATTR_FLAGS:
t->table_flags = *((uint32_t *)data);
break;
- case NFT_TABLE_ATTR_FAMILY:
+ case NFTNL_TABLE_ATTR_FAMILY:
t->family = *((uint32_t *)data);
break;
- case NFT_TABLE_ATTR_USE:
+ case NFTNL_TABLE_ATTR_USE:
t->use = *((uint32_t *)data);
break;
}
@@ -113,46 +113,46 @@ void nft_table_attr_set_data(struct nft_table *t, uint16_t attr,
}
EXPORT_SYMBOL(nftnl_table_attr_set_data, nft_table_attr_set_data);
-void nft_table_attr_set(struct nft_table *t, uint16_t attr, const void *data)
+void nftnl_table_attr_set(struct nftnl_table *t, uint16_t attr, const void *data)
{
- nft_table_attr_set_data(t, attr, data, nft_table_attr_validate[attr]);
+ nftnl_table_attr_set_data(t, attr, data, nftnl_table_attr_validate[attr]);
}
EXPORT_SYMBOL(nftnl_table_attr_set, nft_table_attr_set);
-void nft_table_attr_set_u32(struct nft_table *t, uint16_t attr, uint32_t val)
+void nftnl_table_attr_set_u32(struct nftnl_table *t, uint16_t attr, uint32_t val)
{
- nft_table_attr_set_data(t, attr, &val, sizeof(uint32_t));
+ nftnl_table_attr_set_data(t, attr, &val, sizeof(uint32_t));
}
EXPORT_SYMBOL(nftnl_table_attr_set_u32, nft_table_attr_set_u32);
-void nft_table_attr_set_u8(struct nft_table *t, uint16_t attr, uint8_t val)
+void nftnl_table_attr_set_u8(struct nftnl_table *t, uint16_t attr, uint8_t val)
{
- nft_table_attr_set_data(t, attr, &val, sizeof(uint8_t));
+ nftnl_table_attr_set_data(t, attr, &val, sizeof(uint8_t));
}
EXPORT_SYMBOL(nftnl_table_attr_set_u8, nft_table_attr_set_u8);
-void nft_table_attr_set_str(struct nft_table *t, uint16_t attr, const char *str)
+void nftnl_table_attr_set_str(struct nftnl_table *t, uint16_t attr, const char *str)
{
- nft_table_attr_set_data(t, attr, str, 0);
+ nftnl_table_attr_set_data(t, attr, str, 0);
}
EXPORT_SYMBOL(nftnl_table_attr_set_str, nft_table_attr_set_str);
-const void *nft_table_attr_get_data(struct nft_table *t, uint16_t attr,
+const void *nftnl_table_attr_get_data(struct nftnl_table *t, uint16_t attr,
uint32_t *data_len)
{
if (!(t->flags & (1 << attr)))
return NULL;
switch(attr) {
- case NFT_TABLE_ATTR_NAME:
+ case NFTNL_TABLE_ATTR_NAME:
return t->name;
- case NFT_TABLE_ATTR_FLAGS:
+ case NFTNL_TABLE_ATTR_FLAGS:
*data_len = sizeof(uint32_t);
return &t->table_flags;
- case NFT_TABLE_ATTR_FAMILY:
+ case NFTNL_TABLE_ATTR_FAMILY:
*data_len = sizeof(uint32_t);
return &t->family;
- case NFT_TABLE_ATTR_USE:
+ case NFTNL_TABLE_ATTR_USE:
*data_len = sizeof(uint32_t);
return &t->use;
}
@@ -160,43 +160,43 @@ const void *nft_table_attr_get_data(struct nft_table *t, uint16_t attr,
}
EXPORT_SYMBOL(nftnl_table_attr_get_data, nft_table_attr_get_data);
-const void *nft_table_attr_get(struct nft_table *t, uint16_t attr)
+const void *nftnl_table_attr_get(struct nftnl_table *t, uint16_t attr)
{
uint32_t data_len;
- return nft_table_attr_get_data(t, attr, &data_len);
+ return nftnl_table_attr_get_data(t, attr, &data_len);
}
EXPORT_SYMBOL(nftnl_table_attr_get, nft_table_attr_get);
-uint32_t nft_table_attr_get_u32(struct nft_table *t, uint16_t attr)
+uint32_t nftnl_table_attr_get_u32(struct nftnl_table *t, uint16_t attr)
{
- const void *ret = nft_table_attr_get(t, attr);
+ const void *ret = nftnl_table_attr_get(t, attr);
return ret == NULL ? 0 : *((uint32_t *)ret);
}
EXPORT_SYMBOL(nftnl_table_attr_get_u32, nft_table_attr_get_u32);
-uint8_t nft_table_attr_get_u8(struct nft_table *t, uint16_t attr)
+uint8_t nftnl_table_attr_get_u8(struct nftnl_table *t, uint16_t attr)
{
- const void *ret = nft_table_attr_get(t, attr);
+ const void *ret = nftnl_table_attr_get(t, attr);
return ret == NULL ? 0 : *((uint8_t *)ret);
}
EXPORT_SYMBOL(nftnl_table_attr_get_u8, nft_table_attr_get_u8);
-const char *nft_table_attr_get_str(struct nft_table *t, uint16_t attr)
+const char *nftnl_table_attr_get_str(struct nftnl_table *t, uint16_t attr)
{
- return nft_table_attr_get(t, attr);
+ return nftnl_table_attr_get(t, attr);
}
EXPORT_SYMBOL(nftnl_table_attr_get_str, nft_table_attr_get_str);
-void nft_table_nlmsg_build_payload(struct nlmsghdr *nlh, const struct nft_table *t)
+void nftnl_table_nlmsg_build_payload(struct nlmsghdr *nlh, const struct nftnl_table *t)
{
- if (t->flags & (1 << NFT_TABLE_ATTR_NAME))
+ if (t->flags & (1 << NFTNL_TABLE_ATTR_NAME))
mnl_attr_put_strz(nlh, NFTA_TABLE_NAME, t->name);
- if (t->flags & (1 << NFT_TABLE_ATTR_FLAGS))
+ if (t->flags & (1 << NFTNL_TABLE_ATTR_FLAGS))
mnl_attr_put_u32(nlh, NFTA_TABLE_FLAGS, htonl(t->table_flags));
}
EXPORT_SYMBOL(nftnl_table_nlmsg_build_payload, nft_table_nlmsg_build_payload);
-static int nft_table_parse_attr_cb(const struct nlattr *attr, void *data)
+static int nftnl_table_parse_attr_cb(const struct nlattr *attr, void *data)
{
const struct nlattr **tb = data;
int type = mnl_attr_get_type(attr);
@@ -220,76 +220,76 @@ static int nft_table_parse_attr_cb(const struct nlattr *attr, void *data)
return MNL_CB_OK;
}
-int nft_table_nlmsg_parse(const struct nlmsghdr *nlh, struct nft_table *t)
+int nftnl_table_nlmsg_parse(const struct nlmsghdr *nlh, struct nftnl_table *t)
{
struct nlattr *tb[NFTA_TABLE_MAX+1] = {};
struct nfgenmsg *nfg = mnl_nlmsg_get_payload(nlh);
- if (mnl_attr_parse(nlh, sizeof(*nfg), nft_table_parse_attr_cb, tb) < 0)
+ if (mnl_attr_parse(nlh, sizeof(*nfg), nftnl_table_parse_attr_cb, tb) < 0)
return -1;
if (tb[NFTA_TABLE_NAME]) {
xfree(t->name);
t->name = strdup(mnl_attr_get_str(tb[NFTA_TABLE_NAME]));
- t->flags |= (1 << NFT_TABLE_ATTR_NAME);
+ t->flags |= (1 << NFTNL_TABLE_ATTR_NAME);
}
if (tb[NFTA_TABLE_FLAGS]) {
t->table_flags = ntohl(mnl_attr_get_u32(tb[NFTA_TABLE_FLAGS]));
- t->flags |= (1 << NFT_TABLE_ATTR_FLAGS);
+ t->flags |= (1 << NFTNL_TABLE_ATTR_FLAGS);
}
if (tb[NFTA_TABLE_USE]) {
t->use = ntohl(mnl_attr_get_u32(tb[NFTA_TABLE_USE]));
- t->flags |= (1 << NFT_TABLE_ATTR_USE);
+ t->flags |= (1 << NFTNL_TABLE_ATTR_USE);
}
t->family = nfg->nfgen_family;
- t->flags |= (1 << NFT_TABLE_ATTR_FAMILY);
+ t->flags |= (1 << NFTNL_TABLE_ATTR_FAMILY);
return 0;
}
EXPORT_SYMBOL(nftnl_table_nlmsg_parse, nft_table_nlmsg_parse);
#ifdef XML_PARSING
-int nft_mxml_table_parse(mxml_node_t *tree, struct nft_table *t,
- struct nft_parse_err *err)
+int nftnl_mxml_table_parse(mxml_node_t *tree, struct nftnl_table *t,
+ struct nftnl_parse_err *err)
{
const char *name;
int family;
uint32_t flags, use;
- name = nft_mxml_str_parse(tree, "name", MXML_DESCEND_FIRST,
- NFT_XML_MAND, err);
+ name = nftnl_mxml_str_parse(tree, "name", MXML_DESCEND_FIRST,
+ NFTNL_XML_MAND, err);
if (name != NULL)
- nft_table_attr_set_str(t, NFT_TABLE_ATTR_NAME, name);
+ nftnl_table_attr_set_str(t, NFTNL_TABLE_ATTR_NAME, name);
- family = nft_mxml_family_parse(tree, "family", MXML_DESCEND_FIRST,
- NFT_XML_MAND, err);
+ family = nftnl_mxml_family_parse(tree, "family", MXML_DESCEND_FIRST,
+ NFTNL_XML_MAND, err);
if (family >= 0)
- nft_table_attr_set_u32(t, NFT_TABLE_ATTR_FAMILY, family);
+ nftnl_table_attr_set_u32(t, NFTNL_TABLE_ATTR_FAMILY, family);
- if (nft_mxml_num_parse(tree, "flags", MXML_DESCEND, BASE_DEC,
- &flags, NFT_TYPE_U32, NFT_XML_MAND, err) == 0)
- nft_table_attr_set_u32(t, NFT_TABLE_ATTR_FLAGS, flags);
+ if (nftnl_mxml_num_parse(tree, "flags", MXML_DESCEND, BASE_DEC,
+ &flags, NFTNL_TYPE_U32, NFTNL_XML_MAND, err) == 0)
+ nftnl_table_attr_set_u32(t, NFTNL_TABLE_ATTR_FLAGS, flags);
- if (nft_mxml_num_parse(tree, "use", MXML_DESCEND, BASE_DEC,
- &use, NFT_TYPE_U32, NFT_XML_MAND, err) == 0)
- nft_table_attr_set_u32(t, NFT_TABLE_ATTR_USE, use);
+ if (nftnl_mxml_num_parse(tree, "use", MXML_DESCEND, BASE_DEC,
+ &use, NFTNL_TYPE_U32, NFTNL_XML_MAND, err) == 0)
+ nftnl_table_attr_set_u32(t, NFTNL_TABLE_ATTR_USE, use);
return 0;
}
#endif
-static int nft_table_xml_parse(struct nft_table *t, const void *data,
- struct nft_parse_err *err,
- enum nft_parse_input input)
+static int nftnl_table_xml_parse(struct nftnl_table *t, const void *data,
+ struct nftnl_parse_err *err,
+ enum nftnl_parse_input input)
{
#ifdef XML_PARSING
int ret;
- mxml_node_t *tree = nft_mxml_build_tree(data, "table", err, input);
+ mxml_node_t *tree = nftnl_mxml_build_tree(data, "table", err, input);
if (tree == NULL)
return -1;
- ret = nft_mxml_table_parse(tree, t, err);
+ ret = nftnl_mxml_table_parse(tree, t, err);
mxmlDelete(tree);
return ret;
#else
@@ -299,52 +299,52 @@ static int nft_table_xml_parse(struct nft_table *t, const void *data,
}
#ifdef JSON_PARSING
-int nft_jansson_parse_table(struct nft_table *t, json_t *tree,
- struct nft_parse_err *err)
+int nftnl_jansson_parse_table(struct nftnl_table *t, json_t *tree,
+ struct nftnl_parse_err *err)
{
json_t *root;
uint32_t flags, use;
const char *str;
int family;
- root = nft_jansson_get_node(tree, "table", err);
+ root = nftnl_jansson_get_node(tree, "table", err);
if (root == NULL)
return -1;
- str = nft_jansson_parse_str(root, "name", err);
+ str = nftnl_jansson_parse_str(root, "name", err);
if (str != NULL)
- nft_table_attr_set_str(t, NFT_TABLE_ATTR_NAME, str);
+ nftnl_table_attr_set_str(t, NFTNL_TABLE_ATTR_NAME, str);
- if (nft_jansson_parse_family(root, &family, err) == 0)
- nft_table_attr_set_u32(t, NFT_TABLE_ATTR_FAMILY, family);
+ if (nftnl_jansson_parse_family(root, &family, err) == 0)
+ nftnl_table_attr_set_u32(t, NFTNL_TABLE_ATTR_FAMILY, family);
- if (nft_jansson_parse_val(root, "flags", NFT_TYPE_U32, &flags,
+ if (nftnl_jansson_parse_val(root, "flags", NFTNL_TYPE_U32, &flags,
err) == 0)
- nft_table_attr_set_u32(t, NFT_TABLE_ATTR_FLAGS, flags);
+ nftnl_table_attr_set_u32(t, NFTNL_TABLE_ATTR_FLAGS, flags);
- if (nft_jansson_parse_val(root, "use", NFT_TYPE_U32, &use, err) == 0)
- nft_table_attr_set_u32(t, NFT_TABLE_ATTR_USE, use);
+ if (nftnl_jansson_parse_val(root, "use", NFTNL_TYPE_U32, &use, err) == 0)
+ nftnl_table_attr_set_u32(t, NFTNL_TABLE_ATTR_USE, use);
return 0;
}
#endif
-static int nft_table_json_parse(struct nft_table *t, const void *json,
- struct nft_parse_err *err,
- enum nft_parse_input input)
+static int nftnl_table_json_parse(struct nftnl_table *t, const void *json,
+ struct nftnl_parse_err *err,
+ enum nftnl_parse_input input)
{
#ifdef JSON_PARSING
json_t *tree;
json_error_t error;
int ret;
- tree = nft_jansson_create_root(json, &error, err, input);
+ tree = nftnl_jansson_create_root(json, &error, err, input);
if (tree == NULL)
return -1;
- ret = nft_jansson_parse_table(t, tree, err);
+ ret = nftnl_jansson_parse_table(t, tree, err);
- nft_jansson_free_root(tree);
+ nftnl_jansson_free_root(tree);
return ret;
#else
@@ -353,19 +353,19 @@ static int nft_table_json_parse(struct nft_table *t, const void *json,
#endif
}
-static int nft_table_do_parse(struct nft_table *t, enum nft_parse_type type,
- const void *data, struct nft_parse_err *err,
- enum nft_parse_input input)
+static int nftnl_table_do_parse(struct nftnl_table *t, enum nftnl_parse_type type,
+ const void *data, struct nftnl_parse_err *err,
+ enum nftnl_parse_input input)
{
int ret;
- struct nft_parse_err perr;
+ struct nftnl_parse_err perr;
switch (type) {
- case NFT_PARSE_XML:
- ret = nft_table_xml_parse(t, data, &perr, input);
+ case NFTNL_PARSE_XML:
+ ret = nftnl_table_xml_parse(t, data, &perr, input);
break;
- case NFT_PARSE_JSON:
- ret = nft_table_json_parse(t, data, &perr, input);
+ case NFTNL_PARSE_JSON:
+ ret = nftnl_table_json_parse(t, data, &perr, input);
break;
default:
ret = -1;
@@ -379,106 +379,106 @@ static int nft_table_do_parse(struct nft_table *t, enum nft_parse_type type,
return ret;
}
-int nft_table_parse(struct nft_table *t, enum nft_parse_type type,
- const char *data, struct nft_parse_err *err)
+int nftnl_table_parse(struct nftnl_table *t, enum nftnl_parse_type type,
+ const char *data, struct nftnl_parse_err *err)
{
- return nft_table_do_parse(t, type, data, err, NFT_PARSE_BUFFER);
+ return nftnl_table_do_parse(t, type, data, err, NFTNL_PARSE_BUFFER);
}
EXPORT_SYMBOL(nftnl_table_parse, nft_table_parse);
-int nft_table_parse_file(struct nft_table *t, enum nft_parse_type type,
- FILE *fp, struct nft_parse_err *err)
+int nftnl_table_parse_file(struct nftnl_table *t, enum nftnl_parse_type type,
+ FILE *fp, struct nftnl_parse_err *err)
{
- return nft_table_do_parse(t, type, fp, err, NFT_PARSE_FILE);
+ return nftnl_table_do_parse(t, type, fp, err, NFTNL_PARSE_FILE);
}
EXPORT_SYMBOL(nftnl_table_parse_file, nft_table_parse_file);
-static int nft_table_export(char *buf, size_t size, struct nft_table *t,
+static int nftnl_table_export(char *buf, size_t size, struct nftnl_table *t,
int type)
{
- NFT_BUF_INIT(b, buf, size);
+ NFTNL_BUF_INIT(b, buf, size);
- nft_buf_open(&b, type, TABLE);
- if (t->flags & (1 << NFT_TABLE_ATTR_NAME))
- nft_buf_str(&b, type, t->name, NAME);
- if (t->flags & (1 << NFT_TABLE_ATTR_FAMILY))
- nft_buf_str(&b, type, nft_family2str(t->family), FAMILY);
- if (t->flags & (1 << NFT_TABLE_ATTR_FLAGS))
- nft_buf_u32(&b, type, t->table_flags, FLAGS);
- if (t->flags & (1 << NFT_TABLE_ATTR_USE))
- nft_buf_u32(&b, type, t->use, USE);
+ nftnl_buf_open(&b, type, TABLE);
+ if (t->flags & (1 << NFTNL_TABLE_ATTR_NAME))
+ nftnl_buf_str(&b, type, t->name, NAME);
+ if (t->flags & (1 << NFTNL_TABLE_ATTR_FAMILY))
+ nftnl_buf_str(&b, type, nftnl_family2str(t->family), FAMILY);
+ if (t->flags & (1 << NFTNL_TABLE_ATTR_FLAGS))
+ nftnl_buf_u32(&b, type, t->table_flags, FLAGS);
+ if (t->flags & (1 << NFTNL_TABLE_ATTR_USE))
+ nftnl_buf_u32(&b, type, t->use, USE);
- nft_buf_close(&b, type, TABLE);
+ nftnl_buf_close(&b, type, TABLE);
- return nft_buf_done(&b);
+ return nftnl_buf_done(&b);
}
-static int nft_table_snprintf_default(char *buf, size_t size, struct nft_table *t)
+static int nftnl_table_snprintf_default(char *buf, size_t size, struct nftnl_table *t)
{
return snprintf(buf, size, "table %s %s flags %x use %d",
- t->name, nft_family2str(t->family),
+ t->name, nftnl_family2str(t->family),
t->table_flags, t->use);
}
-static int nft_table_cmd_snprintf(char *buf, size_t size, struct nft_table *t,
+static int nftnl_table_cmd_snprintf(char *buf, size_t size, struct nftnl_table *t,
uint32_t cmd, uint32_t type, uint32_t flags)
{
int ret, len = size, offset = 0;
- ret = nft_cmd_header_snprintf(buf + offset, len, cmd, type, flags);
+ ret = nftnl_cmd_header_snprintf(buf + offset, len, cmd, type, flags);
SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
switch (type) {
- case NFT_OUTPUT_DEFAULT:
- ret = nft_table_snprintf_default(buf+offset, len, t);
+ case NFTNL_OUTPUT_DEFAULT:
+ ret = nftnl_table_snprintf_default(buf+offset, len, t);
break;
- case NFT_OUTPUT_XML:
- case NFT_OUTPUT_JSON:
- ret = nft_table_export(buf+offset, len, t, type);
+ case NFTNL_OUTPUT_XML:
+ case NFTNL_OUTPUT_JSON:
+ ret = nftnl_table_export(buf+offset, len, t, type);
break;
default:
return -1;
}
SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
- ret = nft_cmd_footer_snprintf(buf + offset, len, cmd, type, flags);
+ ret = nftnl_cmd_footer_snprintf(buf + offset, len, cmd, type, flags);
SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
return offset;
}
-int nft_table_snprintf(char *buf, size_t size, struct nft_table *t,
+int nftnl_table_snprintf(char *buf, size_t size, struct nftnl_table *t,
uint32_t type, uint32_t flags)
{
- return nft_table_cmd_snprintf(buf, size, t, nft_flag2cmd(flags), type,
+ return nftnl_table_cmd_snprintf(buf, size, t, nftnl_flag2cmd(flags), type,
flags);
}
EXPORT_SYMBOL(nftnl_table_snprintf, nft_table_snprintf);
-static inline int nft_table_do_snprintf(char *buf, size_t size, void *t,
+static inline int nftnl_table_do_snprintf(char *buf, size_t size, void *t,
uint32_t cmd, uint32_t type,
uint32_t flags)
{
- return nft_table_snprintf(buf, size, t, type, flags);
+ return nftnl_table_snprintf(buf, size, t, type, flags);
}
-int nft_table_fprintf(FILE *fp, struct nft_table *t, uint32_t type,
+int nftnl_table_fprintf(FILE *fp, struct nftnl_table *t, uint32_t type,
uint32_t flags)
{
- return nft_fprintf(fp, t, NFT_CMD_UNSPEC, type, flags,
- nft_table_do_snprintf);
+ return nftnl_fprintf(fp, t, NFTNL_CMD_UNSPEC, type, flags,
+ nftnl_table_do_snprintf);
}
EXPORT_SYMBOL(nftnl_table_fprintf, nft_table_fprintf);
-struct nft_table_list {
+struct nftnl_table_list {
struct list_head list;
};
-struct nft_table_list *nft_table_list_alloc(void)
+struct nftnl_table_list *nftnl_table_list_alloc(void)
{
- struct nft_table_list *list;
+ struct nftnl_table_list *list;
- list = calloc(1, sizeof(struct nft_table_list));
+ list = calloc(1, sizeof(struct nftnl_table_list));
if (list == NULL)
return NULL;
@@ -488,47 +488,47 @@ struct nft_table_list *nft_table_list_alloc(void)
}
EXPORT_SYMBOL(nftnl_table_list_alloc, nft_table_list_alloc);
-void nft_table_list_free(struct nft_table_list *list)
+void nftnl_table_list_free(struct nftnl_table_list *list)
{
- struct nft_table *r, *tmp;
+ struct nftnl_table *r, *tmp;
list_for_each_entry_safe(r, tmp, &list->list, head) {
list_del(&r->head);
- nft_table_free(r);
+ nftnl_table_free(r);
}
xfree(list);
}
EXPORT_SYMBOL(nftnl_table_list_free, nft_table_list_free);
-int nft_table_list_is_empty(struct nft_table_list *list)
+int nftnl_table_list_is_empty(struct nftnl_table_list *list)
{
return list_empty(&list->list);
}
EXPORT_SYMBOL(nftnl_table_list_is_empty, nft_table_list_is_empty);
-void nft_table_list_add(struct nft_table *r, struct nft_table_list *list)
+void nftnl_table_list_add(struct nftnl_table *r, struct nftnl_table_list *list)
{
list_add(&r->head, &list->list);
}
EXPORT_SYMBOL(nftnl_table_list_add, nft_table_list_add);
-void nft_table_list_add_tail(struct nft_table *r, struct nft_table_list *list)
+void nftnl_table_list_add_tail(struct nftnl_table *r, struct nftnl_table_list *list)
{
list_add_tail(&r->head, &list->list);
}
EXPORT_SYMBOL(nftnl_table_list_add_tail, nft_table_list_add_tail);
-void nft_table_list_del(struct nft_table *t)
+void nftnl_table_list_del(struct nftnl_table *t)
{
list_del(&t->head);
}
EXPORT_SYMBOL(nftnl_table_list_del, nft_table_list_del);
-int nft_table_list_foreach(struct nft_table_list *table_list,
- int (*cb)(struct nft_table *t, void *data),
+int nftnl_table_list_foreach(struct nftnl_table_list *table_list,
+ int (*cb)(struct nftnl_table *t, void *data),
void *data)
{
- struct nft_table *cur, *tmp;
+ struct nftnl_table *cur, *tmp;
int ret;
list_for_each_entry_safe(cur, tmp, &table_list->list, head) {
@@ -540,38 +540,38 @@ int nft_table_list_foreach(struct nft_table_list *table_list,
}
EXPORT_SYMBOL(nftnl_table_list_foreach, nft_table_list_foreach);
-struct nft_table_list_iter {
- struct nft_table_list *list;
- struct nft_table *cur;
+struct nftnl_table_list_iter {
+ struct nftnl_table_list *list;
+ struct nftnl_table *cur;
};
-struct nft_table_list_iter *nft_table_list_iter_create(struct nft_table_list *l)
+struct nftnl_table_list_iter *nftnl_table_list_iter_create(struct nftnl_table_list *l)
{
- struct nft_table_list_iter *iter;
+ struct nftnl_table_list_iter *iter;
- iter = calloc(1, sizeof(struct nft_table_list_iter));
+ iter = calloc(1, sizeof(struct nftnl_table_list_iter));
if (iter == NULL)
return NULL;
iter->list = l;
- if (nft_table_list_is_empty(l))
+ if (nftnl_table_list_is_empty(l))
iter->cur = NULL;
else
- iter->cur = list_entry(l->list.next, struct nft_table, head);
+ iter->cur = list_entry(l->list.next, struct nftnl_table, head);
return iter;
}
EXPORT_SYMBOL(nftnl_table_list_iter_create, nft_table_list_iter_create);
-struct nft_table *nft_table_list_iter_next(struct nft_table_list_iter *iter)
+struct nftnl_table *nftnl_table_list_iter_next(struct nftnl_table_list_iter *iter)
{
- struct nft_table *r = iter->cur;
+ struct nftnl_table *r = iter->cur;
if (r == NULL)
return NULL;
/* get next table, if any */
- iter->cur = list_entry(iter->cur->head.next, struct nft_table, head);
+ iter->cur = list_entry(iter->cur->head.next, struct nftnl_table, head);
if (&iter->cur->head == iter->list->list.next)
return NULL;
@@ -579,7 +579,7 @@ struct nft_table *nft_table_list_iter_next(struct nft_table_list_iter *iter)
}
EXPORT_SYMBOL(nftnl_table_list_iter_next, nft_table_list_iter_next);
-void nft_table_list_iter_destroy(struct nft_table_list_iter *iter)
+void nftnl_table_list_iter_destroy(struct nftnl_table_list_iter *iter)
{
xfree(iter);
}