All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
To: netfilter-devel@vger.kernel.org
Cc: pablo@netfilter.org
Subject: [libnftnl PATCH 2/2] examples: nft-events: use new events wrappers
Date: Tue, 15 Apr 2014 11:40:35 +0200	[thread overview]
Message-ID: <20140415094035.23739.59645.stgit@nfdev.cica.es> (raw)
In-Reply-To: <20140415094030.23739.71580.stgit@nfdev.cica.es>

Let's use the new event wrappers in the events example.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
---
 examples/nft-events.c |   16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/examples/nft-events.c b/examples/nft-events.c
index 989f4bd..9d33295 100644
--- a/examples/nft-events.c
+++ b/examples/nft-events.c
@@ -22,6 +22,7 @@
 #include <libnftnl/chain.h>
 #include <libnftnl/rule.h>
 #include <libnftnl/set.h>
+#include <libnftnl/common.h>
 
 static int table_cb(const struct nlmsghdr *nlh, int type)
 {
@@ -40,7 +41,8 @@ static int table_cb(const struct nlmsghdr *nlh, int type)
 	}
 
 	nft_table_snprintf(buf, sizeof(buf), t, NFT_OUTPUT_DEFAULT, 0);
-	printf("[%s]\t%s\n", type == NFT_MSG_NEWTABLE ? "NEW" : "DEL", buf);
+	nft_event_fprintf(stdout, buf, NFT_OUTPUT_DEFAULT, type);
+	fprintf(stdout, "\n");
 
 err_free:
 	nft_table_free(t);
@@ -65,7 +67,8 @@ static int rule_cb(const struct nlmsghdr *nlh, int type)
 	}
 
 	nft_rule_snprintf(buf, sizeof(buf), t, NFT_OUTPUT_DEFAULT, 0);
-	printf("[%s]\t%s\n", type == NFT_MSG_NEWRULE ? "NEW" : "DEL", buf);
+	nft_event_fprintf(stdout, buf, NFT_OUTPUT_DEFAULT, type);
+	fprintf(stdout, "\n");
 
 err_free:
 	nft_rule_free(t);
@@ -90,7 +93,8 @@ static int chain_cb(const struct nlmsghdr *nlh, int type)
 	}
 
 	nft_chain_snprintf(buf, sizeof(buf), t, NFT_OUTPUT_DEFAULT, 0);
-	printf("[%s]\t%s\n", type == NFT_MSG_NEWCHAIN ? "NEW" : "DEL", buf);
+	nft_event_fprintf(stdout, buf, NFT_OUTPUT_DEFAULT, type);
+	fprintf(stdout, "\n");
 
 err_free:
 	nft_chain_free(t);
@@ -115,7 +119,8 @@ static int set_cb(const struct nlmsghdr *nlh, int type)
 	}
 
 	nft_set_snprintf(buf, sizeof(buf), t, NFT_OUTPUT_DEFAULT, 0);
-	printf("[%s]\t%s\n", type == NFT_MSG_NEWSET ? "NEW" : "DEL", buf);
+	nft_event_fprintf(stdout, buf, NFT_OUTPUT_DEFAULT, type);
+	fprintf(stdout, "\n");
 
 err_free:
 	nft_set_free(t);
@@ -141,7 +146,8 @@ static int setelem_cb(const struct nlmsghdr *nlh, int type)
 	}
 
 	nft_set_snprintf(buf, sizeof(buf), s, NFT_OUTPUT_DEFAULT, 0);
-	printf("[%s]\t%s\n", type == NFT_MSG_NEWSETELEM ? "NEW" : "DEL", buf);
+	nft_event_fprintf(stdout, buf, NFT_OUTPUT_DEFAULT, type);
+	fprintf(stdout, "\n");
 
 err_free:
 	nft_set_free(s);


  reply	other threads:[~2014-04-15  9:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-15  9:40 [libnftnl PATCH 1/2] common: add wrapper to represent events Arturo Borrero Gonzalez
2014-04-15  9:40 ` Arturo Borrero Gonzalez [this message]
2014-04-15  9:51 ` Pablo Neira Ayuso
  -- strict thread matches above, loose matches on Subject: below --
2014-04-15 12:50 [libnftnl PATCH 1/2] src: add flag to add event wrapping in output functions Arturo Borrero Gonzalez
2014-04-15 12:50 ` [libnftnl PATCH 2/2] examples: nft-events: use new events wrappers Arturo Borrero Gonzalez

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140415094035.23739.59645.stgit@nfdev.cica.es \
    --to=arturo.borrero.glez@gmail.com \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.