<div dir="ltr">Thank you! Exactly what I was looking for</div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 8, 2017 at 11:27 AM, Aashish Sharma <span dir="ltr"><<a href="mailto:asharma@lbl.gov" target="_blank">asharma@lbl.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">(Not sure if I am interpreting your question right but here is how I read it)<br>
<br>
basically use "in" operator<br>
<br>
<br>
local my_ip_table : table[addr] of bool ;<br>
<br>
local ip: addr = 127.0.0.1<br>
<br>
if ( ip in my_ip_table)<br>
found<br>
else<br>
not found<br>
<br>
<br>
btw, you can also use "!in" operator too which is rather more handy<br>
<br>
<br>
if (something !in table)<br>
initialize it here<br>
table[something] = Blah;<br>
<br>
<br>
or<br>
<br>
most of scripts just flat return in membership doesn't exist that helps<br>
eliminate a lot of unneeded run through scripts.<br>
<br>
if (ip !in Site::local_nets)<br>
return<br>
<br>
<do rest of the heuristics here for local IPs><br>
<br>
<br>
Here is a (rather complicated but) useful example which stretches<br>
above problem with an extended use-case:<br>
<br>
/usr/local/bro/share/bro/<wbr>policy/frameworks/software/<wbr>vulnerable.bro<br>
<br>
Hope this helps. Let me know if you need more clearifications.<br>
<span class="HOEnZb"><font color="#888888"><br>
Aashish<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
On Tue, Aug 08, 2017 at 11:04:23AM -0700, Reinhard Gentz wrote:<br>
> Hi,<br>
><br>
> I would like to check if a certain table element exists and then take<br>
> corresponding action like the following:<br>
><br>
> if (exists(mytable["my_dynamic_<wbr>name"]))<br>
> do something<br>
> else<br>
> do something else<br>
><br>
><br>
> Can someone give me a hint?<br>
> Reinhard<br>
<br>
</div></div><div class="HOEnZb"><div class="h5">> ______________________________<wbr>_________________<br>
> bro-dev mailing list<br>
> <a href="mailto:bro-dev@bro.org">bro-dev@bro.org</a><br>
> <a href="http://mailman.icsi.berkeley.edu/mailman/listinfo/bro-dev" rel="noreferrer" target="_blank">http://mailman.icsi.berkeley.<wbr>edu/mailman/listinfo/bro-dev</a><br>
<br>
</div></div></blockquote></div><br></div>