Fwctl/Services/udp_pkt.pm untested

filter: Statementstmt 0.0% 0 / 33 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 7 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 6 totaltotal 0.0% 0 / 67 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 # udp_pkt.pm - Fwctl modules that will add rules to let through one udp packets.
3 #
4 # This file is part of Fwctl.
5 #
6 # Author: Francis J. Lacoste <francis.lacoste@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::udp_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 my $local_port = $options->{local_port} || "1024:65535";
32 my $port = $options->{port} || "1:65535";
33  
34 # Build prototype rule
35 (
36 IPChains->new(
37 Rule => $target,
38 Prot => 'udp',
39 SourcePort => $local_port,
40 DestPort => $port,
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  
51 my ($fw) = $self->prototypes( $target, $options );
52 block_ip_ruleset( $fw, $src, $src_if, $dst, $dst_if );
53 }
54  
55 sub accept_rules {
56 my $self = shift;
57 my ( $target, $src, $src_if, $dst, $dst_if, $options ) = @_;
58  
59 my ($fw) = $self->prototypes( $target, $options );
60  
61 my $masq = defined $options->{portfw} ? PORTFW :
62 $options->{masq} ? MASQ : NOMASQ;
63 accept_ip_ruleset( $fw, $src, $src_if, $dst, $dst_if,
64 $masq, $options->{portfw} );
65 }
66  
67 sub account_rules {
68 my $self = shift;
69 my ( $target, $src, $src_if, $dst, $dst_if, $options ) = @_;
70  
71 my ($fw) = $self->prototypes( $target, $options );
72  
73 my $masq = defined $options->{portfw} ? PORTFW :
74 $options->{masq} ? MASQ : NOMASQ;
75  
76 acct_ip_ruleset( $fw, $src, $src_if, $dst, $dst_if, $masq );
77 }
78  
79 sub valid_options {
80 my $self = shift;
81 ( "local_port=s", "port=s" );
82 }
83  
84 1;
85  
86 =pod
87  
88 =head1 NAME
89  
90 Fwctl::Services::udp_pkt - Fwctl module to hande unidirectional UDP packets.
91  
92 =head1 SYNOPSIS
93  
94 accept udp_pkt -src ROUTER -dst LOGGER --local_port 514 --port 514
95  
96 =head1 DESCRIPTION
97  
98 This module will add rules to the firewall for unidrectional UDP traffic.
99  
100 =head1 OPTIONS
101  
102 In addition to the standard options, it accepts the following ones.
103  
104 =over
105  
106 =item --local_port
107  
108 This is the source port of the udp packet.
109  
110 =item --port
111  
112 This is the destination port of the udp packet.
113  
114 =back
115  
116 =head1 AUTHOR
117  
118 Francis J. Lacoste <francis.lacoste@iNsu.COM>
119  
120 =head1 COPYRIGHT
121  
122 Copyright (c) 1999,2000 iNsu Innovations Inc.
123 All rights reserved.
124  
125 This program is free software; you can redistribute it and/or modify
126 it under the terms of the GNU General Public License as published by
127 the Free Software Foundation; either version 2 of the License, or
128 (at your option) any later version.
129  
130 =head1 SEE ALSO
131  
132 fwctl(8) Fwctl(3) Fwctl::RuleSet(3)
133  
134 =cut
135