Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
etharp.h
00001 /** 00002 * @file 00003 * Ethernet output function - handles OUTGOING ethernet level traffic, implements 00004 * ARP resolving. 00005 * To be used in most low-level netif implementations 00006 */ 00007 00008 /* 00009 * Copyright (c) 2001-2003 Swedish Institute of Computer Science. 00010 * Copyright (c) 2003-2004 Leon Woestenberg <leon.woestenberg@axon.tv> 00011 * Copyright (c) 2003-2004 Axon Digital Design B.V., The Netherlands. 00012 * All rights reserved. 00013 * 00014 * Redistribution and use in source and binary forms, with or without modification, 00015 * are permitted provided that the following conditions are met: 00016 * 00017 * 1. Redistributions of source code must retain the above copyright notice, 00018 * this list of conditions and the following disclaimer. 00019 * 2. Redistributions in binary form must reproduce the above copyright notice, 00020 * this list of conditions and the following disclaimer in the documentation 00021 * and/or other materials provided with the distribution. 00022 * 3. The name of the author may not be used to endorse or promote products 00023 * derived from this software without specific prior written permission. 00024 * 00025 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 00026 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00027 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 00028 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00029 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 00030 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00031 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00032 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 00033 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 00034 * OF SUCH DAMAGE. 00035 * 00036 * This file is part of the lwIP TCP/IP stack. 00037 * 00038 * Author: Adam Dunkels <adam@sics.se> 00039 * 00040 */ 00041 00042 #ifndef LWIP_HDR_NETIF_ETHARP_H 00043 #define LWIP_HDR_NETIF_ETHARP_H 00044 00045 #include "lwip/opt.h" 00046 00047 #if LWIP_ARP || LWIP_ETHERNET /* don't build if not configured for use in lwipopts.h */ 00048 00049 #include "lwip/pbuf.h" 00050 #include "lwip/ip4_addr.h" 00051 #include "lwip/netif.h" 00052 #include "lwip/ip4.h" 00053 #include "netif/lwip_ethernet.h" 00054 00055 #ifdef __cplusplus 00056 extern "C" { 00057 #endif 00058 00059 #if LWIP_IPV4 && LWIP_ARP /* don't build if not configured for use in lwipopts.h */ 00060 00061 #ifndef ETHARP_HWADDR_LEN 00062 #define ETHARP_HWADDR_LEN ETH_HWADDR_LEN 00063 #endif 00064 00065 #ifdef PACK_STRUCT_USE_INCLUDES 00066 # include "arch/bpstruct.h" 00067 #endif 00068 PACK_STRUCT_BEGIN 00069 /** the ARP message, see RFC 826 ("Packet format") */ 00070 struct etharp_hdr { 00071 PACK_STRUCT_FIELD(u16_t hwtype); 00072 PACK_STRUCT_FIELD(u16_t proto); 00073 PACK_STRUCT_FLD_8(u8_t hwlen); 00074 PACK_STRUCT_FLD_8(u8_t protolen); 00075 PACK_STRUCT_FIELD(u16_t opcode); 00076 PACK_STRUCT_FLD_S(struct eth_addr shwaddr); 00077 PACK_STRUCT_FLD_S(struct ip4_addr2 sipaddr); 00078 PACK_STRUCT_FLD_S(struct eth_addr dhwaddr); 00079 PACK_STRUCT_FLD_S(struct ip4_addr2 dipaddr); 00080 } PACK_STRUCT_STRUCT; 00081 PACK_STRUCT_END 00082 #ifdef PACK_STRUCT_USE_INCLUDES 00083 # include "arch/epstruct.h" 00084 #endif 00085 00086 #define SIZEOF_ETHARP_HDR 28 00087 00088 #define SIZEOF_ETHARP_PACKET (SIZEOF_ETH_HDR + SIZEOF_ETHARP_HDR) 00089 #if ETHARP_SUPPORT_VLAN && defined(LWIP_HOOK_VLAN_SET) 00090 #define SIZEOF_ETHARP_PACKET_TX (SIZEOF_ETHARP_PACKET + SIZEOF_VLAN_HDR) 00091 #else /* ETHARP_SUPPORT_VLAN && defined(LWIP_HOOK_VLAN_SET) */ 00092 #define SIZEOF_ETHARP_PACKET_TX SIZEOF_ETHARP_PACKET 00093 #endif /* ETHARP_SUPPORT_VLAN && defined(LWIP_HOOK_VLAN_SET) */ 00094 00095 /** 1 seconds period */ 00096 #define ARP_TMR_INTERVAL 1000 00097 00098 /** ARP message types (opcodes) */ 00099 #define ARP_REQUEST 1 00100 #define ARP_REPLY 2 00101 00102 #if ARP_QUEUEING 00103 /** struct for queueing outgoing packets for unknown address 00104 * defined here to be accessed by memp.h 00105 */ 00106 struct etharp_q_entry { 00107 struct etharp_q_entry *next; 00108 struct pbuf *p; 00109 }; 00110 #endif /* ARP_QUEUEING */ 00111 00112 #define etharp_init() /* Compatibility define, no init needed. */ 00113 void etharp_tmr(void); 00114 s8_t etharp_find_addr(struct netif *netif, const ip4_addr_t *ipaddr, 00115 struct eth_addr **eth_ret, const ip4_addr_t **ip_ret); 00116 u8_t etharp_get_entry(u8_t i, ip4_addr_t **ipaddr, struct netif **netif, struct eth_addr **eth_ret); 00117 err_t etharp_output(struct netif *netif, struct pbuf *q, const ip4_addr_t *ipaddr); 00118 err_t etharp_query(struct netif *netif, const ip4_addr_t *ipaddr, struct pbuf *q); 00119 err_t etharp_request(struct netif *netif, const ip4_addr_t *ipaddr); 00120 /** For Ethernet network interfaces, we might want to send "gratuitous ARP"; 00121 * this is an ARP packet sent by a node in order to spontaneously cause other 00122 * nodes to update an entry in their ARP cache. 00123 * From RFC 3220 "IP Mobility Support for IPv4" section 4.6. */ 00124 #define etharp_gratuitous(netif) etharp_request((netif), netif_ip4_addr(netif)) 00125 void etharp_cleanup_netif(struct netif *netif); 00126 void etharp_ip_input(struct netif *netif, struct pbuf *p); 00127 00128 #if ETHARP_SUPPORT_STATIC_ENTRIES 00129 err_t etharp_add_static_entry(const ip4_addr_t *ipaddr, struct eth_addr *ethaddr); 00130 err_t etharp_remove_static_entry(const ip4_addr_t *ipaddr); 00131 #endif /* ETHARP_SUPPORT_STATIC_ENTRIES */ 00132 00133 #if LWIP_AUTOIP 00134 err_t etharp_raw(struct netif *netif, const struct eth_addr *ethsrc_addr, 00135 const struct eth_addr *ethdst_addr, 00136 const struct eth_addr *hwsrc_addr, const ip4_addr_t *ipsrc_addr, 00137 const struct eth_addr *hwdst_addr, const ip4_addr_t *ipdst_addr, 00138 const u16_t opcode); 00139 #endif /* LWIP_AUTOIP */ 00140 00141 #endif /* LWIP_IPV4 && LWIP_ARP */ 00142 00143 void etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr, struct pbuf *p); 00144 00145 #ifdef __cplusplus 00146 } 00147 #endif 00148 00149 #endif /* LWIP_ARP || LWIP_ETHERNET */ 00150 00151 #endif /* LWIP_HDR_NETIF_ETHARP_H */
Generated on Tue Jul 12 2022 18:19:29 by
1.7.2