On mån, 2008-06-09 at 13:39 +0200, Warly wrote: > I tried to narrow down the code to the function which is the most linked > to iproute [...]
Thanks! Really helps in the investigation on what the right solution is. > You will see that the code is partly a duplication from iproute code, > and this is the reason why the header are needed. But likely there must > be a cleaner way to do that. By including <libnetlink.h>, the public header for the static library - which you previously got via the other headers, and reorganizing the code the parts your test-code requires boiled down to this: /* from iproute/utils.h */ typedef struct { __u8 family; __u8 bytelen; __s16 bitlen; __u32 flags; __u32 data[4]; } inet_prefix; /* from iproute/ip_common.h */ static inline int rtm_get_table(struct rtmsg *r, struct rtattr **tb) { __u32 table = r->rtm_table; if (tb[RTA_TABLE]) table = *(__u32*) RTA_DATA(tb[RTA_TABLE]); return table; } It looks to me like these are stuff you should copy, rather then use the iproute headers, as a quick-fix. Since your code only seems to work for ipv4-addresses anyway, you might be able to get rid of the requirements for using the inet_prefix structure all together! (I don't know if this is some kind of kernel message which is in this format or if it's just yet another "lets reinvent our own thing". I'll need to have a closer look, but I'd recommend people to have a look at struct sockaddr_storage for protocol-independent userspace code.) As you might have understood, I'm not convinced yet. I'll have a closer look at your code later on and try to figure out which parts is "I'm doing it like iproute2 because I'm lazy and it works..." and which parts are "I'm doing it like iproute2 because that's the only/right way to do it - the kernel is sending me structures which I'm just supposed to know the layout of without any help". If I find stuff that belongs to the second variant we should think about how we could avoid copy+paste. Until we speak again... HTH, HAND! -- Regards, Andreas Henriksson -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]