> How can I add an element to a table, since I get a "run-time error" if I try
> to index a table with a value which is not in the table (as it is specified in
> the bro language)?
It's not clear to me what you're asking. If the problem is "how do I add
a value to a table element if the table element might not be present yet",
the answer is to test with the "in" operator:
if ( foo in my_table )
my_table[foo] += additional_value;
else
my_table[foo] = additional_value;
With the 0.7 release, you'll be able to specify default values for
table entries, so this will look like:
global my_table: table[foo_type] of count &default = 0;
and then you can add to it using simply
my_table[foo] += additional_value;
Or are you asking about something different?
Vern
> could someone tell me why this peace of bro-code makes a segmentation fault?
>
> -------------------------------------------------
>
> global sessions : set[conn_id];
>
> event ftp_request(c:connection, command: string, arg:string)
> {
> add sessions[c$id];
> }
>
> --------------------------------------------------
Ouch, I don't know why that's happening, but I've added it to the
to-fix list.
But the more basic problem is that "add" is not currently supported.
You need to instead use:
global sessions: table[conn_id] of bool;
event ftp_request(c:connection, command: string, arg:string)
{
sessions[c$id] = T;
}
- Vern
Hello,
How can I add an element to a table, since I get a "run-time error" if I try
to index a table with a value which is not in the table (as it is specified in
the bro language)?
Benjamin Morin
Hello,
could someone tell me why this peace of bro-code makes a segmentation fault?
-------------------------------------------------
global sessions : set[conn_id];
event ftp_request(c:connection, command: string, arg:string)
{
add sessions[c$id];
}
--------------------------------------------------
Thanks
Benjamin Morin