| 1 | # | ||
| 2 | # redirect.pm: Fwctl service module to handle ICMP redirect message | ||
| 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::redirect; | ||
| 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 | IPChains->new( | ||
| 32 | Rule => $target, | ||
| 33 | Prot => 'icmp', | ||
| 34 | ICMP => 'redirect', | ||
| 35 | %{$options->{ipchains}}, | ||
| 36 | ), | ||
| 37 | ); | ||
| 38 | } | ||
| 39 | |||
| 40 | sub block_rules { | ||
| 41 | my $self = shift; | ||
| 42 | my ( $target, $src, $src_if, $dst, $dst_if, $options ) = @_; | ||
| 43 | |||
| 44 | # Build prototype rule | ||
| 45 | my ($msg) = $self->prototypes( $target, $options ); | ||
| 46 | |||
| 47 | block_ip_ruleset( $msg, $src, $src_if, $dst, $dst_if ); | ||
| 48 | } | ||
| 49 | |||
| 50 | sub accept_rules { | ||
| 51 | my $self = shift; | ||
| 52 | my ( $target, $src, $src_if, $dst, $dst_if, $options ) = @_; | ||
| 53 | |||
| 54 | # Build prototype rule | ||
| 55 | my ($msg) = $self->prototypes( $target, $options ); | ||
| 56 | |||
| 57 | accept_ip_ruleset( $msg, $src, $src_if, $dst, $dst_if, | ||
| 58 | $options->{masq} ? MASQ : NOMASQ | ||
| 59 | ); | ||
| 60 | } | ||
| 61 | |||
| 62 | sub account_rules { | ||
| 63 | my $self = shift; | ||
| 64 | my ( $target, $src, $src_if, $dst, $dst_if, $options ) = @_; | ||
| 65 | |||
| 66 | # Build prototype rule | ||
| 67 | my ($msg) = $self->prototypes( $target, $options ); | ||
| 68 | |||
| 69 | acct_ip_ruleset( $msg, $src, $src_if, $dst, $dst_if, | ||
| 70 | $options->{masq} ? MASQ : NOMASQ | ||
| 71 | ); | ||
| 72 | } | ||
| 73 | |||
| 74 | sub valid_options { | ||
| 75 | (); # No options | ||
| 76 | } | ||
| 77 | |||
| 78 | 1; | ||
| 79 | =pod | ||
| 80 | |||
| 81 | =head1 NAME | ||
| 82 | |||
| 83 | Fwctl::Services::redirect - Fwctl module to handle ICMP redirect messages. | ||
| 84 | |||
| 85 | =head1 SYNOPSIS | ||
| 86 | |||
| 87 | accept redirect -src INT_IP -dst INT_NET | ||
| 88 | account redirect -src INTERNET | ||
| 89 | |||
| 90 | =head1 DESCRIPTION | ||
| 91 | |||
| 92 | The redirect module can be use to configure policies for ICMP Router Redirect | ||
| 93 | messages. This module takes no options. | ||
| 94 | |||
| 95 | =head1 AUTHOR | ||
| 96 | |||
| 97 | Francis J. Lacoste <francis.lacoste@iNsu.COM> | ||
| 98 | |||
| 99 | =head1 COPYRIGHT | ||
| 100 | |||
| 101 | Copyright (c) 1999,2000 iNsu Innovations Inc. | ||
| 102 | All rights reserved. | ||
| 103 | |||
| 104 | This program is free software; you can redistribute it and/or modify | ||
| 105 | it under the terms of the GNU General Public License as published by | ||
| 106 | the Free Software Foundation; either version 2 of the License, or | ||
| 107 | (at your option) any later version. | ||
| 108 | |||
| 109 | =head1 SEE ALSO | ||
| 110 | |||
| 111 | fwctl(8) Fwctl(3) Fwctl::RuleSet(3) | ||
| 112 | |||
| 113 | =cut | ||
| 114 |