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
inet.h
00001 /** 00002 * @file 00003 * This file (together with sockets.h) aims to provide structs and functions from 00004 * - arpa/inet.h 00005 * - netinet/in.h 00006 * 00007 */ 00008 00009 /* 00010 * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 00011 * All rights reserved. 00012 * 00013 * Redistribution and use in source and binary forms, with or without modification, 00014 * are permitted provided that the following conditions are met: 00015 * 00016 * 1. Redistributions of source code must retain the above copyright notice, 00017 * this list of conditions and the following disclaimer. 00018 * 2. Redistributions in binary form must reproduce the above copyright notice, 00019 * this list of conditions and the following disclaimer in the documentation 00020 * and/or other materials provided with the distribution. 00021 * 3. The name of the author may not be used to endorse or promote products 00022 * derived from this software without specific prior written permission. 00023 * 00024 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 00025 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00026 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 00027 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00028 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 00029 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00030 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00031 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 00032 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 00033 * OF SUCH DAMAGE. 00034 * 00035 * This file is part of the lwIP TCP/IP stack. 00036 * 00037 * Author: Adam Dunkels <adam@sics.se> 00038 * 00039 */ 00040 #ifndef LWIP_HDR_INET_H 00041 #define LWIP_HDR_INET_H 00042 00043 #include "lwip/opt.h" 00044 #include "lwip/def.h" 00045 #include "lwip/ip_addr.h" 00046 #include "lwip/ip6_addr.h" 00047 00048 #ifdef __cplusplus 00049 extern "C" { 00050 #endif 00051 00052 /* If your port already typedef's in_addr_t, define IN_ADDR_T_DEFINED 00053 to prevent this code from redefining it. */ 00054 #if !defined(in_addr_t) && !defined(IN_ADDR_T_DEFINED) 00055 typedef u32_t in_addr_t; 00056 #endif 00057 00058 struct in_addr { 00059 in_addr_t s_addr; 00060 }; 00061 00062 struct in6_addr { 00063 union { 00064 u32_t u32_addr[4]; 00065 u8_t u8_addr[16]; 00066 } un; 00067 #define s6_addr un.u8_addr 00068 }; 00069 00070 /** 255.255.255.255 */ 00071 #define INADDR_NONE IPADDR_NONE 00072 /** 127.0.0.1 */ 00073 #define INADDR_LOOPBACK IPADDR_LOOPBACK 00074 /** 0.0.0.0 */ 00075 #define INADDR_ANY IPADDR_ANY 00076 /** 255.255.255.255 */ 00077 #define INADDR_BROADCAST IPADDR_BROADCAST 00078 00079 /** This macro can be used to initialize a variable of type struct in6_addr 00080 to the IPv6 wildcard address. */ 00081 #define IN6ADDR_ANY_INIT {{{0,0,0,0}}} 00082 /** This macro can be used to initialize a variable of type struct in6_addr 00083 to the IPv6 loopback address. */ 00084 #define IN6ADDR_LOOPBACK_INIT {{{0,0,0,PP_HTONL(1)}}} 00085 /** This variable is initialized by the system to contain the wildcard IPv6 address. */ 00086 extern const struct in6_addr in6addr_any; 00087 00088 /* Definitions of the bits in an (IPv4) Internet address integer. 00089 00090 On subnets, host and network parts are found according to 00091 the subnet mask, not these masks. */ 00092 #define IN_CLASSA(a) IP_CLASSA(a) 00093 #define IN_CLASSA_NET IP_CLASSA_NET 00094 #define IN_CLASSA_NSHIFT IP_CLASSA_NSHIFT 00095 #define IN_CLASSA_HOST IP_CLASSA_HOST 00096 #define IN_CLASSA_MAX IP_CLASSA_MAX 00097 00098 #define IN_CLASSB(b) IP_CLASSB(b) 00099 #define IN_CLASSB_NET IP_CLASSB_NET 00100 #define IN_CLASSB_NSHIFT IP_CLASSB_NSHIFT 00101 #define IN_CLASSB_HOST IP_CLASSB_HOST 00102 #define IN_CLASSB_MAX IP_CLASSB_MAX 00103 00104 #define IN_CLASSC(c) IP_CLASSC(c) 00105 #define IN_CLASSC_NET IP_CLASSC_NET 00106 #define IN_CLASSC_NSHIFT IP_CLASSC_NSHIFT 00107 #define IN_CLASSC_HOST IP_CLASSC_HOST 00108 #define IN_CLASSC_MAX IP_CLASSC_MAX 00109 00110 #define IN_CLASSD(d) IP_CLASSD(d) 00111 #define IN_CLASSD_NET IP_CLASSD_NET /* These ones aren't really */ 00112 #define IN_CLASSD_NSHIFT IP_CLASSD_NSHIFT /* net and host fields, but */ 00113 #define IN_CLASSD_HOST IP_CLASSD_HOST /* routing needn't know. */ 00114 #define IN_CLASSD_MAX IP_CLASSD_MAX 00115 00116 #define IN_MULTICAST(a) IP_MULTICAST(a) 00117 00118 #define IN_EXPERIMENTAL(a) IP_EXPERIMENTAL(a) 00119 #define IN_BADCLASS(a) IP_BADCLASS(a) 00120 00121 #define IN_LOOPBACKNET IP_LOOPBACKNET 00122 00123 00124 #ifndef INET_ADDRSTRLEN 00125 #define INET_ADDRSTRLEN IP4ADDR_STRLEN_MAX 00126 #endif 00127 #if LWIP_IPV6 00128 #ifndef INET6_ADDRSTRLEN 00129 #define INET6_ADDRSTRLEN IP6ADDR_STRLEN_MAX 00130 #endif 00131 #endif 00132 00133 #if LWIP_IPV4 00134 00135 #define inet_addr_from_ip4addr(target_inaddr, source_ipaddr) ((target_inaddr)->s_addr = ip4_addr_get_u32(source_ipaddr)) 00136 #define inet_addr_to_ip4addr(target_ipaddr, source_inaddr) (ip4_addr_set_u32(target_ipaddr, (source_inaddr)->s_addr)) 00137 00138 /* directly map this to the lwip internal functions */ 00139 #define inet_addr(cp) ipaddr_addr(cp) 00140 #define inet_aton(cp, addr) ip4addr_aton(cp, (ip4_addr_t*)addr) 00141 #define inet_ntoa(addr) ip4addr_ntoa((const ip4_addr_t*)&(addr)) 00142 #define inet_ntoa_r(addr, buf, buflen) ip4addr_ntoa_r((const ip4_addr_t*)&(addr), buf, buflen) 00143 00144 #endif /* LWIP_IPV4 */ 00145 00146 #if LWIP_IPV6 00147 #define inet6_addr_from_ip6addr(target_in6addr, source_ip6addr) {(target_in6addr)->un.u32_addr[0] = (source_ip6addr)->addr[0]; \ 00148 (target_in6addr)->un.u32_addr[1] = (source_ip6addr)->addr[1]; \ 00149 (target_in6addr)->un.u32_addr[2] = (source_ip6addr)->addr[2]; \ 00150 (target_in6addr)->un.u32_addr[3] = (source_ip6addr)->addr[3];} 00151 #define inet6_addr_to_ip6addr(target_ip6addr, source_in6addr) {(target_ip6addr)->addr[0] = (source_in6addr)->un.u32_addr[0]; \ 00152 (target_ip6addr)->addr[1] = (source_in6addr)->un.u32_addr[1]; \ 00153 (target_ip6addr)->addr[2] = (source_in6addr)->un.u32_addr[2]; \ 00154 (target_ip6addr)->addr[3] = (source_in6addr)->un.u32_addr[3]; \ 00155 ip6_addr_clear_zone(target_ip6addr);} 00156 00157 /* directly map this to the lwip internal functions */ 00158 #define inet6_aton(cp, addr) ip6addr_aton(cp, (ip6_addr_t*)addr) 00159 #define inet6_ntoa(addr) ip6addr_ntoa((const ip6_addr_t*)&(addr)) 00160 #define inet6_ntoa_r(addr, buf, buflen) ip6addr_ntoa_r((const ip6_addr_t*)&(addr), buf, buflen) 00161 00162 #endif /* LWIP_IPV6 */ 00163 00164 00165 #ifdef __cplusplus 00166 } 00167 #endif 00168 00169 #endif /* LWIP_HDR_INET_H */
Generated on Tue Jul 12 2022 13:54:24 by
