netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [libnftnl PATCH 1/2] common: add wrapper to represent events
Date: Tue, 15 Apr 2014 11:51:53 +0200	[thread overview]
Message-ID: <20140415095153.GB5223@localhost> (raw)
In-Reply-To: <20140415094030.23739.71580.stgit@nfdev.cica.es>

On Tue, Apr 15, 2014 at 11:40:30AM +0200, Arturo Borrero Gonzalez wrote:
> This patch adds a simple string wrapper to represent nf_tables events.
> 
> Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
> ---
>  include/libnftnl/common.h |    6 +++++
>  src/common.c              |   59 +++++++++++++++++++++++++++++++++++++++++++++
>  src/libnftnl.map          |    3 ++
>  3 files changed, 68 insertions(+)
> 
> diff --git a/include/libnftnl/common.h b/include/libnftnl/common.h
> index f0c20f0..96f8155 100644
> --- a/include/libnftnl/common.h
> +++ b/include/libnftnl/common.h
> @@ -2,6 +2,7 @@
>  #define _LIBNFTNL_COMMON_H_
>  
>  #include <stdint.h>
> +#include <stdio.h>
>  
>  enum {
>  	NFT_PARSE_EBADINPUT	= 0,
> @@ -30,4 +31,9 @@ struct nlmsghdr *nft_nlmsg_build_hdr(char *buf, uint16_t cmd, uint16_t family,
>  struct nft_parse_err *nft_parse_err_alloc(void);
>  void nft_parse_err_free(struct nft_parse_err *);
>  int nft_parse_perror(const char *str, struct nft_parse_err *err);
> +int nft_event_snprintf(char *buf, size_t bufsiz, const char *content,
> +		       uint32_t format, uint32_t type);
> +int nft_event_fprintf(FILE *fp, const char *content,
> +		      uint32_t format, uint32_t type);

We have flags in the existing output functions:

int nft_table_snprintf(char *buf, size_t size, struct nft_table *t,
                       uint32_t type, uint32_t flags);
int nft_table_fprintf(FILE *fp, struct nft_table *t, uint32_t type,
                      uint32_t flags);

I think you can add a new flag that tells that you have to add the
extra event handling that you need, thus, we don't need a new
interface.

You can most likely reuse most of the code in this patch.

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

Thread overview: 3+ 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 ` [libnftnl PATCH 2/2] examples: nft-events: use new events wrappers Arturo Borrero Gonzalez
2014-04-15  9:51 ` Pablo Neira Ayuso [this message]

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=20140415095153.GB5223@localhost \
    --to=pablo@netfilter.org \
    --cc=arturo.borrero.glez@gmail.com \
    --cc=netfilter-devel@vger.kernel.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 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).