mirror of
https://github.com/zeek/zeek.git
synced 2025-10-06 08:38:20 +00:00
Add to_subnet bif (fixes #782).
Also fix IPAddr::Mask/ReverseMask not allowing argument of 0. And clarified return value of to_addr bif when the input string does not parse into a valid IP address.
This commit is contained in:
parent
c84394d07f
commit
32aabe8432
9 changed files with 59 additions and 14 deletions
17
src/Val.cc
17
src/Val.cc
|
@ -911,11 +911,18 @@ 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");
|
||||
|
||||
val.subnet_val = new IPPrefix(text, atoi(sep+1));
|
||||
string s(text);
|
||||
size_t slash_loc = s.find('/');
|
||||
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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue