structres and unions problem

L

linux.lover2004

hello,
There is a structure skbuff written in linux kernel. Though my
question is related to linux kernel source i think it will better be
answered here so posting here and in also linux.development.
In skbuff structure network and link layers are written as unions.
/* Network layer header */
union
{
struct iphdr *iph;
unsigned char *raw;
} nh;


/* Link layer header */
union
{
struct ethhdr *ethernet;
unsigned char *raw;
} mac;
when packets received by kernel it stores it as
unsigned char *data;
and then map it to headers union in packet as
skb->h.raw = skb->nh.raw = skb->data ;
then ethernet header is retrieved by
skb->mac.raw=skb->data;
ethhdr=skb->mac.ethernet

1)how can a unsigned char *data which assigns to skb->mac.raw recovers
as struct ethhdr *ethernet?

2) Can it be possible to map some bytes which i know is structure to a
structure from unsigned char *data? Does memcpy help me?
 
M

Mark McIntyre

On 15 Apr 2005 03:15:02 -0700, in comp.lang.c ,
hello,
There is a structure skbuff written in linux kernel. Though my
question is related to linux kernel source i think it will better be
answered here so posting here and in also linux.development.

Firstly, if you post to multiple relevant groups, its often better to
x-post so that you get only one set of answers.

Secondly this is totally offtopic in CLC. You will have more luck in
comp.unix.programming
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,263
Messages
2,571,064
Members
48,769
Latest member
Clifft

Latest Threads

Top