Fwctl/Services/ntp.pm untested

filter: Statementstmt 0.0% 0 / 32 Branchbran 0.0% 0 / 10 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 / 62 CC 6 SCAR 19.3
CC
6
Cov
0%
accept_rules
12.0
account_rules
12.0
prototypes
6.0
CRAP 6.9
1 #
2 # ntp.pm: Fwctl service module to handle the ntp protocol.
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::ntp;
16  
17 use strict;
18  
19 use Fwctl::RuleSet qw(:udp_rulesets :masq :ports);
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 $src_port = $options->{client} ? UNPRIVILEGED_PORTS : 'ntp';
32  
33 # Build prototype rule
34 (
35 IPChains->new(
36 Rule => $target,
37 Prot => 'udp',
38 SourcePort => $src_port,
39 DestPort => 'ntp',
40 %{$options->{ipchains}},
41 ),
42 );
43 }
44  
45 sub block_rules {
46 my $self = shift;
47 my ( $target, $src, $src_if, $dst, $dst_if, $options ) = @_;
48  
49  
50 my ($fw) = $self->prototypes( $target, $options );
51 block_udp_ruleset( $fw, $src, $src_if, $dst, $dst_if );
52 }
53  
54 sub accept_rules {
55 my $self = shift;
56 my ( $target, $src, $src_if, $dst, $dst_if, $options ) = @_;
57  
58 my ($fw) = $self->prototypes( $target, $options );
59  
60 my $masq = defined $options->{portfw} ? PORTFW :
61 $options->{masq} ? MASQ : NOMASQ;
62  
63 accept_udp_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 acct_udp_ruleset( $fw, $src, $src_if, $dst, $dst_if,
76 $masq, $options->{portfw} );
77 }
78  
79 sub valid_options {
80 my $self = shift;
81 ( "client" );
82 }
83  
84 1;
85  
86 =pod
87  
88 =head1 NAME
89  
90 Fwctl::Services::ntp - Fwctl module to handle the NTP protocol.
91  
92 =head1 SYNOPSIS
93  
94 accept ntp -src PROXY -dst NTP_SERVER
95 accept ntp -src PROXY -dst NTP_SERVER -client -masq #For ntpdate
96  
97 =head1 DESCRIPTION
98  
99 This module enable NTP traffic between two NTP servers. If you
100 use the I<client> option, it will use UNPRIVILEGED_PORTS for the
101 SourcePort to enable ntp clients like B<ntpdate>.
102  
103 =head1 AUTHOR
104  
105 Francis J. Lacoste <francis.lacoste@iNsu.COM>
106  
107 =head1 COPYRIGHT
108  
109 Copyright (c) 1999,2000 iNsu Innovations Inc.
110 All rights reserved.
111  
112 This program is free software; you can redistribute it and/or modify
113 it under the terms of the GNU General Public License as published by
114 the Free Software Foundation; either version 2 of the License, or
115 (at your option) any later version.
116  
117 =head1 SEE ALSO
118  
119 fwctl(8) Fwctl(3) Fwctl::RuleSet(3)
120  
121 =cut
122