00001 /*############################################################################## 00002 00003 nIP - nano IP stack 00004 00005 File : arp.h 00006 00007 Description : nIP Internetstack ARP implementation 00008 00009 Copyright notice: 00010 00011 Copyright (C) 2005 - 00012 Andreas Dittrich, dittrich@informatik.hu-berlin.de 00013 Jon Kowal, kowal@informatik.hu-berlin.de 00014 00015 This program is free software; you can redistribute it and/or 00016 modify it under the terms of the GNU General Public License 00017 as published by the Free Software Foundation; either version 2 00018 of the License, or (at your option) any later version. 00019 00020 This program is distributed in the hope that it will be useful, 00021 but WITHOUT ANY WARRANTY; without even the implied warranty of 00022 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00023 GNU General Public License for more details. 00024 00025 You should have received a copy of the GNU General Public License 00026 along with this program; if not, write to the Free Software 00027 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00028 00029 ##############################################################################*/ 00030 00031 #ifndef _NIP_ARP_H 00032 #define _NIP_ARP_H 00033 00034 #include "os_core.h" 00035 00036 #ifndef NIP_ARP_CACHE_SIZE 00037 #define NIP_ARP_CACHE_SIZE 4 /**< number of entries in ARP cache */ 00038 #endif 00039 #define NIP_ARP_CACHE_LIFE 300 /**< lifetime of ARP cache entry in seconds */ 00040 #define NIP_ARP_MAX_RETRIES 3 /**< maximum number of ARP resolve retries */ 00041 #define NIP_ARP_RETRY_INTVL 1 /**< interval of ARP resolve retries in seconds*/ 00042 00043 #define NIP_ARP_OP_REQUEST 0x01 00044 #define NIP_ARP_OP_REPLY 0x02 00045 00046 // #define NIP_ARP_HW_TYPE 0x0001 00047 #define NIP_ARP_HW_SIZE 6 /**< ethernet address length */ 00048 #define NIP_ARP_PR_TYPE NIP_NUM_PR_IP /**< IP protocol type in network byte order */ 00049 #define NIP_ARP_PR_SIZE 4 /**< IP address length */ 00050 00051 /** ARP packet structure. 00052 * @note That this implementation of ARP is limited to IP and Ethernet addresses 00053 * being used. For usage with other protocols the above ..SIZE defines have to 00054 * be adapted or for use with multiple protocols the implementation has to be 00055 * modified to support dynamically sized ARP packets. 00056 */ 00057 struct ARP_PACKET { 00058 uint16_t hrd; /**< hardware address space, e.g. Ethernet:0x0001 */ 00059 uint16_t pro; /**< protocol address space, e.g. IP:0x0800 */ 00060 uint8_t hln; /**< byte length of each hardware address */ 00061 uint8_t pln; /**< byte length of each protocol address */ 00062 uint8_t op[2]; /**< opcode, Request:0x0001, Reply:0x0002 */ 00063 uint8_t sha[NIP_ARP_HW_SIZE]; /**< hardware address of sender */ 00064 uint8_t spa[NIP_ARP_PR_SIZE]; /**< protocol address of sender */ 00065 uint8_t tha[NIP_ARP_HW_SIZE]; /**< hardware address of target */ 00066 uint8_t tpa[NIP_ARP_PR_SIZE]; /**< protocol address of target */ 00067 } 00068 #ifndef DOXYGEN 00069 __attribute__((packed)) 00070 #endif 00071 ; 00072 00073 00074 #if ( NIP_ARP_CACHE_SIZE <= 256 ) 00075 typedef uint8_t arp_cache_id_t; 00076 #elif ( NIP_ARP_CACHE_SIZE <= 65536 ) 00077 typedef uint16_t arp_cache_id_t; 00078 #else 00079 typedef uint32_t arp_cache_id_t; 00080 #endif 00081 00082 00083 struct ARP_CACHE { 00084 uint8_t hw_addr[NIP_ARP_HW_SIZE]; /**< hardware address */ 00085 uint8_t pr_addr[NIP_ARP_PR_SIZE]; /**< protocol address */ 00086 nip_time_t timestamp; /**< timeout time of this entry */ 00087 } 00088 #ifndef DOXYGEN 00089 __attribute__((packed)) 00090 #endif 00091 ; 00092 00093 void nip_arp_disp_resolve_any( void ); 00094 void nip_disp_arp_receive( void ); 00095 void nip_arp_disp_resolve( void ); 00096 void nip_arp_disp_probe_announcement( void ); 00097 #endif /* _NIP_ARP_H */ 00098