Fwctl/Services/ping.pm untested

filter: Statementstmt 0.0% 0 / 32 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 6 totaltotal 0.0% 0 / 60 CC 5 SCAR 18.9
CC
5
Cov
0%
accept_rules
12.0
account_rules
12.0
new
2.0
CRAP 6.6
1 #
2 # ping.pm: Fwctl service module to handle the ping service.
3 #
4 # This file is part of Fwctl.
5 #
6 # Author: Francis J. Lacoste <francis@iNsu.COM>
7 #
8 # Copyright (c) 1999,2000 iNsu Innovations Inc.
9 #
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 2 of the License, or
13 # (at your option) any later version.
14 #
15 package Fwctl::Services::ping;
16  
17 use strict;
18  
19 use Fwctl::RuleSet qw(:ip_rulesets :masq);
20 use IPChains;
21  
22 sub new {
23 my $proto = shift;
24 my $class = ref $proto || $proto;
25 bless {}, $class;
26 }
27  
28 sub prototypes {
29 my ($self,$target,$options) = @_;
30 (
31 IPChains->new(
32 Rule => $target,
33 Prot => 'icmp',
34 ICMP => 'echo-request',
35 %{$options->{ipchains}},
36 ),
37 IPChains->new(
38 Rule => $target,
39 Prot => 'icmp',
40 ICMP => 'echo-reply',
41 %{$options->{ipchains}},
42 ),
43 );
44 }
45  
46 sub block_rules {
47 my $self = shift;
48 my ( $target, $src, $src_if, $dst, $dst_if, $options ) = @_;
49  
50 # Build prototype rule
51 my ($ping,$pong) = $self->prototypes( $target, $options );
52  
53 block_ip_ruleset( $ping, $src, $src_if, $dst, $dst_if );
54 block_ip_ruleset( $pong, $dst, $dst_if, $src, $src_if );
55 }
56  
57 sub accept_rules {
58 my $self = shift;
59 my ( $target, $src, $src_if, $dst, $dst_if, $options ) = @_;
60  
61 # Build prototype rule
62 my ($ping,$pong) = $self->prototypes( $target, $options );
63  
64 accept_ip_ruleset( $ping, $src, $src_if, $dst, $dst_if,
65 $options->{masq} ? MASQ : NOMASQ
66 );
67 accept_ip_ruleset( $pong, $dst, $dst_if, $src, $src_if,
68 $options->{masq} ? UNMASQ : NOMASQ
69 );
70 }
71  
72 sub account_rules {
73 my $self = shift;
74 my ( $target, $src, $src_if, $dst, $dst_if, $options ) = @_;
75  
76 # Build prototype rule
77 my ($ping,$pong) = $self->prototypes( $target, $options );
78  
79 acct_ip_ruleset( $ping, $src, $src_if, $dst, $dst_if,
80 $options->{masq} ? MASQ : NOMASQ
81 );
82 acct_ip_ruleset( $pong, $dst, $dst_if, $src, $src_if,
83 $options->{masq} ? UNMASQ : NOMASQ
84 );
85 }
86  
87 sub valid_options {
88 (); # No options
89 }
90  
91 1;
92 =pod
93  
94 =head1 NAME
95  
96 Fwctl::Services::ping - Fwctl module to handle the ping service.
97  
98 =head1 SYNOPSIS
99  
100 accept ping -src INTERNAL_NET -dst INTERNET -masq
101 deny ping -dst BAD_GUYS_NET --account
102 account ping -src INTERNET -dst FIREWALL
103  
104 =head1 DESCRIPTION
105  
106 The ping module manages rules for the ICMP echo-request and echo-reply
107 types used by the ping B<program>.
108  
109 =head1 AUTHOR
110  
111 Francis J. Lacoste <francis.lacoste@iNsu.COM>
112  
113 =head1 COPYRIGHT
114  
115 Copyright (c) 1999,2000 iNsu Innovations Inc.
116 All rights reserved.
117  
118 This program is free software; you can redistribute it and/or modify
119 it under the terms of the GNU General Public License as published by
120 the Free Software Foundation; either version 2 of the License, or
121 (at your option) any later version.
122  
123 =head1 SEE ALSO
124  
125 fwctl(8) Fwctl(3) Fwctl::RuleSet(3)
126  
127 =cut
128