From 60378318d3e614310a27d05f19a623e69605b3a2 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Sun, 29 Mar 2020 01:17:48 +0900 Subject: [PATCH] udpblaster: Fix build on macOS s6_addr is in standard. s6_addr16 is not. See RFC 2553. --- examples/udpblaster/udpblaster_host.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/examples/udpblaster/udpblaster_host.c b/examples/udpblaster/udpblaster_host.c index 67f3067d4..935f98f17 100644 --- a/examples/udpblaster/udpblaster_host.c +++ b/examples/udpblaster/udpblaster_host.c @@ -39,6 +39,7 @@ #include "config.h" +#include #include #include #include @@ -83,14 +84,23 @@ int main(int argc, char **argv, char **envp) #else target.sin6_family = AF_INET6; target.sin6_port = HTONS(UDPBLASTER_TARGET_PORTNO); - target.sin6_addr.s6_addr16[0] = HTONS(CONFIG_EXAMPLES_UDPBLASTER_TARGETIPv6_1); - target.sin6_addr.s6_addr16[1] = HTONS(CONFIG_EXAMPLES_UDPBLASTER_TARGETIPv6_2); - target.sin6_addr.s6_addr16[2] = HTONS(CONFIG_EXAMPLES_UDPBLASTER_TARGETIPv6_3); - target.sin6_addr.s6_addr16[3] = HTONS(CONFIG_EXAMPLES_UDPBLASTER_TARGETIPv6_4); - target.sin6_addr.s6_addr16[4] = HTONS(CONFIG_EXAMPLES_UDPBLASTER_TARGETIPv6_5); - target.sin6_addr.s6_addr16[5] = HTONS(CONFIG_EXAMPLES_UDPBLASTER_TARGETIPv6_6); - target.sin6_addr.s6_addr16[6] = HTONS(CONFIG_EXAMPLES_UDPBLASTER_TARGETIPv6_7); - target.sin6_addr.s6_addr16[7] = HTONS(CONFIG_EXAMPLES_UDPBLASTER_TARGETIPv6_8); + + *(uint16_t *)&target.sin6_addr.s6_addr[0] = + HTONS(CONFIG_EXAMPLES_UDPBLASTER_TARGETIPv6_1); + *(uint16_t *)&target.sin6_addr.s6_addr[2] = + HTONS(CONFIG_EXAMPLES_UDPBLASTER_TARGETIPv6_2); + *(uint16_t *)&target.sin6_addr.s6_addr[4] = + HTONS(CONFIG_EXAMPLES_UDPBLASTER_TARGETIPv6_3); + *(uint16_t *)&target.sin6_addr.s6_addr[6] = + HTONS(CONFIG_EXAMPLES_UDPBLASTER_TARGETIPv6_4); + *(uint16_t *)&target.sin6_addr.s6_addr[8] = + HTONS(CONFIG_EXAMPLES_UDPBLASTER_TARGETIPv6_5); + *(uint16_t *)&target.sin6_addr.s6_addr[10] = + HTONS(CONFIG_EXAMPLES_UDPBLASTER_TARGETIPv6_6); + *(uint16_t *)&target.sin6_addr.s6_addr[12] = + HTONS(CONFIG_EXAMPLES_UDPBLASTER_TARGETIPv6_7); + *(uint16_t *)&target.sin6_addr.s6_addr[14] = + HTONS(CONFIG_EXAMPLES_UDPBLASTER_TARGETIPv6_8); addrlen = sizeof(struct sockaddr_in6); sockfd = socket(PF_INET6, SOCK_DGRAM, 0);