在语音对讲注册时,需要绑定本机ip及端口,甚至于如果在手机端连接本机wifi,进行呼叫时,需要进行IPV4获取:
bool checkIPAddress(resip::Data& ipAddessCanUsed, const resip::Data& ipUserInputAddress)
{
LOG_JNI_E("Insert checkIPAddress, ipUserInputAddress= %s!", ipUserInputAddress.c_str());
std::list<std::pair<resip::Data, resip::Data> > interfaces = resip::DnsUtil::getInterfaces();
LOG_JNI_E("Insert getInterfaces!");
if (!ipUserInputAddress.empty())
{
LOG_JNI_E("ipUserInputAddress is not empty!ipUserInputAddress is :%s", ipUserInputAddress.c_str());
CompareIPAddress compare(ipUserInputAddress);
if (std::find_if(interfaces.begin(), interfaces.end(), compare) != interfaces.end()) //find
{
ipAddessCanUsed = ipUserInputAddress;
return resip::DnsUtil::isIpV4Address(ipUserInputAddress);
}
}
//ip address invailed
LOG_JNI_E("ipUserInputAddress is empty!");
std::list<std::pair<resip::Data, resip::Data> >::iterator iter = interfaces.begin();
for (; iter != interfaces.end(); iter++)
{
if (resip::DnsUtil::isIpV4Address(iter->second))
{
ipAddessCanUsed = iter->second;
LOG_JNI_E("ipAddessCanUsed:%s", ipAddessCanUsed.c_str());
break;
}
}
return !ipAddessCanUsed.empty();
}