aboutsummaryrefslogtreecommitdiff
path: root/tests/echo_srv.c
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2014-05-23 14:36:23 +0200
committerAndreas Schneider <asn@samba.org>2014-05-26 16:45:16 +0200
commitc9b06b39df767539e47da8b6ce2208a5463a5314 (patch)
treec85540f26c5c99180d3bc57a61c2f5ab1caaed4c /tests/echo_srv.c
parent27be91da8fbb56826c361abd67ebb1e081540bfe (diff)
downloadsocket_wrapper-c9b06b39df767539e47da8b6ce2208a5463a5314.tar.gz
socket_wrapper-c9b06b39df767539e47da8b6ce2208a5463a5314.tar.xz
socket_wrapper-c9b06b39df767539e47da8b6ce2208a5463a5314.zip
echo_srv: Add support for IP_SENDSRCADDR.
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 'tests/echo_srv.c')
-rw-r--r--tests/echo_srv.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/tests/echo_srv.c b/tests/echo_srv.c
index 3d53994..88d8170 100644
--- a/tests/echo_srv.c
+++ b/tests/echo_srv.c
@@ -730,9 +730,13 @@ static ssize_t echo_udp_send_to_from(int sock,
msg.msg_controllen = 0;
switch (from->sa_family) {
-#ifdef IP_PKTINFO
+#if defined(IP_PKTINFO) || defined(IP_SENDSRCADDR)
case AF_INET: {
+#ifdef IP_PKTINFO
struct in_pktinfo *p = (struct in_pktinfo *)CMSG_DATA(cmsgptr);
+#elif defined(IP_SENDSRCADDR)
+ struct in_addr *p = (struct in_addr *)CMSG_DATA(cmsgptr);
+#endif
const struct sockaddr_in *from4 = (const struct sockaddr_in *)from;
if (fromlen != sizeof(struct sockaddr_in)) {
@@ -740,16 +744,20 @@ static ssize_t echo_udp_send_to_from(int sock,
}
cmsgptr->cmsg_level = IPPROTO_IP;
+#ifdef IP_PKTINFO
cmsgptr->cmsg_type = IP_PKTINFO;
- cmsgptr->cmsg_len = CMSG_LEN(sizeof(struct in_pktinfo));
-
p->ipi_spec_dst = from4->sin_addr;
+#elif defined(IP_SENDSRCADDR)
+ cmsgptr->cmsg_type = IP_SENDSRCADDR;
+ *p = from4->sin_addr;
+#endif
+ cmsgptr->cmsg_len = CMSG_LEN(sizeof(*p));
- msg.msg_controllen = CMSG_SPACE(sizeof(struct in_pktinfo));
+ msg.msg_controllen = CMSG_SPACE(sizeof(*p));
break;
}
-#endif /* IP_PKTINFO */
+#endif /* IP_PKTINFO || IP_SENDSRCADDR */
#ifdef IPV6_PKTINFO
case AF_INET6: {
struct in6_pktinfo *p = (struct in6_pktinfo *)CMSG_DATA(cmsgptr);