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?
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?