rtnetlink (route netlink)
I started to work on a network manager with IPv6 for some private project
when I ran into a new problem: "Fetching all IPv6 addresses". When using IPv4,
this was simple:
"Use ioctl SIOCGIFCONF defined in #include <linux/sockios.h>".
IPv6 however uses much more space when transfering a single address, so instead of
adding more ioctl calls, they started to use a new interface instead. A netlink socket
of the type routing. This connection is simple to create:
int fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
So I started to read up what I could find of documentation. This includes man-pages and linux kernel documentation:
netlink(3)
netlink(7)
rtnetlink(3)
rtnetlink(7)
ip(7)
raw(7)
But that did not actually enlighten me much. After spending lots of time on
google I found some example, but non of them were 100% correct and reliable. So I ended
up modifying the one I liked the most:
if_show.c