diff --git a/Parse-Netstat-Search/lib/Parse/Netstat/Search.pm b/Parse-Netstat-Search/lib/Parse/Netstat/Search.pm index cecbd57..0028165 100644 --- a/Parse-Netstat-Search/lib/Parse/Netstat/Search.pm +++ b/Parse-Netstat-Search/lib/Parse/Netstat/Search.pm @@ -131,6 +131,28 @@ sub get_cidrs{ return @{ $self->{cidrs} }; } +=head2 get_cidrs_invert + +Gets the invert status of the CIDRs search. + + if ( $search->get_cidrs_invert ){ + print "The search will be inverted\n"; + }else{ + print "The search will not be inverted"; + } + +=cut + +sub get_cidrs_invert{ + my $self=$_[0]; + + if( ! $self->errorblank ){ + return undef; + } + + return $self->{cidr_invert}; +} + =head2 get_ports Gets a list of desired ports. @@ -154,6 +176,14 @@ sub get_ports{ =head2 get_ports_invert +Gets the invert status of the ports search. + + if ( $search->get_ports_invert ){ + print "The search will be inverted\n"; + }else{ + print "The search will not be inverted"; + } + =cut sub get_ports_invert{ @@ -163,7 +193,7 @@ sub get_ports_invert{ return undef; } - return $self->{ports_invert}; + return $self->{port_invert}; } =head2 get_protocols @@ -190,6 +220,28 @@ sub get_protocols{ return keys( %{ $self->{protocols} } ); } +=head2 get_protocols_invert + +Gets the invert status of the protocols search. + + if ( $search->get_protocols_invert ){ + print "The search will be inverted\n"; + }else{ + print "The search will not be inverted"; + } + +=cut + +sub get_protocols_invert{ + my $self=$_[0]; + + if( ! $self->errorblank ){ + return undef; + } + + return $self->{protocol_invert}; +} + =head2 get_states Get a list of desired sets. @@ -213,6 +265,28 @@ sub get_states{ return keys( %{ $self->{states} } ); } +=head2 get_state_invert + +Gets the invert status of the states search. + + if ( $search->get_state_invert ){ + print "The search will be inverted\n"; + }else{ + print "The search will not be inverted"; + } + +=cut + +sub get_states_invert{ + my $self=$_[0]; + + if( ! $self->errorblank ){ + return undef; + } + + return $self->{state_invert}; +} + =head2 get_ptrs Gets the list of PTRs to search for. @@ -233,6 +307,70 @@ sub get_ptrs{ return keys( %{ $self->{ptrs} } ); } +=head2 get_ptrs_invert + +Gets the invert status of the PTRs search. + + if ( $search->get_ptr_invert ){ + print "The search will be inverted\n"; + }else{ + print "The search will not be inverted"; + } + +=cut + +sub get_ptrs_invert{ + my $self=$_[0]; + + if( ! $self->errorblank ){ + return undef; + } + + return $self->{ptr_invert}; +} + +=head2 get_ptrs_r + +Gets the list of PTR regexps to search for. + +The returned value is a array. Each item is a PTR. + + my @regexps=$search->get_ptrs_r; + +=cut + +sub get_ptrs_r{ + my $self=$_[0]; + + if( ! $self->errorblank ){ + return undef; + } + + return @{ $self->{ptrs_r} }; +} + +=head2 get_ptrs_invert + +Gets the invert status of the PTRs search. + + if ( $search->get_ptr_invert ){ + print "The search will be inverted\n"; + }else{ + print "The search will not be inverted"; + } + +=cut + +sub get_ptrs_r_invert{ + my $self=$_[0]; + + if( ! $self->errorblank ){ + return undef; + } + + return $self->{ptr_r_invert}; +} + =head2 search This runs the search results. @@ -577,6 +715,38 @@ sub set_cidrs{ return 1; } +=head2 set_cidrs_invert + +This sets if the CIDRs search should be inverted or not. + +One value is taken and that is a boolean. + + # if it does not match, hit on it + $search->set_cidrs_invert(1); + + # only hit on matches, the default + $search->set_cidrs_invert; # or... + $search->set_cidrs_invert(0); + +=cut + +sub set_cidrs_invert{ + my $self=$_[0]; + my $bool=$_[1]; + + if( ! $self->errorblank ){ + return undef; + } + + if ( $bool ){ + $self->{cidr_invert}=1; + }else{ + $self->{cidr_invert}=0; + } + + return 1; +} + =head2 set_ports This sets the ports to search for in either @@ -644,6 +814,17 @@ sub set_ports{ =head2 set_ports_invert +This sets if the ports search should be inverted or not. + +One value is taken and that is a boolean. + + # if it does not match, hit on it + $search->set_port_invert(1); + + # only hit on matches, the default + $search->set_port_invert; # or... + $search->set_port_invert(0); + =cut sub set_ports_invert{ @@ -655,9 +836,9 @@ sub set_ports_invert{ } if ( $bool ){ - $self->{ports_invert}=1; + $self->{port_invert}=1; }else{ - $self->{ports_invert}=0; + $self->{port_invert}=0; } return 1; @@ -718,6 +899,38 @@ sub set_protocols{ return 1; } +=head2 set_protocols_invert + +This sets if the protocols search should be inverted or not. + +One value is taken and that is a boolean. + + # if it does not match, hit on it + $search->set_port_invert(1); + + # only hit on matches, the default + $search->set_protocol_invert; # or... + $search->set_protocol_invert(0); + +=cut + +sub set_protocols_invert{ + my $self=$_[0]; + my $bool=$_[1]; + + if( ! $self->errorblank ){ + return undef; + } + + if ( $bool ){ + $self->{protocol_invert}=1; + }else{ + $self->{protocol_invert}=0; + } + + return 1; +} + =head2 set_ptrs This sets a list of PTRs to search for. @@ -772,6 +985,38 @@ sub set_ptrs{ return 1; } +=head2 set_ptrs_invert + +This sets if the PTRs search should be inverted or not. + +One value is taken and that is a boolean. + + # if it does not match, hit on it + $search->set_ptrs_invert(1); + + # only hit on match, the default + $search->set_ptrs_invert; # or... + $search->set_ptrs_invert(0); + +=cut + +sub set_ptrs_invert{ + my $self=$_[0]; + my $bool=$_[1]; + + if( ! $self->errorblank ){ + return undef; + } + + if ( $bool ){ + $self->{ptr_invert}=1; + }else{ + $self->{ptr_invert}=0; + } + + return 1; +} + =head2 set_ptrs_r This sets a list of PTRs to search for via regexp @@ -804,6 +1049,38 @@ sub set_ptrs_r{ return 1; } +=head2 set_ptrs_invert + +This sets if the regexp PTRs search should be inverted or not. + +One value is taken and that is a boolean. + + # if it does not match, hit on it + $search->set_ptrs_r_invert(1); + + # only hit on match, the default + $search->set_ptrs_r_invert; # or... + $search->set_ptrs_r_invert(0); + +=cut + +sub set_ptrs_r_invert{ + my $self=$_[0]; + my $bool=$_[1]; + + if( ! $self->errorblank ){ + return undef; + } + + if ( $bool ){ + $self->{ptr_r_invert}=1; + }else{ + $self->{ptr_r_invert}=0; + } + + return 1; +} + =head2 set_states Sets the list of desired states to match. @@ -862,6 +1139,38 @@ sub set_states{ return 1; } +=head2 set_ptrs_invert + +This sets if the state search should be inverted or not. + +One value is taken and that is a boolean. + + # if it does not match, hit on it + $search->set_state_invert(1); + + # only hit on match, the default + $search->set_state_invert; # or... + $search->set_state_invert(0); + +=cut + +sub set_state_invert{ + my $self=$_[0]; + my $bool=$_[1]; + + if( ! $self->errorblank ){ + return undef; + } + + if ( $bool ){ + $self->{state_invert}=1; + }else{ + $self->{state_invert}=0; + } + + return 1; +} + =head1 ERROR CODES / FLAGS Error handling is provided by L.