+sub check_cdr {
+ # Verify that these records belong to the same call.
+ # BYE records sometimes have the caller/callee fields swapped.
+ # We allow empty src/dst so as not to make noise about incomplete calls. If
+ # this check fails, something is wrong with the source data.
+ my ($cdr, $a, $b) = @_;
+ if ( ( $cdr->src and $cdr->src ne $a and $cdr->src ne $b )
+ or ( $cdr->dst and $cdr->dst ne $a and $cdr->dst ne $b ) ) {
+ warn $cdr->uniqueid . ": src/dst mismatch, skipped.\n";
+ return 0;
+ }
+ return 1;
+}