Merge remote-tracking branch 'origin/fastpath'

* origin/fastpath:
  Add to_subnet bif (fixes #782).
  Refactor IPAddr v4 initialization from string. (fixes #775)

Closes #782.
Closes #775.
Closes #784.
This commit is contained in:
Robin Sommer 2012-02-24 15:26:18 -08:00
commit 2eeac54857
10 changed files with 72 additions and 57 deletions

View file

@ -911,11 +911,19 @@ bool AddrVal::DoUnserialize(UnserialInfo* info)
SubNetVal::SubNetVal(const char* text) : Val(TYPE_SUBNET)
{
const char* sep = strchr(text, '/');
if ( ! sep )
Internal("separator missing in SubNetVal::SubNetVal");
string s(text);
size_t slash_loc = s.find('/');
val.subnet_val = new IPPrefix(text, atoi(sep+1));
if ( slash_loc == string::npos )
{
reporter->Error("Bad string in SubNetVal ctor: %s", text);
val.subnet_val = new IPPrefix();
}
else
{
val.subnet_val = new IPPrefix(s.substr(0, slash_loc),
atoi(s.substr(slash_loc + 1).c_str()));
}
}
SubNetVal::SubNetVal(const char* text, int width) : Val(TYPE_SUBNET)