[Bro] default function not get called in Table ...

Seth Hall hall.692 at osu.edu
Thu Aug 6 04:39:58 PDT 2009


On Aug 6, 2009, at 1:22 AM, Navdeep Singh wrote:

> Hi everyone
>
> I have a got a problem. I want to call a function called world but  
> it is throwing the following error:
>
> line 1: error: unknown identifier world, at or near "world"

The main problem you're running into here is that you're defining the  
world function after you're trying to use it.  When you use functions  
as default values, there is an argument passed to the function that is  
the value of the index and you forgot to return the string value from  
the world function.  Lastly, when you call most code it needs to be  
inside of an event handler, but you can wrap the code inside of a  
bro_init event handler which executes once Bro has completed it's  
initialization.

I'll include a fixed version of your test script.

function world(i: count): string
{
return fmt("hello world - index is %d", i);
}

global a: table[count] of string &default=world;

event bro_init()
         {
         a[1] = "navdeep";
         a[2] = "singh";

         print a[2];
         print a[3];
         }


----script output----
$ ./src/bro test5
singh
hello world - index is 3


   .Seth

---
Seth Hall
Network Security - Office of the CIO
The Ohio State University
Phone: 614-292-9721




More information about the Bro mailing list