Get multicast addresses from interface
Hello, How can a user process get IPv6 multicast addresses of ethernet interfaces? I have FreeBSD 5.2.1 and get interface addresses via ioctl(SIOCGIFCONF) or sysctl(witch NET_RT_IFLIST), but all returned addresses are unicast. In net/if.h there is a struct ifma_msghdr: /* * Message format for use in obtaining information about multicast addresses * from the routing socket */ struct ifma_msghdr { u_short ifmam_msglen; /* to skip over non-understood messages */ u_char ifmam_version; /* future binary compatibility */ u_char ifmam_type; /* message type */ int ifmam_addrs;/* like rtm_addrs */ int ifmam_flags;/* value of ifa_flags */ u_short ifmam_index;/* index for associated ifp */ }; How it may be used? Regards, Grigory Klyuchnikov. ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Get multicast addresses from interface
On Thu, Oct 14, 2004 at 05:44:57PM +0400, Grigory Klyuchnikov wrote: Hello, How can a user process get IPv6 multicast addresses of ethernet interfaces? I have FreeBSD 5.2.1 and get interface addresses via ioctl(SIOCGIFCONF) or sysctl(witch NET_RT_IFLIST), but all returned addresses are unicast. getifaddrs(3) and getifmaddrs(3) may do what you want. In net/if.h there is a struct ifma_msghdr: /* * Message format for use in obtaining information about multicast addresses * from the routing socket */ struct ifma_msghdr { u_short ifmam_msglen; /* to skip over non-understood messages */ u_char ifmam_version; /* future binary compatibility */ u_char ifmam_type; /* message type */ int ifmam_addrs;/* like rtm_addrs */ int ifmam_flags;/* value of ifa_flags */ u_short ifmam_index;/* index for associated ifp */ }; How it may be used? In addition to the functions above, you can directly access these structures via sysctl (see src/lib/libc/net/getifmaddrs.c for an example). -- Brooks -- Any statement of the form X is the one, true Y is FALSE. PGP fingerprint 655D 519C 26A7 82E7 2529 9BF0 5D8E 8BE9 F238 1AD4 pgpXgCxZPPbXl.pgp Description: PGP signature
Re: Get multicast addresses from interface
On Thu, Oct 14, 2004 at 08:01:49AM -0700, Brooks Davis wrote: On Thu, Oct 14, 2004 at 05:44:57PM +0400, Grigory Klyuchnikov wrote: How can a user process get IPv6 multicast addresses of ethernet interfaces? I have FreeBSD 5.2.1 and get interface addresses via ioctl(SIOCGIFCONF) or sysctl(witch NET_RT_IFLIST), but all returned addresses are unicast. getifaddrs(3) and getifmaddrs(3) may do what you want. See http://people.freebsd.org/~bms/dump/mcastlist/ for the original code (harti@ submitted most of the kernel bits). I didn't specifically set out to test getifmaddrs(3) with AF_INET6 addresses when I wrote it, but I seem to recall that it should work with them, from testing. If not, please feel free to submit a PR with a patch. Thanks, BMS pgpfeYl0of2Ky.pgp Description: PGP signature