in reply to Creating trailer on packets

Don't know if it actually solves your problem (untested!):
# creating the packet chunks my $packet_eth = $ethernet->encode(); my $packet_ip = $ip->encode(); my $packet = $packet_eth . (0 x (60 - length($packet_eth) - length($packet_ip))) . $packet_ip;
The "x" operator does the right thing when (60 - length($packet_eth) - length($packet_ip)) isn't positive, of course.

30-sec-after update: it would probably pad with character '0' instead of nulls as you want; a quick hack could be:

# creating the packet chunks my $packet_eth = $ethernet->encode(); my $packet_ip = $ip->encode(); my $packet = $packet_eth . (pack 'H*', ('00' x (60 - length($packet_eth) - length($packet_ip +)))) # Note 0 -> 00 . $packet_ip;

Flavio (perl -e 'print(scalar(reverse("\nti.xittelop\@oivalf")))')

Don't fool yourself.

Replies are listed 'Best First'.
Re^2: Creating trailer on packets
by mosh (Scribe) on May 17, 2005 at 07:11 UTC
    Thanks a lot guys, it was very helpful !

    Mosh.