libnet context

[email protected] Tue, 15 Jun 2004 17:19:25 +0530
Newsgroups gmane.comp.security.libnet
Message-ID <[email protected]>



What is a libnet context queue and when and where are they used. Suppose I
have two processes, that want to use the libnet library, I hope they can
have libnet contexts of their own, and both are  each other.

i.e
 process A_init(){
 lh=libnet_init(...);
}

processB_init(){
lh=libnet_init();
}

now if these two processes have o send raw packets using these contexts,
then I hope there is no problem in doing that
i.e

processA_sen()
{
libnet_build_udp() ...
libnet_write(lh)
}

processB_send()
{
libnet_build_udp() ...
libnet_write(lh)
}

I hope these two writes do not interfere with each other .... !!!! I had
taken this assumption all along.

So where do we really use context queues, and why is it erquired.

Also, when I am trying to send more than one udp packet from the same
context I am getting a write error : why is that so ?

thanks
Amit





Amit Kumar Singh
06/15/2004 05:08 PM

To:    "Jee J.Z." <[email protected]>
cc:

Subject:    libnet doubt


---------------------- Forwarded by Amit Kumar Singh/HSS on 06/15/2004
05:16 PM ---------------------------


Amit Kumar Singh
06/15/2004 04:27 PM

To:    "Mustafa Abu Sedera" <[email protected]>
cc:    [email protected]

Subject:    libnet doubt  (Document link: Amit Kumar Singh)

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