Discussion:
libnet_write_raw_ipv4() Message too long
Ben L
2004-09-02 13:28:10 UTC
Permalink
Hello,

i have a problem with my libnet application. I have written a small programm to test my firewall and a packetlogger. My code simply creates some ip packets with valid ip addresses in a loop.
Those packets are transmitted via tcp.

Everything works fine for about 70 packets, then i get the (Message too long) error msg.

The problem is that my code always adds the data for the new packet to the current libnet context. I need a way to get rid of the old data after i have sended a packet in a loop.

pseudo code:

while (ip addresses)
Mustafa Abu Sedera
2004-09-03 12:33:07 UTC
Permalink
Hello,

use a tag for your builder functions, this way your pblocks will be altered
instead of creating each time a new pblock.
pseudo code:

ptag_data = 0;
ptag_tcp_or_udp_or_icmp= 0;
ptag_ip = 0;

for()
{
ptag_data = libnet_build_data (...,...,..., ptag_data);

ptag_tcp_or_udp_or_icmp = libnet_build_tcp_or_udp_or_icmp
(..,...ptag_tcp_or_udp_or_icmp );

ptag_ip = libnet_build_ip (...., ..., ptag_ip);

libnet_wrilt();
}

like this the first time you enter the loop you will create a new pblock for
each build_xxx() because the tags passed are 0, these fns will return you a
tag, the next time you call the functions the tags will have a value. so
libnet will search for the blocks with the corresponding tags and modify the
contents of the block instaed of creating a new one.

You could also use libnet_clear_packet() after you send the packet each
time, which will delete all the pblocks of the libnet context. if you use
this method always pass a zero in the tag field of the build_xx fns. after
you libnet_write() call libnet_clear_packet().

also check the samples, I think if you read through the codes you can easily
do what you want.

Regards, Mustaffa Abu Sedira
Subject: libnet_write_raw_ipv4() Message too long
Date: 2 Sep 2004 13:28:10 -0000
Hello,
i have a problem with my libnet application. I have written a small
programm to test my firewall and a packetlogger. My code simply creates
some ip packets with valid ip addresses in a loop.
Those packets are transmitted via tcp.
Everything works fine for about 70 packets, then i get the (Message too
long) error msg.
The problem is that my code always adds the data for the new packet to the
current libnet context. I need a way to get rid of the old data after i
have sended a packet in a loop.
while (ip addresses)
_________________________________________________________________
Add photos to your e-mail with MSN 8. Get 2 months FREE*.
http://join.msn.com/?page=features/featuredemail

Loading...