tcpblaster: 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-30 14:56:01 +09:00 committed by Xiang Xiao
parent 5f91364d44
commit 7e6e19d80c
2 changed files with 13 additions and 10 deletions

View File

@ -104,8 +104,7 @@ void tcpblaster_client(void)
#ifdef CONFIG_EXAMPLES_TCPBLASTER_IPv6
server.sin6_family = AF_INET6;
server.sin6_port = HTONS(CONFIG_EXAMPLES_TCPBLASTER_SERVER_PORTNO);
memcpy(server.sin6_addr.s6_addr16,
g_tcpblasterserver_ipv6, 8 * sizeof(uint16_t));
memcpy(server.sin6_addr.s6_addr, g_tcpblasterserver_ipv6, 16);
addrlen = sizeof(struct sockaddr_in6);
printf("Connecting to IPv6 Address: "

View File

@ -118,19 +118,23 @@ void tcpblaster_server(void)
myaddr.sin6_family = AF_INET6;
myaddr.sin6_port = HTONS(CONFIG_EXAMPLES_TCPBLASTER_SERVER_PORTNO);
#if defined(CONFIG_EXAMPLES_TCPBLASTER_LOOPBACK) && !defined(CONFIG_NET_LOOPBACK)
memcpy(myaddr.sin6_addr.s6_addr16,
g_tcpblasterserver_ipv6, 8 * sizeof(uint16_t));
memcpy(myaddr.sin6_addr.s6_addr, g_tcpblasterserver_ipv6, 16);
#else
memset(myaddr.sin6_addr.s6_addr16, 0, 8 * sizeof(uint16_t));
memset(myaddr.sin6_addr.s6_addr, 0, 16);
#endif
addrlen = sizeof(struct sockaddr_in6);
printf("Binding to IPv6 Address: "
"%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n",
myaddr.sin6_addr.s6_addr16[0], myaddr.sin6_addr.s6_addr16[1],
myaddr.sin6_addr.s6_addr16[2], myaddr.sin6_addr.s6_addr16[3],
myaddr.sin6_addr.s6_addr16[4], myaddr.sin6_addr.s6_addr16[5],
myaddr.sin6_addr.s6_addr16[6], myaddr.sin6_addr.s6_addr16[7]);
"%02x%02x:%02x%02x:%02x%02x:%02x%02x:"
"%02x%02x:%02x%02x:%02x%02x:%02x%02x\n",
myaddr.sin6_addr.s6_addr[0], myaddr.sin6_addr.s6_addr[1],
myaddr.sin6_addr.s6_addr[2], myaddr.sin6_addr.s6_addr[3],
myaddr.sin6_addr.s6_addr[4], myaddr.sin6_addr.s6_addr[5],
myaddr.sin6_addr.s6_addr[6], myaddr.sin6_addr.s6_addr[7],
myaddr.sin6_addr.s6_addr[8], myaddr.sin6_addr.s6_addr[9],
myaddr.sin6_addr.s6_addr[10], myaddr.sin6_addr.s6_addr[11],
myaddr.sin6_addr.s6_addr[12], myaddr.sin6_addr.s6_addr[13],
myaddr.sin6_addr.s6_addr[14], myaddr.sin6_addr.s6_addr[15]);
#else
myaddr.sin_family = AF_INET;
myaddr.sin_port = HTONS(CONFIG_EXAMPLES_TCPBLASTER_SERVER_PORTNO);