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.
Dependents: TYBLE16_simple_data_logger TYBLE16_MP3_Air
etharp.h
00001 /** 00002 * @file 00003 * ARP protocol definitions 00004 */ 00005 00006 /* 00007 * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 00008 * All rights reserved. 00009 * 00010 * Redistribution and use in source and binary forms, with or without modification, 00011 * are permitted provided that the following conditions are met: 00012 * 00013 * 1. Redistributions of source code must retain the above copyright notice, 00014 * this list of conditions and the following disclaimer. 00015 * 2. Redistributions in binary form must reproduce the above copyright notice, 00016 * this list of conditions and the following disclaimer in the documentation 00017 * and/or other materials provided with the distribution. 00018 * 3. The name of the author may not be used to endorse or promote products 00019 * derived from this software without specific prior written permission. 00020 * 00021 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 00022 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00023 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 00024 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00025 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 00026 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00027 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00028 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 00029 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 00030 * OF SUCH DAMAGE. 00031 * 00032 * This file is part of the lwIP TCP/IP stack. 00033 * 00034 * Author: Adam Dunkels <adam@sics.se> 00035 * 00036 */ 00037 #ifndef LWIP_HDR_PROT_ETHARP_H 00038 #define LWIP_HDR_PROT_ETHARP_H 00039 00040 #include "lwip/arch.h" 00041 #include "lwip/prot/ethernet.h" 00042 00043 #ifdef __cplusplus 00044 extern "C" { 00045 #endif 00046 00047 #ifndef ETHARP_HWADDR_LEN 00048 #define ETHARP_HWADDR_LEN ETH_HWADDR_LEN 00049 #endif 00050 00051 /** 00052 * struct ip4_addr_wordaligned is used in the definition of the ARP packet format in 00053 * order to support compilers that don't have structure packing. 00054 */ 00055 #ifdef PACK_STRUCT_USE_INCLUDES 00056 # include "arch/bpstruct.h" 00057 #endif 00058 PACK_STRUCT_BEGIN 00059 struct ip4_addr_wordaligned { 00060 PACK_STRUCT_FIELD(u16_t addrw[2]); 00061 } PACK_STRUCT_STRUCT; 00062 PACK_STRUCT_END 00063 #ifdef PACK_STRUCT_USE_INCLUDES 00064 # include "arch/epstruct.h" 00065 #endif 00066 00067 /** MEMCPY-like copying of IP addresses where addresses are known to be 00068 * 16-bit-aligned if the port is correctly configured (so a port could define 00069 * this to copying 2 u16_t's) - no NULL-pointer-checking needed. */ 00070 #ifndef IPADDR_WORDALIGNED_COPY_TO_IP4_ADDR_T 00071 #define IPADDR_WORDALIGNED_COPY_TO_IP4_ADDR_T(dest, src) SMEMCPY(dest, src, sizeof(ip4_addr_t)) 00072 #endif 00073 00074 /** MEMCPY-like copying of IP addresses where addresses are known to be 00075 * 16-bit-aligned if the port is correctly configured (so a port could define 00076 * this to copying 2 u16_t's) - no NULL-pointer-checking needed. */ 00077 #ifndef IPADDR_WORDALIGNED_COPY_FROM_IP4_ADDR_T 00078 #define IPADDR_WORDALIGNED_COPY_FROM_IP4_ADDR_T(dest, src) SMEMCPY(dest, src, sizeof(ip4_addr_t)) 00079 #endif 00080 00081 #ifdef PACK_STRUCT_USE_INCLUDES 00082 # include "arch/bpstruct.h" 00083 #endif 00084 PACK_STRUCT_BEGIN 00085 /** the ARP message, see RFC 826 ("Packet format") */ 00086 struct etharp_hdr { 00087 PACK_STRUCT_FIELD(u16_t hwtype); 00088 PACK_STRUCT_FIELD(u16_t proto); 00089 PACK_STRUCT_FLD_8(u8_t hwlen); 00090 PACK_STRUCT_FLD_8(u8_t protolen); 00091 PACK_STRUCT_FIELD(u16_t opcode); 00092 PACK_STRUCT_FLD_S(struct eth_addr shwaddr); 00093 PACK_STRUCT_FLD_S(struct ip4_addr_wordaligned sipaddr); 00094 PACK_STRUCT_FLD_S(struct eth_addr dhwaddr); 00095 PACK_STRUCT_FLD_S(struct ip4_addr_wordaligned dipaddr); 00096 } PACK_STRUCT_STRUCT; 00097 PACK_STRUCT_END 00098 #ifdef PACK_STRUCT_USE_INCLUDES 00099 # include "arch/epstruct.h" 00100 #endif 00101 00102 #define SIZEOF_ETHARP_HDR 28 00103 00104 /* ARP message types (opcodes) */ 00105 enum etharp_opcode { 00106 ARP_REQUEST = 1, 00107 ARP_REPLY = 2 00108 }; 00109 00110 #ifdef __cplusplus 00111 } 00112 #endif 00113 00114 #endif /* LWIP_HDR_PROT_ETHARP_H */
Generated on Tue Jul 12 2022 13:54:18 by
