Updates for directions-and-hosts

This commit is contained in:
Seth Hall 2011-06-14 13:53:50 -04:00
parent 844afba017
commit dc7229f15a

View file

@ -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)) );
}