structres and unions problem
linux.lover2004_at_gmail.com
Date: 04/15/05
- Next message: Kasper Dupont: "Re: Operating system design questions"
- Previous message: Santosh Kamat: "Re: popen usage - bug in the code"
- Next in thread: Josef Moellers: "Re: structres and unions problem"
- Reply: Josef Moellers: "Re: structres and unions problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 15 Apr 2005 03:15:15 -0700
hello,
There is a structure skbuff written in linux kernel.
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?
- Next message: Kasper Dupont: "Re: Operating system design questions"
- Previous message: Santosh Kamat: "Re: popen usage - bug in the code"
- Next in thread: Josef Moellers: "Re: structres and unions problem"
- Reply: Josef Moellers: "Re: structres and unions problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|