For Programmers: Free Programming Magazines  


Home > Archive > Unix Programming > September 2006 > linux arp header









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author linux arp header
janemba

2006-09-24, 7:01 pm

Hello,

In /usr/include/linux/if_arp.h we have the struct arphdr that look
like this :

struct arphdr
{
unsigned short ar_hrd; /* format of hardware address */
unsigned short ar_pro; /* format of protocol address */
unsigned char ar_hln; /* length of hardware address */
unsigned char ar_pln; /* length of protocol address */
unsigned short ar_op; /* ARP opcode (command) */

#if 0
/*
* Ethernet looks like this : This bit is variable sized however...
*/
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]; /* target IP address */
#endif

};

We have the block "#if 0" inside this block we can't use the field "ar_sha, ..."
How can I handle this ?

Regards
Barry Margolin

2006-09-24, 7:01 pm

In article <pan.2006.09.24.18.02.11.818860@wanadoo.fr>,
janemba <janemba@wanadoo.fr> wrote:

> Hello,
>
> In /usr/include/linux/if_arp.h we have the struct arphdr that look
> like this :
>
> struct arphdr
> {
> unsigned short ar_hrd; /* format of hardware address */
> unsigned short ar_pro; /* format of protocol address */
> unsigned char ar_hln; /* length of hardware address */
> unsigned char ar_pln; /* length of protocol address */
> unsigned short ar_op; /* ARP opcode (command) */
>
> #if 0
> /*
> * Ethernet looks like this : This bit is variable sized however...
> */
> 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]; /* target IP address */
> #endif
>
> };
>
> We have the block "#if 0" inside this block we can't use the field "ar_sha,
> ..."
> How can I handle this ?


That part isn't the header, it's the data. Treat it as an array of
bytes, and use the ar_hln and ar_pln fields to determine how many bytes
there are in each piece. The commented-out fields are just a
description of how it will be laid out in the most common case, which is
IP over Ethernet, but ARP was designed to be usable with other network
and link protocols.

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
janemba

2006-09-26, 7:00 pm

On Sun, 24 Sep 2006 15:50:04 -0400, Barry Margolin wrote:


>
> That part isn't the header, it's the data. Treat it as an array of
> bytes, and use the ar_hln and ar_pln fields to determine how many bytes
> there are in each piece. The commented-out fields are just a
> description of how it will be laid out in the most common case, which is
> IP over Ethernet, but ARP was designed to be usable with other network
> and link protocols.


Thanks man !

Regards

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com