Efficient way to get IPs attached to a specific interface by index / if_index
2
votes
0
answers
120
views
I am interested in getting the associated IPs with an interface, but by if_index, because all I actually have is an
ipi6_ifindex
from IPV6_PKTINFO
/ IPV6_RECVPKTINFO
. I could use getifaddrs
but, that would return struct ifaddrs
which only has an ifa_name
so I'd have to get the name and do a bunch of string comparisons, and it is particularly expensive to boot.
I already have the ifindex
, so it feels like there should be an efficient way to get the addresses associated with the device. But I can't find any solution.
Asked by Charles Lohr
(133 rep)
Jun 7, 2024, 04:23 AM