Reputation: 5806
I am trying to create a BSD socket to listen for messages from a specific IPv6 multicast address. I currently have no problem creating the socket listening on the correct address 0::0.
The problem is that I am running on a small embedded linux server with multiple NICs; here the ipv6mr_interface field of the ipv6_mreq is important. By trial and error, I have determined that 0, 1 and 3 do not work, but 2, does (it gives me all IPv6 multicast messages to my address, ff05::3, arriving on the correct interface).
My question is: How do I correlate, in linux, my interface, whos' address I know, to the correct interface number?
Upvotes: 0
Views: 2542
Reputation: 31
maybe you can have a look to the if_nametoindex(3) function (seen in /usr/include/net/in.h).
Sincerely, Rémi
Upvotes: 3
Reputation: 5806
To summarize my comments on the original answer:
Presumably option 1 is the most robust since the proc filesystem can change how it's organized, what information is available and how it's formatted. I am not personally familiar with how often the Linux Kernel changes these attributes, so, someone with more information about this is welcome to comment or edit this post.
Upvotes: 0