A version of LWIP, provided for backwards compatibility.
Dependents: AA_DemoBoard DemoBoard HelloServerDemo DemoBoard_RangeIndicator ... more
etharp.h
00001 /* 00002 * Copyright (c) 2001-2003 Swedish Institute of Computer Science. 00003 * Copyright (c) 2003-2004 Leon Woestenberg <leon.woestenberg@axon.tv> 00004 * Copyright (c) 2003-2004 Axon Digital Design B.V., The Netherlands. 00005 * All rights reserved. 00006 * 00007 * Redistribution and use in source and binary forms, with or without modification, 00008 * are permitted provided that the following conditions are met: 00009 * 00010 * 1. Redistributions of source code must retain the above copyright notice, 00011 * this list of conditions and the following disclaimer. 00012 * 2. Redistributions in binary form must reproduce the above copyright notice, 00013 * this list of conditions and the following disclaimer in the documentation 00014 * and/or other materials provided with the distribution. 00015 * 3. The name of the author may not be used to endorse or promote products 00016 * derived from this software without specific prior written permission. 00017 * 00018 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 00019 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00020 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 00021 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00022 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 00023 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00024 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00025 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 00026 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 00027 * OF SUCH DAMAGE. 00028 * 00029 * This file is part of the lwIP TCP/IP stack. 00030 * 00031 * Author: Adam Dunkels <adam@sics.se> 00032 * 00033 */ 00034 00035 #ifndef __NETIF_ETHARP_H__ 00036 #define __NETIF_ETHARP_H__ 00037 00038 #include "lwip/opt.h" 00039 00040 #if LWIP_ARP /* don't build if not configured for use in lwipopts.h */ 00041 00042 #include "lwip/pbuf.h" 00043 #include "lwip/ip_addr.h" 00044 #include "lwip/netif.h" 00045 #include "lwip/ip.h" 00046 00047 #ifdef __cplusplus 00048 extern "C" { 00049 #endif 00050 00051 #ifndef ETH_PAD_SIZE 00052 #define ETH_PAD_SIZE 0 00053 #endif 00054 00055 #ifndef ETHARP_HWADDR_LEN 00056 #define ETHARP_HWADDR_LEN 6 00057 #endif 00058 00059 // XXX: Copy packt to unpackt structure. 00060 #define CPY_ETH_ADDR(a, b) \ 00061 { \ 00062 int i=0; \ 00063 for(;i<ETHARP_HWADDR_LEN;++i) { \ 00064 a.addr[i] = b.addr[i]; \ 00065 }} 00066 00067 #ifdef PACK_STRUCT_USE_INCLUDES 00068 # include "arch/bpstruct.h" 00069 #endif 00070 PACK_STRUCT_BEGIN 00071 struct eth_addr { 00072 PACK_STRUCT_FIELD(u8_t addr[ETHARP_HWADDR_LEN]); 00073 } PACK_STRUCT_STRUCT; 00074 PACK_STRUCT_END 00075 #ifdef PACK_STRUCT_USE_INCLUDES 00076 # include "arch/epstruct.h" 00077 #endif 00078 00079 #ifdef PACK_STRUCT_USE_INCLUDES 00080 # include "arch/bpstruct.h" 00081 #endif 00082 PACK_STRUCT_BEGIN 00083 struct eth_hdr { 00084 #if ETH_PAD_SIZE 00085 PACK_STRUCT_FIELD(u8_t padding[ETH_PAD_SIZE]); 00086 #endif 00087 PACK_STRUCT_FIELD(struct eth_addr dest); 00088 PACK_STRUCT_FIELD(struct eth_addr src); 00089 PACK_STRUCT_FIELD(u16_t type); 00090 } PACK_STRUCT_STRUCT; 00091 PACK_STRUCT_END 00092 #ifdef PACK_STRUCT_USE_INCLUDES 00093 # include "arch/epstruct.h" 00094 #endif 00095 00096 #ifdef PACK_STRUCT_USE_INCLUDES 00097 # include "arch/bpstruct.h" 00098 #endif 00099 PACK_STRUCT_BEGIN 00100 /** the ARP message */ 00101 struct etharp_hdr { 00102 PACK_STRUCT_FIELD(struct eth_hdr ethhdr); 00103 PACK_STRUCT_FIELD(u16_t hwtype); 00104 PACK_STRUCT_FIELD(u16_t proto); 00105 PACK_STRUCT_FIELD(u16_t _hwlen_protolen); 00106 PACK_STRUCT_FIELD(u16_t opcode); 00107 PACK_STRUCT_FIELD(struct eth_addr shwaddr); 00108 PACK_STRUCT_FIELD(struct ip_addr2 sipaddr); 00109 PACK_STRUCT_FIELD(struct eth_addr dhwaddr); 00110 PACK_STRUCT_FIELD(struct ip_addr2 dipaddr); 00111 } PACK_STRUCT_STRUCT; 00112 PACK_STRUCT_END 00113 #ifdef PACK_STRUCT_USE_INCLUDES 00114 # include "arch/epstruct.h" 00115 #endif 00116 00117 #ifdef PACK_STRUCT_USE_INCLUDES 00118 # include "arch/bpstruct.h" 00119 #endif 00120 PACK_STRUCT_BEGIN 00121 struct ethip_hdr { 00122 PACK_STRUCT_FIELD(struct eth_hdr eth); 00123 PACK_STRUCT_FIELD(struct ip_hdr ip); 00124 } PACK_STRUCT_STRUCT; 00125 PACK_STRUCT_END 00126 #ifdef PACK_STRUCT_USE_INCLUDES 00127 # include "arch/epstruct.h" 00128 #endif 00129 00130 /** 5 seconds period */ 00131 #define ARP_TMR_INTERVAL 5000 00132 00133 #define ETHTYPE_ARP 0x0806 00134 #define ETHTYPE_IP 0x0800 00135 #define ETHTYPE_PPPOEDISC 0x8863 /* PPP Over Ethernet Discovery Stage */ 00136 #define ETHTYPE_PPPOE 0x8864 /* PPP Over Ethernet Session Stage */ 00137 00138 /** ARP message types (opcodes) */ 00139 #define ARP_REQUEST 1 00140 #define ARP_REPLY 2 00141 00142 #if ARP_QUEUEING 00143 /** struct for queueing outgoing packets for unknown address 00144 * defined here to be accessed by memp.h 00145 */ 00146 struct etharp_q_entry { 00147 struct etharp_q_entry *next; 00148 struct pbuf *p; 00149 }; 00150 #endif /* ARP_QUEUEING */ 00151 00152 #define etharp_init() /* Compatibility define, not init needed. */ 00153 void etharp_tmr(void); 00154 s8_t etharp_find_addr(struct netif *netif, struct ip_addr *ipaddr, 00155 struct eth_addr **eth_ret, struct ip_addr **ip_ret); 00156 void etharp_ip_input(struct netif *netif, struct pbuf *p); 00157 void etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr, 00158 struct pbuf *p); 00159 err_t etharp_output(struct netif *netif, struct pbuf *q, struct ip_addr *ipaddr); 00160 err_t etharp_query(struct netif *netif, struct ip_addr *ipaddr, struct pbuf *q); 00161 err_t etharp_request(struct netif *netif, struct ip_addr *ipaddr); 00162 00163 err_t ethernet_input(struct pbuf *p, struct netif *netif); 00164 00165 #if LWIP_AUTOIP 00166 err_t etharp_raw(struct netif *netif, const struct eth_addr *ethsrc_addr, 00167 const struct eth_addr *ethdst_addr, 00168 const struct eth_addr *hwsrc_addr, const struct ip_addr *ipsrc_addr, 00169 const struct eth_addr *hwdst_addr, const struct ip_addr *ipdst_addr, 00170 const u16_t opcode); 00171 #endif /* LWIP_AUTOIP */ 00172 00173 #define eth_addr_cmp(addr1, addr2) (memcmp((addr1)->addr, (addr2)->addr, ETHARP_HWADDR_LEN) == 0) 00174 00175 extern const struct eth_addr ethbroadcast, ethzero; 00176 00177 #ifdef __cplusplus 00178 } 00179 #endif 00180 00181 #endif /* LWIP_ARP */ 00182 00183 #endif /* __NETIF_ARP_H__ */
Generated on Tue Jul 12 2022 16:06:05 by 1.7.2