| 1 | # | ||
| 2 | # syslog.pm - Fwctl module to handle syslog 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::syslog; | ||
| 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 | my $local_port; | ||
| 32 | if ( $options->{client} ) { | ||
| 33 | $local_port = "1024:65535"; | ||
| 34 | } else { | ||
| 35 | $local_port = "514"; | ||
| 36 | } | ||
| 37 | |||
| 38 | # Build prototype rule | ||
| 39 | ( | ||
| 40 | IPChains->new( | ||
| 41 | Rule => $target, | ||
| 42 | Prot => 'udp', | ||
| 43 | SourcePort => $local_port, | ||
| 44 | DestPort => 514, | ||
| 45 | %{$options->{ipchains}}, | ||
| 46 | ), | ||
| 47 | ); | ||
| 48 | } | ||
| 49 | |||
| 50 | sub block_rules { | ||
| 51 | my $self = shift; | ||
| 52 | my ( $target, $src, $src_if, $dst, $dst_if, $options ) = @_; | ||
| 53 | |||
| 54 | |||
| 55 | my ($fw) = $self->prototypes( $target, $options ); | ||
| 56 | block_ip_ruleset( $fw, $src, $src_if, $dst, $dst_if ); | ||
| 57 | } | ||
| 58 | |||
| 59 | sub accept_rules { | ||
| 60 | my $self = shift; | ||
| 61 | my ( $target, $src, $src_if, $dst, $dst_if, $options ) = @_; | ||
| 62 | |||
| 63 | my ($fw) = $self->prototypes( $target, $options ); | ||
| 64 | |||
| 65 | my $masq = defined $options->{portfw} ? PORTFW : | ||
| 66 | $options->{masq} ? MASQ : NOMASQ; | ||
| 67 | accept_ip_ruleset( $fw, $src, $src_if, $dst, $dst_if, | ||
| 68 | $masq, $options->{portfw} ); | ||
| 69 | } | ||
| 70 | |||
| 71 | sub account_rules { | ||
| 72 | my $self = shift; | ||
| 73 | my ( $target, $src, $src_if, $dst, $dst_if, $options ) = @_; | ||
| 74 | |||
| 75 | my ($fw) = $self->prototypes( $target, $options ); | ||
| 76 | |||
| 77 | my $masq = defined $options->{portfw} ? PORTFW : | ||
| 78 | $options->{masq} ? MASQ : NOMASQ; | ||
| 79 | acct_ip_ruleset( $fw, $src, $src_if, $dst, $dst_if, $masq ); | ||
| 80 | } | ||
| 81 | |||
| 82 | sub valid_options { | ||
| 83 | my $self = shift; | ||
| 84 | ( "client" ); | ||
| 85 | } | ||
| 86 | |||
| 87 | 1; | ||
| 88 | |||
| 89 | =pod | ||
| 90 | |||
| 91 | =head1 NAME | ||
| 92 | |||
| 93 | Fwctl::Services::syslog - Fwctl module to handle syslog UDP traffic. | ||
| 94 | |||
| 95 | =head1 SYNOPSIS | ||
| 96 | |||
| 97 | accept syslog -src ROUTER -dst LOGGER | ||
| 98 | |||
| 99 | =head1 DESCRIPTION | ||
| 100 | |||
| 101 | This modules handles syslog traffic. Syslog traffic is unidirectional | ||
| 102 | UDP message from client to server. | ||
| 103 | |||
| 104 | =head1 OPTIONS | ||
| 105 | |||
| 106 | In addition to the standard options, it accepts the following ones. | ||
| 107 | |||
| 108 | =over | ||
| 109 | |||
| 110 | =item --client | ||
| 111 | |||
| 112 | This will accepts message coming from a syslog client not bound | ||
| 113 | to port 514. The default is to accept messages only coming from | ||
| 114 | port 514. | ||
| 115 | |||
| 116 | =back | ||
| 117 | |||
| 118 | =head1 AUTHOR | ||
| 119 | |||
| 120 | Francis J. Lacoste <francis.lacoste@iNsu.COM> | ||
| 121 | |||
| 122 | =head1 COPYRIGHT | ||
| 123 | |||
| 124 | Copyright (c) 1999,2000 iNsu Innovations Inc. | ||
| 125 | All rights reserved. | ||
| 126 | |||
| 127 | This program is free software; you can redistribute it and/or modify | ||
| 128 | it under the terms of the GNU General Public License as published by | ||
| 129 | the Free Software Foundation; either version 2 of the License, or | ||
| 130 | (at your option) any later version. | ||
| 131 | |||
| 132 | =head1 SEE ALSO | ||
| 133 | |||
| 134 | fwctl(8) Fwctl(3) Fwctl::RuleSet(3) | ||
| 135 | |||
| 136 | =cut | ||
| 137 |