# Read a packet from $file, using the correct record separator
#
sub read_SIP_packet {
- my $record;
my $fh = shift or syslog("LOG_ERR", "read_SIP_packet: no filehandle argument!");
+ my $sip_server = shift;
+ my $record;
my $len1 = 999;
+ # during login, the account will not exist yet.
+ my $account = '';
+ $account = $sip_server->{account}->{id}
+ if $sip_server && $sip_server->{account};
+
# local $/ = "\r"; # don't need any of these here. use whatever the prevailing $/ is.
local $/ = "\015"; # proper SPEC: (octal) \015 = (hex) x0D = (dec) 13 = (ascii) carriage return
{ # adapted from http://perldoc.perl.org/5.8.8/functions/readline.html
}
if ($record) {
my $len2 = length($record);
- syslog("LOG_INFO", "read_SIP_packet, INPUT MSG: '$record'") if $record;
($len1 != $len2) and syslog("LOG_DEBUG", "read_SIP_packet, trimmed %s character(s) (after chomps).", $len1-$len2);
} else {
syslog("LOG_WARNING", "read_SIP_packet input %s, end of input.", (defined($record) ? "empty ($record)" : 'undefined'));
# on the input.
#
# This is now handled by the vigorous cleansing above.
- syslog("LOG_INFO", encode_utf8("INPUT MSG: '$record'")) if $record;
+ syslog("LOG_INFO", encode_utf8("INPUT MSG [$account]: '$record'")) if $record;
return $record;
}
my ($self, $msg, $file) = @_;
my $cksum;
+ my $account = '';
+ $account = $self->{server}->{account}->{id}
+ if $self->{server} && $self->{server}->{account};
+
$msg = encode_utf8($msg);
if ($error_detection) {
if (defined($self->{seqno})) {
print $file "$msg\r";
} else {
print "$msg\r";
- syslog("LOG_INFO", "OUTPUT MSG: '$msg'");
+ syslog("LOG_INFO", "OUTPUT MSG [$account]: '$msg'");
}
$last_response = $msg;
$req && (substr($msg, 0, 2) ne $req)) {
return substr($msg, 0, 2);
}
+
+ # link the server to the message so we don't have to
+ # propagate the server to subs called by the handler (below).
+ $self->{server} = $server;
return($self->{handler}->($self, $server));
}