View | Details | Raw Unified | Return to bug 7787
Collapse All | Expand All

(-)a/C4/SIP/SIPServer.pm (-12 / +9 lines)
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 = '';
(-)a/C4/SIP/Sip.pm (-8 lines)
Lines 156-162 sub read_SIP_packet { Link Here
156
    # local $/ = "\r";      # don't need any of these here.  use whatever the prevailing $/ is.
156
    # local $/ = "\r";      # don't need any of these here.  use whatever the prevailing $/ is.
157
    local $/ = "\015";    # proper SPEC: (octal) \015 = (hex) x0D = (dec) 13 = (ascii) carriage return
157
    local $/ = "\015";    # proper SPEC: (octal) \015 = (hex) x0D = (dec) 13 = (ascii) carriage return
158
    {    # adapted from http://perldoc.perl.org/5.8.8/functions/readline.html
158
    {    # adapted from http://perldoc.perl.org/5.8.8/functions/readline.html
159
        for ( my $tries = 1 ; $tries <= 3 ; $tries++ ) {
160
            undef $!;
159
            undef $!;
161
            $record = readline($fh);
160
            $record = readline($fh);
162
            if ( defined($record) ) {
161
            if ( defined($record) ) {
Lines 171-184 sub read_SIP_packet { Link Here
171
                while ( chomp($record) ) { 1; }
170
                while ( chomp($record) ) { 1; }
172
171
173
                $record and last;    # success
172
                $record and last;    # success
174
            } else {
175
                if ($!) {
176
                    syslog( "LOG_DEBUG", "read_SIP_packet (try #$tries) ERROR: $! $@" );
177
                    # die "read_SIP_packet ERROR: $!";
178
                    warn "read_SIP_packet ERROR: $! $@";
179
                }
180
            }
173
            }
181
        }
182
    }
174
    }
183
    if ($record) {
175
    if ($record) {
184
        my $len2 = length($record);
176
        my $len2 = length($record);
(-)a/C4/SIP/Sip/MsgType.pm (-2 / +3 lines)
Lines 405-411 sub handle { Link Here
405
	}
405
	}
406
	unless ($self->{handler}) {
406
	unless ($self->{handler}) {
407
		syslog("LOG_WARNING", "No handler defined for '%s'", $msg);
407
		syslog("LOG_WARNING", "No handler defined for '%s'", $msg);
408
		return undef;
408
		$last_response = REQUEST_SC_RESEND;
409
		print("$last_response\r");
410
		return REQUEST_ACS_RESEND;
409
	}
411
	}
410
    return($self->{handler}->($self, $server));  # FIXME
412
    return($self->{handler}->($self, $server));  # FIXME
411
	# FIXME: Use of uninitialized value in subroutine entry
413
	# FIXME: Use of uninitialized value in subroutine entry
412
- 

Return to bug 7787