| 1 | package CDR::Parser::SI3000; | ||||||||||||||||||
| 2 | |||||||||||||||||||
| 3 | 3 | ▶ | use 5.10.0; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 4 | 3 | ▶ | use strict; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 5 | 3 | ▶ | use warnings FATAL => 'all'; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 6 | 3 | ▶ | use Data::Dumper; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 7 | 3 | ▶ | use IO::File (); | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 8 | |||||||||||||||||||
| 9 | =head1 NAME | ||||||||||||||||||
| 10 | |||||||||||||||||||
| 11 | CDR::Parser::SI3000 - parser for binary CDR files (*.ama) produced by Iskratel SI3000 MSCN telephony product | ||||||||||||||||||
| 12 | |||||||||||||||||||
| 13 | CDR = Call Detail Records | ||||||||||||||||||
| 14 | |||||||||||||||||||
| 15 | =head1 VERSION | ||||||||||||||||||
| 16 | |||||||||||||||||||
| 17 | Version 0.01 | ||||||||||||||||||
| 18 | |||||||||||||||||||
| 19 | =cut | ||||||||||||||||||
| 20 | |||||||||||||||||||
| 21 | 3 | our $VERSION = '0.02'; | |||||||||||||||||
| 22 | |||||||||||||||||||
| 23 | 3 | our $VERBOSE = 0; | |||||||||||||||||
| 24 | |||||||||||||||||||
| 25 | =head1 SYNOPSIS | ||||||||||||||||||
| 26 | |||||||||||||||||||
| 27 | Whis module parses the binary file format and returns it as Perl data. | ||||||||||||||||||
| 28 | |||||||||||||||||||
| 29 | Usage example | ||||||||||||||||||
| 30 | |||||||||||||||||||
| 31 | use CDR::Parser::SI3000; | ||||||||||||||||||
| 32 | |||||||||||||||||||
| 33 | my ($cdr_list, $num_failed) = CDR::Parser::SI3000->parse_file('somefile.ama'); | ||||||||||||||||||
| 34 | |||||||||||||||||||
| 35 | There | ||||||||||||||||||
| 36 | $cdr_list is a array-reference containing individual records as hash-ref. | ||||||||||||||||||
| 37 | $num_failed is a number of unparseable records | ||||||||||||||||||
| 38 | |||||||||||||||||||
| 39 | |||||||||||||||||||
| 40 | =head1 SUBROUTINES/METHODS | ||||||||||||||||||
| 41 | |||||||||||||||||||
| 42 | =head2 parse_file | ||||||||||||||||||
| 43 | |||||||||||||||||||
| 44 | Get filename as input, open it, read it, returns the parsed result | ||||||||||||||||||
| 45 | |||||||||||||||||||
| 46 | =cut | ||||||||||||||||||
| 47 | |||||||||||||||||||
| 48 | |||||||||||||||||||
| 49 | #-- | ||||||||||||||||||
| 50 | |||||||||||||||||||
| 51 | # $| = 1; | ||||||||||||||||||
| 52 | |||||||||||||||||||
| 53 | sub _log { | ||||||||||||||||||
| 54 | 901 | ▶ | my($format, @args) = @_; | ||||||||||||||||
|
Subroutine
_log: called CC=2 SCAR=8.1
| |||||||||||||||||||
| 55 | 901 | ▶ | return if(! $VERBOSE); | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 56 | 0 | printf $format."\n", @args; | |||||||||||||||||
| 57 | } | ||||||||||||||||||
| 58 | |||||||||||||||||||
| 59 | # public | ||||||||||||||||||
| 60 | sub parse_file { | ||||||||||||||||||
| 61 | 1 | ▶ | my($class, $filename) = @_; | ||||||||||||||||
|
Subroutine
parse_file: called CC=5 SCAR=16.3
Pod
documented
| |||||||||||||||||||
| 62 | 1 | ▶ | die "No filename argument" if(! $filename); | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 63 | 1 | _log('Parsing file %s', $filename); | |||||||||||||||||
| 64 | |||||||||||||||||||
| 65 | 1 | ▶ | my $fh = IO::File->new($filename) || die "Failed to open $filename - $!"; | ||||||||||||||||
|
Condition50%1/2
'IO::File'->new($filename) || die("Failed to open $filename - $!")
MC/DC0%0/1
'IO::File'->new($filename) || die("Failed to open $filename - $!")
'IO::File'->new($filename)
Truth table50%1/2
A
A= 'IO::File'->new($filename)
| |||||||||||||||||||
| 66 | 1 | binmode($fh, ':bytes'); | |||||||||||||||||
| 67 | |||||||||||||||||||
| 68 | 1 | my @records = (); | |||||||||||||||||
| 69 | |||||||||||||||||||
| 70 | 1 | my $rows = 0; | |||||||||||||||||
| 71 | 1 | my $failed = 0; | |||||||||||||||||
| 72 | |||||||||||||||||||
| 73 | 1 | while(1) { | |||||||||||||||||
| 74 | 16 | my $call = parse_record($fh); | |||||||||||||||||
| 75 | 16 | ▶ | if($call) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 76 | 15 | push @records, $call; | |||||||||||||||||
| 77 | } | ||||||||||||||||||
| 78 | else { | ||||||||||||||||||
| 79 | 1 | ▶ | last if($call == 0); | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 80 | 0 | $failed++; | |||||||||||||||||
| 81 | } | ||||||||||||||||||
| 82 | } | ||||||||||||||||||
| 83 | |||||||||||||||||||
| 84 | 1 | $fh->close; | |||||||||||||||||
| 85 | |||||||||||||||||||
| 86 | 1 | return (\@records, $failed); | |||||||||||||||||
| 87 | } | ||||||||||||||||||
| 88 | |||||||||||||||||||
| 89 | #------ private implementation ------ | ||||||||||||||||||
| 90 | |||||||||||||||||||
| 91 | # 100. Called number | ||||||||||||||||||
| 92 | sub block_100 { | ||||||||||||||||||
| 93 | 15 | ▶ | my($call,$variable) = @_; | ||||||||||||||||
|
Subroutine
block_100: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||
| 94 | |||||||||||||||||||
| 95 | 15 | _log('100. Called number'); | |||||||||||||||||
| 96 | 15 | my $cld_len; | |||||||||||||||||
| 97 | 15 | ($cld_len, $$variable) = unpack('C a*', $$variable); | |||||||||||||||||
| 98 | 15 | my $cut = $cld_len; | |||||||||||||||||
| 99 | 15 | ▶ | $cut++ if($cld_len % 2 == 1); | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 100 | 15 | my $cld; | |||||||||||||||||
| 101 | 15 | ($cld, $$variable) = unpack("H$cut a*", $$variable); | |||||||||||||||||
| 102 | 15 | ▶ | if($cut > $cld_len) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 103 | 15 | $cld = substr($cld, 0, -1); | |||||||||||||||||
| 104 | } | ||||||||||||||||||
| 105 | 15 | _log(' CLD: %s', $cld); | |||||||||||||||||
| 106 | 15 | $call->{cld} = $cld; | |||||||||||||||||
| 107 | } | ||||||||||||||||||
| 108 | |||||||||||||||||||
| 109 | # 101. Call accepting party number | ||||||||||||||||||
| 110 | # 102. Start Date and Time | ||||||||||||||||||
| 111 | sub block_102 { | ||||||||||||||||||
| 112 | 15 | ▶ | my($call, $var) = @_; | ||||||||||||||||
|
Subroutine
block_102: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 113 | 15 | _log("102. Start Date and Time"); | |||||||||||||||||
| 114 | 15 | my($year,$month,$day,$hour,$min,$sec,$msec,$reserved); | |||||||||||||||||
| 115 | 15 | ($year,$month,$day,$hour,$min,$sec,$msec,$reserved,$$var) = unpack('CCCCCCC H2 a*', $$var); | |||||||||||||||||
| 116 | 15 | $year += 2000; | |||||||||||||||||
| 117 | 15 | my $start_time = sprintf "%04d-%02d-%02d %02d:%02d:%02d.%02d", $year,$month,$day,$hour,$min,$sec,$msec; | |||||||||||||||||
| 118 | 15 | _log(' Start Time: %s', $start_time); | |||||||||||||||||
| 119 | 15 | $call->{start_time} = $start_time; | |||||||||||||||||
| 120 | } | ||||||||||||||||||
| 121 | # 103. End Date and Time | ||||||||||||||||||
| 122 | sub block_103 { | ||||||||||||||||||
| 123 | 15 | ▶ | my($call, $var) = @_; | ||||||||||||||||
|
Subroutine
block_103: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 124 | 15 | _log("103. End Date and Time"); | |||||||||||||||||
| 125 | 15 | my($year,$month,$day,$hour,$min,$sec,$msec,$reliable); | |||||||||||||||||
| 126 | 15 | ($year,$month,$day,$hour,$min,$sec,$msec,$reliable,$$var) = unpack('CCCCCCC H2 a*', $$var); | |||||||||||||||||
| 127 | 15 | $year += 2000; | |||||||||||||||||
| 128 | 15 | my $end_time = sprintf "%04d-%02d-%02d %02d:%02d:%02d.%02d", $year,$month,$day,$hour,$min,$sec,$msec; | |||||||||||||||||
| 129 | 15 | _log(' End Time: %s', $end_time); | |||||||||||||||||
| 130 | 15 | $call->{end_time} = $end_time; | |||||||||||||||||
| 131 | } | ||||||||||||||||||
| 132 | # 104. Number of charging units | ||||||||||||||||||
| 133 | sub block_104 { | ||||||||||||||||||
| 134 | 15 | ▶ | my($call, $var) = @_; | ||||||||||||||||
|
Subroutine
block_104: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 135 | 15 | _log("104. Number of charging units"); | |||||||||||||||||
| 136 | 15 | my($unit1,$unit2,$unit3); | |||||||||||||||||
| 137 | 15 | ($unit1,$unit2,$unit3,$$var) = unpack('CCC a*', $$var); | |||||||||||||||||
| 138 | 15 | my $units = ($unit1 << 16) + ($unit2 << 8) + $unit3; | |||||||||||||||||
| 139 | 15 | _log(' Units: %d', $units); | |||||||||||||||||
| 140 | 15 | $call->{charging_units} = $units; | |||||||||||||||||
| 141 | } | ||||||||||||||||||
| 142 | # 105. Basic service | ||||||||||||||||||
| 143 | sub block_105 { | ||||||||||||||||||
| 144 | 15 | ▶ | my($call, $var) = @_; | ||||||||||||||||
|
Subroutine
block_105: called CC=5 SCAR=16.6
Pod
undocumented
| |||||||||||||||||||
| 145 | 15 | _log("105. Basic service"); | |||||||||||||||||
| 146 | 15 | my %bearer_label = ( | |||||||||||||||||
| 147 | 0 => '64 kbit/s for speech information transfer', | ||||||||||||||||||
| 148 | 8 => '64 kbit/s unrestricted', | ||||||||||||||||||
| 149 | 16 => '64 kbit/s for 3.1kHz audio information transfer', | ||||||||||||||||||
| 150 | ); | ||||||||||||||||||
| 151 | 15 | my %service_label = ( | |||||||||||||||||
| 152 | 1 => 'Telephony', | ||||||||||||||||||
| 153 | # .... TODO | ||||||||||||||||||
| 154 | ); | ||||||||||||||||||
| 155 | 15 | my($bearer,$service); | |||||||||||||||||
| 156 | 15 | ($bearer,$service,$$var) = unpack('C C a*', $$var); | |||||||||||||||||
| 157 | 15 | ▶ | _log(" Bearer: %d / %s", $bearer, $bearer_label{ $bearer } // 'UNKNOWN'); | ||||||||||||||||
|
Condition50%1/2
$bearer_label{$bearer} // "UNKNOWN"
MC/DC0%0/1
$bearer_label{$bearer} // "UNKNOWN"
$bearer_label{$bearer}
Truth table50%1/2
A
A= $bearer_label{$bearer}
| |||||||||||||||||||
| 158 | 15 | ▶ | _log(" Service: %d / %s", $service, $service_label{ $service } // 'UNKNOWN'); | ||||||||||||||||
|
Condition50%1/2
$service_label{$service} // "UNKNOWN"
MC/DC0%0/1
$service_label{$service} // "UNKNOWN"
$service_label{$service}
Truth table50%1/2
A
A= $service_label{$service}
| |||||||||||||||||||
| 159 | 15 | ▶ | $call->{bearer} = $bearer_label{ $bearer } // 'UNKNOWN'; | ||||||||||||||||
|
Condition50%1/2
$bearer_label{$bearer} // "UNKNOWN"
MC/DC0%0/1
$bearer_label{$bearer} // "UNKNOWN"
$bearer_label{$bearer}
Truth table50%1/2
A
A= $bearer_label{$bearer}
| |||||||||||||||||||
| 160 | 15 | ▶ | $call->{service} = $service_label{ $service } // 'UNKNOWN'; | ||||||||||||||||
|
Condition50%1/2
$service_label{$service} // "UNKNOWN"
MC/DC0%0/1
$service_label{$service} // "UNKNOWN"
$service_label{$service}
Truth table50%1/2
A
A= $service_label{$service}
| |||||||||||||||||||
| 161 | } | ||||||||||||||||||
| 162 | # 106. Supplementary service used by calling subscriber | ||||||||||||||||||
| 163 | sub block_106 { | ||||||||||||||||||
| 164 | 0 | ▶ | my($call, $var) = @_; | ||||||||||||||||
|
Subroutine
block_106: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||
| 165 | 0 | _log('106. Supplementary service used by calling subscriber'); | |||||||||||||||||
| 166 | 0 | my($sup_service); | |||||||||||||||||
| 167 | 0 | ($sup_service, $$var) = unpack('C a*', $$var); | |||||||||||||||||
| 168 | 0 | _log(' Supplementary calling service: %d', $sup_service); | |||||||||||||||||
| 169 | 0 | $call->{supplementary_calling_service} = $sup_service; | |||||||||||||||||
| 170 | } | ||||||||||||||||||
| 171 | # 107. Supplementary service used by called subscriber | ||||||||||||||||||
| 172 | sub block_107 { | ||||||||||||||||||
| 173 | 0 | ▶ | my($call, $var) = @_; | ||||||||||||||||
|
Subroutine
block_107: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||
| 174 | 0 | _log('106. Supplementary service used by called subscriber'); | |||||||||||||||||
| 175 | 0 | my($sup_service); | |||||||||||||||||
| 176 | 0 | ($sup_service, $$var) = unpack('C a*', $$var); | |||||||||||||||||
| 177 | 0 | _log(' Supplementary called service: %d', $sup_service); | |||||||||||||||||
| 178 | 0 | $call->{supplementary_called_service} = $sup_service; | |||||||||||||||||
| 179 | } | ||||||||||||||||||
| 180 | # 108. Subscriber controlled input | ||||||||||||||||||
| 181 | # 109. Dialed digits | ||||||||||||||||||
| 182 | # 110. Origin category | ||||||||||||||||||
| 183 | sub block_110 { | ||||||||||||||||||
| 184 | 15 | ▶ | my($call, $var) = @_; | ||||||||||||||||
|
Subroutine
block_110: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 185 | 15 | _log("110. Origin category"); | |||||||||||||||||
| 186 | 15 | my($origin); | |||||||||||||||||
| 187 | 15 | ($origin,$$var) = unpack('C a*', $$var); | |||||||||||||||||
| 188 | 15 | _log(" Origin category: %d", $origin); | |||||||||||||||||
| 189 | 15 | $call->{origin_category} = $origin; | |||||||||||||||||
| 190 | } | ||||||||||||||||||
| 191 | # 111. Tariff direction | ||||||||||||||||||
| 192 | sub block_111 { | ||||||||||||||||||
| 193 | 15 | ▶ | my($call, $var) = @_; | ||||||||||||||||
|
Subroutine
block_111: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 194 | 15 | _log("111. Tariff direction"); | |||||||||||||||||
| 195 | 15 | my($tariff); | |||||||||||||||||
| 196 | 15 | ($tariff,$$var) = unpack('C a*', $$var); | |||||||||||||||||
| 197 | 15 | _log(" Tariff direction: %d", $tariff); | |||||||||||||||||
| 198 | 15 | $call->{tariff_direction} = $tariff; | |||||||||||||||||
| 199 | } | ||||||||||||||||||
| 200 | # 112. Call failure cause | ||||||||||||||||||
| 201 | # 113. Incoming trunk data | ||||||||||||||||||
| 202 | sub block_113 { | ||||||||||||||||||
| 203 | 15 | ▶ | my($call, $var) = @_; | ||||||||||||||||
|
Subroutine
block_113: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 204 | 15 | _log("113. Incoming trunk data"); | |||||||||||||||||
| 205 | 15 | my($group,$id,$shelf,$port,$channel); | |||||||||||||||||
| 206 | 15 | ($group,$id,$shelf,$port,$channel,$$var) = unpack('n n C n C a*', $$var); | |||||||||||||||||
| 207 | 15 | _log(" Trunk group: %d\n Trunk identification: %d\n Shelf identification: %d\n Port identification: %d\n Channel identification: %d", | |||||||||||||||||
| 208 | $group,$id,$shelf,$port,$channel); | ||||||||||||||||||
| 209 | 15 | $call->{incoming_trunk_group} = $group; | |||||||||||||||||
| 210 | 15 | $call->{incoming_trunk} = $id; | |||||||||||||||||
| 211 | 15 | $call->{incoming_shelf} = $shelf; | |||||||||||||||||
| 212 | 15 | $call->{incoming_port} = $port; | |||||||||||||||||
| 213 | 15 | $call->{incoming_channel} = $channel; | |||||||||||||||||
| 214 | } | ||||||||||||||||||
| 215 | # 114. Outgoing trunk data | ||||||||||||||||||
| 216 | sub block_114 { | ||||||||||||||||||
| 217 | 15 | ▶ | my($call, $var) = @_; | ||||||||||||||||
|
Subroutine
block_114: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 218 | 15 | _log("114. Outgoing trunk data"); | |||||||||||||||||
| 219 | 15 | my($group,$id,$shelf,$port,$channel); | |||||||||||||||||
| 220 | 15 | ($group,$id,$shelf,$port,$channel,$$var) = unpack('n n C n C a*', $$var); | |||||||||||||||||
| 221 | 15 | _log(" Trunk group: %d\n Trunk identification: %d\n Shelf identification: %d\n Port identification: %d\n Channel identification: %d", | |||||||||||||||||
| 222 | $group,$id,$shelf,$port,$channel); | ||||||||||||||||||
| 223 | 15 | $call->{outgoing_trunk_group} = $group; | |||||||||||||||||
| 224 | 15 | $call->{outgoing_trunk} = $id; | |||||||||||||||||
| 225 | 15 | $call->{outgoing_shelf} = $shelf; | |||||||||||||||||
| 226 | 15 | $call->{outgoing_port} = $port; | |||||||||||||||||
| 227 | 15 | $call->{outgoing_channel} = $channel; | |||||||||||||||||
| 228 | } | ||||||||||||||||||
| 229 | # 115. Call duration | ||||||||||||||||||
| 230 | sub block_115 { | ||||||||||||||||||
| 231 | 15 | ▶ | my($call, $var) = @_; | ||||||||||||||||
|
Subroutine
block_115: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 232 | 15 | _log("115. Call duration"); | |||||||||||||||||
| 233 | 15 | my($duration); | |||||||||||||||||
| 234 | 15 | ($duration,$$var) = unpack('N a*', $$var); | |||||||||||||||||
| 235 | 15 | _log(" Call duration: %d msec / %.5f sec", $duration, $duration / 1000.0); | |||||||||||||||||
| 236 | 15 | $call->{call_duration} = sprintf '%.5f', $duration / 1000.0; | |||||||||||||||||
| 237 | 15 | $call->{call_duration_ms} = $duration; | |||||||||||||||||
| 238 | } | ||||||||||||||||||
| 239 | # 116. Checksum | ||||||||||||||||||
| 240 | sub block_116 { | ||||||||||||||||||
| 241 | 15 | ▶ | my($call, $var) = @_; | ||||||||||||||||
|
Subroutine
block_116: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 242 | 15 | _log("116. Checksum"); | |||||||||||||||||
| 243 | 15 | my($len,$checksum); | |||||||||||||||||
| 244 | 15 | ($len,$checksum,$$var) = unpack('C a2 a*', $$var); | |||||||||||||||||
| 245 | 15 | _log(" Checksum: 0x%s", unpack('H*', $checksum));; | |||||||||||||||||
| 246 | 15 | $call->{checksum} = unpack('H*', $checksum); | |||||||||||||||||
| 247 | } | ||||||||||||||||||
| 248 | # 117. Business and Centrex group ID | ||||||||||||||||||
| 249 | sub block_117 { | ||||||||||||||||||
| 250 | 0 | ▶ | my($call, $var) = @_; | ||||||||||||||||
|
Subroutine
block_117: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||
| 251 | 0 | _log("117. Business and Centrex group ID"); | |||||||||||||||||
| 252 | 0 | my($len,$business,$centrex); | |||||||||||||||||
| 253 | 0 | ($len,$business,$centrex,$$var) = unpack('C N N a*', $$var); | |||||||||||||||||
| 254 | 0 | _log(" Business group ID: %d", $business); | |||||||||||||||||
| 255 | 0 | _log(" Centrex group ID: %d", $centrex); | |||||||||||||||||
| 256 | 0 | $call->{business_group} = $business; | |||||||||||||||||
| 257 | 0 | $call->{centrex_group} = $centrex; | |||||||||||||||||
| 258 | } | ||||||||||||||||||
| 259 | # 118. Carrier access code | ||||||||||||||||||
| 260 | # 119. Original calling party number | ||||||||||||||||||
| 261 | sub block_119 { | ||||||||||||||||||
| 262 | 0 | ▶ | my($call, $var) = @_; | ||||||||||||||||
|
Subroutine
block_119: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||
| 263 | 0 | _log("119. Original calling party number"); | |||||||||||||||||
| 264 | 0 | my($len,$num_len); | |||||||||||||||||
| 265 | 0 | ($len,$num_len,$$var) = unpack('C C a*', $$var); | |||||||||||||||||
| 266 | 0 | my $cut = $num_len; | |||||||||||||||||
| 267 | 0 | ▶ | $cut++ if($num_len %2 == 1); | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 268 | 0 | my $num; | |||||||||||||||||
| 269 | 0 | ($num,$$var) = unpack("H$cut a*", $$var); | |||||||||||||||||
| 270 | 0 | ▶ | if($cut > $num_len) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 271 | 0 | $num = substr($num, 0, -1); | |||||||||||||||||
| 272 | } | ||||||||||||||||||
| 273 | 0 | _log(" Original CLI: %s", $num); | |||||||||||||||||
| 274 | 0 | $call->{original_cli} = $num; | |||||||||||||||||
| 275 | } | ||||||||||||||||||
| 276 | # 120. Prepaid account recharge data | ||||||||||||||||||
| 277 | # 121. Call release cause | ||||||||||||||||||
| 278 | sub block_121 { | ||||||||||||||||||
| 279 | 15 | ▶ | my($call, $var) = @_; | ||||||||||||||||
|
Subroutine
block_121: called CC=7 SCAR=20.1
Pod
undocumented
| |||||||||||||||||||
| 280 | 15 | _log("121. Call release cause"); | |||||||||||||||||
| 281 | 15 | my %cause_label = ( | |||||||||||||||||
| 282 | 16 => 'normal call clearing', | ||||||||||||||||||
| 283 | 41 => 'temporary failure', | ||||||||||||||||||
| 284 | ); | ||||||||||||||||||
| 285 | 15 | my %coding_label = ( | |||||||||||||||||
| 286 | 0 => 'ITU-T standard', | ||||||||||||||||||
| 287 | ); | ||||||||||||||||||
| 288 | 15 | my %location_label = ( | |||||||||||||||||
| 289 | 0 => 'user', | ||||||||||||||||||
| 290 | 1 => 'private network serving the local user', | ||||||||||||||||||
| 291 | 2 => 'public network serving the local user', | ||||||||||||||||||
| 292 | 3 => 'transit network', | ||||||||||||||||||
| 293 | 4 => 'public network serving the remote user', | ||||||||||||||||||
| 294 | 5 => 'private network serving the remote user', | ||||||||||||||||||
| 295 | 7 => 'international network', | ||||||||||||||||||
| 296 | 10 => 'network beyond interworking point', | ||||||||||||||||||
| 297 | ); | ||||||||||||||||||
| 298 | 15 | my($len,$cause,$flag); | |||||||||||||||||
| 299 | 15 | ($len,$cause,$flag,$$var) = unpack('C n C a*', $$var); | |||||||||||||||||
| 300 | 15 | my $coding = (($flag & 0xF0) >> 4); | |||||||||||||||||
| 301 | 15 | my $location = ($flag & 0x0F); | |||||||||||||||||
| 302 | 15 | ▶ | _log(" Cause: %d / %s", $cause, $cause_label{ $cause } // 'UNKNOWN');; | ||||||||||||||||
|
Condition50%1/2
$cause_label{$cause} // "UNKNOWN"
MC/DC0%0/1
$cause_label{$cause} // "UNKNOWN"
$cause_label{$cause}
Truth table50%1/2
A
A= $cause_label{$cause}
| |||||||||||||||||||
| 303 | 15 | ▶ | _log(" Coding standard: %d / %s", $coding, $coding_label{ $coding } // 'UNKNOWN'); | ||||||||||||||||
|
Condition50%1/2
$coding_label{$coding} // "UNKNOWN"
MC/DC0%0/1
$coding_label{$coding} // "UNKNOWN"
$coding_label{$coding}
Truth table50%1/2
A
A= $coding_label{$coding}
| |||||||||||||||||||
| 304 | 15 | ▶ | _log(" Location: %d / %s", $location, $location_label{ $location } // 'UNKNOWN'); | ||||||||||||||||
|
Condition50%1/2
$location_label{$location} // "UNKNOWN"
MC/DC0%0/1
$location_label{$location} // "UNKNOWN"
$location_label{$location}
Truth table50%1/2
A
A= $location_label{$location}
| |||||||||||||||||||
| 305 | 15 | ▶ | $call->{call_release_cause} = $cause_label{ $cause } // 'UNKNOWN'; | ||||||||||||||||
|
Condition50%1/2
$cause_label{$cause} // "UNKNOWN"
MC/DC0%0/1
$cause_label{$cause} // "UNKNOWN"
$cause_label{$cause}
Truth table50%1/2
A
A= $cause_label{$cause}
| |||||||||||||||||||
| 306 | 15 | $call->{call_release_cause_code} = $cause; | |||||||||||||||||
| 307 | 15 | ▶ | $call->{call_coding_standard} = $coding_label{ $coding } // 'UNKNOWN'; | ||||||||||||||||
|
Condition50%1/2
$coding_label{$coding} // "UNKNOWN"
MC/DC0%0/1
$coding_label{$coding} // "UNKNOWN"
$coding_label{$coding}
Truth table50%1/2
A
A= $coding_label{$coding}
| |||||||||||||||||||
| 308 | 15 | ▶ | $call->{call_location} = $location_label{ $location } // 'UNKNOWN'; | ||||||||||||||||
|
Condition50%1/2
$location_label{$location} // "UNKNOWN"
MC/DC0%0/1
$location_label{$location} // "UNKNOWN"
$location_label{$location}
Truth table50%1/2
A
A= $location_label{$location}
| |||||||||||||||||||
| 309 | } | ||||||||||||||||||
| 310 | # 122. CBNO (Charge Band Number) | ||||||||||||||||||
| 311 | # 123. Common call ID | ||||||||||||||||||
| 312 | # 124. Durations before answer | ||||||||||||||||||
| 313 | # 125. VoIP Info (old) | ||||||||||||||||||
| 314 | # 126. Amount of Transferred Data (old) | ||||||||||||||||||
| 315 | # 127. IP Address | ||||||||||||||||||
| 316 | sub block_127 { | ||||||||||||||||||
| 317 | 15 | ▶ | my($call, $var) = @_; | ||||||||||||||||
|
Subroutine
block_127: called CC=9 SCAR=27.9
Pod
undocumented
| |||||||||||||||||||
| 318 | 15 | _log("127. IP Address"); | |||||||||||||||||
| 319 | 15 | my($len,$ip_data); | |||||||||||||||||
| 320 | 15 | ($len,$$var) = unpack('C a*', $$var); | |||||||||||||||||
| 321 | 15 | $len -= 2; | |||||||||||||||||
| 322 | 15 | ($ip_data,$$var) = unpack("a$len a*", $$var); | |||||||||||||||||
| 323 | 15 | my($flag,$reserved,@ip); | |||||||||||||||||
| 324 | 15 | ($flag,$reserved,@ip) = unpack('C C N*', $ip_data); | |||||||||||||||||
| 325 | 15 | @ip = map { join '.', unpack 'C4', pack 'N', $_ } @ip; | |||||||||||||||||
| 326 | 15 | ▶ | if($flag & 0x1) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 327 | 15 | my $ip = shift(@ip); | |||||||||||||||||
| 328 | 15 | _log(" Origin side remote RTP IP: %s", $ip); | |||||||||||||||||
| 329 | 15 | $call->{origin_remote_rtp} = $ip; | |||||||||||||||||
| 330 | } | ||||||||||||||||||
| 331 | 15 | ▶ | if($flag & 0x2) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 332 | 0 | my $ip = shift(@ip); | |||||||||||||||||
| 333 | 0 | _log(" Origin side local RTP IP: %s", $ip); | |||||||||||||||||
| 334 | 0 | $call->{origin_local_rtp} = $ip; | |||||||||||||||||
| 335 | } | ||||||||||||||||||
| 336 | 15 | ▶ | if($flag & 0x4) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 337 | 15 | my $ip = shift(@ip); | |||||||||||||||||
| 338 | 15 | _log(" Terminating side remote RTP IP: %s", $ip); | |||||||||||||||||
| 339 | 15 | $call->{terminating_remote_rtp} = $ip; | |||||||||||||||||
| 340 | } | ||||||||||||||||||
| 341 | 15 | ▶ | if($flag & 0x8) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 342 | 0 | my $ip = shift(@ip); | |||||||||||||||||
| 343 | 0 | _log(" Terminating side local RTP IP: %s", $ip); | |||||||||||||||||
| 344 | 0 | $call->{terminating_local_rtp} = $ip; | |||||||||||||||||
| 345 | } | ||||||||||||||||||
| 346 | 15 | ▶ | if($flag & 0x10) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 347 | 0 | my $ip = shift(@ip); | |||||||||||||||||
| 348 | 0 | _log(' Origin side remote signaling IP: %s', $ip); | |||||||||||||||||
| 349 | 0 | $call->{origin_remote_signaling} = $ip; | |||||||||||||||||
| 350 | } | ||||||||||||||||||
| 351 | 15 | ▶ | if($flag & 0x20) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 352 | 0 | my $ip = shift(@ip); | |||||||||||||||||
| 353 | 0 | _log(' Origin side local signaling IP: %s', $ip); | |||||||||||||||||
| 354 | 0 | $call->{origin_local_signaling} = $ip; | |||||||||||||||||
| 355 | } | ||||||||||||||||||
| 356 | 15 | ▶ | if($flag & 0x40) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 357 | 0 | my $ip = shift(@ip); | |||||||||||||||||
| 358 | 0 | _log(' Terminating side remote signaling IP: %s', $ip); | |||||||||||||||||
| 359 | 0 | $call->{terminating_remote_signaling} = $ip; | |||||||||||||||||
| 360 | } | ||||||||||||||||||
| 361 | 15 | ▶ | if($flag & 0x80) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 362 | 0 | my $ip = shift(@ip); | |||||||||||||||||
| 363 | 0 | _log(' Terminating side local signaling IP: %s', $ip); | |||||||||||||||||
| 364 | 0 | $call->{terminating_local_signaling} = $ip; | |||||||||||||||||
| 365 | } | ||||||||||||||||||
| 366 | } | ||||||||||||||||||
| 367 | # 128. VoIP info | ||||||||||||||||||
| 368 | sub block_128 { | ||||||||||||||||||
| 369 | 15 | ▶ | my($call, $var) = @_; | ||||||||||||||||
|
Subroutine
block_128: called CC=9 SCAR=22.5
Pod
undocumented
| |||||||||||||||||||
| 370 | 15 | _log("128. VoIP info"); | |||||||||||||||||
| 371 | 15 | my($len,$rx_codec,$tx_codec,$rx_period,$tx_period,$rx_bandwidth,$tx_bandwidth,$max_jitter,$flag); | |||||||||||||||||
| 372 | 15 | ($len,$rx_codec,$tx_codec,$rx_period,$tx_period,$rx_bandwidth,$tx_bandwidth,$max_jitter,$flag,$$var) = unpack('CCCCCnnnC a*', $$var); | |||||||||||||||||
| 373 | 15 | my %codec_label = ( | |||||||||||||||||
| 374 | 0 => 'Undefined', | ||||||||||||||||||
| 375 | 8 => 'G711Alaw64k', | ||||||||||||||||||
| 376 | 9 => 'G711Ulaw64k', | ||||||||||||||||||
| 377 | 66 => 'G728', | ||||||||||||||||||
| 378 | 67 => 'G729', | ||||||||||||||||||
| 379 | 68 => 'G729annexA', | ||||||||||||||||||
| 380 | 70 => 'G729wAnnexB', | ||||||||||||||||||
| 381 | 71 => 'G729AnnexAwAnnexB', | ||||||||||||||||||
| 382 | 72 => 'GsmFullRate', | ||||||||||||||||||
| 383 | 80 => 'G7231A5_3k', | ||||||||||||||||||
| 384 | 81 => 'G7231A6_3k', | ||||||||||||||||||
| 385 | 129 => 'FaxT38', | ||||||||||||||||||
| 386 | ); | ||||||||||||||||||
| 387 | 15 | my %side_label = ( 0 => 'origin side', 1 => 'terminating side'); | |||||||||||||||||
| 388 | 15 | my %type_label = ( | |||||||||||||||||
| 389 | 0 => 'Undefined', | ||||||||||||||||||
| 390 | 1 => 'Audio', | ||||||||||||||||||
| 391 | 2 => 'Data', | ||||||||||||||||||
| 392 | 3 => 'Fax', | ||||||||||||||||||
| 393 | ); | ||||||||||||||||||
| 394 | |||||||||||||||||||
| 395 | 15 | ▶ | _log(" Rx codec: %d / %s", $rx_codec, $codec_label{ $rx_codec } // 'UNKNOWN'); | ||||||||||||||||
|
Condition50%1/2
$codec_label{$rx_codec} // "UNKNOWN"
MC/DC0%0/1
$codec_label{$rx_codec} // "UNKNOWN"
$codec_label{$rx_codec}
Truth table50%1/2
A
A= $codec_label{$rx_codec}
| |||||||||||||||||||
| 396 | 15 | ▶ | _log(" Tx codec: %d / %s", $tx_codec, $codec_label{ $tx_codec } // 'UNKNOWN'); | ||||||||||||||||
|
Condition50%1/2
$codec_label{$tx_codec} // "UNKNOWN"
MC/DC0%0/1
$codec_label{$tx_codec} // "UNKNOWN"
$codec_label{$tx_codec}
Truth table50%1/2
A
A= $codec_label{$tx_codec}
| |||||||||||||||||||
| 397 | 15 | _log(" Rx packetization period: %d ms", $rx_period); | |||||||||||||||||
| 398 | 15 | _log(" Tx packetization period: %d ms", $tx_period); | |||||||||||||||||
| 399 | 15 | _log(" Rx bandwidth: %d kbit/s", $rx_bandwidth); | |||||||||||||||||
| 400 | 15 | _log(" Tx bandwidth: %d kbit/s", $tx_bandwidth); | |||||||||||||||||
| 401 | 15 | _log(" Max. jitter buffer size: %d ms", $max_jitter); | |||||||||||||||||
| 402 | 15 | my $call_side = ($flag & 0x80) >> 7; | |||||||||||||||||
| 403 | 15 | my $call_type = $flag & 0x7F; | |||||||||||||||||
| 404 | 15 | ▶ | _log(" Call side: %d / %s", $call_side, $side_label{ $call_side } // 'UNKNOWN'); | ||||||||||||||||
|
Condition50%1/2
$side_label{$call_side} // "UNKNOWN"
MC/DC0%0/1
$side_label{$call_side} // "UNKNOWN"
$side_label{$call_side}
Truth table50%1/2
A
A= $side_label{$call_side}
| |||||||||||||||||||
| 405 | 15 | ▶ | _log(" VoIP call type: %d / %s", $call_type, $type_label{ $call_type } // 'UNKNOWN'); | ||||||||||||||||
|
Condition50%1/2
$type_label{$call_type} // "UNKNOWN"
MC/DC0%0/1
$type_label{$call_type} // "UNKNOWN"
$type_label{$call_type}
Truth table50%1/2
A
A= $type_label{$call_type}
| |||||||||||||||||||
| 406 | |||||||||||||||||||
| 407 | 15 | ▶ | $call->{voip_rx_codec} = $codec_label{ $rx_codec } // 'UNKNOWN'; | ||||||||||||||||
|
Condition50%1/2
$codec_label{$rx_codec} // "UNKNOWN"
MC/DC0%0/1
$codec_label{$rx_codec} // "UNKNOWN"
$codec_label{$rx_codec}
Truth table50%1/2
A
A= $codec_label{$rx_codec}
| |||||||||||||||||||
| 408 | 15 | ▶ | $call->{voip_tx_codec} = $codec_label{ $tx_codec } // 'UNKNOWN'; | ||||||||||||||||
|
Condition50%1/2
$codec_label{$tx_codec} // "UNKNOWN"
MC/DC0%0/1
$codec_label{$tx_codec} // "UNKNOWN"
$codec_label{$tx_codec}
Truth table50%1/2
A
A= $codec_label{$tx_codec}
| |||||||||||||||||||
| 409 | 15 | $call->{voip_rx_packetization} = $rx_period; | |||||||||||||||||
| 410 | 15 | $call->{voip_tx_packetization} = $tx_period; | |||||||||||||||||
| 411 | 15 | $call->{voip_rx_bandwidth} = $rx_bandwidth; | |||||||||||||||||
| 412 | 15 | $call->{voip_tx_bandwidth} = $tx_bandwidth; | |||||||||||||||||
| 413 | 15 | $call->{voip_max_jitter} = $max_jitter; | |||||||||||||||||
| 414 | 15 | ▶ | $call->{voip_call_size} = $side_label{ $call_side } // 'UNKNOWN'; | ||||||||||||||||
|
Condition50%1/2
$side_label{$call_side} // "UNKNOWN"
MC/DC0%0/1
$side_label{$call_side} // "UNKNOWN"
$side_label{$call_side}
Truth table50%1/2
A
A= $side_label{$call_side}
| |||||||||||||||||||
| 415 | 15 | ▶ | $call->{voip_call_type} = $type_label{ $call_type } // 'UNKNOWN'; | ||||||||||||||||
|
Condition50%1/2
$type_label{$call_type} // "UNKNOWN"
MC/DC0%0/1
$type_label{$call_type} // "UNKNOWN"
$type_label{$call_type}
Truth table50%1/2
A
A= $type_label{$call_type}
| |||||||||||||||||||
| 416 | } | ||||||||||||||||||
| 417 | # 129. Amount of transferred data | ||||||||||||||||||
| 418 | sub block_129 { | ||||||||||||||||||
| 419 | 15 | ▶ | my($call, $var) = @_; | ||||||||||||||||
|
Subroutine
block_129: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||
| 420 | 15 | _log("129. Amount of transferred data"); | |||||||||||||||||
| 421 | 15 | my($len,$side,$rx_packets,$tx_packets,$rx_octets,$tx_octets,$lost,$jitter,$latency); | |||||||||||||||||
| 422 | 15 | ($len,$side,$rx_packets,$tx_packets,$rx_octets,$tx_octets,$lost,$jitter,$latency,$$var) = unpack('CCNNNNNCC a*', $$var); | |||||||||||||||||
| 423 | 15 | my %side_label = ( 0 => 'origin side', 1 => 'terminating side'); | |||||||||||||||||
| 424 | 15 | ▶ | _log(" Call side: %d / %s", $side, $side_label{ $side } // 'UNKNOWN'); | ||||||||||||||||
|
Condition50%1/2
$side_label{$side} // "UNKNOWN"
MC/DC0%0/1
$side_label{$side} // "UNKNOWN"
$side_label{$side}
Truth table50%1/2
A
A= $side_label{$side}
| |||||||||||||||||||
| 425 | 15 | _log(" Rx packets: %d", $rx_packets); | |||||||||||||||||
| 426 | 15 | _log(" Tx packets: %d", $tx_packets); | |||||||||||||||||
| 427 | 15 | _log(" Rx octets: %d", $rx_octets); | |||||||||||||||||
| 428 | 15 | _log(" Tx octets: %d", $tx_octets); | |||||||||||||||||
| 429 | 15 | _log(" Packets lost: %d", $lost); | |||||||||||||||||
| 430 | 15 | _log(" Average jitter: %d ms", $jitter); | |||||||||||||||||
| 431 | 15 | _log(" Average latency: %d ms", $latency); | |||||||||||||||||
| 432 | 15 | ▶ | $call->{call_side} = $side_label{ $side } // 'UNKNOWN'; | ||||||||||||||||
|
Condition50%1/2
$side_label{$side} // "UNKNOWN"
MC/DC0%0/1
$side_label{$side} // "UNKNOWN"
$side_label{$side}
Truth table50%1/2
A
A= $side_label{$side}
| |||||||||||||||||||
| 433 | 15 | $call->{rx_packets} = $rx_packets; | |||||||||||||||||
| 434 | 15 | $call->{tx_packets} = $tx_packets; | |||||||||||||||||
| 435 | 15 | $call->{rx_octets} = $rx_octets; | |||||||||||||||||
| 436 | 15 | $call->{tx_octets} = $tx_octets; | |||||||||||||||||
| 437 | 15 | $call->{packets_lost} = $lost; | |||||||||||||||||
| 438 | 15 | $call->{average_jitter} = $jitter; | |||||||||||||||||
| 439 | 15 | $call->{everage_latency} = $latency; | |||||||||||||||||
| 440 | } | ||||||||||||||||||
| 441 | # 130. Service control data | ||||||||||||||||||
| 442 | # 131. New destination number | ||||||||||||||||||
| 443 | # 132. VoIP Quality of Service data (QoS VoIP Data) | ||||||||||||||||||
| 444 | # 133. Additional Centrex data | ||||||||||||||||||
| 445 | # 134. Additional statistics data | ||||||||||||||||||
| 446 | sub block_134 { | ||||||||||||||||||
| 447 | 15 | ▶ | my($call, $var) = @_; | ||||||||||||||||
|
Subroutine
block_134: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 448 | 15 | _log("134. Additional statistics data"); | |||||||||||||||||
| 449 | 15 | my($len,$stats); | |||||||||||||||||
| 450 | 15 | ($len,$$var) = unpack('C a*', $$var); | |||||||||||||||||
| 451 | 15 | $len -= 2; | |||||||||||||||||
| 452 | 15 | ($stats,$$var) = unpack("a$len a*", $$var); | |||||||||||||||||
| 453 | 15 | _log(" Stats: 0x%s (len %d)", unpack('H*', $stats), $len); | |||||||||||||||||
| 454 | # no useful info? | ||||||||||||||||||
| 455 | } | ||||||||||||||||||
| 456 | # TODO NOT IMPLEMENTED YET: | ||||||||||||||||||
| 457 | # 135. IMS charging identifier | ||||||||||||||||||
| 458 | # 136. Inter Operator Identifiers – IOI) | ||||||||||||||||||
| 459 | # 137. Supplementary service additional info | ||||||||||||||||||
| 460 | # 138. Calling Party Number | ||||||||||||||||||
| 461 | # 139. Additional calling number | ||||||||||||||||||
| 462 | # 140. Called party number | ||||||||||||||||||
| 463 | # 141. Sent called party number | ||||||||||||||||||
| 464 | # 142. Third party number | ||||||||||||||||||
| 465 | # 143. Redirecting party number | ||||||||||||||||||
| 466 | # 144. Incoming trunk data - Name | ||||||||||||||||||
| 467 | # 145. Outgoing trunk data - name | ||||||||||||||||||
| 468 | # 146. Node info | ||||||||||||||||||
| 469 | # 147. Global call reference | ||||||||||||||||||
| 470 | # 148. MLPP Data | ||||||||||||||||||
| 471 | # 149. Customer Data | ||||||||||||||||||
| 472 | # 150. Received Called Party Number | ||||||||||||||||||
| 473 | # 151. Call Type | ||||||||||||||||||
| 474 | # 152. IN Service Data | ||||||||||||||||||
| 475 | # 153. URI (Universal Resource Identification) | ||||||||||||||||||
| 476 | # 154. Free Format Operator Specific Data | ||||||||||||||||||
| 477 | # 155. ----- | ||||||||||||||||||
| 478 | # 156. Additional Numbers | ||||||||||||||||||
| 479 | |||||||||||||||||||
| 480 | sub dump_var { | ||||||||||||||||||
| 481 | 0 | ▶ | my $var = shift; | ||||||||||||||||
|
Subroutine
dump_var: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||
| 482 | 0 | _log("---- Variable data (%d) ----", length($var)); | |||||||||||||||||
| 483 | 0 | _log('%s', unpack('H*', $var)); | |||||||||||||||||
| 484 | } | ||||||||||||||||||
| 485 | |||||||||||||||||||
| 486 | # Parse individual record | ||||||||||||||||||
| 487 | # | ||||||||||||||||||
| 488 | # Each record has fixed part 16+(2..19) bytes | ||||||||||||||||||
| 489 | # and optional set of additional blocks | ||||||||||||||||||
| 490 | sub parse_record { | ||||||||||||||||||
| 491 | 16 | ▶ | my $fh = shift; | ||||||||||||||||
|
Subroutine
parse_record: called CC=11 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||
| 492 | |||||||||||||||||||
| 493 | 16 | my $type_id; | |||||||||||||||||
| 494 | 16 | ▶ | sysread($fh, $type_id, 1) || return 0; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 495 | 15 | my $code = unpack('H2', $type_id); | |||||||||||||||||
| 496 | |||||||||||||||||||
| 497 | # Recort type: | ||||||||||||||||||
| 498 | # d2 -- Record at date and time changes (parsed but ignored) | ||||||||||||||||||
| 499 | # d3 -- Record of the loss of a certain amount of records (NOT SUPPORTED) | ||||||||||||||||||
| 500 | # d4 -- Restart record (NOT SUPPORTED) | ||||||||||||||||||
| 501 | # c8 -- Call record | ||||||||||||||||||
| 502 | 15 | ▶ | if($code eq 'd2') { | ||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||
| 503 | 0 | parse_time_change_record($fh, $code); | |||||||||||||||||
| 504 | # next | ||||||||||||||||||
| 505 | 0 | return parse_record($fh); | |||||||||||||||||
| 506 | } | ||||||||||||||||||
| 507 | elsif($code eq 'd4') { | ||||||||||||||||||
| 508 | 0 | parse_reboot_record($fh, $code); | |||||||||||||||||
| 509 | 0 | return parse_record($fh); | |||||||||||||||||
| 510 | } | ||||||||||||||||||
| 511 | elsif($code ne 'c8') { | ||||||||||||||||||
| 512 | 0 | die "Unknown record type: $code"; | |||||||||||||||||
| 513 | } | ||||||||||||||||||
| 514 | 15 | _log('Found Call Record marker %s', $code); | |||||||||||||||||
| 515 | |||||||||||||||||||
| 516 | 15 | my %call = (); | |||||||||||||||||
| 517 | |||||||||||||||||||
| 518 | # Statis header | ||||||||||||||||||
| 519 | # 1 - c8 | ||||||||||||||||||
| 520 | # 2 - record length | ||||||||||||||||||
| 521 | # 4 - record index (in file?) | ||||||||||||||||||
| 522 | # 4 - call identifier (sequentially incremented number, unique - | ||||||||||||||||||
| 523 | # but incomplete calls can have call-id repeated again in later file) | ||||||||||||||||||
| 524 | # 3 - flags | ||||||||||||||||||
| 525 | # 1 - Sequence (4bits) / Charge status (4bits) | ||||||||||||||||||
| 526 | # 1 - Area code length (3bits) / Subscriber number length (5bits) | ||||||||||||||||||
| 527 | # ... - Area code and subscriber number of record owner | ||||||||||||||||||
| 528 | 15 | my $len; | |||||||||||||||||
| 529 | 15 | ▶ | sysread($fh, $len, 2) || die $!; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 530 | 15 | $len = unpack('n', $len); | |||||||||||||||||
| 531 | #printf "Record lengh: %d bytes\n", $len; | ||||||||||||||||||
| 532 | |||||||||||||||||||
| 533 | 15 | my $data; | |||||||||||||||||
| 534 | 15 | ▶ | sysread($fh, $data, $len - 3) || die $!; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 535 | #print unpack('H*', $data), "\n"; | ||||||||||||||||||
| 536 | |||||||||||||||||||
| 537 | 15 | my($rec_index,$call_id,$flags,$seq,$area,$variable) = unpack('N N H6 H2 C a*', $data); | |||||||||||||||||
| 538 | 15 | _log("Header"); | |||||||||||||||||
| 539 | 15 | _log(" Record index: %d", $rec_index); | |||||||||||||||||
| 540 | 15 | _log(" Call ID: %d / %s", $call_id, unpack('H*', pack('N', $call_id))); | |||||||||||||||||
| 541 | 15 | _log(" Flags: 0x%s", unpack('H6', pack('H6', $flags))); | |||||||||||||||||
| 542 | 15 | _log(" Record sequence: %d", (($seq & 0xF0) >> 4)); | |||||||||||||||||
| 543 | 15 | _log(" Charge status: %d", ($seq & 0x0F)); | |||||||||||||||||
| 544 | |||||||||||||||||||
| 545 | 15 | $call{record_index} = $rec_index; | |||||||||||||||||
| 546 | 15 | $call{call_id} = $call_id; | |||||||||||||||||
| 547 | 15 | $call{flags} = $flags; | |||||||||||||||||
| 548 | 15 | $call{record_sequence} = (($seq & 0xF0) >> 4); | |||||||||||||||||
| 549 | 15 | $call{charge_status} = ($seq & 0x0F); | |||||||||||||||||
| 550 | |||||||||||||||||||
| 551 | 15 | my($area_len) = ($area & 0xE0) >> 5; | |||||||||||||||||
| 552 | 15 | my($subscriber_len) = ($area & 0x1F); | |||||||||||||||||
| 553 | #my($subscriber_len) = ($area & 0x07); | ||||||||||||||||||
| 554 | #printf "Area/Subscriber: %s / %d . %d\n", $area, $area_len, $subscriber_len; | ||||||||||||||||||
| 555 | #printf " Area code length: %d\n", $area_len; | ||||||||||||||||||
| 556 | #printf " Subscriber number length: %d\n", $subscriber_len; | ||||||||||||||||||
| 557 | |||||||||||||||||||
| 558 | #printf "---- Variable data (%d) ----\n", length($variable); | ||||||||||||||||||
| 559 | #print unpack('H*', $variable), "\n"; | ||||||||||||||||||
| 560 | |||||||||||||||||||
| 561 | 15 | my $area_code = ''; | |||||||||||||||||
| 562 | 15 | ▶ | if($area_len) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 563 | 0 | ($area_code,$variable) = unpack("H[$area_len] a*", $variable); | |||||||||||||||||
| 564 | 0 | _log(' Aread: %s', $area_code); | |||||||||||||||||
| 565 | } | ||||||||||||||||||
| 566 | |||||||||||||||||||
| 567 | 15 | my $cli_len = $subscriber_len; | |||||||||||||||||
| 568 | 15 | ▶ | if($subscriber_len % 2 == 1) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 569 | 15 | $cli_len++; | |||||||||||||||||
| 570 | } | ||||||||||||||||||
| 571 | 15 | my $cli; | |||||||||||||||||
| 572 | 15 | ($cli, $variable) = unpack("H$cli_len a*", $variable); | |||||||||||||||||
| 573 | 15 | ▶ | if($cli_len > $subscriber_len) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 574 | 15 | $cli = substr($cli, 0, -1); | |||||||||||||||||
| 575 | } | ||||||||||||||||||
| 576 | 15 | _log(" CLI: %s", $cli); | |||||||||||||||||
| 577 | 15 | $call{cli_area} = $area_code; | |||||||||||||||||
| 578 | 15 | $call{cli} = $cli; | |||||||||||||||||
| 579 | |||||||||||||||||||
| 580 | # dynamic part: | ||||||||||||||||||
| 581 | 15 | my $block_marker; | |||||||||||||||||
| 582 | 15 | ▶ | while( length($variable) > 0) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 583 | # each block has type marker + variable data, which depends on type | ||||||||||||||||||
| 584 | 240 | ($block_marker, $variable) = unpack('C a*', $variable); | |||||||||||||||||
| 585 | #_log('Found block marker: %s', $block_marker); | ||||||||||||||||||
| 586 | { | ||||||||||||||||||
| 587 | 3 | ▶ | no strict 'refs'; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 588 | 240 | my $sub = 'block_' . $block_marker; | |||||||||||||||||
| 589 | 240 | $sub->(\%call, \$variable); | |||||||||||||||||
| 590 | } | ||||||||||||||||||
| 591 | #dump_var($variable); | ||||||||||||||||||
| 592 | } | ||||||||||||||||||
| 593 | |||||||||||||||||||
| 594 | 15 | _log(''); | |||||||||||||||||
| 595 | 15 | return \%call; | |||||||||||||||||
| 596 | } | ||||||||||||||||||
| 597 | |||||||||||||||||||
| 598 | # d2 - time change event | ||||||||||||||||||
| 599 | sub parse_time_change_record { | ||||||||||||||||||
| 600 | 0 | ▶ | my ($fh, $code) = @_; | ||||||||||||||||
|
Subroutine
parse_time_change_record: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||
| 601 | |||||||||||||||||||
| 602 | 0 | _log('Found Date Time Change marker %s', $code); | |||||||||||||||||
| 603 | |||||||||||||||||||
| 604 | 0 | my $data; | |||||||||||||||||
| 605 | # 7 - old date and time | ||||||||||||||||||
| 606 | # 7 - new date and time | ||||||||||||||||||
| 607 | # 1 - cause of change | ||||||||||||||||||
| 608 | 0 | ▶ | sysread($fh, $data, 15) || die $!; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 609 | 0 | my($year,$month,$day,$hour,$min,$sec,$msec,$reason); | |||||||||||||||||
| 610 | 0 | ($year,$month,$day,$hour,$min,$sec,$msec,$data) = unpack('CCCCCCC a*', $data); | |||||||||||||||||
| 611 | 0 | $year += 2000; | |||||||||||||||||
| 612 | 0 | my $dtime = sprintf "%04d-%02d-%02d %02d:%02d:%02d.%02d", $year,$month,$day,$hour,$min,$sec,$msec; | |||||||||||||||||
| 613 | 0 | _log(' Old Time: %s', $dtime); | |||||||||||||||||
| 614 | |||||||||||||||||||
| 615 | 0 | ($year,$month,$day,$hour,$min,$sec,$msec,$reason) = unpack('CCCCCCC C', $data); | |||||||||||||||||
| 616 | 0 | $year += 2000; | |||||||||||||||||
| 617 | 0 | $dtime = sprintf "%04d-%02d-%02d %02d:%02d:%02d.%02d", $year,$month,$day,$hour,$min,$sec,$msec; | |||||||||||||||||
| 618 | 0 | _log(' New Time: %s', $dtime); | |||||||||||||||||
| 619 | |||||||||||||||||||
| 620 | # 1 - The real-time clock correction | ||||||||||||||||||
| 621 | # 2 - Summer / winter time changes | ||||||||||||||||||
| 622 | 0 | _log(' Change reason: %s', $reason); | |||||||||||||||||
| 623 | } | ||||||||||||||||||
| 624 | |||||||||||||||||||
| 625 | # d4 - System was rebooted | ||||||||||||||||||
| 626 | sub parse_reboot_record { | ||||||||||||||||||
| 627 | 0 | ▶ | my ($fh, $code) = @_; | ||||||||||||||||
|
Subroutine
parse_reboot_record: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||
| 628 | 0 | _log('Found Restart marker %s', $code); | |||||||||||||||||
| 629 | |||||||||||||||||||
| 630 | 0 | my $data; | |||||||||||||||||
| 631 | # 7 - restart date and time | ||||||||||||||||||
| 632 | # 4 - reserved | ||||||||||||||||||
| 633 | 0 | ▶ | sysread($fh, $data, 7) || die $!; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 634 | 0 | my($year,$month,$day,$hour,$min,$sec,$msec); | |||||||||||||||||
| 635 | 0 | ($year,$month,$day,$hour,$min,$sec,$msec) = unpack('CCCCCCC', $data); | |||||||||||||||||
| 636 | 0 | $year += 2000; | |||||||||||||||||
| 637 | 0 | my $reboot_time = sprintf "%04d-%02d-%02d %02d:%02d:%02d.%02d", $year,$month,$day,$hour,$min,$sec,$msec; | |||||||||||||||||
| 638 | 0 | _log(' Restart time: %s', $reboot_time); | |||||||||||||||||
| 639 | |||||||||||||||||||
| 640 | # ignored... | ||||||||||||||||||
| 641 | 0 | ▶ | sysread($fh, $data, 4) || die $!; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 642 | } | ||||||||||||||||||
| 643 | |||||||||||||||||||
| 644 | 3 | 1; | |||||||||||||||||
| 645 | #-- | ||||||||||||||||||
| 646 | |||||||||||||||||||
| 647 | =head1 AUTHOR | ||||||||||||||||||
| 648 | |||||||||||||||||||
| 649 | Sergey Leschenko, C<< <sergle.ua at gmail.com> >> | ||||||||||||||||||
| 650 | |||||||||||||||||||
| 651 | =head1 BUGS | ||||||||||||||||||
| 652 | |||||||||||||||||||
| 653 | Please note that some blocks are not implemented, as I haven't seen them in real data files. | ||||||||||||||||||
| 654 | |||||||||||||||||||
| 655 | Please report any bugs or feature requests to C<bug-cdr-parser-si3000 at rt.cpan.org>, or through | ||||||||||||||||||
| 656 | the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=CDR-Parser-SI3000>. I will be notified, and then you'll | ||||||||||||||||||
| 657 | automatically be notified of progress on your bug as I make changes. | ||||||||||||||||||
| 658 | |||||||||||||||||||
| 659 | |||||||||||||||||||
| 660 | |||||||||||||||||||
| 661 | |||||||||||||||||||
| 662 | =head1 SUPPORT | ||||||||||||||||||
| 663 | |||||||||||||||||||
| 664 | You can find documentation for this module with the perldoc command. | ||||||||||||||||||
| 665 | |||||||||||||||||||
| 666 | perldoc CDR::Parser::SI3000 | ||||||||||||||||||
| 667 | |||||||||||||||||||
| 668 | |||||||||||||||||||
| 669 | You can also look for information at: | ||||||||||||||||||
| 670 | |||||||||||||||||||
| 671 | =over 4 | ||||||||||||||||||
| 672 | |||||||||||||||||||
| 673 | =item * RT: CPAN's request tracker (report bugs here) | ||||||||||||||||||
| 674 | |||||||||||||||||||
| 675 | L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=CDR-Parser-SI3000> | ||||||||||||||||||
| 676 | |||||||||||||||||||
| 677 | =item * AnnoCPAN: Annotated CPAN documentation | ||||||||||||||||||
| 678 | |||||||||||||||||||
| 679 | L<http://annocpan.org/dist/CDR-Parser-SI3000> | ||||||||||||||||||
| 680 | |||||||||||||||||||
| 681 | =item * CPAN Ratings | ||||||||||||||||||
| 682 | |||||||||||||||||||
| 683 | L<http://cpanratings.perl.org/d/CDR-Parser-SI3000> | ||||||||||||||||||
| 684 | |||||||||||||||||||
| 685 | =item * Search CPAN | ||||||||||||||||||
| 686 | |||||||||||||||||||
| 687 | L<http://search.cpan.org/dist/CDR-Parser-SI3000/> | ||||||||||||||||||
| 688 | |||||||||||||||||||
| 689 | =back | ||||||||||||||||||
| 690 | |||||||||||||||||||
| 691 | |||||||||||||||||||
| 692 | =head1 ACKNOWLEDGEMENTS | ||||||||||||||||||
| 693 | |||||||||||||||||||
| 694 | |||||||||||||||||||
| 695 | =head1 LICENSE AND COPYRIGHT | ||||||||||||||||||
| 696 | |||||||||||||||||||
| 697 | Copyright 2013 Sergey Leschenko. | ||||||||||||||||||
| 698 | |||||||||||||||||||
| 699 | This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||
| 700 | under the terms of the the Artistic License (2.0). You may obtain a | ||||||||||||||||||
| 701 | copy of the full license at: | ||||||||||||||||||
| 702 | |||||||||||||||||||
| 703 | L<http://www.perlfoundation.org/artistic_license_2_0> | ||||||||||||||||||
| 704 | |||||||||||||||||||
| 705 | Any use, modification, and distribution of the Standard or Modified | ||||||||||||||||||
| 706 | Versions is governed by this Artistic License. By using, modifying or | ||||||||||||||||||
| 707 | distributing the Package, you accept this license. Do not use, modify, | ||||||||||||||||||
| 708 | or distribute the Package, if you do not accept this license. | ||||||||||||||||||
| 709 | |||||||||||||||||||
| 710 | If your Modified Version has been derived from a Modified Version made | ||||||||||||||||||
| 711 | by someone other than you, you are nevertheless required to ensure that | ||||||||||||||||||
| 712 | your Modified Version complies with the requirements of this license. | ||||||||||||||||||
| 713 | |||||||||||||||||||
| 714 | This license does not grant you the right to use any trademark, service | ||||||||||||||||||
| 715 | mark, tradename, or logo of the Copyright Holder. | ||||||||||||||||||
| 716 | |||||||||||||||||||
| 717 | This license includes the non-exclusive, worldwide, free-of-charge | ||||||||||||||||||
| 718 | patent license to make, have made, use, offer to sell, sell, import and | ||||||||||||||||||
| 719 | otherwise transfer the Package with respect to any patent claims | ||||||||||||||||||
| 720 | licensable by the Copyright Holder that are necessarily infringed by the | ||||||||||||||||||
| 721 | Package. If you institute patent litigation (including a cross-claim or | ||||||||||||||||||
| 722 | counterclaim) against any party alleging that the Package constitutes | ||||||||||||||||||
| 723 | direct or contributory patent infringement, then this Artistic License | ||||||||||||||||||
| 724 | to you shall terminate on the date that such litigation is filed. | ||||||||||||||||||
| 725 | |||||||||||||||||||
| 726 | Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER | ||||||||||||||||||
| 727 | AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. | ||||||||||||||||||
| 728 | THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR | ||||||||||||||||||
| 729 | PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY | ||||||||||||||||||
| 730 | YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR | ||||||||||||||||||
| 731 | CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR | ||||||||||||||||||
| 732 | CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, | ||||||||||||||||||
| 733 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||||||||||||||||
| 734 | |||||||||||||||||||
| 735 | |||||||||||||||||||
| 736 | =cut | ||||||||||||||||||
| 737 | |||||||||||||||||||
| 738 | 3 | 1; # End of CDR::Parser::SI3000 | |||||||||||||||||