in reply to Re^12: p0fq.pl and pack
in thread p0fq.pl and pack?

I tried your script, but it got:

I have never used Convert::Binary::C. I didn't even have it installed. I figured you'd be able to sort out the details.

the strange thing is that the pack method seems eat up the src_ip, dst_ip, from the query hex dump

Ah, of course! You're feeding it the string "\xC0\xA8\x00\x01" (packed) where it's expecting the number (0xC0<<24)|(0xA8<<16)|(0x00<<8)|(0x01) (unpacked).

src_ad => unpack('N', $src->intip()), # or 'L'? dst_ad => unpack('N', $dst->intip()), # or 'L'?

Replies are listed 'Best First'.
Re^14: p0fq.pl and pack
by Anonymous Monk on Feb 26, 2007 at 00:58 UTC
    No I am feed it as:
    src_ad => $src->intip(), dst_ad => $dst->intip(),

    $src->intip() is 3232235778 and $dst-intip() is 3232235777
    If If hard coded in the src,dst ip as:
    src_ad => '3232235778', dst_ad => '3232235777',
    It works, seems Convert::Binary::C pack method won't take varible but constant only, isn't that odd?
      intip "converts the IP in integer format and return it as a Math::BigInt object", according to the docs. It doesn't return a number.
        I used the wrong method of Net::IP, the hexip did it. now it works except a little problem
        print "Genre : " . $data->{genre} . "\n"; print "Details : " . $data->{detail} . "\n"; print "Distance : " . $data->{dist} . " hops\n"; print "Link : " . $data->{link} . "\n"; print "Uptime : " . $data->{uptime} . " hrs\n";
        print out:
        Genre : ARRAY(0x101127d4) Details : ARRAY(0x103826d8) Distance : 0 hops Link : ARRAY(0x1016a60c) Uptime : 4431 hrs
        print Dumper($data)
        :
        $VAR1 = {'link' => [101,116,104,101,114,110,101,116,47,109,111,100,101 +,109,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],'magic' => 233811181,'nat' => 0 +,'score' => -100,'dist' => 0,'genre' => [76,105,110,117,120,0,0,0,0,0 +,0,0,0,0,0,0,0,0,0,0],'fw' => 0,'detail' => [50,46,54,44,32,115,101,1 +08,100,111,109,32,50,46,52,32,40,111,108,100,101,114,44,32,52,41,0,0, +0,0,0,0,0,0,0,0,0,0,0,0],'tos' => [104,105,103,104,32,116,104,114,111 +,117,103,104,112,117,116,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],'uptime' => 4 +431,'id' => 305419896,'type' => 0,'mflags' => 0,'real' => 1}
        What is the correct way to print out those information?
        print "Genre : " . @$data->{genre} . "\n";
        does not help