On 11/23/05, Eric Pretorious <[EMAIL PROTECTED]> wrote: > I'm attempting to write a small program to decode OSCAR packets and just > can't get my mind wrapped-around whatever it is that > NetPacket::TCP->decode() is returning when stripping-away the ethernet, > IP, and TCP encapsulation from OSCAR packets. (Maybe it's unicode? Maybe > it's hex? I don't quite understand how to work with anything but ASCII.) > > > #!/usr/bin/perl -w > > > > use Net::PcapUtils; > > use NetPacket::Ethernet qw( :strip ); > > use NetPacket::TCP; > > use NetPacket::IP qw( :strip ); > > > > my $pkt_descriptor = Net::PcapUtils::open( > > FILTER => 'port 5190', > > SNAPLEN => 1500, > > DEV => 'eth1' > > ); > > > > if (!ref($pkt_descriptor)) { > > print "Net::PcapUtils::open returned: $pkt_descriptor\n"; > > exit; > > } > > > > while (1) { > > my ($packet,%header) = Net::PcapUtils::next($pkt_descriptor); > > &process($packet); > > } > > > > sub process() { > > my $packet = shift; > > my $tcp = NetPacket::TCP->decode(ip_strip(eth_strip($packet))); > > # How to check the value of the first byte? > > # How to remove the first six bytes? > > } > > Being new to network programming I'm hoping that somebody can recommend > some tutorials/articles on how to decode the payload of the OSCAR > segment and work with the payload on a byte-by-byte basis. e.g., > Checking the value of each of the first six bytes? > > I'd _really_ appreciate any guidance. TIA! > > Eric P. > Sunnyvale, CA
Eric, NetPacket::TCP->decode() returns a NetPacket::* object. The payload (in your script) is $tcp->{data}. As for what that data looks like, that's defined in the OSCAR protocol. Use vec() or unpack() to get the particular bytes you want based on the byte order defined by OSCAR. You might also want to check Net::OSCAR and Net::AIM to see if they can be bent to your needs. I know Net::OSCAR at least has some pretty powerful debugging and hex dump features. HTH, -- jay -------------------------------------------------- This email and attachment(s): [ ] blogable; [ x ] ask first; [ ] private and confidential daggerquill [at] gmail [dot] com http://www.tuaw.com http://www.dpguru.com http://www.engatiki.org values of β will give rise to dom!