Re: [PATCH lnf-queue] api: add nfq_nlmsg_get_timestamp helper

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Florian,

On Thu, Aug 22, 2013 at 05:07:17PM +0200, Florian Westphal wrote:
> The NFQA_TIMESTAMP structure is in network byte order, so it seems
> appropriate to add a helper to convert it to a timeval struct.
> 
> Signed-off-by: Florian Westphal <fw@xxxxxxxxx>
> ---
>  examples/nf-queue.c                             |    9 ++++++++-
>  include/libnetfilter_queue/libnetfilter_queue.h |    2 ++
>  src/nlmsg.c                                     |   15 +++++++++++++++
>  3 files changed, 25 insertions(+), 1 deletions(-)
> 
> diff --git a/examples/nf-queue.c b/examples/nf-queue.c
> index 1f465ad..2722426 100644
> --- a/examples/nf-queue.c
> +++ b/examples/nf-queue.c
> @@ -5,6 +5,7 @@
>  #include <string.h>
>  #include <time.h>
>  #include <arpa/inet.h>
> +#include <sys/time.h>
>  
>  #include <libmnl/libmnl.h>
>  #include <linux/netfilter.h>
> @@ -54,6 +55,7 @@ static int queue_cb(const struct nlmsghdr *nlh, void *data)
>  	uint32_t id = 0, skbinfo;
>  	struct nfgenmsg *nfg;
>  	uint16_t plen;
> +	struct timeval tv;
>  
>  	if (nfq_nlmsg_parse(nlh, attr) < 0) {
>  		perror("problems parsing");
> @@ -72,7 +74,11 @@ static int queue_cb(const struct nlmsghdr *nlh, void *data)
>  	plen = mnl_attr_get_payload_len(attr[NFQA_PAYLOAD]);
>  	/* void *payload = mnl_attr_get_payload(attr[NFQA_PAYLOAD]); */
>  
> -	skbinfo = attr[NFQA_SKB_INFO] ? ntohl(mnl_attr_get_u32(attr[NFQA_SKB_INFO])) : 0;
> +	if (attr[NFQA_TIMESTAMP])
> +		nfq_nlmsg_get_timestamp(attr[NFQA_TIMESTAMP], &tv);

I think we can update nfq_get_timestamp to use libmnl without breaking
backward compatibility. Same thing with all other getter functions
that we have.

Regards.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux