summaryrefslogtreecommitdiffstats
path: root/lib/sockopt.h
diff options
context:
space:
mode:
authorpaul <paul>2004-07-23 17:11:07 +0200
committerpaul <paul>2004-07-23 17:11:07 +0200
commit4f7baa0e434053c9f9a70f526be1514ea47cd274 (patch)
tree656c9850fa836fd99a2637bc126148536000ed87 /lib/sockopt.h
parent2004-07-14 Paul Jakma <paul@dishone.st> (diff)
downloadfrr-4f7baa0e434053c9f9a70f526be1514ea47cd274.tar.xz
frr-4f7baa0e434053c9f9a70f526be1514ea47cd274.zip
2004-07-23 Paul Jakma <paul@dishone.st>
* sockopt.h: Add SOPT_SIZE_CMSG_PKTINFO{_IPV{4,6}} define, for sizeof pktinfo as appropriate, to be used when allocating msg buffers. export setsockopt_pktinfo() and getsockopt_pktinfo_ifindex() * sockopt.c: (setsockopt_pktinfo_ifindex) new function to portably set received ifindex sock option. (getsockopt_pktinfo_ifindex) portably retrieve ifindex. (getsockopt_cmsg_data) retrieve indicated control info from message header. (getsockopt_ipv6_pktinfo_ifindex) ipv6 version of above. (setsockopt_ipv4_pktinfo) v4 version (setsockopt_pktinfo) the exported version (getsockopt_ipv4_pktinfo_ifindex) v4 specific version (getsockopt_pktinfo_ifindex) the exported version
Diffstat (limited to 'lib/sockopt.h')
-rw-r--r--lib/sockopt.h20
1 files changed, 18 insertions, 2 deletions
diff --git a/lib/sockopt.h b/lib/sockopt.h
index 7fb31c186..c5d171c25 100644
--- a/lib/sockopt.h
+++ b/lib/sockopt.h
@@ -31,11 +31,27 @@ int setsockopt_ipv6_hoplimit (int, int);
int setsockopt_ipv6_multicast_loop (int, int);
#endif /* HAVE_IPV6 */
+#if defined (IP_PKTINFO)
+#define SOPT_SIZE_CMSG_PKTINFO_IPV4() (sizeof (struct in_pktinfo))
+#elif defined (IP_RECVIF)
+#if defined (SUNOS_5)
+#define SOPT_SIZE_CMSG_PKTINFO_IPV4() (sizeof (uint_t))
+#else
+#define SOPT_SIZE_CMSG_PKTINFO_IPV4() (sizeof (struct sockaddr_dl))
+#endif /* SUNOS_5 */
+#endif
+
+#define SOPT_SIZE_CMSG_PKTINFO_IPV6() (sizeof (struct in6_pktinfo));
+
+#define SOPT_SIZE_CMSG_PKTINFO(af) \
+ ((af == AF_INET) ? SOPT_SIZE_CMSG_PKTINFO_IPV4() \
+ : SOPT_SIZE_CMSG_PKTINFO_IPV6()
+
int setsockopt_multicast_ipv4(int sock,
int optname,
struct in_addr if_addr,
unsigned int mcast_addr,
unsigned int ifindex);
-
-
+int setsockopt_pktinfo (int, int, int);
+int getsockopt_pktinfo_ifindex (int, struct msghdr *);
#endif /*_ZEBRA_SOCKOPT_H */