trying to get some simple code working using version 3 of the library

John Davis davisjf at gmail.com
Mon Feb 20 14:53:40 PST 2017


I got some help via stackoverflow, for completeness here is the link
in case you have the same question.
http://stackoverflow.com/questions/42307658/how-to-get-ipv4-address-of-an-interface-using-libnl3-netlink-version-3-on-linu/42355622#42355622

On Thu, Feb 16, 2017 at 6:56 PM, John Davis <davisjf at gmail.com> wrote:
> Actually, I used the cli sample code to get the mac and ip address and
> then I tried to do the same thing using the non cli api.  I could get
> the mac address and the interface name but I could not get the ip
> address.  The interface name query was kind of silly because I had
> specified it already, but it was just to get a feel for the api.
>
> Here is a pastebin/gist of  what I have done.
> https://gist.github.com/netskink/4f554ed6657954b17ab255ad5bc6d1f0
>
> On Thu, Feb 16, 2017 at 1:11 PM, John Davis <davisjf at gmail.com> wrote:
>> After searching for awhile, I found a reference to this dir.
>>
>> http://git.infradead.org/users/tgr/libnl.git/tree/HEAD:/src
>>
>> The code here should help immensely.  Never mind.
>>
>> On Wed, Feb 15, 2017 at 4:33 PM, John Davis <davisjf at gmail.com> wrote:
>>> Hello
>>>
>>> I found some code from the mailing list archives and I am trying to modify
>>> it to get additional functionality working.
>>> Specificially I am trying to get the mac address of my desired network
>>> interface and the number of bytes transmitted.
>>>
>>> The code I am working on is here:
>>>
>>> https://gist.github.com/netskink/6f712a9a0a2beccc8504fdf625825762
>>>
>>> I have two problems.
>>> 1) how to modify the code so that the qdisc structure is associated with my
>>> specified network interface?
>>> 2) how to get the mac address of the interface?  When I try to execute
>>> nl_addr_info() I get a failure even though the previous routines worked.
>>>
>>> Here is the output of the code pasted above:
>>>
>>> davis at smeagol:~/progs/netlink$
>>> ./stats
>>> name is enp6s0
>>> Total # of packets transmitted is 0
>>> nl_addr_info failed with -11: Address family not supported
>>>
>>> --
>>> John F. Davis
>>> 6 Kandes Court
>>> Durham, NC 27713
>>> 919-888-8358
>>> Public Profilehttps://www.linkedin.com/in/netskink
>>>
>>> 独树一帜
>>
>>
>>
>> --
>> John F. Davis
>> 6 Kandes Court
>> Durham, NC 27713
>> 919-888-8358
>> Public Profilehttps://www.linkedin.com/in/netskink
>>
>> 独树一帜
>
>
>
> --
> John F. Davis
> 6 Kandes Court
> Durham, NC 27713
> 919-888-8358
> Public Profilehttps://www.linkedin.com/in/netskink
>
> 独树一帜



-- 
John F. Davis
6 Kandes Court
Durham, NC 27713
919-888-8358
Public Profile https://www.linkedin.com/in/netskink

独树一帜



More information about the libnl mailing list