udpblaster: Fix build on macOS

s6_addr is in standard. s6_addr16 is not.
See RFC 2553.
This commit is contained in:
YAMAMOTO Takashi 2020-03-29 01:17:48 +09:00 committed by Xiang Xiao
parent 5c9df7bc7a
commit 60378318d3

View File

@ -39,6 +39,7 @@
#include "config.h"
#include <stdint.h>
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
@ -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);