Passing a Table to the policy engine

Robin Sommer sommer at in.tum.de
Thu Apr 1 23:58:27 PST 2004


On Thu, Apr 01, 2004 at 16:16 -0500, Charles John Wa wrote:

> in my myfile.cc code, i tried doing this:
> 
> 	myFuncInC ()
> 	{
> 		printf ("I am in this function\n");
>     		int pathArr[100];
>     		val_list* vl = new val_list;
>      		RecordVal* myrec = new RecordVal(some_rec);
>      		...
>      		TableVal* myPath = new TableVal(internal_type("count")->AsTableType());
>      		for ( int i=0; i < 100; i++ ) {
>      		        myPath->Assign(new Val(i, TYPE_COUNT), new Val(pathArr[i], TYPE_COUNT));
>      		}
>      		myrec->Assign(0, myPath);
>      		vl->append(myrec);
>      		mgr.QueueEvent(some_event, vl, Event::LOCAL, this);
> 	}
> 
> But i get a runtime error:
> 
> %I am in this function
> %1078809250.202295 internal error: internal type count missing
> 
> I dont think its because of my TYPC_COUNT as opposed to TYPE_INT.  it does
> not like me using a count for my table, maybe because i have not defined
> it?  It could be my line:
> 
> 	TableVal* myPath = new TableVal(internal_type("count")->AsTableType());
> 
> where I am using internal_type("count")->AsTableType(), which might not
> work.  However, i dont know how else to create a table[count] of count
> otherwise.

There are two possibilities:

- you can define a new type in bro.init and then access it:

      bro.init:
            type my_table_count_of_count: table[count] of count;      
      *.cc:             
         	TableVal* myPath = new TableVal(internal_type("my_table_count_of_count")->AsTableType());

- you instantiate a new BroType yourself:

      TypeList *myIndices = new TypeList(base_type(TYPE_COUNT));
      myIndices->Append(base_type(TYPE_COUNT));
      TableType* myType = new TableType(myIndices, base_type(TYPE_COUNT));
      
      TableVal* myPath = new TableVal(myType);
            
(Both are completely untested which means that they probably won't
work out-of-the-box :-)

Robin

-- 
Robin Sommer * Room        01.08.055 * www.net.in.tum.de
TU Munich    * Phone (089) 289-18006 *  sommer at in.tum.de 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://mailman.ICSI.Berkeley.EDU/pipermail/bro/attachments/20040402/afe83e85/attachment.bin 


More information about the Bro mailing list