* [libnftables PATCH] src: get and set NFT_*_ATTR_FAMILY
@ 2013-03-31 1:15 Arturo Borrero
2013-04-02 11:35 ` Pablo Neira Ayuso
0 siblings, 1 reply; 2+ messages in thread
From: Arturo Borrero @ 2013-03-31 1:15 UTC (permalink / raw)
To: netfilter-devel; +Cc: pablo
This patch adds support to get and set the attribute NFT_{TABLE|CHAIN|RULE}_ATTR_FAMILY easily.
I found this very useful when parsing a XML table|chain|rule (future patch).
---
src/chain.c | 9 +++++++++
src/rule.c | 3 +++
src/table.c | 8 ++++++++
3 files changed, 20 insertions(+)
diff --git a/src/chain.c b/src/chain.c
index 1b1c3fe..9d77179 100644
--- a/src/chain.c
+++ b/src/chain.c
@@ -90,6 +90,9 @@ void nft_chain_attr_set(struct nft_chain *c, uint16_t attr, void *data)
case NFT_CHAIN_ATTR_HANDLE:
c->handle = *((uint64_t *)data);
break;
+ case NFT_CHAIN_ATTR_FAMILY:
+ c->family = *((uint8_t *)data);
+ break;
case NFT_CHAIN_ATTR_TYPE:
if (c->type)
free(c->type);
@@ -177,6 +180,12 @@ void *nft_chain_attr_get(struct nft_chain *c, uint16_t attr)
else
return NULL;
break;
+ case NFT_CHAIN_ATTR_FAMILY:
+ if (c->flags & (1 << NFT_CHAIN_ATTR_FAMILY))
+ return &c->family;
+ else
+ return NULL;
+ break;
case NFT_CHAIN_ATTR_TYPE:
if (c->flags & (1 << NFT_CHAIN_ATTR_TYPE))
return c->type;
diff --git a/src/rule.c b/src/rule.c
index 501b4f6..57b849d 100644
--- a/src/rule.c
+++ b/src/rule.c
@@ -96,6 +96,9 @@ void nft_rule_attr_set(struct nft_rule *r, uint16_t attr, void *data)
case NFT_RULE_ATTR_COMPAT_FLAGS:
r->compat.flags = *((uint32_t *)data);
break;
+ case NFT_RULE_ATTR_FAMILY:
+ r->family = *((uint8_t *)data);
+ break;
default:
return;
}
diff --git a/src/table.c b/src/table.c
index d2e07db..f109cdd 100644
--- a/src/table.c
+++ b/src/table.c
@@ -61,6 +61,10 @@ void nft_table_attr_set(struct nft_table *t, uint16_t attr, void *data)
t->table_flags = *((uint32_t *)data);
t->flags |= (1 << NFT_TABLE_ATTR_FLAGS);
break;
+ case NFT_TABLE_ATTR_FAMILY:
+ t->family = *((uint8_t *)data);
+ t->flags |= (1 << NFT_TABLE_ATTR_FAMILY);
+ break;
}
}
EXPORT_SYMBOL(nft_table_attr_set);
@@ -84,6 +88,10 @@ const void *nft_table_attr_get(struct nft_table *t, uint16_t attr)
if (t->flags & (1 << NFT_TABLE_ATTR_FLAGS))
ret = &t->table_flags;
break;
+ case NFT_TABLE_ATTR_FAMILY:
+ if (t->flags & (1 << NFT_TABLE_ATTR_FAMILY))
+ ret = &t->family;
+ break;
}
return ret;
}
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-04-02 11:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-31 1:15 [libnftables PATCH] src: get and set NFT_*_ATTR_FAMILY Arturo Borrero
2013-04-02 11:35 ` Pablo Neira Ayuso
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).