Ask for link and address data on the same socket.
Tilman Baumann
tilman at baumann.name
Wed Jul 10 10:48:59 EDT 2013
On 04/07/13 20:55, Thomas Graf wrote:
> On 07/04/13 at 02:56pm, Tilman Baumann wrote:
>> Hi,
>>
>> I have a receive function that reads RTM_NEWADDR and RTM_NEWLINK messages.
>>
>> But my code for sending the request is buggered.
>>
>> I must be doing the chaining of netlink messages wrong.
>> The RTM_GETLINK part seems to be ignored. I never receive the response
>> to that.
>>
>> My kernel is really old, 2.6.18 plus some montavista patches. (Running
>> on arm)
>> But it probably has to do with the way I send the request.
>>
>> How should it be done?
>>
>> Thank you very much for your help.
>> I started that code a long time ago, but left the macaddress stuff
>> broken so far, but now I need it and I don't even remember if I was sure
>> the way I coded it way back made any sense. :-/
>>
>>
> NLMSG_DONE is not a flag but a message type. You would need to
> send it as a separate message to end the multi message stream.
> You can find additional information on this in the libnl guide.
>
> However, I suggest you send each request separately to ease
> parsing of the response.
>
>
The parse part can deal with both types of responses very well.
Do you mean I should send the requests individually via send() and with
NLMSG_DONE?
Or assemble the request chain how I did with NLMSG_NEXT() and a empty or
rtgenmsg request with NLMSG_DONE at the end?
Thanks
Tilman
More information about the libnl
mailing list