diff --git a/policy/utils/directions-and-hosts.bro b/policy/utils/directions-and-hosts.bro index 6d605f27b0..46f134875a 100644 --- a/policy/utils/directions-and-hosts.bro +++ b/policy/utils/directions-and-hosts.bro @@ -1,26 +1,24 @@ # Some enums for deciding what and when to log. -type Directions_and_Hosts: enum { - Inbound, Outbound, - LocalHosts, RemoteHosts, - Enabled, Disabled +type DirectionsAndHosts: enum { + Inbound, Outbound, Bidirectional, + LocalHosts, RemoteHosts, AllHosts, + NoHosts, Disabled }; -const DIRECTIONS = set(Inbound, Outbound, Enabled, Disabled); -const HOSTS = set(LocalHosts, RemoteHosts, Enabled, Disabled); -function id_matches_directions(id: conn_id, d: Directions_and_Hosts): bool +function id_matches_directions(id: conn_id, d: DirectionsAndHosts): bool { if ( d == Disabled ) return F; - return ( d == Enabled || + return ( d == Bidirectional || (d == Outbound && is_local_addr(id$orig_h)) || (d == Inbound && is_local_addr(id$resp_h)) ); } -function addr_matches_hosts(ip: addr, h: Directions_and_Hosts): bool +function addr_matches_hosts(ip: addr, h: DirectionsAndHosts): bool { - if ( h == Disabled ) return F; + if ( h == Disabled || h == NoHosts ) return F; - return ( h == Enabled || + return ( h == AllHosts || (h == LocalHosts && is_local_addr(ip)) || (h == RemoteHosts && !is_local_addr(ip)) ); }