Home | History | Annotate | Download | only in gpxe
      1 #ifndef	_GPXE_IF_ARP_H
      2 #define	_GPXE_IF_ARP_H
      3 
      4 /** @file
      5  *
      6  * Address Resolution Protocol constants and types
      7  *
      8  */
      9 
     10 FILE_LICENCE ( GPL2_OR_LATER );
     11 
     12 #include <stdint.h>
     13 
     14 /* ARP protocol HARDWARE identifiers. */
     15 #define ARPHRD_NETROM	0		/**< from KA9Q: NET/ROM pseudo	*/
     16 #define ARPHRD_ETHER 	1		/**< Ethernet 10Mbps		*/
     17 #define	ARPHRD_EETHER	2		/**< Experimental Ethernet	*/
     18 #define	ARPHRD_AX25	3		/**< AX.25 Level 2		*/
     19 #define	ARPHRD_PRONET	4		/**< PROnet token ring		*/
     20 #define	ARPHRD_CHAOS	5		/**< Chaosnet			*/
     21 #define	ARPHRD_IEEE802	6		/**< IEEE 802.2 Ethernet/TR/TB	*/
     22 #define	ARPHRD_ARCNET	7		/**< ARCnet			*/
     23 #define	ARPHRD_APPLETLK	8		/**< APPLEtalk			*/
     24 #define ARPHRD_DLCI	15		/**< Frame Relay DLCI		*/
     25 #define ARPHRD_ATM	19		/**< ATM 			*/
     26 #define ARPHRD_METRICOM	23		/**< Metricom STRIP (new IANA id) */
     27 #define	ARPHRD_IEEE1394	24		/**< IEEE 1394 IPv4 - RFC 2734	*/
     28 #define ARPHRD_EUI64	27		/**< EUI-64			*/
     29 #define ARPHRD_INFINIBAND 32		/**< InfiniBand			*/
     30 
     31 /* ARP protocol opcodes. */
     32 #define	ARPOP_REQUEST	1		/**< ARP request		*/
     33 #define	ARPOP_REPLY	2		/**< ARP reply			*/
     34 #define	ARPOP_RREQUEST	3		/**< RARP request		*/
     35 #define	ARPOP_RREPLY	4		/**< RARP reply			*/
     36 #define	ARPOP_InREQUEST	8		/**< InARP request		*/
     37 #define	ARPOP_InREPLY	9		/**< InARP reply		*/
     38 #define	ARPOP_NAK	10		/**< (ATM)ARP NAK		*/
     39 
     40 /**
     41  * An ARP header
     42  *
     43  * This contains only the fixed-size portions of an ARP header; for
     44  * other fields use the arp_{sender,target}_{ha,pa} family of
     45  * functions.
     46  */
     47 struct arphdr {
     48 	/** Link-layer protocol
     49 	 *
     50 	 * This is an ARPHRD_XXX constant
     51 	 */
     52 	uint16_t ar_hrd;
     53 	/** Network-layer protocol
     54 	 *
     55 	 * This is, for Ethernet, an ETH_P_XXX constant.
     56 	 */
     57 	uint16_t ar_pro;
     58 	/** Link-layer address length */
     59 	uint8_t ar_hln;
     60 	/** Network-layer address length */
     61 	uint8_t ar_pln;
     62 	/** ARP opcode */
     63 	uint16_t ar_op;
     64 } __attribute__ (( packed ));
     65 
     66 /** ARP packet sender hardware address
     67  *
     68  * @v arphdr	ARP header
     69  * @ret ar_sha	Sender hardware address
     70  */
     71 static inline void * arp_sender_ha ( struct arphdr *arphdr ) {
     72 	return ( ( ( void * ) arphdr ) + sizeof ( *arphdr ) );
     73 }
     74 
     75 /** ARP packet sender protocol address
     76  *
     77  * @v arphdr	ARP header
     78  * @ret ar_spa	Sender protocol address
     79  */
     80 static inline void * arp_sender_pa ( struct arphdr *arphdr ) {
     81 	return ( arp_sender_ha ( arphdr ) + arphdr->ar_hln );
     82 }
     83 
     84 /** ARP packet target hardware address
     85  *
     86  * @v arphdr	ARP header
     87  * @ret ar_tha	Target hardware address
     88  */
     89 static inline void * arp_target_ha ( struct arphdr *arphdr ) {
     90 	return ( arp_sender_pa ( arphdr ) + arphdr->ar_pln );
     91 }
     92 
     93 /** ARP packet target protocol address
     94  *
     95  * @v arphdr	ARP header
     96  * @ret ar_tpa	Target protocol address
     97  */
     98 static inline void * arp_target_pa ( struct arphdr *arphdr ) {
     99 	return ( arp_target_ha ( arphdr ) + arphdr->ar_hln );
    100 }
    101 
    102 #endif	/* _GPXE_IF_ARP_H */
    103