Andreas Henriksson <[EMAIL PROTECTED]> writes:

> On mån, 2008-06-09 at 13:39 +0200, Warly wrote:
>> 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.)

Yes ! With only libnetlink and your suggestions, I can successfully use
the latest iproute-dev. I may need to support IPv6 soon, so I may
investigate how to deal with that.

Thanks again! 

-- 
Warly



--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to