libnet doubt

[email protected] Tue, 15 Jun 2004 16:27:07 +0530
Newsgroups gmane.comp.security.libnet
Message-ID <[email protected]>



Hi,

 I am trying to do this :

libnet_t lh;
libnet_ptag_t udp_ptag=0, ip_ptag=0;
u_long dst_ip;

build_send_udp()
{
udp_ptag=0;
udp_ptag=libnet_build_udp( ...... );
if(udp_ptag==-1) {printf("we're goig to bad from here udptag");goto bad;}
ip_ptag=libnet_autobuild_ipv4(....);
if(ip_ptag==-1) {printf("\nwe're going to abd from iptag\n");goto bad;}

bad:
destroy (lh);
exit;
}

main()
{
char * dst="192.x.x.x";
lh=libnet_init(libnet_raw4 , NULL, err_buf);
dst_ip=libnet_name2addr(lh, dst, DONT_RESOLVE);
build_send_udp();
build_send_udp();
build_send_udp();
libnet_destroy(lh);
}

WHAT I AM TRYING TO DO :
basically i am trying to send more than one udp packets from the same
context. What I do is this :
1. first in main initialize using libnet_init, the handle is a global
variable accessible to build_send_udp() too.
2. then send a udp packeteverytime build_send_udp is called.
3 finally after all 3 packets have been sent, destroy the context using
libnet_destroy(lh);

PROBLEM :  On running the .out, the first packet goes out fine, but for the
second, third (all after first ) I get the following error :

We're going to bad from iptag
cannot build ip header : libnet_get_ipaddr4() : ioctl : no such device ....
what is this can someone tell me how to send more than one packet from the
same context.

i tried adding libnet_clear_packet(lh); after every call to
build_send_udp(), but the same error persists.

Any clues ?

thanks
Amit