[Bro] Type conversion and table initialization

Robin Sommer robin at icir.org
Wed Feb 28 09:39:55 PST 2007


On Tue, Feb 27, 2007 at 17:25 -0600, Mike Dopheide wrote:

> I've got a udp packet that contains an IP address in the packet
> contents[*]. 

Hmmm... can't think of any other way than adding a new built-in
ffunction specifically for this.

> global myset: set[addr] = {192.168.1.1};
> global mytable: table[string] of set[addr] = {
> 	["blaa"] = myset,
> };

Yeah, unfortunately this is the way to do it. Clumsy, but we don't
have set constructors at the moment. 

> 	["blaa"] = 192.168.1.1,

The problem is here that you're initialiazing a set[addr] with just
an addr (rather than a set of addrs). The natural way would be:

   	["blaa"] = { 192.168.1.1 }

But that is not supported. 

> I read somewhere that 'bad tag' is an internal error and I should never 
> see it. 

That's true, at least in theory. :-) In practice, there are a couple
of places where this can happen when types don't match. Not nice but
hasn't been a high priority so far to fix.

Robin

-- 
Robin Sommer * Phone +1 (510) 931-5555 * robin at icir.org 
LBNL/ICSI    * Fax   +1 (510) 666-2956 *   www.icir.org



More information about the Bro mailing list