From 3c0078582662e179bc1cbbf81086ed253fcbb2bf Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Thu, 9 Jun 2016 05:34:49 -0500 Subject: [PATCH] Added handling for already connected sockets in LWIPInterface::connect --- net/LWIPInterface/LWIPInterface.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/net/LWIPInterface/LWIPInterface.cpp b/net/LWIPInterface/LWIPInterface.cpp index 74cf9c1646..8e192cb8f8 100644 --- a/net/LWIPInterface/LWIPInterface.cpp +++ b/net/LWIPInterface/LWIPInterface.cpp @@ -94,6 +94,11 @@ static void set_mac_address(void) /* Interface implementation */ int LWIPInterface::connect() { + // Check if we've already connected + if (get_ip_address()) { + return 0; + } + // Set up network set_mac_address(); init_netif(0, 0, 0); @@ -118,18 +123,20 @@ int LWIPInterface::disconnect() dhcp_stop(&netif); eth_arch_disable_interrupts(); + ip_addr[0] = '\0'; + mac_addr[0] = '\0'; return 0; } const char *LWIPInterface::get_ip_address() { - return ip_addr; + return ip_addr[0] ? ip_addr : 0; } const char *LWIPInterface::get_mac_address() { - return mac_addr; + return mac_addr[0] ? mac_addr : 0; } struct lwip_socket {