|
|
@ -4511,7 +4511,23 @@ void CPhoneDevice::SetStaticIp()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (m_network != NULL)
|
|
|
|
if (m_network != NULL)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
SetStaticIp(m_network->iface, m_network->ip, m_network->netmask, m_network->gateway);
|
|
|
|
unsigned int ip = 0;
|
|
|
|
|
|
|
|
unsigned int netMask = 0;
|
|
|
|
|
|
|
|
unsigned int gateway = 0;
|
|
|
|
|
|
|
|
std::string ipStr = m_network->ip;
|
|
|
|
|
|
|
|
if (GetNetInfo("eth0", ip, netMask, gateway))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// const
|
|
|
|
|
|
|
|
sockaddr_in addrIn = { AF_INET, 0, ip};
|
|
|
|
|
|
|
|
char buf[32] = { 0 };
|
|
|
|
|
|
|
|
inet_ntop(AF_INET, &addrIn.sin_addr, buf, sizeof(buf));//其中recvAddr为SOCKADDR_IN类型
|
|
|
|
|
|
|
|
if (strcmp(ipStr.c_str(), buf) == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ipStr = "0.0.0.0";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SetStaticIp(m_network->iface, ipStr, m_network->netmask, m_network->gateway);
|
|
|
|
XYLOG(XYLOG_SEVERITY_INFO, "Set Static IP on %s: %s", m_network->iface.c_str(),
|
|
|
|
XYLOG(XYLOG_SEVERITY_INFO, "Set Static IP on %s: %s", m_network->iface.c_str(),
|
|
|
|
m_network->ip.c_str());
|
|
|
|
m_network->ip.c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|