I have a simple requirement of copying type OPCUA_Binary::XXX record structures into another variable of same type. I don’t want to copy all the fields inside the structure one by one. Is it possible? icsnpp-opcua-binary
example:
type Info: record {
bin_info: OPCUA_Binary::Info &optional;
};
redef record connection += {
opcua_bin: Info &optional;
};
event opcua_binary_event(c: connection, info: OPCUA_Binary::Info)
{
set_service(c, "opcua-binary");
info$ts = network_time();
info$uid = c$uid;
info$id = c$id;
c$opcua_bin$bin_info = info;
Log::write(ICSNPP_OPCUA_Binary::LOG, info);
}
c$opcua_bin$bin_info = info; this assignement is giving expression error in main.zeek, line XXX: field value missing (ICSNPP_OPCUA_Binary::c$opcua_bin)
The $opcua_bin field is &optional, so it doesn’t exist unless you assign to it (not to an element within it). So try c$opcua_bin = Info($bin_info = info). That creates a new Info record to assign to $opcua_bin, and populates its one field with the value of info.