package Filter;

## This method returns the filter type code
sub getFilterType {
   my ($self) = @_;
   return $self->{FILTER_TYPE};
}

## This method returns the ip address value
sub getIpAddress {
   my ($self) = @_;
   return $self->{IP_ADDRESS};
}

## This method returns the netmask value
sub getNetmask {
   my ($self) = @_;
   return $self->{NETMASK};
}

## This method returns the xchg address value
sub getXchgAddress {
   my ($self) = @_;
   return $self->{XCHG_ADDRESS};
}

## This method returns the port value
sub getPort {
   my ($self) = @_;
   return $self->{PORT};
}

## This method returns the protocol value
sub getProtocol {
   my ($self) = @_;
   return $self->{PROTOCOL};
}

## This method instantiates a new source address filter
sub newSourceAddressFilter {
   ## Throw out the first parameter, the class name
   shift @_;

   ## Use the arguments given to the constructor
   my ($IpAddress, $Netmask) = @_;

   ## Used for our object reference
   my ($self) = {};

   ## Setup variables that will be maintained inside the object reference
   $self->{FILTER_TYPE} = &SOURCE_ADDRESS;
   $self->{IP_ADDRESS}  = $IpAddress;
   $self->{NETMASK}     = $Netmask;

   ## Obtain an object reference for this package
   bless($self);

   ## Return it to the caller
   return $self;
}

## This method returns non-zero if the object is a source address filter
sub isSourceAddressFilter {
   my ($self) = @_;
   return ($self->{FILTER_TYPE} == &SOURCE_ADDRESS);
}

## This method instantiates a new destination port filter
sub newDestinationPortFilter {
   ## Throw out the first parameter, the class name
   shift @_;

   ## Use the arguments given to the constructor
   my ($Port, $Protocol) = @_;

   ## Used for our object reference
   my ($self) = {};

   ## Setup variables that will be maintained inside the object reference
   $self->{FILTER_TYPE} = &DESTINATION_PORT;
   $self->{PORT}        = $Port;
   $self->{PROTOCOL}    = $Protocol;

   ## Obtain an object reference for this package
   bless($self);

   ## Return it to the caller
   return $self;
}

## This method returns non-zero if the object is a destination port filter
sub isDestinationPortFilter {
   my ($self) = @_;
   return ($self->{FILTER_TYPE} == &DESTINATION_PORT);
}

## This method instantiates a new protocol filter
sub newProtocolFilter {
   ## Throw out the first parameter, the class name
   shift @_;

   ## Use the arguments given to the constructor
   my ($Protocol) = @_;

   ## Used for our object reference
   my ($self) = {};

   ## Setup variables that will be maintained inside the object reference
   $self->{FILTER_TYPE} = &PROTOCOL;
   $self->{PROTOCOL}    = $Protocol;

   ## Obtain an object reference for this package
   bless($self);

   ## Return it to the caller
   return $self;
}

## This method returns non-zero if the object is a protocol filter
sub isProtocolFilter {
   my ($self) = @_;
   return ($self->{FILTER_TYPE} == &PROTOCOL);
}

## This method instantiates a new destination address filter
sub newDestinationAddressFilter {
   ## Throw out the first parameter, the class name
   shift @_;

   ## Use the arguments given to the constructor
   my ($IpAddress, $Netmask) = @_;

   ## Used for our object reference
   my ($self) = {};

   ## Setup variables that will be maintained inside the object reference
   $self->{FILTER_TYPE} = &DESTINATION_ADDRESS;
   $self->{IP_ADDRESS}  = $IpAddress;
   $self->{NETMASK}     = $Netmask;

   ## Obtain an object reference for this package
   bless($self);

   ## Return it to the caller
   return $self;
}

## This method returns non-zero if the object is a destination address filter
sub isDestinationAddressFilter {
   my ($self) = @_;
   return ($self->{FILTER_TYPE} == &DESTINATION_ADDRESS);
}

## This method instantiates a new source port filter
sub newSourcePortFilter {
   ## Throw out the first parameter, the class name
   shift @_;

   ## Use the arguments given to the constructor
   my ($Port, $Protocol) = @_;

   ## Used for our object reference
   my ($self) = {};

   ## Setup variables that will be maintained inside the object reference
   $self->{FILTER_TYPE} = &SOURCE_PORT;
   $self->{PORT}        = $Port;
   $self->{PROTOCOL}    = $Protocol;

   ## Obtain an object reference for this package
   bless($self);

   ## Return it to the caller
   return $self;
}

## This method returns non-zero if the object is a source port filter
sub isSourcePortFilter {
   my ($self) = @_;
   return ($self->{FILTER_TYPE} == &SOURCE_PORT);
}

## This method instantiates a new xchg address filter
sub newXchgAddressFilter {
   ## Throw out the first parameter, the class name
   shift @_;

   ## Use the arguments given to the constructor
   my ($IpAddress, $Netmask, $XchgAddress) = @_;

   ## Used for our object reference
   my ($self) = {};

   ## Setup variables that will be maintained inside the object reference
   $self->{FILTER_TYPE}  = &XCHG_ADDRESS;
   $self->{IP_ADDRESS}   = $IpAddress;
   $self->{NETMASK}      = $Netmask;
   $self->{XCHG_ADDRESS} = $XchgAddress;

   ## Obtain an object reference for this package
   bless($self);

   ## Return it to the caller
   return $self;
}

## This method returns non-zero if the object is a xchg address filter
sub isXchgAddressFilter {
   my ($self) = @_;
   return ($self->{FILTER_TYPE} == &XCHG_ADDRESS);
}

## This method instantiates a new firewall filter
sub newFirewallFilter {
   ## Throw out the first parameter, the class name
   shift @_;

   ## Use the arguments given to the constructor
   my ($IpAddress, $Netmask) = @_;

   ## Used for our object reference
   my ($self) = {};

   ## Setup variables that will be maintained inside the object reference
   $self->{FILTER_TYPE}  = &FIREWALL_FILTER;
   $self->{IP_ADDRESS}   = $IpAddress;
   $self->{NETMASK}      = $Netmask;

   ## Obtain an object reference for this package
   bless($self);

   ## Return it to the caller
   return $self;
}

## This method returns non-zero if the object is a firewall filter
sub isFirewallFilter {
   my ($self) = @_;
   return ($self->{FILTER_TYPE} == &FIREWALL_FILTER);
}

## These are our type codes
sub SOURCE_ADDRESS      {0;}
sub DESTINATION_PORT    {1;}
sub PROTOCOL            {2;}
sub DESTINATION_ADDRESS {3;}
sub SOURCE_PORT         {4;}
sub XCHG_ADDRESS        {5;}
sub FIREWALL_FILTER     {101;}

1;
