From 5f61c9bde961d54fc176d3b72a415f3ef6329129 Mon Sep 17 00:00:00 2001 From: Seth Hall Date: Tue, 9 Aug 2011 11:15:07 -0400 Subject: [PATCH] New variable in utils/site for mapping address to defined local subnet. - Site::local_nets_table[1.2.3.4] might yield "1.2.0.0/16" if that subnet is defined in the Site::local_nets variable. --- scripts/base/utils/site.bro | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/scripts/base/utils/site.bro b/scripts/base/utils/site.bro index b8414a7a84..96fc46ec56 100644 --- a/scripts/base/utils/site.bro +++ b/scripts/base/utils/site.bro @@ -16,6 +16,10 @@ export { ## Networks that are considered "local". const local_nets: set[subnet] &redef; + + ## This is used for mapping between local networks and string + ## values for the CIDRs represented. + global local_nets_table: table[subnet] of string = {}; ## Networks that are considered "neighbors". const neighbor_nets: set[subnet] &redef; @@ -138,4 +142,9 @@ event bro_init() &priority=10 # Double backslashes are needed due to string parsing. local_dns_suffix_regex = set_to_regex(local_zones, "(^\\.?|\\.)(~~)$"); local_dns_neighbor_suffix_regex = set_to_regex(neighbor_zones, "(^\\.?|\\.)(~~)$"); + + # Create the local_nets mapping table. + for ( cidr in Site::local_nets ) + local_nets_table[cidr] = fmt("%s", cidr); + }