Hi,

I'm just beginner, new winpcap user.
Here is something working : 

memcpy(ethernet, packet, sizeof (struct ethernet_header));

BTW, be careful about how packed are your datas, for exemple
struct ex
{
        char c; 
        int i;
};
can be 8 bits wide instead of 5. Look at how to use 
#pragma pack(1) within visual studio.

In fact, you can do it with many ways. This one is quick but 
dirty.


> 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