From 3a35c7f2f84dde96c42de015cfd5fc44d115a0d7 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Mon, 14 May 2012 16:21:13 +0200 Subject: examples: fix nfct-helper-add example to adapt it to the new API Signed-off-by: Pablo Neira Ayuso --- examples/nfct-helper-add.c | 16 +++++++++++++--- examples/nfct-helper-get.c | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/examples/nfct-helper-add.c b/examples/nfct-helper-add.c index 4371761..6c47626 100644 --- a/examples/nfct-helper-add.c +++ b/examples/nfct-helper-add.c @@ -13,6 +13,7 @@ int main(int argc, char *argv[]) struct nlmsghdr *nlh; uint32_t portid, seq; struct nfct_helper *nfct_helper; + struct nfct_helper_policy *p; int ret; if (argc != 3) { @@ -28,11 +29,19 @@ int main(int argc, char *argv[]) nfct_helper_attr_set(nfct_helper, NFCTH_ATTR_NAME, argv[1]); nfct_helper_attr_set_u32(nfct_helper, NFCTH_ATTR_QUEUE_NUM, atoi(argv[2])); - nfct_helper_attr_set(nfct_helper, NFCTH_ATTR_EXP_POLICY_NAME, "test"); nfct_helper_attr_set_u16(nfct_helper, NFCTH_ATTR_PROTO_L3NUM, AF_INET); nfct_helper_attr_set_u8(nfct_helper, NFCTH_ATTR_PROTO_L4NUM, IPPROTO_TCP); - nfct_helper_attr_set_u32(nfct_helper, NFCTH_ATTR_EXP_POLICY_TIMEOUT, 100); - nfct_helper_attr_set_u32(nfct_helper, NFCTH_ATTR_EXP_POLICY_MAX, 100); + + p = nfct_helper_policy_alloc(); + if (p == NULL) { + perror("OOM"); + exit(EXIT_FAILURE); + } + nfct_helper_policy_attr_set(p, NFCTH_ATTR_POLICY_NAME, "test"); + nfct_helper_policy_attr_set_u32(p, NFCTH_ATTR_POLICY_TIMEOUT, 100); + nfct_helper_policy_attr_set_u32(p, NFCTH_ATTR_POLICY_MAX, 100); + + nfct_helper_attr_set(nfct_helper, NFCTH_ATTR_POLICY, p); seq = time(NULL); nlh = nfct_helper_nlmsg_build_hdr(buf, NFNL_MSG_CTHELPER_NEW, @@ -40,6 +49,7 @@ int main(int argc, char *argv[]) nfct_helper_nlmsg_build_payload(nlh, nfct_helper); nfct_helper_free(nfct_helper); + nfct_helper_policy_free(p); nl = mnl_socket_open(NETLINK_NETFILTER); if (nl == NULL) { diff --git a/examples/nfct-helper-get.c b/examples/nfct-helper-get.c index 634062a..d3e9dbc 100644 --- a/examples/nfct-helper-get.c +++ b/examples/nfct-helper-get.c @@ -21,7 +21,7 @@ static int nfct_helper_cb(const struct nlmsghdr *nlh, void *data) goto err_free; } - nfct_helper_snprintf(buf, sizeof(buf), nfct_helper, 0); + nfct_helper_snprintf(buf, sizeof(buf), nfct_helper, 0, 0); printf("%s\n", buf); err_free: -- cgit v1.2.3