use constant LOG_SIP => "local6"; # Local alias for the logging facility
+our $VERSION = 0.02;
our @ISA = qw(Net::Server::PreFork);
#
# Main
# Read configuration
-my $config = new Sip::Configuration $ARGV[0];
+my $config = Sip::Configuration->new($ARGV[0]);
my @parms;
$self->{service} = $config->find_service( $sockaddr, $port, $proto );
if (! defined($self->{service})) {
- syslog( "LOG_ERR", "process_request: Unknown recognized server connection: %s:%s/%s",
+ syslog( "LOG_ERR", "process_request: Unrecognized server connection: %s:%s/%s",
$sockaddr, $port, $proto );
die "process_request: Bad server connection";
}
package Sip::Configuration;
+our $VERSION = 0.02;
+
use strict;
-use English;
use warnings;
use XML::Simple qw(:strict);
use Sip::Configuration::Account;
use Sip::Configuration::Service;
-my $parser = new XML::Simple( KeyAttr => { login => '+id',
- institution => '+id',
- service => '+port' },
- GroupTags => { listeners => 'service',
- accounts => 'login',
- institutions => 'institution', },
- ForceArray=> [ 'service',
- 'login',
- 'institution' ],
- ValueAttr => { 'error-detect' => 'enabled',
- 'timeout' => 'value',
- 'min_servers' => 'value',
- 'max_servers' => 'value'} );
+my $parser = new XML::Simple(
+ KeyAttr => {
+ login => '+id',
+ institution => '+id',
+ service => '+port'
+ },
+ GroupTags => {
+ listeners => 'service',
+ accounts => 'login',
+ institutions => 'institution',
+ },
+ ForceArray => [ 'service', 'login', 'institution' ],
+ ValueAttr => {
+ 'error-detect' => 'enabled',
+ 'timeout' => 'value',
+ 'min_servers' => 'value',
+ 'max_servers' => 'value'
+ }
+);
sub new {
my ($class, $config_file) = @_;
my %listeners;
foreach my $acct (values %{$cfg->{accounts}}) {
- new Sip::Configuration::Account $acct;
+ new Sip::Configuration::Account $acct;
}
# The key to the listeners hash is the 'port' component of the
# find_server() when building the keys to search the hash.
foreach my $service (values %{$cfg->{listeners}}) {
- new Sip::Configuration::Service $service;
- $listeners{lc $service->{port}} = $service;
+ new Sip::Configuration::Service $service;
+ $listeners{lc $service->{port}} = $service;
}
$cfg->{listeners} = \%listeners;
foreach my $inst (values %{$cfg->{institutions}}) {
- new Sip::Configuration::Institution $inst;
+ new Sip::Configuration::Institution $inst;
}
return bless $cfg, $class;
sub error_detect {
my $self = shift;
-
return $self->{'error-detect'};
}
sub timeout {
my $self = shift;
-
return $self->{'timeout'}
}
sub accounts {
my $self = shift;
-
return values %{$self->{accounts}};
}
sub find_service {
- my ($self, $sockaddr, $port, $proto) = @_;
+ my ( $self, $sockaddr, $port, $proto ) = @_;
my $portstr;
$proto = lc($proto);