X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=bin%2Fcdr-opensips.import;h=b8169d5236f44f708e666c15a48c947455eb1114;hp=489fac6d63ea88b9d013b8dcbf191a0c984fc0bd;hb=88e9a56677d343392416c262f976f069157b06cb;hpb=fb4ab1073f0d15d660c6cdc4e07afebf68ef3924 diff --git a/bin/cdr-opensips.import b/bin/cdr-opensips.import index 489fac6d6..b8169d523 100755 --- a/bin/cdr-opensips.import +++ b/bin/cdr-opensips.import @@ -82,15 +82,26 @@ while ( $row = $sth->fetchrow_hashref ) { #i guess now we're NANPA-centric, but at least we warn on non-numeric numbers my $src = ''; - if ( $row->{'caller_id'} =~ /^sip:(\+1)?(\d+)@/ ) { + my $src_ip = ''; + if ( $row->{'caller_id'} =~ /^sip:(\+1?)?(\w+)@(.*)/ ) { $src = $2; + my $rest = $3; + if ($rest =~ /^([\d\.]{7,15})/) { + # canonicalize it so that ascii sort order works + $src_ip = sprintf('%03d.%03d.%03d.%03d', split('\.', $1)); + } } else { warn "unparseable caller_id ". $row->{'caller_id'}. "\n"; } my $dst = ''; - if ( $row->{'callee_id'} =~ /^sip:(\+1)?(\d+)@/ ) { + my $dst_ip = ''; + if ( $row->{'callee_id'} =~ /^sip:(\+1?)?(\w+)@(.*)/ ) { $dst = $2; + my $rest = $3; + if ($rest =~ /^([\d\.]{7,15})/) { + $dst_ip = sprintf('%03d.%03d.%03d.%03d', split('\.', $1)); + } } else { warn "unparseable callee_id ". $row->{'callee_id'}. "\n"; } @@ -108,6 +119,8 @@ while ( $row = $sth->fetchrow_hashref ) { $cdr->startdate($date); $cdr->src($src); $cdr->dst($dst); + $cdr->src_ip_addr($src_ip); + $cdr->dst_ip_addr($dst_ip); } elsif ( $row->{'method'} eq 'ACK' ) { $cdr->answerdate($date);