From 49f933fbc3a55071e1cac362f7e1b5f2fd41b657 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 19 Apr 2006 01:52:41 +0000 Subject: Moved if_ether.h and if_arp.h to include/gpxe, for consistency with Linux kernel. Removed obsolete struct arprequest from if_arp.h and put it in nic.c so that nic.c will still compile. ARP will very shortly be handled by net/arp.c instead. --- src/include/gpxe/if_arp.h | 100 ++++++++++++++++++++++++++++++++++++++++++++ src/include/gpxe/if_ether.h | 31 ++++++++++++++ 2 files changed, 131 insertions(+) create mode 100644 src/include/gpxe/if_arp.h create mode 100644 src/include/gpxe/if_ether.h (limited to 'src/include/gpxe') diff --git a/src/include/gpxe/if_arp.h b/src/include/gpxe/if_arp.h new file mode 100644 index 000000000..31e993dee --- /dev/null +++ b/src/include/gpxe/if_arp.h @@ -0,0 +1,100 @@ +#ifndef _IF_ARP_H +#define _IF_ARP_H + +/** @file + * + * Address Resolution Protocol constants and types + * + */ + +#include + +/* ARP protocol HARDWARE identifiers. */ +#define ARPHRD_NETROM 0 /**< from KA9Q: NET/ROM pseudo */ +#define ARPHRD_ETHER 1 /**< Ethernet 10Mbps */ +#define ARPHRD_EETHER 2 /**< Experimental Ethernet */ +#define ARPHRD_AX25 3 /**< AX.25 Level 2 */ +#define ARPHRD_PRONET 4 /**< PROnet token ring */ +#define ARPHRD_CHAOS 5 /**< Chaosnet */ +#define ARPHRD_IEEE802 6 /**< IEEE 802.2 Ethernet/TR/TB */ +#define ARPHRD_ARCNET 7 /**< ARCnet */ +#define ARPHRD_APPLETLK 8 /**< APPLEtalk */ +#define ARPHRD_DLCI 15 /**< Frame Relay DLCI */ +#define ARPHRD_ATM 19 /**< ATM */ +#define ARPHRD_METRICOM 23 /**< Metricom STRIP (new IANA id) */ +#define ARPHRD_IEEE1394 24 /**< IEEE 1394 IPv4 - RFC 2734 */ +#define ARPHRD_EUI64 27 /**< EUI-64 */ +#define ARPHRD_INFINIBAND 32 /**< InfiniBand */ + +/* ARP protocol opcodes. */ +#define ARPOP_REQUEST 1 /**< ARP request */ +#define ARPOP_REPLY 2 /**< ARP reply */ +#define ARPOP_RREQUEST 3 /**< RARP request */ +#define ARPOP_RREPLY 4 /**< RARP reply */ +#define ARPOP_InREQUEST 8 /**< InARP request */ +#define ARPOP_InREPLY 9 /**< InARP reply */ +#define ARPOP_NAK 10 /**< (ATM)ARP NAK */ + +/** + * An ARP header + * + * This contains only the fixed-size portions of an ARP header; for + * other fields use the arp_{sender,target}_{ha,pa} family of + * functions. + */ +struct arphdr { + /** Link-layer protocol + * + * This is an ARPHRD_XXX constant + */ + uint16_t ar_hrd; + /** Network-layer protocol + * + * This is, for Ethernet, an ETH_P_XXX constant. + */ + uint16_t ar_pro; + /** Link-layer address length */ + uint8_t ar_hln; + /** Network-layer address length */ + uint8_t ar_pln; + /** ARP opcode */ + uint16_t ar_op; +} __attribute__ (( packed )); + +/** ARP packet sender hardware address + * + * @v arphdr ARP header + * @ret ar_sha Sender hardware address + */ +static inline void * arp_sender_ha ( struct arphdr *arphdr ) { + return ( ( ( void * ) arphdr ) + sizeof ( *arphdr ) ); +} + +/** ARP packet sender protocol address + * + * @v arphdr ARP header + * @ret ar_spa Sender protocol address + */ +static inline void * arp_sender_pa ( struct arphdr *arphdr ) { + return ( arp_sender_ha ( arphdr ) + arphdr->ar_hln ); +} + +/** ARP packet target hardware address + * + * @v arphdr ARP header + * @ret ar_tha Target hardware address + */ +static inline void * arp_target_ha ( struct arphdr *arphdr ) { + return ( arp_sender_pa ( arphdr ) + arphdr->ar_pln ); +} + +/** ARP packet target protocol address + * + * @v arphdr ARP header + * @ret ar_tpa Target protocol address + */ +static inline void * arp_target_pa ( struct arphdr *arphdr ) { + return ( arp_target_ha ( arphdr ) + arphdr->ar_hln ); +} + +#endif /* _IF_ARP_H */ diff --git a/src/include/gpxe/if_ether.h b/src/include/gpxe/if_ether.h new file mode 100644 index 000000000..7f0abacbd --- /dev/null +++ b/src/include/gpxe/if_ether.h @@ -0,0 +1,31 @@ +#ifndef _IF_ETHER_H +#define _IF_ETHER_H + +#include + +#define ETH_ALEN 6 /* Size of Ethernet address */ +#define ETH_HLEN 14 /* Size of ethernet header */ +#define ETH_ZLEN 60 /* Minimum packet */ +#define ETH_FRAME_LEN 1514 /* Maximum packet */ +#define ETH_DATA_ALIGN 2 /* Amount needed to align the data after an ethernet header */ +#ifndef ETH_MAX_MTU +#define ETH_MAX_MTU (ETH_FRAME_LEN-ETH_HLEN) +#endif + +#define ETH_P_IP 0x0800 /* Internet Protocl Packet */ +#define ETH_P_ARP 0x0806 /* Address Resolution Protocol */ +#define ETH_P_RARP 0x8035 /* Reverse Address resolution Protocol */ +#define ETH_P_IPV6 0x86DD /* IPv6 over blueblook */ +#define ETH_P_SLOW 0x8809 /* Ethernet slow protocols */ + +/** An Ethernet link-layer header */ +struct ethhdr { + /** Destination MAC address */ + uint8_t h_dest[ETH_ALEN]; + /** Source MAC address */ + uint8_t h_source[ETH_ALEN]; + /** Protocol ID */ + uint16_t h_protocol; +} __attribute__ ((packed)); + +#endif /* _IF_ETHER_H */ -- cgit v1.2.3-55-g7522