[Bro-Dev] [Bro-Commits] [git/bro] topic/robin/logging-internals: Enable passing events into bifs. (c0cd62a)

Gregor Maier gregor at icir.org
Tue Feb 22 13:01:49 PST 2011


Just wondering whether this might affect the way the C++ layer checks
whether there's a handler for a particular event by testing its boolean
value....

On 2/21/11 18:30 , Robin Sommer wrote:
> Repository : ssh://bro@envoy.icir.org/bro
> 
> On branch  : topic/robin/logging-internals
> 
>> ---------------------------------------------------------------
> 
> commit c0cd62a5a5e7270db901d56a1d651df7bd87338f
> Author: Robin Sommer <robin at icir.org>
> Date:   Mon Feb 21 13:45:44 2011 -0800
> 
>     Enable passing events into bifs.
>     
>     When an event was globally decleared, previously it did not get
>     assigned a value initially until the first implementation body was
>     added. That then triggered an "not used" error when passing such an
>     event as argument into a bif. Now we always assign a function value
>     immediately, just without any body inititally.
>     
>     When globally declaring an event, i
> 
> 
>> ---------------------------------------------------------------
> 
>  src/Func.cc |   12 ++++++++----
>  src/Var.cc  |   10 ++++++++++
>  2 files changed, 18 insertions(+), 4 deletions(-)
> 
> diff --git a/src/Func.cc b/src/Func.cc
> index 5d71be2..f398425 100644
> --- a/src/Func.cc
> +++ b/src/Func.cc
> @@ -239,11 +239,15 @@ BroFunc::BroFunc(ID* arg_id, Stmt* arg_body, id_list* aggr_inits,
>  : Func(BRO_FUNC)
>  	{
>  	id = arg_id;
> -	Body b;
> -	b.stmts = AddInits(arg_body, aggr_inits);
> -	b.priority = 0;
> -	bodies.push_back(b);
>  	frame_size = arg_frame_size;
> +
> +	if ( arg_body )
> +		{
> +		Body b;
> +		b.stmts = AddInits(arg_body, aggr_inits);
> +		b.priority = 0;
> +		bodies.push_back(b);
> +		}
>  	}
>  
>  BroFunc::~BroFunc()
> diff --git a/src/Var.cc b/src/Var.cc
> index b107156..c9e497d 100644
> --- a/src/Var.cc
> +++ b/src/Var.cc
> @@ -170,6 +170,16 @@ static void make_var(ID* id, BroType* t, init_class c, Expr* init,
>  		}
>  
>  	id->UpdateValAttrs();
> +
> +	if ( t && t->Tag() == TYPE_FUNC && t->AsFuncType()->IsEvent() )
> +		{
> +		// For events, add a function value (without any body) here so that
> +		// we can later access the ID even if no implementations have been
> +		// defined.
> +		Func* f = new BroFunc(id, 0, 0, 0);
> +		id->SetVal(new Val(f));
> +		id->SetConst();
> +		}
>  	}
>  
>  
> 
> _______________________________________________
> bro-commits mailing list
> bro-commits at bro-ids.org
> http://mailman.icsi.berkeley.edu/mailman/listinfo/bro-commits
> 


-- 
Gregor Maier
<gregor at icir.org>  <gregor at icsi.berkeley.edu>
Int. Computer Science Institute (ICSI)
1947 Center St., Ste. 600
Berkeley, CA 94704, USA
http://www.icir.org/gregor/


More information about the bro-dev mailing list