I am wondering whether it is possible to use a global variable that is defined in other policy script? In other words, do Bro script have a equivalence of “extern” in C?
I found that in some scripts, “export” are used. Does this achieve similar function?
I am wondering whether it is possible to use a global variable that is defined in other policy script?
That's basically the definition of a global. It's just a runtime modifiable variable that can exist outside of a particular scope. You just need to make sure that the script that defines the variable is loaded prior to the script that uses it. Bro's parser will tell you if the variable isn't available yet which would mean you probably loaded the scripts in the wrong order.
I found that in some scripts, "export" are used. Does this achieve similar function?
The export keyword is only to making variables and types available outside of a module's namespace. If variables are defined within a module but not in the export section then you will only have access to those from code within that module.
At first, I am thinking about using in this way. However, then I found that Seth’s way is probably more convenient in Bro.
I think I am starting to get the concept of “redef” and “load” now.