Sounds like a C question really! Try this:

packet = (u_char*) malloc(1500);        // MTU of Ethernet

memcpy(packet, &ethernet, sizeof(ethernet));
memcpy(packet+sizeof(ethernet), &ip, sizeof(ip))

// send packet

free(packet);
packet = NULL;  //tidy up


Does this look like what you're trying to achieve?

If the compiler grumbles, you may have to cast the various parameters to
void* or char*. Any warnings will give you a clue!



On Mon, 10 Mar 2003 06:54:11 -0800 (PST)
Kenny Cauwerts <[EMAIL PROTECTED]> wrote:

> Helo,
> 
> I'm trying to write a packet generator using wpcap.dll
> but I have a problem with creating a packet.
> 
> Suppose I'm able to create a ethernet header and a
> packet header. How can I make from these two structure
> a pointer to u_char?
> This is my problem:
> 
> 
> const u_char *packet
> 
> struct ethernet_header{
>       u_char ether_dhost[6];
>       u_char ether_shost[6];
>       u_short ether_type;
>       };
> 
> struct ip_header{
> 
>       ...
>       
>       }; 
> 
> 
> ethernet_header ethernet;
> ip_header ip;
> 
> //?how do I push 'ethernet' and 'ip' into 'packet'?
> 
> 
> 
> Thanks,
> Kenny Cauwerts
> 
> 
> 
> 
> 




==================================================================
 This is the WinPcap users list. It is archived at
 http://www.mail-archive.com/[EMAIL PROTECTED]/

 To unsubscribe use 
 mailto: [EMAIL PROTECTED]
==================================================================

Reply via email to