obtain ARP header from 'sk_buff'

Hello,

kernel 2.4.20 in embedded system. 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 (I gueess this is right, as the hardware addresses might have different lengths depending on network type). So I've tried this trick -- defined 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]; /* sender hardware address */ unsigned char ar_sip[4]; /* sender IP address */ unsigned char ar_tha[ETH_ALEN]; /* target hardware address */ 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 garbage and waht is the right way to do what I want?

Thanks in advance!

--
Mark
Reply to
Mark
Loading thread data ...

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.