tags:

views:

29

answers:

0

Hello,

embedded system (kernel 2.4.20). In my driver I need to access ARP header fields, including MAC addresses; unfortunately in include/linux/if_arp.h those specific fields are commented . So I've tried to define my own 'arp_hdr' structure in my code with necessary fields:

struct arp_hdr {
    /* all the fields taken from include/linux/if_arp.h */
    /* and  additionaly these*/
   unsigned char       ar_sha[ETH_ALEN];
   unsigned char       ar_sip[4];
   unsigned char       ar_tha[ETH_ALEN];
   unsigned char       ar_tip[4];
}

int my_func(struct sk_buff *skb)
{
    struct arp_hdr  *arph;

   arph = (struct arp_hdr *)skb->nh.raw;

  /* now print out the contents of the ARP header, but I get garbage */
}

Why do I get the garbage and what is the right way to do what I want?

Thanks in advance!