Fwctl/Services/pcanywhere.pm untested

filter: Statementstmt 0.0% 0 / 41 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 / 71 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 # pcanywhere.pm: Fwctl service module to handle the PC Anywhere 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::pcanywhere;
16  
17 use strict;
18  
19 use Fwctl::RuleSet qw(:tcp_rulesets :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 # Build prototype rule
32 my ($udp_port,$tcp_port);
33 if ( $options->{old} ) {
34 $udp_port = 22;
35 $tcp_port = 65301;
36 } else {
37 $udp_port = 5632;
38 $tcp_port = 5631;
39 }
40 (
41 IPChains->new(
42 Rule => $target,
43 Prot => 'udp',
44 SourcePort => UNPRIVILEGED_PORTS,
45 DestPort => $udp_port,
46 %{$options->{ipchains}},
47 ),
48 IPChains->new(
49 Rule => $target,
50 Prot => 'tcp',
51 SourcePort => UNPRIVILEGED_PORTS,
52 DestPort => $tcp_port,
53 %{$options->{ipchains}},
54 ),
55 );
56 }
57  
58 sub block_rules {
59 my $self = shift;
60 my ( $target, $src, $src_if, $dst, $dst_if, $options ) = @_;
61  
62  
63 my ( $udp, $tcp ) = $self->prototypes( $target, $options );
64  
65 block_udp_ruleset( $udp, $src, $src_if, $dst, $dst_if );
66 block_tcp_ruleset( $tcp, $src, $src_if, $dst, $dst_if );
67 }
68  
69 sub accept_rules {
70 my $self = shift;
71 my ( $target, $src, $src_if, $dst, $dst_if, $options ) = @_;
72  
73 my ( $udp, $tcp ) = $self->prototypes( $target, $options );
74  
75 my $masq = defined $options->{portfw} ? PORTFW :
76 $options->{masq} ? MASQ : NOMASQ;
77  
78 accept_udp_ruleset( $udp, $src, $src_if, $dst, $dst_if,
79 $masq, $options->{portfw} );
80  
81 accept_tcp_ruleset( $tcp, $src, $src_if, $dst, $dst_if,
82 $masq, $options->{portfw} );
83 }
84  
85 sub account_rules {
86 my $self = shift;
87 my ( $target, $src, $src_if, $dst, $dst_if, $options ) = @_;
88  
89 my ( $udp, $tcp ) = $self->prototypes( $target, $options );
90  
91 my $masq = defined $options->{portfw} ? PORTFW :
92 $options->{masq} ? MASQ : NOMASQ;
93  
94 acct_udp_ruleset( $udp, $src, $src_if, $dst, $dst_if,
95 $masq, $options->{portfw} );
96  
97 acct_tcp_ruleset( $tcp, $src, $src_if, $dst, $dst_if,
98 $masq, $options->{portfw} );
99  
100 }
101  
102 sub valid_options {
103 my $self = shift;
104 ( );
105 }
106  
107 1;
108  
109 =pod
110  
111 =head1 NAME
112  
113 Fwctl::Services::pcanywhere - Fwctl module to handle the PC Anywhere protocol.
114  
115 =head1 SYNOPSIS
116  
117 accept pcanywhere -src INT_NET -dst REMOTE -masq -account -name PCA
118  
119 =head1 DESCRIPTION
120  
121 This module encapsulates the different TCP and UDP connections used by
122 the PC Anywhere protocol. Use the -old option to use the older set of
123 non registered ports.
124  
125 =head1 AUTHOR
126  
127 Francis J. Lacoste <francis.lacoste@iNsu.COM>
128  
129 =head1 COPYRIGHT
130  
131 Copyright (c) 1999,2000 iNsu Innovations Inc.
132 All rights reserved.
133  
134 This program is free software; you can redistribute it and/or modify
135 it under the terms of the GNU General Public License as published by
136 the Free Software Foundation; either version 2 of the License, or
137 (at your option) any later version.
138  
139 =head1 SEE ALSO
140  
141 fwctl(8) Fwctl(3) Fwctl::RuleSet(3)
142  
143 =cut
144