Fwctl/Services/all.pm untested

filter: Statementstmt 0.0% 0 / 42 Branchbran 0.0% 0 / 16 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 / 78 CC 9 SCAR 32.6
CC
9
Cov
0%
accept_rules
56.0
account_rules
12.0
new
2.0
CRAP 26.0
1 #
2 # all.pm: Fwctl service module that represents rules matching all IP traffic.
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::all;
16  
17 use strict;
18  
19 use Fwctl::RuleSet qw(:ip_rulesets :tcp_rulesets :udp_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 => 'tcp',
34 %{$options->{ipchains}},
35 ),
36 IPChains->new(
37 Rule => $target,
38 Prot => 'udp',
39 %{$options->{ipchains}},
40 ),
41 IPChains->new(
42 Rule => $target,
43 Prot => 'icmp',
44 %{$options->{ipchains}},
45 ),
46 IPChains->new(
47 Rule => $target,
48 %{$options->{ipchains}},
49 ),
50 );
51 }
52  
53 sub block_rules {
54 my $self = shift;
55 my ( $target, $src, $src_if, $dst, $dst_if, $options ) = @_;
56  
57 # Build prototype rule
58 my ($tcp, $udp, $icmp, $all) = $self->prototypes( $target, $options );
59  
60 block_tcp_ruleset( $tcp, $src, $src_if, $dst, $dst_if );
61 block_udp_ruleset( $udp, $src, $src_if, $dst, $dst_if );
62 block_ip_ruleset( $icmp, $src, $src_if, $dst, $dst_if );
63 block_ip_ruleset( $icmp, $dst, $dst_if, $src, $src_if );
64 block_ip_ruleset( $all, $src, $src_if, $dst, $dst_if );
65 block_ip_ruleset( $all, $dst, $dst_if, $src, $src_if );
66 }
67  
68 sub accept_rules {
69 my $self = shift;
70 my ( $target, $src, $src_if, $dst, $dst_if, $options ) = @_;
71  
72 # Build prototype rule
73 my ($tcp, $udp, $icmp, $all) = $self->prototypes( $target, $options );
74  
75 accept_tcp_ruleset( $tcp, $src, $src_if, $dst, $dst_if,
76 $options->{masq} ? MASQ : NOMASQ );
77 accept_udp_ruleset( $udp, $src, $src_if, $dst, $dst_if,
78 $options->{masq} ? MASQ : NOMASQ
79 );
80 accept_ip_ruleset( $icmp, $src, $src_if, $dst, $dst_if,
81 $options->{masq} ? MASQ : NOMASQ
82 );
83 accept_ip_ruleset( $icmp, $dst, $dst_if, $src, $src_if,
84 $options->{masq} ? UNMASQ : NOMASQ
85 );
86 accept_ip_ruleset( $all, $src, $src_if, $dst, $dst_if,
87 $options->{masq} ? MASQ : NOMASQ
88 );
89 accept_ip_ruleset( $all, $dst, $dst_if, $src, $src_if,
90 $options->{masq} ? UNMASQ : NOMASQ
91 );
92 }
93  
94 sub account_rules {
95 my $self = shift;
96 my ( $target, $src, $src_if, $dst, $dst_if, $options ) = @_;
97  
98 # Build prototype rule
99 my ($tcp, $udp, $icmp, $all) = $self->prototypes( $target, $options );
100  
101 acct_ip_ruleset( $all, $src, $src_if, $dst, $dst_if,
102 $options->{masq} ? MASQ : NOMASQ
103 );
104 acct_ip_ruleset( $all, $dst, $dst_if, $src, $src_if,
105 $options->{masq} ? UNMASQ : NOMASQ
106 );
107 }
108  
109 sub valid_options {
110 (); # No options
111 }
112  
113 1;
114 =pod
115  
116 =head1 NAME
117  
118 Fwctl::Services::all - Fwctl module to handle any IP traffic.
119  
120 =head1 SYNOPSIS
121  
122 accept all -src INTERNAL_NET -dst INTERNET -masq
123 deny all -src BAD_GUYS_NET --account
124 account all -src PERIM_NET -dst INTERNET
125  
126 =head1 DESCRIPTION
127  
128 The all module is used to match any IP traffic. It can be used for
129 accounting all traffic between nets or to create bazooka sized hole
130 in our filters.
131  
132 Needless to say that
133  
134 accept all
135  
136 is not a really secure use of this module.
137  
138  
139 =head1 AUTHOR
140  
141 Francis J. Lacoste <francis.lacoste@iNsu.COM>
142  
143 =head1 COPYRIGHT
144  
145 Copyright (c) 1999,2000 iNsu Innovations Inc.
146 All rights reserved.
147  
148 This program is free software; you can redistribute it and/or modify
149 it under the terms of the GNU General Public License as published by
150 the Free Software Foundation; either version 2 of the License, or
151 (at your option) any later version.
152  
153 =head1 SEE ALSO
154  
155 fwctl(8) Fwctl(3) Fwctl::RuleSet(3)
156  
157 =cut
158