Beginning exploration of network centric data types, starting with subnets.

This commit is contained in:
Scott Runnels 2012-12-01 02:22:52 -05:00
parent d1d7fe5d4d
commit d35268a41c
3 changed files with 107 additions and 11 deletions

View file

@ -0,0 +1,4 @@
172.16.4.56 belongs to subnet 172.16.0.0/20
172.16.47.254 belongs to subnet 172.16.32.0/20
172.16.22.45 belongs to subnet 172.16.16.0/20
172.16.1.1 belongs to subnet 172.16.0.0/20

View file

@ -0,0 +1,22 @@
# @TEST-EXEC: bro -b %INPUT
# @TEST-EXEC: btest-diff .stdout
event bro_init()
{
local subnets = vector(172.16.0.0/20, 172.16.16.0/20, 172.16.32.0/20, 172.16.48.0/20);
local addresses = vector(172.16.4.56, 172.16.47.254, 172.16.22.45, 172.16.1.1);
for (a in addresses)
{
for (s in subnets)
{
if (addresses[a] in subnets[s])
{
print fmt("%s belongs to subnet %s", addresses[a], subnets[s]);
}
}
}
}