Networking Forums

Networking Forums > Computer Networking > Linux Networking > obtain ARP header from 'sk_buff'

Reply
Thread Tools Display Modes

obtain ARP header from 'sk_buff'

 
 
Mark
Guest
Posts: n/a

 
      10-07-2010, 09: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!

--
Mark

 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
sk_buff & DMA Bill Linux Networking 2 04-23-2008 07:36 AM
How to send a tcp packet to same machine from a kernel module by creating a sk_buff struct will_u_tellmemore Linux Networking 0 01-11-2007 12:45 PM
linux cooked header to ethernet header conversion makwak Linux Networking 0 05-10-2005 12:36 PM
problems with sk_buff implementation Venu Linux Networking 0 06-24-2004 02:59 AM
how to construct the sk_buff structure by myself? fangweiwei Linux Networking 0 02-17-2004 10:13 AM



1 2 3 4 5 6 7 8 9 10 11