[freeside-commits] freeside/FS/FS/cdr netcentrex.pm,1.1,1.2
Ivan,,,
ivan at wavetail.420.am
Fri May 29 16:17:26 PDT 2009
Update of /home/cvs/cvsroot/freeside/FS/FS/cdr
In directory wavetail.420.am:/tmp/cvs-serv312/cdr
Modified Files:
netcentrex.pm
Log Message:
fixup pivot code handling in netcentrex CDR handling, RT#4081
Index: netcentrex.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cdr/netcentrex.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- netcentrex.pm 6 Oct 2008 15:28:14 -0000 1.1
+++ netcentrex.pm 29 May 2009 23:17:24 -0000 1.2
@@ -29,8 +29,8 @@
_cdr_date_parser_maker('startdate'), #05 Authorize timestamp
_cdr_date_parser_maker('answerdate'), #06 Start timestamp
'billsec', #'duration', #07 Duration
- _e164_parser_maker('src'), #08 Caller
- _e164_parser_maker('dst'), #09 Callee
+ _e164_parser_maker('src', 'charged_party'), #08 Caller
+ _e164_parser_maker('dcontext', 'dst', 'norewrite_pivotonly'=>1) ,#09 Callee
'channel', #10 Source IP
'dstchannel', #11 Destination IP
'userfield', #12 selector Tag
@@ -80,43 +80,40 @@
);
sub _e164_parser_maker {
- my $field = shift;
+ my( $field, $pivot_field, %opt ) = @_;
return sub {
my( $cdr, $e164 ) = @_;
- eval { $cdr->$field( _e164_parse($e164) ); };
- die "error parsing e164 for $field from $e164: $@\n" if $@;
+ my( $pivot, $number ) = _e164_parse($e164);
+ if ( $opt{'norewrite_pivotonly'} && ! $pivot ) {
+ $cdr->$pivot_field( $number );
+ } else {
+ $cdr->$field( $number );
+ $cdr->$pivot_field( $pivot );
+ }
};
}
-my %e164_types = (
- '000000' => '',
- '100005' => '',
- '100009' => '',
- '100012' => '',
- '100014' => '',
- '100015' => '',
- '100016' => '',
- '300000' => '',
-);
-
sub _e164_parse {
my $e164 = shift;
$e164 =~ s/^e164://;
- my ($type, $number);
+ my ($pivot, $number);
if ( $e164 =~ /^O(\d+)$/ ) {
- $type = ''; #?
+ $pivot = ''; #?
$number = $1;
- } elsif ( $e164 =~ /^(\d{6})(\d+)$/ ) {
- $type = $1;
+ } elsif ( $e164 =~ /^000000(\d+)$/ ) {
+ $pivot = '';
+ $number = $1;
+ } elsif ( $e164 =~ /^(1\d{5})(\d+)$/ ) {
+ $pivot = $1;
$number = $2;
} else {
- $type = '';
+ $pivot = '';
$number = $e164; #unparsable...
}
- #$type...?
- $number;
+
+ ( $pivot, $number );
}
1;
More information about the freeside-commits
mailing list