/**The IP address will be 0.0.0.0 after performing a release. * * \note If communication is disabled, when calling release, * a release message will not be sent to the DHCP server. */ void RTIPDHCPClient::release() { msemaphore.enter(); IPAddress nulladdr(0,0,0,0); if (!mcomdisabled && mlinkstatus) { if (xn_dhcp_release(&msession)) { handleError(0); } } mgotlease = false; mleasetime = 0; mleasegone = 0; mrenewtime = 0; mrebindtime = 0; mipaddress = nulladdr; msubnetmask = nulladdr; mdefaultgateway = nulladdr; mprimarydns = nulladdr; msecondarydns = nulladdr; gotNewLease(); msemaphore.exit(); }
HRESULT RTIP_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)); if(0 != (updateFlags & SOCK_NETWORKCONFIGURATION_UPDATE_DHCP)) { if(fEnableDhcp) { DHCP_conf reg_conf; memset(®_conf, 0, sizeof(reg_conf)); memset(&g_RTIP_SOCKETS_Driver.m_interfaces[interfaceIndex].m_currentDhcpSession, 0, sizeof(DHCP_session)); xn_dhcp_init_conf(®_conf); g_RTIP_SOCKETS_Driver.m_interfaces[interfaceIndex].m_currentDhcpSession.packet_style = DHCP_MICROSOFT; if (SOCK_SOCKET_ERROR == xn_dhcp(g_RTIP_SOCKETS_Driver.m_interfaces[interfaceIndex].m_interfaceNumber, &g_RTIP_SOCKETS_Driver.m_interfaces[interfaceIndex].m_currentDhcpSession, ®_conf)) { DEBUG_HANDLE_SOCKET_ERROR("update cfg: xn_dhcp", FALSE); return CLR_E_FAIL; } } else { if(SOCK_SOCKET_ERROR == rtp_net_set_ip(g_RTIP_SOCKETS_Driver.m_interfaces[interfaceIndex].m_interfaceNumber, (RTP_PFUINT8)&config->ipaddr, (RTP_PFUINT8)&config->subnetmask)) { DEBUG_HANDLE_SOCKET_ERROR("update cfg: rtp_net_set_ip", FALSE); return CLR_E_FAIL; } UINT32 destMask = SOCK_MAKE_IP_ADDR_LITTLEEND(0,0,0,0); if(SOCK_SOCKET_ERROR == xn_rt_add((RTP_PFUINT8)RT_DEFAULT, (RTP_PFUINT8)&destMask, (RTP_PFUINT8)&config->gateway, RT_USEIFACEMETRIC, g_RTIP_SOCKETS_Driver.m_interfaces[interfaceIndex].m_interfaceNumber, RT_INF)) { DEBUG_HANDLE_SOCKET_ERROR("update cfg: xn_rt_add", FALSE); return FALSE; } } } if(fEnableDhcp) { if(0 != (updateFlags & SOCK_NETWORKCONFIGURATION_UPDATE_DHCP_RELEASE)) { if(g_RTIP_SOCKETS_Driver.m_interfaces[interfaceIndex].m_currentDhcpSession.client_ip != 0) { if(SOCK_SOCKET_ERROR == xn_dhcp_release(&g_RTIP_SOCKETS_Driver.m_interfaces[interfaceIndex].m_currentDhcpSession)) { DEBUG_HANDLE_SOCKET_ERROR("update cfg: xn_dhcp_release", FALSE); /*return CLR_E_FAIL;*/ } } memset(&g_RTIP_SOCKETS_Driver.m_interfaces[interfaceIndex].m_currentDhcpSession, 0, sizeof(DHCP_session)); } if(0 != (updateFlags & SOCK_NETWORKCONFIGURATION_UPDATE_DHCP_RENEW)) { DHCP_conf reg_conf; xn_dhcp_init_conf(®_conf); g_RTIP_SOCKETS_Driver.m_interfaces[interfaceIndex].m_currentDhcpSession.packet_style = DHCP_MICROSOFT; if (SOCK_SOCKET_ERROR == xn_dhcp(g_RTIP_SOCKETS_Driver.m_interfaces[interfaceIndex].m_interfaceNumber, &g_RTIP_SOCKETS_Driver.m_interfaces[interfaceIndex].m_currentDhcpSession, ®_conf)) { DEBUG_HANDLE_SOCKET_ERROR("update cfg: xn_dhcp", FALSE); return CLR_E_FAIL; } } } // when using DHCP do not use the static settings else if(0 != (updateFlags & SOCK_NETWORKCONFIGURATION_UPDATE_DNS)) { if(config->dnsServer1 != 0 || config->dnsServer2 != 0) { xn_set_server_list( NULL, 0); // add the DNS servers of the config if( config->dnsServer1 != 0) { RTP_PFCUINT8 dns1 = (RTP_PFCUINT8)&(config->dnsServer1); if (SOCK_SOCKET_ERROR == xn_add_dns_server( dns1 )) { DEBUG_HANDLE_SOCKET_ERROR("update cfg: xn_add_dns_server(1)", FALSE); } } if( config->dnsServer2 != 0) { RTP_PFCUINT8 dns2 = (RTP_PFCUINT8)&(config->dnsServer2); if (SOCK_SOCKET_ERROR == xn_add_dns_server( dns2 )) { DEBUG_HANDLE_SOCKET_ERROR("update cfg: xn_add_dns_server(2)", FALSE); } } } } if(0 != (updateFlags & SOCK_NETWORKCONFIGURATION_UPDATE_MAC)) { // mac address requires stack re-init Network_Uninitialize(); Network_Initialize(); } if(0 != (config->flags & SOCK_NETWORKCONFIGURATION_FLAGS_DYNAMIC_DNS)) { // the rtip stack doesn't support dynamic dns return CLR_E_NOT_SUPPORTED; } return S_OK; }