diff --git a/features/net/FEATURE_IPV4/lwip-interface/LWIPIPStack.cpp b/features/net/FEATURE_IPV4/lwip-interface/LWIPIPStack.cpp index 61a2f9f085..624fbb0924 100644 --- a/features/net/FEATURE_IPV4/lwip-interface/LWIPIPStack.cpp +++ b/features/net/FEATURE_IPV4/lwip-interface/LWIPIPStack.cpp @@ -34,6 +34,16 @@ void IPStackInterface::bringdown() lwip_bringdown(); } +int IPStackInterface::start_dhcp(uint timeout) +{ + return lwip_start_dhcp(timeout); +} + +int IPStackINterface::start_static_ip(const char *ip, const char *netmask, const char *gw) +{ + return lwip_start_static_ip(); +} + const char * IPStackInterface::get_mac_address() { return lwip_get_mac_address(); diff --git a/features/net/FEATURE_IPV4/lwip-interface/lwip_stack.c b/features/net/FEATURE_IPV4/lwip-interface/lwip_stack.c index fdd5a1666a..fedefc9b49 100644 --- a/features/net/FEATURE_IPV4/lwip-interface/lwip_stack.c +++ b/features/net/FEATURE_IPV4/lwip-interface/lwip_stack.c @@ -403,7 +403,7 @@ int lwip_bringup(emac_interface_t *emac, bool dhcp, const char *ip, const char * } // Zero out socket set - lwip_arena_init(); + lwip_arena_init(15000); #if LWIP_IPV6 netif_create_ip6_linklocal_address(&lwip_netif, 1/*from MAC*/); @@ -510,10 +510,6 @@ int lwip_bringdown(void) } #endif - lwip_connected = false; - // TO DO - actually remove addresses from stack, and shut down properly - return 0; -} /* LWIP error remapping */ static int lwip_err_remap(err_t err) { diff --git a/features/net/network-socket/IPStackInterface.h b/features/net/network-socket/IPStackInterface.h index 7ad239eefb..88c3a63bed 100644 --- a/features/net/network-socket/IPStackInterface.h +++ b/features/net/network-socket/IPStackInterface.h @@ -43,6 +43,24 @@ public: */ virtual void bringdown(); + /** + * Sends the dhcp request + * + * @param timeout Request timeout in ms + * @return NSAPI_ERROR_OK in case of success, error code otherwise + */ + virtual int start_dhcp(uint timeout = 15000); + + /** + * Starts the interface with static IP + * + * @param ip Static IP to use (in XYZ.XYZ.XYZ.XYZ format) + * @param netmask Network mask to use (in XYZ.XYZ.XYZ.XYZ format) + * @param gw Gateway IP address (in XYZ.XYZ.XYZ.XYZ format) + * @return NSAPI_ERROR_OK in case of success, error code otherwise + */ + virtual int start_static_ip(const char *ip, const char *netmask, const char *gw); + /** * Returns MAC address *