[cisco-voip] CDR IP Address Conversion

Andrius Kislas Andrius-conf at elsis.lt
Thu Sep 28 02:40:37 EDT 2006


perl version:

sub fromDecToIP {
    my $dec = $_[0];
    $dec = unpack('I', pack('i', $dec));

    if (!defined($dec) || ($dec==0) || $dec eq '') {
        return '';
    }

    if ($dec == 0){
        return '';
    }
    my $hex = sprintf("%X", $dec);
    if (length($hex) != 8) {
        $hex = "0$hex";
    }

    #print "hex=$hex\n";

    my $D = substr($hex, 0, 2);
    my $C = substr($hex, 2, 2);
    my $B = substr($hex, 4, 2);
    my $A = substr($hex, 6, 2);

    #print "$A $B $C $D\n";
    #print sprintf("%d", hex($A)) . "." . sprintf("%d", hex($B)) . "." .
sprintf("%d", hex($C)) . "." . sprintf("%d", hex($D));
    return sprintf("%d", hex($A)) . "." . sprintf("%d", hex($B)) . "." .
sprintf("%d", hex($C)) . "." . sprintf("%d", hex($D));
}



STEVEN CASPER wrote:
> Does anyone have a tool or formula they could share that can be used to
> convert the signed decimal value in the CDR database to an IP address?
> 
> Thanks!
> Steve
> 
> 
> 
> 
> Steve Casper
> Voice Technologies
> M&T Bank
> (410) 347-6026
> 
> _______________________________________________
> cisco-voip mailing list
> cisco-voip at puck.nether.net
> https://puck.nether.net/mailman/listinfo/cisco-voip
> 



More information about the cisco-voip mailing list