From: Roy Marples Date: Thu, 7 Dec 2017 21:12:43 +0000 (+0000) Subject: bsd: set sa_len X-Git-Tag: v7.0.0~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4356c648096d47defc5b68303fd7808dac9fe1cb;p=thirdparty%2Fdhcpcd.git bsd: set sa_len --- diff --git a/src/dhcp.c b/src/dhcp.c index 44d99fe2..283b4034 100644 --- a/src/dhcp.c +++ b/src/dhcp.c @@ -1689,10 +1689,7 @@ dhcp_sendudp(struct interface *ifp, struct in_addr *to, void *data, size_t len) { int s; struct msghdr msg; - union { - struct sockaddr sa; - struct sockaddr_in sin; - } sto; + struct sockaddr_in sin; struct iovec iov[1]; ssize_t r; #ifdef IP_PKTINFO @@ -1704,14 +1701,17 @@ dhcp_sendudp(struct interface *ifp, struct in_addr *to, void *data, size_t len) iov[0].iov_base = data; iov[0].iov_len = len; - memset(&sto, 0, sizeof(sto)); - sto.sin.sin_family = AF_INET; - sto.sin.sin_addr = *to; - sto.sin.sin_port = htons(BOOTPS); + memset(&sin, 0, sizeof(sin)); + sin.sin_family = AF_INET; + sin.sin_addr = *to; + sin.sin_port = htons(BOOTPS); +#ifdef HAVE_SA_LEN + sin.sin_len = sizeof(sin); +#endif memset(&msg, 0, sizeof(msg)); - msg.msg_name = (void *)&sto.sa; - msg.msg_namelen = sizeof(sto); + msg.msg_name = (void *)&sin; + msg.msg_namelen = sizeof(sin); msg.msg_iov = iov; msg.msg_iovlen = 1; diff --git a/src/dhcp6.c b/src/dhcp6.c index fb73d3b9..a2252e38 100644 --- a/src/dhcp6.c +++ b/src/dhcp6.c @@ -1099,7 +1099,7 @@ dhcp6_sendmessage(struct interface *ifp, void (*callback)(void *)) memset(&dst, 0, sizeof(dst)); dst.sin6_family = AF_INET6; dst.sin6_port = htons(DHCP6_SERVER_PORT); -#ifdef SIN6_LEN +#ifdef HAVE_SA_LEN dst.sin6_len = sizeof(dst); #endif diff --git a/src/ipv6nd.c b/src/ipv6nd.c index a4bae15b..a7a2902a 100644 --- a/src/ipv6nd.c +++ b/src/ipv6nd.c @@ -286,7 +286,7 @@ ipv6nd_sendrsprobe(void *arg) memset(&dst, 0, sizeof(dst)); dst.sin6_family = AF_INET6; -#ifdef SIN6_LEN +#ifdef HAVE_SA_LEN dst.sin6_len = sizeof(dst); #endif dst.sin6_scope_id = ifp->index;