Looking for examples of the python wrapper

Teto mattator at gmail.com
Fri Sep 6 09:08:49 EDT 2013


Sorry for the bad report, as my callbacks didn't get called I thought
it was linked to this message. By enabling NLDBG=4 I could see that it
was due to bad sequence number.
I've added bindings for nl and  genl msg header in SWIG so that I
could do sthg like (patch enclosed)
        nlmsghdr = nl.nlmsg_hdr(m)
        print("message length", nlmsghdr.nlmsg_len);
        print("message sent from pid ", nlmsghdr.nlmsg_pid);
        print("message sent from type ", nlmsghdr.nlmsg_type);

        genlhdr = genl.genlmsg_hdr( nlmsghdr )

Matt

On Fri, Sep 6, 2013 at 10:01 AM, Arend van Spriel <arend at broadcom.com> wrote:
> On 09/05/2013 08:03 PM, Teto wrote:
>>
>> Thanks for commiting the patches.
>>
>> I thnik there is a bug with py_nl_cb_set/py_nl_cb_err . The first
>> registration always fail (I've changed the order of registrations
>> etc..) whereas the following cb registrations work.
>> pynl_find_cbinfo: cb=0x2005a30: not found
>> pynl_get_cbinfo: cb=0x2005a30: added 0x1f156b0
>> py_nl_cb_err: cb=0x2005a30, info=0x1f156b0, kind=3
>> pynl_find_cbinfo: cb=0x2005a30: found=0x1f156b0
>> pynl_get_cbinfo: cb=0x2005a30: done
>> py_nl_cb_set: cb=0x2005a30, info=0x1f156b0, type=0, kind=3
>
>
> This is not a bug. The function pynl_get_cbinfo tries to lookup the callback
> info for the given nl_cb instance using pynl_find_cbinfo. When that lookup
> fails it will allocate a new callback info structure. That is exactly what
> the first two messages tell. This tracing is actually for debugging purposes
> and I should have turned it off.
>
>
>> I've joined a copy of the file which is a slight modification of the
>> commited example. As I needed nl_socket_add_membership, I've added it
>> to the bindings.
>
>
> Indeed, for receiving netlink events. I had a patch for that as well. Not
> sure where that ended up.
>
> Regards,
> Arend
>
>
>> On Fri, Aug 30, 2013 at 9:55 AM, Arend van Spriel <arend at broadcom.com>
>> wrote:
>>>
>>> On 08/29/13 11:59, Thomas Graf wrote:
>>>>
>>>>
>>>> On 08/28/13 at 09:46pm, Teto wrote:
>>>>>
>>>>>
>>>>> Hi,
>>>>>
>>>>> I am really interested in using your python wrapper. I've compiled it
>>>>> from trunk. Before losing a lot of time trying to find how it works, I
>>>>> was wondering if you had any example available you could send on this
>>>>> mailing-list please ?
>>>>>
>>>>> I am especially interested in the genl wrapper (that's why I
>>>>> downloaded i from trunk) to subscribe to a custom netlink family
>>>>> requests.
>>>>
>>>>
>>>>
>>>> Arend, do you have examples to share?
>>>
>>>
>>>
>>> I have. They are mainly on nl80211 family (I am biased to that). I will
>>> share them through a patch.
>>>
>>> Regards,
>>> Arend
>>>
>>>
>>>
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Added-struct-nlmsghdr-and-genlmsghdr-some-associated.patch
Type: application/octet-stream
Size: 2079 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/libnl/attachments/20130906/bfc1031f/attachment.obj>


More information about the libnl mailing list