Hi,
I wanted to change an internal variable from the C code. I have defined
a variable in a .bro file as
global my_count: count;
At some later point in the C code, I want to change it:
Val *my_count = internal_val("my_count");
// change the value of my_count to something else
I am at loss on how to accomplish this. Can the Bro gurus help me out?
thanks
-vish
Hi,
Please take a look at NetVar.{h,cc} as a starting point. That's where
"internal variables" are defined.
By the way, which is the variable you want to manipulate in C++ code?
Ruoming
Please take a look at NetVar.{h,cc} as a starting point. That's where
"internal variables" are defined.
Net.cc doesn't seem to modify anything. I wanted to know how can I
modify variables that are defined in the .bro files.
By the way, which is the variable you want to manipulate in C++ code?
It's my own variable - a variable defined by my .bro file which is
loaded on startup. I want to modify it later in the C++ code.
thanks!
-vish
> Please take a look at NetVar.{h,cc} as a starting point. That's where
> "internal variables" are defined.
Net.cc doesn't seem to modify anything. I wanted to know how can I
modify variables that are defined in the .bro files.
Well, first, it's not Net.cc, but NetVar.cc. Are you looking at the
right file? Second, the way it works is that you define a variable in
NetVar.{h,cc} and also in bro.init. Then you can access the variable
from both C++ and bro scripts.
> By the way, which is the variable you want to manipulate in C++ code?
It's my own variable - a variable defined by my .bro file which is
loaded on startup. I want to modify it later in the C++ code.
What does the variable represent? I'm curious about why you need an
additional internal variable because they are not needed for most
cases---that's why there are only a limited number of them.
Ruoming
> Net.cc doesn't seem to modify anything. I wanted to know how can I
> modify variables that are defined in the .bro files.
Well, first, it's not Net.cc, but NetVar.cc. Are you looking at the
right file? Second, the way it works is that you define a variable in
NetVar.{h,cc} and also in bro.init. Then you can access the variable
from both C++ and bro scripts.
Sorry about the typo... I did mean NetVar.cc. Accessing is one thing.. I
know how to do it. Can you point me to an example where C++ code
modifies it? Or give a li'l sample code.
> > By the way, which is the variable you want to manipulate in C++ code?
>
> It's my own variable - a variable defined by my .bro file which is
> loaded on startup. I want to modify it later in the C++ code.
What does the variable represent? I'm curious about why you need an
additional internal variable because they are not needed for most
cases---that's why there are only a limited number of them.
Well... it's a variable defined and required by my .bro module. I want
to be able to send a signal to Bro and change its value... in C++ code.
I want to use it to change Bro behavior.
thanks!
-yp