rtnl_link_get_kernel()
Thomas Graf
tgraf at suug.ch
Wed Jul 4 05:04:12 EDT 2012
On Tue, Jul 03, 2012 at 11:32:15PM -0600, Wouter Verhelst wrote:
> So I'm trying to use that (I don't need no steenking cache), but it's
> not working.
>
> My code does this:
>
> (common.c)
> static nl_sock* socket;
>
> struct nl_sock* get_socket() {
> if(!socket) {
> socket = nl_socket_alloc();
> nl_socket_set_local_port(socket, 0);
Setting the local port to 0 is not needed, generating a
unique port is the default.
> }
> return socket;
> }
>
> (actual code later on)
>
> struct nl_sock* socket = get_socket();
> struct rtnl_link* link = rtnl_link_alloc();
>
> rtnl_link_get_kernel(socket, 0, "eth0", &link);
>
> but that returns -NLE_BAD_SOCK. What am I missing?
Your socket is not connected, call nl_connect() and bind it
to the NETLINK_ROUTE netlink protocol.
More information about the libnl
mailing list