Subject: Re: Generic netlink interface help

From: jamal <[email-masked]>
Date: Thu, 24 May 2007 09:51:45 -0400

On Thu, 2007-24-05 at 13:21 +0200, Rodolfo Giometti wrote:
> On Thu, May 24, 2007 at 10:04:08AM -0000, Samuel Ortiz wrote:
> > 
> > Yes it's possible, even though it could be more tedious and painful.
> 
> I know that. Have you some links to suggest to me in order to have
> some programming examples?
> 

For debugging or writting some simple apps you could also use
iproute2/genl
example on my laptop to discover loaded users:

---------------
hadi@lilsol:~$ genl ctrl ls

Name: nlctrl
        ID: 0x10  Version: 0x2  header size: 0  max attribs: 6
        commands supported:
                #1:  ID-0x3  flags-0xe

Name: nl80211
        ID: 0x11  Version: 0x1  header size: 0  max attribs: 22
        commands supported:
                #1:  ID-0x1  flags-0xa
                #2:  ID-0x6  flags-0xa
                #3:  ID-0x8  flags-0xa
                #4:  ID-0x3  flags-0xb
                #5:  ID-0x4  flags-0xb
                #6:  ID-0x5  flags-0xb
                #7:  ID-0xa  flags-0xb
                #8:  ID-0xb  flags-0xa
                #9:  ID-0xf  flags-0xb
                #10:  ID-0x10  flags-0xa
                #11:  ID-0x12  flags-0xb
                #12:  ID-0x13  flags-0xa
                #13:  ID-0x15  flags-0xa
                #14:  ID-0x19  flags-0xb
                #15:  ID-0x17  flags-0xb
                #16:  ID-0x18  flags-0xb
                #17:  ID-0x1a  flags-0xb
                #18:  ID-0x1b  flags-0xa
                #19:  ID-0xd  flags-0xb

Name: TASKSTATS
        ID: 0x12  Version: 0x1  header size: 0  max attribs: 4
        commands supported:
                #1:  ID-0x1  flags-0xa
---------------------------

Load tipc and repeat...

-----------

hadi@lilsol:~$ sudo modprobe tipc
Name: nlctrl
        ID: 0x10  Version: 0x2  header size: 0  max attribs: 6
        commands supported:
                #1:  ID-0x3  flags-0xe

Name: nl80211
        ID: 0x11  Version: 0x1  header size: 0  max attribs: 22
        commands supported:
                #1:  ID-0x1  flags-0xa
                #2:  ID-0x6  flags-0xa
                #3:  ID-0x8  flags-0xa
                #4:  ID-0x3  flags-0xb
                #5:  ID-0x4  flags-0xb
                #6:  ID-0x5  flags-0xb
                #7:  ID-0xa  flags-0xb
                #8:  ID-0xb  flags-0xa
                #9:  ID-0xf  flags-0xb
                #10:  ID-0x10  flags-0xa
                #11:  ID-0x12  flags-0xb
                #12:  ID-0x13  flags-0xa
                #13:  ID-0x15  flags-0xa
                #14:  ID-0x19  flags-0xb
                #15:  ID-0x17  flags-0xb
                #16:  ID-0x18  flags-0xb
                #17:  ID-0x1a  flags-0xb
                #18:  ID-0x1b  flags-0xa
                #19:  ID-0xd  flags-0xb

Name: TASKSTATS
        ID: 0x12  Version: 0x1  header size: 0  max attribs: 4
        commands supported:
                #1:  ID-0x1  flags-0xa

Name: TIPC
        ID: 0x13  Version: 0x1  header size: 8  max attribs: 0
        commands supported:
                #1:  ID-0x1  flags-0x2

===============

You essentially write a little .so in user space that knows how to
access/intepret your kernel module
I know you are avoiding to use external libraries etc; but this may be a
good way to get started.
I can dig up some simple kernel/user code i have and if you bug Thomas
long enough he may give you another sample code he has.

cheers,
jamal