Changeset View
Changeset View
Standalone View
Standalone View
src/netbase.cpp
Show First 20 Lines • Show All 895 Lines • ▼ Show 20 Lines | bool LookupSubNet(const std::string &strSubnet, CSubNet &ret) { | ||||
std::string strAddress = strSubnet.substr(0, slash); | std::string strAddress = strSubnet.substr(0, slash); | ||||
// TODO: Use LookupHost(const std::string&, CNetAddr&, bool) instead to just | // TODO: Use LookupHost(const std::string&, CNetAddr&, bool) instead to just | ||||
// get one CNetAddr. | // get one CNetAddr. | ||||
if (LookupHost(strAddress, vIP, 1, false)) { | if (LookupHost(strAddress, vIP, 1, false)) { | ||||
CNetAddr network = vIP[0]; | CNetAddr network = vIP[0]; | ||||
if (slash != strSubnet.npos) { | if (slash != strSubnet.npos) { | ||||
std::string strNetmask = strSubnet.substr(slash + 1); | std::string strNetmask = strSubnet.substr(slash + 1); | ||||
int32_t n; | uint8_t n; | ||||
if (ParseInt32(strNetmask, &n)) { | if (ParseUInt8(strNetmask, &n)) { | ||||
// If valid number, assume CIDR variable-length subnet masking | // If valid number, assume CIDR variable-length subnet masking | ||||
ret = CSubNet(network, n); | ret = CSubNet(network, n); | ||||
return ret.IsValid(); | return ret.IsValid(); | ||||
} else { | } else { | ||||
// If not a valid number, try full netmask syntax | // If not a valid number, try full netmask syntax | ||||
// Never allow lookup for netmask | // Never allow lookup for netmask | ||||
if (LookupHost(strNetmask, vIP, 1, false)) { | if (LookupHost(strNetmask, vIP, 1, false)) { | ||||
ret = CSubNet(network, vIP[0]); | ret = CSubNet(network, vIP[0]); | ||||
▲ Show 20 Lines • Show All 101 Lines • Show Last 20 Lines |