diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ChangeLog | 5 | ||||
-rw-r--r-- | lib/sockopt.h | 39 |
2 files changed, 37 insertions, 7 deletions
diff --git a/lib/ChangeLog b/lib/ChangeLog index 514f47a1..7c372df3 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,8 @@ +2004-08-26 Greg Troxel <gdt@fnord.ir.bbn.com> + + * sockopt.h: Define method-independent macro for callers of + get_ifindex to use for cmsg length. + 2004-08-19 Paul Jakma <paul@dishone.st> * zebra.h: add MAX and MIN defines (eg for ospf6d) diff --git a/lib/sockopt.h b/lib/sockopt.h index b7aa1b3a..cd797182 100644 --- a/lib/sockopt.h +++ b/lib/sockopt.h @@ -31,25 +31,46 @@ int setsockopt_ipv6_hoplimit (int, int); int setsockopt_ipv6_multicast_loop (int, int); #endif /* HAVE_IPV6 */ -#if defined (IP_PKTINFO) +/* + * It is OK to reference in6_pktinfo here without a protecting #if + * because this macro will only be used #if HAVE_IPV6, and in6_pktinfo + * is not optional for HAVE_IPV6. + */ +#define SOPT_SIZE_CMSG_PKTINFO_IPV6() (sizeof (struct in6_pktinfo)); +/* + * Size defines for control messages used to get ifindex. We define + * values for each method, and define a macro that can be used by code + * that is unaware of which method is in use. + * XXX Needs to use CMSG_DATA and CMSG_ALIGN. + */ +#if defined (IP_PKTINFO) +/* Linux in_pktinfo. */ #define SOPT_SIZE_CMSG_PKTINFO_IPV4() (sizeof (struct in_pktinfo)) -#define SOPT_SIZE_CMSG_IFINDEX_IPV4 SOPT_SIZE_CMSG_PKTINFO_IPV4 + +/* XXX This should perhaps be defined even if IP_PKTINFO is not. */ #define SOPT_SIZE_CMSG_PKTINFO(af) \ ((af == AF_INET) ? SOPT_SIZE_CMSG_PKTINFO_IPV4() \ : SOPT_SIZE_CMSG_PKTINFO_IPV6() +#define SOPT_SIZE_CMSG_IFINDEX_IPV4() SOPT_SIZE_CMSG_PKTINFO_IPV4 + #elif defined (IP_RECVIF) +/* BSD/Solaris. Arguably these should say RECVIF rather than IFINDEX. */ + #if defined (SUNOS_5) #define SOPT_SIZE_CMSG_IFINDEX_IPV4() (sizeof (uint_t)) #else -#define SOPT_SIZE_CMSG_IFINDEX_IPV4() (sizeof (struct sockaddr_dl)) +#define SOPT_SIZE_CMSG_IFINDEX_IPV4() \ + __CMSG_ALIGN((sizeof (struct sockaddr_dl))) #endif /* SUNOS_5 */ #endif -#define SOPT_SIZE_CMSG_PKTINFO_IPV6() (sizeof (struct in6_pktinfo)); - +/* + * AF-parameterized message size. + * XXX Why is this here? Is it used? The v6 case is not defined. + */ #define SOPT_SIZE_CMSG_IFINDEX(af) \ ((af == AF_INET) ? SOPT_SIZE_CMSG_IFINDEX_IPV4() \ : SOPT_SIZE_CMSG_IFINDEX_IPV6() @@ -60,9 +81,13 @@ int setsockopt_multicast_ipv4(int sock, unsigned int mcast_addr, unsigned int ifindex); -#if defined (IP_PKTINFO) +/* + * XXX Exactly what is this an interface to? Specifically, what calls + * can be made after calling it? + */ int setsockopt_pktinfo (int, int, int); -#endif + +/* Ask for, and get, ifindex, by whatever method is supported. */ int setsockopt_ifindex (int, int, int); int getsockopt_ifindex (int, struct msghdr *); #endif /*_ZEBRA_SOCKOPT_H */ |