tests/lwip_sock_{i,ud}p: correctly get array address

We want the address of the start of the array.
This commit is contained in:
Martine Lenders 2018-10-16 12:07:03 +02:00
parent dfe03562a8
commit bf8ebbac81
2 changed files with 18 additions and 4 deletions

View File

@ -197,9 +197,16 @@ void _net_init(void)
netif_add(&netif, &netdev, lwip_netdev_init, tcpip_input);
#endif
#if LWIP_IPV6
static const uint8_t local6[] = _TEST_ADDR6_LOCAL;
static const uint8_t local6_a[] = _TEST_ADDR6_LOCAL;
/* XXX need to copy into a stack variable. Otherwise, when just using
* `local6_a` this leads to weird alignment problems on some platforms with
* netif_add_ip6_address() below */
ip6_addr_t local6;
s8_t idx;
netif_add_ip6_address(&netif, (ip6_addr_t *)&local6, &idx);
memcpy(&local6.addr, local6_a, sizeof(local6));
ip6_addr_clear_zone(&local6);
netif_add_ip6_address(&netif, &local6, &idx);
for (int i = 0; i <= idx; i++) {
netif.ip6_addr_state[i] |= IP6_ADDR_VALID;
}

View File

@ -199,9 +199,16 @@ void _net_init(void)
netif_add(&netif, &netdev, lwip_netdev_init, tcpip_input);
#endif
#if LWIP_IPV6
static const uint8_t local6[] = _TEST_ADDR6_LOCAL;
static const uint8_t local6_a[] = _TEST_ADDR6_LOCAL;
/* XXX need to copy into a stack variable. Otherwise, when just using
* `local6_a` this leads to weird alignment problems on some platforms with
* netif_add_ip6_address() below */
ip6_addr_t local6;
s8_t idx;
netif_add_ip6_address(&netif, (ip6_addr_t *)&local6, &idx);
memcpy(&local6.addr, local6_a, sizeof(local6));
ip6_addr_clear_zone(&local6);
netif_add_ip6_address(&netif, &local6, &idx);
for (int i = 0; i <= idx; i++) {
netif.ip6_addr_state[i] |= IP6_ADDR_VALID;
}