Fwctl/Services/traceroute.pm untested

filter: Statementstmt 0.0% 0 / 30 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 6 totaltotal 0.0% 0 / 59 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 # traceroute.pm: Fwctl service module to handle traceroute service.
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::traceroute;
16  
17 use strict;
18  
19 use Fwctl::RuleSet qw(:ip_rulesets :masq :ports);
20 use IPChains;
21  
22 sub new {
23 my $proto = shift;
24 my $class = ref $proto || $proto;
25 bless {
26 port => "33434:33534", # Default numer of hops is 30
27 }, $class;
28 }
29  
30 sub prototypes {
31 my ($self,$target,$options) = @_;
32  
33 my $port = $options->{port} || $self->{port};
34  
35 # Build prototype rule
36 (
37 IPChains->new(
38 Rule => $target,
39 Prot => 'udp',
40 SourcePort => UNPRIVILEGED_PORTS,
41 DestPort => $port,
42 %{$options->{ipchains}},
43 ),
44 );
45 }
46  
47 sub block_rules {
48 my $self = shift;
49 my ( $target, $src, $src_if, $dst, $dst_if, $options ) = @_;
50  
51  
52 my ($fw) = $self->prototypes( $target, $options );
53 block_ip_ruleset( $fw, $src, $src_if, $dst, $dst_if );
54 }
55  
56 sub accept_rules {
57 my $self = shift;
58 my ( $target, $src, $src_if, $dst, $dst_if, $options ) = @_;
59  
60 my ($fw) = $self->prototypes( $target, $options );
61  
62 accept_ip_ruleset( $fw, $src, $src_if, $dst, $dst_if,
63 $options->{masq} ? MASQ : NOMASQ
64 );
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 acct_ip_ruleset( $fw, $src, $src_if, $dst, $dst_if,
74 $options->{masq} ? MASQ : NOMASQ
75 );
76 }
77  
78 sub valid_options {
79 my $self = shift;
80 ( "port=s" );
81 }
82  
83 1;
84 =pod
85  
86 =head1 NAME
87  
88 Fwctl::Services::traceroute - Fwctl module to handle traceroute service.
89  
90 =head1 SYNOPSIS
91  
92 accept traceroute -src INTERNAL_NET -dst INTERNET -masq
93 deny traceroute -src INTERNET --account
94 account traceroute -src INTERNET -dst PERIM_NET
95  
96 =head1 DESCRIPTION
97  
98 This module handle the usual UDP traffic used by the B<traceroute> program.
99 You can use the I<port> option to set the range of port used if your
100 program isn't using the default 33434 and higher.
101  
102 =head1 AUTHOR
103  
104 Francis J. Lacoste <francis.lacoste@iNsu.COM>
105  
106 =head1 COPYRIGHT
107  
108 Copyright (c) 1999,2000 iNsu Innovations Inc.
109 All rights reserved.
110  
111 This program is free software; you can redistribute it and/or modify
112 it under the terms of the GNU General Public License as published by
113 the Free Software Foundation; either version 2 of the License, or
114 (at your option) any later version.
115  
116 =head1 SEE ALSO
117  
118 fwctl(8) Fwctl(3) Fwctl::RuleSet(3)
119  
120 =cut
121