You can initialize values of type
record
using either assignment from another, already existing
record
value; or element-by-element; or using a
In a Bro function or event handler, we could declare a local
variable the conn_id
type given above:
local id: conn_id;
and then explicitly assign each of its fields:
id$orig_h = 207.46.138.11; id$orig_p = 31337/tcp; id$resp_h = 207.110.0.15; id$resp_p = 22/tcp;
Deficiency: One danger with this initialization method is that if you forget to initialize a field, and then later access it, you will crash Bro.
Or we could use:
id = [$orig_h = 207.46.138.11, $orig_p = 31337/tcp, $resp_h = 207.110.0.15, $resp_p = 22/tcp];
This second form is no different from assigning a record
value
computed in some other fashion, such as the value of another variable,
a table element, or the value returned by a function call. Such assignments
must specify all of the fields in the target (i.e., in id
in
this example), unless the missing field has the &optional
or &default
attribute.