| 1 | # | ||
| 2 | # traffic_control.pm: Fwctl module to handle ICMP traffic control. | ||
| 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::traffic_control; | ||
| 16 | |||
| 17 | use strict; | ||
| 18 | |||
| 19 | use Fwctl::RuleSet qw(:ip_rulesets :masq); | ||
| 20 | use IPChains; | ||
| 21 | |||
| 22 | use vars qw( @TYPES ); | ||
| 23 | |||
| 24 | @TYPES = qw( ttl-exceeded parameter-problem source-quench | ||
| 25 | destination-unreachable ); | ||
| 26 | |||
| 27 | sub new { | ||
| 28 | my $proto = shift; | ||
| 29 | my $class = ref $proto || $proto; | ||
| 30 | bless {}, $class; | ||
| 31 | } | ||
| 32 | |||
| 33 | sub prototypes { | ||
| 34 | my ($self,$target,$options) = @_; | ||
| 35 | ( | ||
| 36 | IPChains->new( | ||
| 37 | Rule => $target, | ||
| 38 | Prot => 'icmp', | ||
| 39 | %{$options->{ipchains}}, | ||
| 40 | ), | ||
| 41 | ); | ||
| 42 | } | ||
| 43 | |||
| 44 | sub block_rules { | ||
| 45 | my $self = shift; | ||
| 46 | my ( $target, $src, $src_if, $dst, $dst_if, $options ) = @_; | ||
| 47 | |||
| 48 | # Build prototype rule | ||
| 49 | my ($icmp) = $self->prototypes( $target, $options ); | ||
| 50 | |||
| 51 | for (@TYPES) { | ||
| 52 | $icmp->attribute( ICMP => $_ ); | ||
| 53 | block_ip_ruleset( $icmp, $src, $src_if, $dst, $dst_if ); | ||
| 54 | } | ||
| 55 | } | ||
| 56 | |||
| 57 | sub accept_rules { | ||
| 58 | my $self = shift; | ||
| 59 | my ( $target, $src, $src_if, $dst, $dst_if, $options ) = @_; | ||
| 60 | |||
| 61 | # Build prototype rule | ||
| 62 | my ($icmp) = $self->prototypes( $target, $options ); | ||
| 63 | |||
| 64 | for (@TYPES) { | ||
| 65 | $icmp->attribute( ICMP => $_ ); | ||
| 66 | accept_ip_ruleset( $icmp, $src, $src_if, $dst, $dst_if, | ||
| 67 | $options->{masq} ? MASQ : NOMASQ | ||
| 68 | ); | ||
| 69 | } | ||
| 70 | } | ||
| 71 | |||
| 72 | sub account_rules { | ||
| 73 | my $self = shift; | ||
| 74 | my ( $target, $src, $src_if, $dst, $dst_if, $options ) = @_; | ||
| 75 | |||
| 76 | # Build prototype rule | ||
| 77 | my ($icmp) = $self->prototypes( $target, $options ); | ||
| 78 | |||
| 79 | for (@TYPES) { | ||
| 80 | $icmp->attribute( ICMP => $_ ); | ||
| 81 | acct_ip_ruleset( $icmp, $src, $src_if, $dst, $dst_if, | ||
| 82 | $options->{masq} ? MASQ : NOMASQ | ||
| 83 | ); | ||
| 84 | } | ||
| 85 | } | ||
| 86 | |||
| 87 | sub valid_options { | ||
| 88 | (); # No options | ||
| 89 | } | ||
| 90 | |||
| 91 | 1; | ||
| 92 | =pod | ||
| 93 | |||
| 94 | =head1 NAME | ||
| 95 | |||
| 96 | Fwctl::Services::traffic_control - Fwctl module to handle the necessary | ||
| 97 | ICMP traffic. | ||
| 98 | |||
| 99 | =head1 SYNOPSIS | ||
| 100 | |||
| 101 | accept traffic_control -src INTERNET --account | ||
| 102 | accept traffic_control | ||
| 103 | |||
| 104 | =head1 DESCRIPTION | ||
| 105 | |||
| 106 | This module handles rules for the necessary ICMP traffic control types: | ||
| 107 | destination-unreachable, source-quench, ttl-exceeded and parameter-problem. | ||
| 108 | |||
| 109 | You should really accept this with any network you want to communicate. | ||
| 110 | Failure to do so, will hinder communication severly. YHBW. | ||
| 111 | |||
| 112 | =head1 AUTHOR | ||
| 113 | |||
| 114 | Francis J. Lacoste <francis.lacoste@iNsu.COM> | ||
| 115 | |||
| 116 | =head1 COPYRIGHT | ||
| 117 | |||
| 118 | Copyright (c) 1999,2000 iNsu Innovations Inc. | ||
| 119 | All rights reserved. | ||
| 120 | |||
| 121 | This program is free software; you can redistribute it and/or modify | ||
| 122 | it under the terms of the GNU General Public License as published by | ||
| 123 | the Free Software Foundation; either version 2 of the License, or | ||
| 124 | (at your option) any later version. | ||
| 125 | |||
| 126 | =head1 SEE ALSO | ||
| 127 | |||
| 128 | fwctl(8) Fwctl(3) Fwctl::RuleSet(3) | ||
| 129 | |||
| 130 | =cut | ||
| 131 |