diff options
author | Andreas Schneider <asn@samba.org> | 2014-06-03 15:02:17 +0200 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2014-06-05 23:57:10 +0200 |
commit | 0247bdbbc8a3b0ee5d0186a6a9f0d58e03469618 (patch) | |
tree | 23b6f279675468904db5b290e88ad28d28a49f7e /lib | |
parent | aa1e24ead4712728cdc3bdd46c5171b1ac12bd23 (diff) | |
download | samba-0247bdbbc8a3b0ee5d0186a6a9f0d58e03469618.tar.gz samba-0247bdbbc8a3b0ee5d0186a6a9f0d58e03469618.tar.xz samba-0247bdbbc8a3b0ee5d0186a6a9f0d58e03469618.zip |
swrap: Implement support for IP_RECVDSTADDR on BSD.
Pair-Programmed-With: Michael Adam <obnox@samba.org>
Signed-off-by: Andreas Schneider <asn@samba.org>
Signed-off-by: Michael Adam <obnox@samba.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/socket_wrapper/socket_wrapper.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/lib/socket_wrapper/socket_wrapper.c b/lib/socket_wrapper/socket_wrapper.c index 56d1d966a0a..7a0b63ca61f 100644 --- a/lib/socket_wrapper/socket_wrapper.c +++ b/lib/socket_wrapper/socket_wrapper.c @@ -125,6 +125,18 @@ enum swrap_dbglvl_e { # endif /* IPV6_RECVPKTINFO */ #endif /* IPV6_PKTINFO */ +/* + * On BSD IP_PKTINFO has a different name because during + * the time when they implemented it, there was no RFC. + * The name for IPv6 is the same as on Linux. + */ +#ifndef IP_PKTINFO +# ifdef IP_RECVDSTADDR +# define IP_PKTINFO IP_RECVDSTADDR +# endif +#endif + + #define SWRAP_DLIST_ADD(list,item) do { \ if (!(list)) { \ (item)->prev = NULL; \ @@ -3053,10 +3065,15 @@ static int swrap_msghdr_add_pktinfo(struct socket_info *si, { /* Add packet info */ switch (si->pktinfo) { -#if defined(IP_PKTINFO) && defined(HAVE_STRUCT_IN_PKTINFO) +#if defined(IP_PKTINFO) +/* && (defined(HAVE_STRUCT_IN_PKTINFO) || defined(IP_RECVDSTADDR)) */ case AF_INET: { struct sockaddr_in *sin; +#if defined(HAVE_STRUCT_IN_PKTINFO) struct in_pktinfo pkt; +#elif defined(IP_RECVDSTADDR) + struct in_addr pkt; +#endif if (si->bindname_len == sizeof(struct sockaddr_in)) { sin = (struct sockaddr_in*)si->bindname; @@ -3069,8 +3086,12 @@ static int swrap_msghdr_add_pktinfo(struct socket_info *si, ZERO_STRUCT(pkt); +#if defined(HAVE_STRUCT_IN_PKTINFO) pkt.ipi_ifindex = socket_wrapper_default_iface(); pkt.ipi_addr.s_addr = sin->sin_addr.s_addr; +#elif defined(IP_RECVDSTADDR) + pkt = sin->sin_addr; +#endif swrap_msghdr_add_cmsghdr(msg, IPPROTO_IP, IP_PKTINFO, &pkt, sizeof(pkt)); |