All of lore.kernel.org
 help / color / mirror / Atom feed
* Confusion regarding nfct_query and nfct_callback_register
@ 2016-02-12  4:10 Gadre Nayan
  2016-02-12  7:30 ` Ken-ichirou MATSUZAWA
  0 siblings, 1 reply; 3+ messages in thread
From: Gadre Nayan @ 2016-02-12  4:10 UTC (permalink / raw)
  To: netfilter

Dear All,

I using Netfilter framework and associated tools (
libnetfilter_conntrack, Conntrack-tools).

I am particularly confused with the arguments of 2 functions.

1. int nfct_callback_register ( struct nfct_handle * h, enum
nf_conntrack_msg_type type,
                                                int(*)(enum
nf_conntrack_msg_type type, struct nf_conntrack *ct, void *data)cb,
                                                void * data ).

2. int nfct_query (struct nfct_handle *h, const enum
nf_conntrack_query qt, const void *data).

The typical usage I see is as below:

nfct_callback_register(h, NFCT_T_ALL, update_cb, NULL); ret =
nfct_query(h, NFCT_Q_DUMP, &family);

static int update_cb(enum nf_conntrack_msg_type type, struct
nf_conntrack *ct, void *data)
{
        int res;
        struct nf_conntrack *obj = data;
}

So both data and ct parameters of update_cb are of type struct nf_conntrack.
Who is providing both these structures (struct nf_conntrack *ct, void
data) in update_cb.
Which struct nf_conntrack* among the 2 is the actual data received
from the kernel space.

Thanks and Regards

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Confusion regarding nfct_query and nfct_callback_register
  2016-02-12  4:10 Confusion regarding nfct_query and nfct_callback_register Gadre Nayan
@ 2016-02-12  7:30 ` Ken-ichirou MATSUZAWA
  2016-02-23  4:16   ` Gadre Nayan
  0 siblings, 1 reply; 3+ messages in thread
From: Ken-ichirou MATSUZAWA @ 2016-02-12  7:30 UTC (permalink / raw)
  To: Gadre Nayan; +Cc: netfilter

 Hi,
 
On Fri, Feb 12, 2016 at 09:40:49AM +0530, Gadre Nayan wrote:
> Who is providing both these structures (struct nf_conntrack *ct, void

struct nf_conntrack is allocated by nfct_new(). You would find this
function called in __callback() in src/callback.c. Then it parses
nlmsg and updates nf_conntrack, calls callback function you
registered.

The __callback() is registerd as callback of which libnfnetlink will
call when conntrack nlmsg has received, at nfct_callback_register()
in src/conntrack/api.c.

# it seems that using nfct_callback_register, functions related to
# libnfnetlink, is discouraged for me.

I hope this is an answer you are looking for.
Thanks,

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Confusion regarding nfct_query and nfct_callback_register
  2016-02-12  7:30 ` Ken-ichirou MATSUZAWA
@ 2016-02-23  4:16   ` Gadre Nayan
  0 siblings, 0 replies; 3+ messages in thread
From: Gadre Nayan @ 2016-02-23  4:16 UTC (permalink / raw)
  To: Ken-ichirou MATSUZAWA; +Cc: netfilter

Thanks Ken!

On Fri, Feb 12, 2016 at 1:00 PM, Ken-ichirou MATSUZAWA
<chamaken@gmail.com> wrote:
>  Hi,
>
> On Fri, Feb 12, 2016 at 09:40:49AM +0530, Gadre Nayan wrote:
>> Who is providing both these structures (struct nf_conntrack *ct, void
>
> struct nf_conntrack is allocated by nfct_new(). You would find this
> function called in __callback() in src/callback.c. Then it parses
> nlmsg and updates nf_conntrack, calls callback function you
> registered.
>
> The __callback() is registerd as callback of which libnfnetlink will
> call when conntrack nlmsg has received, at nfct_callback_register()
> in src/conntrack/api.c.
>
> # it seems that using nfct_callback_register, functions related to
> # libnfnetlink, is discouraged for me.
>
> I hope this is an answer you are looking for.
> Thanks,

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-02-23  4:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-12  4:10 Confusion regarding nfct_query and nfct_callback_register Gadre Nayan
2016-02-12  7:30 ` Ken-ichirou MATSUZAWA
2016-02-23  4:16   ` Gadre Nayan

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.