Fwctl/Services/icmp_pkt.pm untested

filter: Statementstmt 0.0% 0 / 28 Branchbran 0.0% 0 / 4 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 / 52 CC 3 SCAR 12.4
CC
3
Cov
0%
accept_rules
6.0
account_rules
6.0
new
2.0
CRAP 3.5
1 #
2 # icmp.pm: Fwctl service module to handle arbitrery ICMP packets.
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::icmp_pkt;
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 (
32 IPChains->new(
33 Rule => $target,
34 Prot => 'icmp',
35 ICMP => $options->{code},
36 %{$options->{ipchains}},
37 ),
38 );
39 }
40  
41 sub block_rules {
42 my $self = shift;
43 my ( $target, $src, $src_if, $dst, $dst_if, $options ) = @_;
44  
45 # Build prototype rule
46 my ($msg) = $self->prototypes( $target, $options );
47  
48 block_ip_ruleset( $msg, $src, $src_if, $dst, $dst_if );
49 }
50  
51 sub accept_rules {
52 my $self = shift;
53 my ( $target, $src, $src_if, $dst, $dst_if, $options ) = @_;
54  
55 # Build prototype rule
56 my ($msg) = $self->prototypes( $target, $options );
57  
58 accept_ip_ruleset( $msg, $src, $src_if, $dst, $dst_if,
59 $options->{masq} ? MASQ : NOMASQ
60 );
61 }
62  
63 sub account_rules {
64 my $self = shift;
65 my ( $target, $src, $src_if, $dst, $dst_if, $options ) = @_;
66  
67 # Build prototype rule
68 my ($msg) = $self->prototypes( $target, $options );
69  
70 acct_ip_ruleset( $msg, $src, $src_if, $dst, $dst_if,
71 $options->{masq} ? MASQ : NOMASQ
72 );
73 }
74  
75 sub valid_options {
76 ( "code=s" );
77 }
78  
79 1;
80  
81 =pod
82  
83 =head1 NAME
84  
85 Fwctl::Services::icmp_pkt - Fwctl module to handle arbitrary ICMP packet.
86  
87 =head1 SYNOPSIS
88  
89 accept icmp_pkt -src INT_IP -dst INT_NET --code redirect
90  
91 =head1 DESCRIPTION
92  
93 This module can be use to add rules for arbitrary ICMP packets. Use the
94 --code option to specify the ICMP code of the packet to build the rules
95 for.
96  
97 =head1 AUTHOR
98  
99 Francis J. Lacoste <francis.lacoste@iNsu.COM>
100  
101 =head1 COPYRIGHT
102  
103 Copyright (c) 1999,2000 iNsu Innovations Inc.
104 All rights reserved.
105  
106 This program is free software; you can redistribute it and/or modify
107 it under the terms of the GNU General Public License as published by
108 the Free Software Foundation; either version 2 of the License, or
109 (at your option) any later version.
110  
111 =head1 SEE ALSO
112  
113 fwctl(8) Fwctl(3) Fwctl::RuleSet(3)
114  
115 =cut
116