00001 /*! \file include/net/arp.h 00002 * \brief ARP (Address Resolution Protocol) layer header. 00003 * \author Andrea Righi <drizzt@inwind.it> 00004 * \date Last update: 2003-11-09 00005 * \note Copyright (©) 2003 Andrea Righi 00006 */ 00007 00008 #ifndef ARP_H 00009 #define ARP_H 00010 00011 #include <net/ip.h> 00012 00013 //! Ethernet hardware addresses. 00014 #define ARPHRD_ETHER 1 00015 00016 /** \ingroup Network 00017 * \defgroup NetARP ARP (Address Resolution Protocol) layer 00018 * The ARP (Address Resolution Protocol) layer. 00019 * @{ 00020 */ 00021 00022 //! ARP request operation. 00023 #define ARP_OP_REQUEST 1 00024 //! ARP reply operation. 00025 #define ARP_OP_REPLY 2 00026 //! RARP request operation. 00027 #define RARP_OP_REQUEST 3 00028 //! RARP reply operation. 00029 #define RARP_OP_REPLY 4 00030 00031 // The ARP packet structure. 00032 typedef struct arp 00033 { 00034 //! Format of hardware address. 00035 uint16_t arp_hard_type; 00036 //! Format of protocol address. 00037 uint16_t arp_proto_type; 00038 //! Length of hardware address. 00039 uint8_t arp_hard_size; 00040 //! Length of protocol address. 00041 uint8_t arp_proto_size; 00042 //! ARP operation code (command). 00043 uint16_t arp_op; 00044 //! Hardware source address. 00045 uint8_t arp_eth_source[6]; 00046 //! IP source address. 00047 uint32_t arp_ip_source; 00048 //! Hardware destination address. 00049 uint8_t arp_eth_dest[6]; 00050 //! IP destination address. 00051 uint32_t arp_ip_dest; 00052 } __attribute__ ((packed)) arp_t; 00053 00054 // --- Prototypes ----------------------------------------------------- // 00055 00056 void to_arp_layer(arp_t *packet); 00057 void arp_reset_cache(); 00058 void arp_add_cache(in_addr_t ip, uint8_t *mac); 00059 bool arp_remove_cache(in_addr_t ip); 00060 bool arp_ip_to_eth(uint8_t *eth_addr, in_addr_t ip_addr); 00061 int arp_ip_to_eth(uint8_t *eth_addr, uint32_t ip_addr); 00062 int send_arp_packet(in_addr_t ip_to, const uint8_t *eth_to, uint16_t arp_op); 00063 void arp_request(char *ip_dot); 00064 00065 /** @} */ // end of NetARP 00066 00067 #endif