diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2016-11-30 22:05:54 +0100 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2016-11-30 22:05:54 +0100 |
commit | 6a32dbd4cd56c8fede6044a447469fbd0e35c10a (patch) | |
tree | 15f8126a4bda8dce27a14b3d7883adc45cbb2607 /examples/nft-set-add.c | |
parent | 2d894a97c28e6c7c7f064d16bec0167d000e901c (diff) |
examples: nft-set-add: update it to add a set that stores port numbers
This patch updates the existing example to add a set that stores port
numbers. In order to interoperate with the nft tool, we use the datatype
numbers defined there.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'examples/nft-set-add.c')
-rw-r--r-- | examples/nft-set-add.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/examples/nft-set-add.c b/examples/nft-set-add.c index e040aca..bae6e8e 100644 --- a/examples/nft-set-add.c +++ b/examples/nft-set-add.c @@ -42,9 +42,10 @@ static struct nftnl_set *setup_set(uint8_t family, const char *table, nftnl_set_set_str(s, NFTNL_SET_TABLE, table); nftnl_set_set_str(s, NFTNL_SET_NAME, name); nftnl_set_set_u32(s, NFTNL_SET_FAMILY, family); - nftnl_set_set_u32(s, NFTNL_SET_KEY_LEN, 2); + nftnl_set_set_u32(s, NFTNL_SET_KEY_LEN, sizeof(uint16_t)); + /* inet service type, see nftables/include/datatypes.h */ + nftnl_set_set_u32(s, NFTNL_SET_KEY_TYPE, 13); nftnl_set_set_u32(s, NFTNL_SET_ID, 1); - nftnl_set_set_u32(s, NFTNL_SET_FLAGS, NFT_SET_CONSTANT); return s; } |