BOOL LWIP_SOCKETS_Driver::Uninitialize() { NATIVE_PROFILE_PAL_NETWORK(); PostAddressChangedContinuation.Abort(); PostAvailabilityOnContinuation.Abort(); PostAvailabilityOffContinuation.Abort(); for(int i=0; i<g_NetworkConfig.NetworkInterfaceCount; i++) { Network_Interface_Close(i); } tcpip_shutdown(); return TRUE; }
BOOL LWIP_SOCKETS_Driver::Uninitialize() { NATIVE_PROFILE_PAL_NETWORK(); lwip_uninit(); #if defined(NETWORK_USE_LOOPBACK) // close the loopback driver g_LOOPBACK_LWIP_Driver.Close(); #endif for(int i=0; i<g_NetworkConfig.NetworkInterfaceCount; i++) { Network_Interface_Close(i); } return TRUE; }
BOOL RTIP_SOCKETS_Driver::Uninitialize() { NATIVE_PROFILE_PAL_NETWORK(); const int c_exitTimeout = 1; // secs int exitRetries = 3; bool fEnabled = INTERRUPTS_ENABLED_STATE(); if(!fEnabled) ENABLE_INTERRUPTS(); while(exitRetries--) { if(!xn_wait_pkts_output( RTP_TRUE, c_exitTimeout * rtp_get_ticks_p_sec() )) break; while(HAL_CONTINUATION::Dequeue_And_Execute()); } if(!fEnabled) DISABLE_INTERRUPTS(); #if defined(NETWORK_USE_LOOPBACK) // close the loopback driver g_LOOPBACK_Driver.Close(); #endif for(int i=0; i<g_NetworkConfig.NetworkInterfaceCount; i++) { UpdateAdapterConfiguration(i, SOCK_NETWORKCONFIGURATION_UPDATE_DHCP_RELEASE, &g_NetworkConfig.NetworkInterfaces[i]); Network_Interface_Close(i); } rtp_net_exit(); return TRUE; }
HRESULT LWIP_SOCKETS_Driver::UpdateAdapterConfiguration( UINT32 interfaceIndex, UINT32 updateFlags, SOCK_NetworkConfiguration* config ) { NATIVE_PROFILE_PAL_NETWORK(); if(interfaceIndex >= NETWORK_INTERFACE_COUNT) { return CLR_E_INVALID_PARAMETER; } BOOL fEnableDhcp = (0 != (config->flags & SOCK_NETWORKCONFIGURATION_FLAGS_DHCP)); BOOL fDynamicDns = (0 != (config->flags & SOCK_NETWORKCONFIGURATION_FLAGS_DYNAMIC_DNS)); BOOL fDhcpStarted; struct netif *pNetIf = netif_find_interface(g_LWIP_SOCKETS_Driver.m_interfaces[interfaceIndex].m_interfaceNumber); if (NULL == pNetIf) { return CLR_E_FAIL; } fDhcpStarted = (0 != (pNetIf->flags & NETIF_FLAG_DHCP)); #if LWIP_DNS // when using DHCP do not use the static settings if(0 != (updateFlags & SOCK_NETWORKCONFIGURATION_UPDATE_DNS)) { if(!fDynamicDns && (config->dnsServer1 != 0 || config->dnsServer2 != 0)) { // user defined DNS addresses if(config->dnsServer1 != 0) { u8_t idx = 0; dns_setserver(idx, (struct ip_addr *)&config->dnsServer1); } if(config->dnsServer2 != 0) { u8_t idx = 1; dns_setserver(idx, (struct ip_addr *)&config->dnsServer2); } } } #endif #if LWIP_DHCP if(0 != (updateFlags & SOCK_NETWORKCONFIGURATION_UPDATE_DHCP)) { if(fEnableDhcp) { if(!fDhcpStarted) { if(ERR_OK != dhcp_start(pNetIf)) { return CLR_E_FAIL; } } } else { if(fDhcpStarted) { dhcp_stop(pNetIf); } netif_set_addr(pNetIf, (struct ip_addr *) &config->ipaddr, (struct ip_addr *)&config->subnetmask, (struct ip_addr *)&config->gateway); Network_PostEvent( NETWORK_EVENT_TYPE_ADDRESS_CHANGED, 0 ); } } if(fEnableDhcp && fDhcpStarted) { // Try Renew before release since renewing after release will fail if(0 != (updateFlags & SOCK_NETWORKCONFIGURATION_UPDATE_DHCP_RENEW)) { //netifapi_netif_common(pNetIf, NULL, dhcp_renew); dhcp_renew(pNetIf); } else if(0 != (updateFlags & SOCK_NETWORKCONFIGURATION_UPDATE_DHCP_RELEASE)) { //netifapi_netif_common(pNetIf, NULL, dhcp_release); dhcp_release(pNetIf); } } #endif if(0 != (updateFlags & SOCK_NETWORKCONFIGURATION_UPDATE_MAC)) { int len = __min(config->macAddressLen, sizeof(pNetIf->hwaddr)); memcpy(pNetIf->hwaddr, config->macAddressBuffer, len); pNetIf->hwaddr_len = len; // mac address requires stack re-init Network_Interface_Close(interfaceIndex); g_LWIP_SOCKETS_Driver.m_interfaces[interfaceIndex].m_interfaceNumber = Network_Interface_Open(interfaceIndex); } return S_OK; }