Do you have a question? Post it now! No Registration Necessary
October 7, 2010, 9:16 am

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!
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
Mark
Site Timeline
- » The Perfect Gift, A Diamond Flak; Luxmini 323 & Touch 852 USB flash drive
- — Next thread in » Embedded Linux
-
- » can u belive ultra fast transferspeed of Armor A80 portable hard drive?!?
- — Previous thread in » Embedded Linux
-
- » Crosscompiling for ARM: reloc type R_ARM_ABS32 is not supported for PIC - ...
- — Newest thread in » Embedded Linux
-
- » What limits noise in voltage regulators?
- — The site's Newest Thread. Posted in » Electronics Design
-
- » Slow (industrial?) SD cards
- — The site's Last Updated Thread. Posted in » Embedded Programming
-