Lines 21-27
use constant LOG_SIP => "local6"; # Local alias for the logging facility
Link Here
|
21 |
use vars qw(@ISA $VERSION); |
21 |
use vars qw(@ISA $VERSION); |
22 |
|
22 |
|
23 |
BEGIN { |
23 |
BEGIN { |
24 |
$VERSION = 1.02; |
24 |
$VERSION = 1.03; |
25 |
@ISA = qw(Net::Server::PreFork); |
25 |
@ISA = qw(Net::Server::PreFork); |
26 |
} |
26 |
} |
27 |
|
27 |
|
Lines 269-300
sub sip_protocol_loop {
Link Here
|
269 |
# In short, we'll take any valid message here. |
269 |
# In short, we'll take any valid message here. |
270 |
#my $expect = SC_STATUS; |
270 |
#my $expect = SC_STATUS; |
271 |
my $expect = ''; |
271 |
my $expect = ''; |
272 |
my $strikes = 3; |
272 |
while (1) { |
273 |
while ($input = Sip::read_SIP_packet(*STDIN)) { |
273 |
$input = Sip::read_SIP_packet(*STDIN); |
|
|
274 |
unless ($input) { |
275 |
print("96$CR"); |
276 |
next; |
277 |
} |
274 |
# begin input hacks ... a cheap stand in for better Telnet layer |
278 |
# begin input hacks ... a cheap stand in for better Telnet layer |
275 |
$input =~ s/^[^A-z0-9]+//s; # Kill leading bad characters... like Telnet handshakers |
279 |
$input =~ s/^[^A-z0-9]+//s; # Kill leading bad characters... like Telnet handshakers |
276 |
$input =~ s/[^A-z0-9]+$//s; # Same on the end, should get DOSsy ^M line-endings too. |
280 |
$input =~ s/[^A-z0-9]+$//s; # Same on the end, should get DOSsy ^M line-endings too. |
277 |
while (chomp($input)) {warn "Extra line ending on input";} |
281 |
while (chomp($input)) {warn "Extra line ending on input";} |
278 |
unless ($input) { |
282 |
unless ($input) { |
279 |
if ($strikes--) { |
283 |
syslog("LOG_ERR", "sip_protocol_loop: empty input skipped"); |
280 |
syslog("LOG_ERR", "sip_protocol_loop: empty input skipped"); |
284 |
next; |
281 |
next; |
|
|
282 |
} else { |
283 |
syslog("LOG_ERR", "sip_protocol_loop: quitting after too many errors"); |
284 |
die "sip_protocol_loop: quitting after too many errors"; |
285 |
} |
286 |
} |
285 |
} |
287 |
# end cheap input hacks |
286 |
# end cheap input hacks |
288 |
my $status = Sip::MsgType::handle($input, $self, $expect); |
287 |
my $status = Sip::MsgType::handle($input, $self, $expect); |
289 |
if (!$status) { |
288 |
if (!$status) { |
290 |
syslog("LOG_ERR", "sip_protocol_loop: failed to handle %s",substr($input,0,2)); |
289 |
syslog("LOG_ERR", "sip_protocol_loop: failed to handle %s",substr($input,0,2)); |
291 |
die "sip_protocol_loop: failed Sip::MsgType::handle('$input', $self, '$expect')"; |
|
|
292 |
} |
290 |
} |
293 |
next if $status eq REQUEST_ACS_RESEND; |
291 |
next if $status eq REQUEST_ACS_RESEND; |
294 |
if ($expect && ($status ne $expect)) { |
292 |
if ($expect && ($status ne $expect)) { |
295 |
# We received a non-"RESEND" that wasn't what we were expecting. |
293 |
# We received a non-"RESEND" that wasn't what we were expecting. |
296 |
syslog("LOG_ERR", "sip_protocol_loop: expected %s, received %s, exiting", $expect, $input); |
294 |
syslog("LOG_ERR", "sip_protocol_loop: expected %s, received %s, exiting", $expect, $input); |
297 |
die "sip_protocol_loop: exiting: expected '$expect', received '$status'"; |
|
|
298 |
} |
295 |
} |
299 |
# We successfully received and processed what we were expecting |
296 |
# We successfully received and processed what we were expecting |
300 |
$expect = ''; |
297 |
$expect = ''; |