All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pablo Neira <pablo@netfilter.org>
To: Eric Leblond <eric@inl.fr>
Cc: laforge@netfilter.org, netfilter-devel@lists.netfilter.org,
	Vincent Deffontaines <vincent@inl.fr>
Subject: Re: [PATCH] message parsing functions for nfqueue
Date: Fri, 12 Aug 2005 03:30:21 +0200	[thread overview]
Message-ID: <42FBFBAD.8020807@netfilter.org> (raw)
In-Reply-To: <1123794106.4980.11.camel@porky>

Eric Leblond wrote:
> This is a patch against libnfnetlink_queue.
> 
> It adds "high" level functions to access to the data contained in a
> nfqueue message. These are mostly encapsulation of NFA macros.
> 
> -
> -	if (tb[NFQA_PACKET_HDR-1]) {
> -		struct nfqnl_msg_packet_hdr *ph = 
> -					NFA_DATA(tb[NFQA_PACKET_HDR-1]);
> +	struct nfqnl_msg_packet_hdr *ph;
> +	u_int32_t mark,ifi; 
> +	int ret;
> +	unsigned int datalength;
> +	char * data;
> +	
> +	ph = nfqnl_get_msg_packet_hdr(tb);
> +	if (ph){
>  		id = ntohl(ph->packet_id);
>  		printf("hw_protocol=0x%04x hook=%u id=%u ",
>  			ntohs(ph->hw_protocol), ph->hook, id);
>  	}

Instead of adding a function to access every attribute like above, why 
don't we add something more generic in libnfnetlink? Like the following 
macros:

#define nfnl_get_data(tb, attr, type)			\
({	type __ret = 0;					\
  	if (tb[attr-1])					\
  		__ret = *(type *)NFA_DATA(tb[attr-1]);	\
	__ret;						\
})

#define nfnl_get_pointer_to_data(tb, attr, type)	\
({	type *__ret = NULL;				\
  	if (tb[attr-1])					\
  		__ret = NFA_DATA(tb[attr-1]);		\
  	__ret;						\
})

Maybe too generic ?

OTOH, if we add such high level functions we'll have to do the same in 
other libnfnetlink_* libraries to keep homogeneity of the API.

--
Pablo

  parent reply	other threads:[~2005-08-12  1:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-11 21:01 [PATCH] message parsing functions for nfqueue Eric Leblond
2005-08-11 22:48 ` Harald Welte
2005-08-12 12:41   ` Harald Welte
2005-08-12  1:30 ` Pablo Neira [this message]
2005-08-12  8:42   ` Eric Leblond
2005-08-12 12:04     ` Harald Welte
2005-09-14 19:57       ` Eric Leblond

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=42FBFBAD.8020807@netfilter.org \
    --to=pablo@netfilter.org \
    --cc=eric@inl.fr \
    --cc=laforge@netfilter.org \
    --cc=netfilter-devel@lists.netfilter.org \
    --cc=vincent@inl.fr \
    /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.