| 1 | # | ||
| 2 | # ip_pkt.pm: Fwctl service module to handle non ICMP/TCP/UDP protocol | ||
| 3 | # packets. | ||
| 4 | # | ||
| 5 | # This file is part of Fwctl. | ||
| 6 | # | ||
| 7 | # Author: Francis J. Lacoste <francis@iNsu.COM> | ||
| 8 | # | ||
| 9 | # Copyright (c) 1999,2000 iNsu Innovations Inc. | ||
| 10 | # | ||
| 11 | # This program is free software; you can redistribute it and/or modify | ||
| 12 | # it under the terms of the GNU General Public License as published by | ||
| 13 | # the Free Software Foundation; either version 2 of the License, or | ||
| 14 | # (at your option) any later version. | ||
| 15 | # | ||
| 16 | package Fwctl::Services::ip_pkt; | ||
| 17 | |||
| 18 | use strict; | ||
| 19 | |||
| 20 | use Fwctl::RuleSet qw(:ip_rulesets :masq); | ||
| 21 | use IPChains; | ||
| 22 | |||
| 23 | sub new { | ||
| 24 | my $proto = shift; | ||
| 25 | my $class = ref $proto || $proto; | ||
| 26 | bless {}, $class; | ||
| 27 | } | ||
| 28 | |||
| 29 | sub prototypes { | ||
| 30 | my ($self,$target,$options) = @_; | ||
| 31 | |||
| 32 | my $proto = $options->{protocol}; | ||
| 33 | |||
| 34 | ( | ||
| 35 | IPChains->new( | ||
| 36 | Rule => $target, | ||
| 37 | Prot => $proto, | ||
| 38 | %{$options->{ipchains}}, | ||
| 39 | ), | ||
| 40 | ); | ||
| 41 | } | ||
| 42 | |||
| 43 | sub block_rules { | ||
| 44 | my $self = shift; | ||
| 45 | my ( $target, $src, $src_if, $dst, $dst_if, $options ) = @_; | ||
| 46 | |||
| 47 | # Build prototype rule | ||
| 48 | my ($msg) = $self->prototypes( $target, $options ); | ||
| 49 | |||
| 50 | block_ip_ruleset( $msg, $src, $src_if, $dst, $dst_if ); | ||
| 51 | } | ||
| 52 | |||
| 53 | sub accept_rules { | ||
| 54 | my $self = shift; | ||
| 55 | my ( $target, $src, $src_if, $dst, $dst_if, $options ) = @_; | ||
| 56 | |||
| 57 | # Build prototype rule | ||
| 58 | my ($msg) = $self->prototypes( $target, $options ); | ||
| 59 | |||
| 60 | accept_ip_ruleset( $msg, $src, $src_if, $dst, $dst_if, | ||
| 61 | $options->{masq} ? MASQ : NOMASQ | ||
| 62 | ); | ||
| 63 | } | ||
| 64 | |||
| 65 | sub account_rules { | ||
| 66 | my $self = shift; | ||
| 67 | my ( $target, $src, $src_if, $dst, $dst_if, $options ) = @_; | ||
| 68 | |||
| 69 | # Build prototype rule | ||
| 70 | my ($msg) = $self->prototypes( $target, $options ); | ||
| 71 | |||
| 72 | acct_ip_ruleset( $msg, $src, $src_if, $dst, $dst_if, | ||
| 73 | $options->{masq} ? MASQ : NOMASQ | ||
| 74 | ); | ||
| 75 | } | ||
| 76 | |||
| 77 | sub valid_options { | ||
| 78 | ( "protocol=s" ); | ||
| 79 | } | ||
| 80 | |||
| 81 | 1; | ||
| 82 | =pod | ||
| 83 | |||
| 84 | =head1 NAME | ||
| 85 | |||
| 86 | Fwctl::Services::ip_pkt - Fwctl module to handle non UDP/TCP/ICMP packets. | ||
| 87 | |||
| 88 | =head1 SYNOPSIS | ||
| 89 | |||
| 90 | accept ip_pkt -src LOCAL_NET -dst REMOTE_IPIP --protocol ipip | ||
| 91 | |||
| 92 | =head1 DESCRIPTION | ||
| 93 | |||
| 94 | This module can be use to add rules for other IP protocols than | ||
| 95 | UDP, TCP or ICMP. | ||
| 96 | |||
| 97 | Use the --protocol option to specify the protocol. | ||
| 98 | |||
| 99 | =head1 AUTHOR | ||
| 100 | |||
| 101 | Francis J. Lacoste <francis.lacoste@iNsu.COM> | ||
| 102 | |||
| 103 | =head1 COPYRIGHT | ||
| 104 | |||
| 105 | Copyright (c) 1999,2000 iNsu Innovations Inc. | ||
| 106 | All rights reserved. | ||
| 107 | |||
| 108 | This program is free software; you can redistribute it and/or modify | ||
| 109 | it under the terms of the GNU General Public License as published by | ||
| 110 | the Free Software Foundation; either version 2 of the License, or | ||
| 111 | (at your option) any later version. | ||
| 112 | |||
| 113 | =head1 SEE ALSO | ||
| 114 | |||
| 115 | fwctl(8) Fwctl(3) Fwctl::RuleSet(3) | ||
| 116 | |||
| 117 | =cut | ||
| 118 |