mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
pkg/lwip: Implement getting option NETOPT_IPV6_ADDR
This commit is contained in:
parent
ebdcccbd99
commit
8796293c5a
@ -13,6 +13,7 @@
|
||||
*
|
||||
* @file
|
||||
* @author Benjamin Valentin <benjamin.valentin@ml-pa.com>
|
||||
* @author Erik Ekman <eekman@google.com>
|
||||
*/
|
||||
|
||||
#include "fmt.h"
|
||||
@ -32,4 +33,37 @@ int netif_get_name(netif_t *iface, char *name)
|
||||
return res;
|
||||
}
|
||||
|
||||
int netif_get_opt(netif_t *iface, netopt_t opt, uint16_t context,
|
||||
void *value, size_t max_len)
|
||||
{
|
||||
(void)context;
|
||||
lwip_netif_t *lwip_netif = (lwip_netif_t*) iface;
|
||||
struct netif *netif = &lwip_netif->lwip_netif;
|
||||
int res = -ENOTSUP;
|
||||
switch (opt) {
|
||||
#ifdef MODULE_LWIP_IPV6
|
||||
case NETOPT_IPV6_ADDR: {
|
||||
assert(max_len >= sizeof(ipv6_addr_t));
|
||||
ipv6_addr_t *tgt = value;
|
||||
|
||||
res = 0;
|
||||
for (unsigned i = 0;
|
||||
((res + sizeof(ipv6_addr_t)) <= max_len) &&
|
||||
(i < LWIP_IPV6_NUM_ADDRESSES);
|
||||
i++) {
|
||||
if (netif_ip6_addr_state(netif, i) != IP6_ADDR_INVALID) {
|
||||
memcpy(tgt, &(netif_ip6_addr(netif, i)->addr), sizeof(ipv6_addr_t));
|
||||
res += sizeof(ipv6_addr_t);
|
||||
tgt++;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/** @} */
|
||||
|
Loading…
Reference in New Issue
Block a user