Here's my first "Baby Bro" post. Before getting into using Bro scripting for its intended use of network traffic analysis, I wanted to figure out how to accomplish basic tasks common to most programming languages:
- Common types and variable definitions
- Iteration of container types
- Basic string and arithmetic operations
I'm not sure if I'll get through all of them in this series, but here's a start: a main dish of functions, with a side of string formatting and concatenation.
I think this is fairly self explanatory, given the comments. We have two functions:
- add_one: adds one to whatever integer is passed into the function, and returns the resulting integer.
- concat: concatenates two strings, separated by a space, and returns the result. There is a built-in string function for this, but I wanted to show that you can also do it with "+".
We can run this from the CLI with no PCAP ingestion just to get the standard output:
jswan@so12a:~/bro$ bro test.bro
3 + 1 = 4