zeek/scripts/policy/protocols/conn/ip-proto-name-logging.zeek
Johanna Amann 3e4f67e67c Move Conn::set_conn() from connection_state_remove to new_connection
c$conn is often needed for connection events, but it being established
in connection_state_removed can be a problem because event handlers have
to remember to call Con::set_conn().

This commit moves to call Conn::set_conn() in new_connection.

Addresses GH-4202

update logs
2025-07-29 09:11:57 +01:00

17 lines
568 B
Text

##! This script adds a string version of the ip_proto field. It's not recommended
##! to load this policy and the ip_proto removal policy at the same time, as
##! conn.log will end up with useless information in the log from this field.
@load base/protocols/conn
module Conn;
redef record Info += {
## A string version of the ip_proto field
ip_proto_name: string &log &optional;
};
event new_connection(c: connection) &priority=5 {
if ( c$conn?$ip_proto && c$conn$ip_proto in IP::protocol_names )
c$conn$ip_proto_name = IP::protocol_names[c$conn$ip_proto];
}