Skip to content

Commit

Permalink
pkg/lwip: netif_set_opt for IPv4 address
Browse files Browse the repository at this point in the history
  • Loading branch information
krzysztof-cabaj committed Oct 6, 2023
1 parent 62d8315 commit c6f74d9
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion pkg/lwip/contrib/_netif.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
#include "lwip/netif/compat.h"
#include "net/netif.h"

#include <lwip/netif/compat.h>
//#include <arpa/inet.h>

int netif_get_name(netif_t *iface, char *name)
{
lwip_netif_t *lwip_netif = (lwip_netif_t*) iface;
Expand Down Expand Up @@ -80,7 +83,30 @@ int netif_set_opt(netif_t *iface, netopt_t opt, uint16_t context,
(void)value;
(void)value_len;

return -ENOTSUP;
int res = -ENOTSUP;

switch (opt) {
#ifdef MODULE_LWIP_IPV4
case NETOPT_IPV4_ADDR: {
lwip_netif_t *lwip_netif = (lwip_netif_t*) iface;
struct netif *netif = &lwip_netif->lwip_netif;
ip4_addr_t ip, subnet, gw;

res = 0;
memcpy((void*)&(ip.addr), value, value_len);
//ToDO: get current value
subnet.addr = 0x00ffffff;
gw.addr = 0x00000000;

netif_set_addr(netif, &ip, &subnet, &gw);
}
break;
#endif

default:
break;
}
return res;
}

/** @} */

0 comments on commit c6f74d9

Please sign in to comment.