sdk-core v2026.11.05
PS2 SDK - core tier (build-critical EE/IOP modules)
Loading...
Searching...
No Matches
inet.h
Go to the documentation of this file.
1
9
10/*
11 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
12 * All rights reserved.
13 *
14 * Redistribution and use in source and binary forms, with or without modification,
15 * are permitted provided that the following conditions are met:
16 *
17 * 1. Redistributions of source code must retain the above copyright notice,
18 * this list of conditions and the following disclaimer.
19 * 2. Redistributions in binary form must reproduce the above copyright notice,
20 * this list of conditions and the following disclaimer in the documentation
21 * and/or other materials provided with the distribution.
22 * 3. The name of the author may not be used to endorse or promote products
23 * derived from this software without specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
26 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
27 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
28 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
29 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
30 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
33 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
34 * OF SUCH DAMAGE.
35 *
36 * This file is part of the lwIP TCP/IP stack.
37 *
38 * Author: Adam Dunkels <adam@sics.se>
39 *
40 */
41#ifndef LWIP_HDR_INET_H
42#define LWIP_HDR_INET_H
43
44#include "lwip/opt.h"
45
46#if LWIP_SOCKET_EXTERNAL_HEADERS
47#include LWIP_SOCKET_EXTERNAL_HEADER_INET_H
48#else /* LWIP_SOCKET_EXTERNAL_HEADERS */
49
50#include "lwip/def.h"
51#include "lwip/ip_addr.h"
52#include "lwip/ip6_addr.h"
53
54#ifdef __cplusplus
55extern "C" {
56#endif
57
58/* If your port already typedef's in_addr_t, define IN_ADDR_T_DEFINED
59 to prevent this code from redefining it. */
60#if !defined(in_addr_t) && !defined(IN_ADDR_T_DEFINED)
61typedef u32_t in_addr_t;
62#endif
63
64struct in_addr {
65 in_addr_t s_addr;
66};
67
68struct in6_addr {
69 union {
70 u32_t u32_addr[4];
71 u8_t u8_addr[16];
72 } un;
73#define s6_addr un.u8_addr
74};
75
77#define INADDR_NONE IPADDR_NONE
79#define INADDR_LOOPBACK IPADDR_LOOPBACK
81#define INADDR_ANY IPADDR_ANY
83#define INADDR_BROADCAST IPADDR_BROADCAST
84
87#define IN6ADDR_ANY_INIT {{{0,0,0,0}}}
90#define IN6ADDR_LOOPBACK_INIT {{{0,0,0,PP_HTONL(1)}}}
92extern const struct in6_addr in6addr_any;
93
94/* Definitions of the bits in an (IPv4) Internet address integer.
95
96 On subnets, host and network parts are found according to
97 the subnet mask, not these masks. */
98#define IN_CLASSA(a) IP_CLASSA(a)
99#define IN_CLASSA_NET IP_CLASSA_NET
100#define IN_CLASSA_NSHIFT IP_CLASSA_NSHIFT
101#define IN_CLASSA_HOST IP_CLASSA_HOST
102#define IN_CLASSA_MAX IP_CLASSA_MAX
103
104#define IN_CLASSB(b) IP_CLASSB(b)
105#define IN_CLASSB_NET IP_CLASSB_NET
106#define IN_CLASSB_NSHIFT IP_CLASSB_NSHIFT
107#define IN_CLASSB_HOST IP_CLASSB_HOST
108#define IN_CLASSB_MAX IP_CLASSB_MAX
109
110#define IN_CLASSC(c) IP_CLASSC(c)
111#define IN_CLASSC_NET IP_CLASSC_NET
112#define IN_CLASSC_NSHIFT IP_CLASSC_NSHIFT
113#define IN_CLASSC_HOST IP_CLASSC_HOST
114#define IN_CLASSC_MAX IP_CLASSC_MAX
115
116#define IN_CLASSD(d) IP_CLASSD(d)
117#define IN_CLASSD_NET IP_CLASSD_NET /* These ones aren't really */
118#define IN_CLASSD_NSHIFT IP_CLASSD_NSHIFT /* net and host fields, but */
119#define IN_CLASSD_HOST IP_CLASSD_HOST /* routing needn't know. */
120#define IN_CLASSD_MAX IP_CLASSD_MAX
121
122#define IN_MULTICAST(a) IP_MULTICAST(a)
123
124#define IN_EXPERIMENTAL(a) IP_EXPERIMENTAL(a)
125#define IN_BADCLASS(a) IP_BADCLASS(a)
126
127#define IN_LOOPBACKNET IP_LOOPBACKNET
128
129#define IN6_IS_ADDR_UNSPECIFIED(a) ip6_addr_isany((ip6_addr_t*)(a))
130#define IN6_IS_ADDR_LOOPBACK(a) ip6_addr_isloopback((ip6_addr_t*)(a))
131#define IN6_IS_ADDR_MULTICAST(a) ip6_addr_ismulticast((ip6_addr_t*)(a))
132#define IN6_IS_ADDR_LINKLOCAL(a) ip6_addr_islinklocal((ip6_addr_t*)(a))
133#define IN6_IS_ADDR_SITELOCAL(a) ip6_addr_issitelocal((ip6_addr_t*)(a))
134#define IN6_IS_ADDR_V4MAPPED(a) ip6_addr_isipv4mappedipv6((ip6_addr_t*)(a))
135#define IN6_IS_ADDR_V4COMPAT(a) ip6_addr_isipv4compat((ip6_addr_t*)(a))
136#define IN6_IS_ADDR_MC_NODELOCAL(a) ip6_addr_ismulticast_iflocal((ip6_addr_t*)(a))
137#define IN6_IS_ADDR_MC_LINKLOCAL(a) ip6_addr_ismulticast_linklocal((ip6_addr_t*)(a))
138#define IN6_IS_ADDR_MC_SITELOCAL(a) ip6_addr_ismulticast_sitelocal((ip6_addr_t*)(a))
139#define IN6_IS_ADDR_MC_ORGLOCAL(a) ip6_addr_ismulticast_orglocal((ip6_addr_t*)(a))
140#define IN6_IS_ADDR_MC_GLOBAL(a) ip6_addr_ismulticast_global((ip6_addr_t*)(a))
141
142#ifndef INET_ADDRSTRLEN
143#define INET_ADDRSTRLEN IP4ADDR_STRLEN_MAX
144#endif
145#if LWIP_IPV6
146#ifndef INET6_ADDRSTRLEN
147#define INET6_ADDRSTRLEN IP6ADDR_STRLEN_MAX
148#endif
149#endif
150
151#if LWIP_IPV4
152
153#define inet_addr_from_ip4addr(target_inaddr, source_ipaddr) ((target_inaddr)->s_addr = ip4_addr_get_u32(source_ipaddr))
154#define inet_addr_to_ip4addr(target_ipaddr, source_inaddr) (ip4_addr_set_u32(target_ipaddr, (source_inaddr)->s_addr))
155
156/* directly map this to the lwip internal functions */
157#define inet_addr(cp) ipaddr_addr(cp)
158#define inet_aton(cp, addr) ip4addr_aton(cp, (ip4_addr_t*)addr)
159#define inet_ntoa(addr) ip4addr_ntoa((const ip4_addr_t*)&(addr))
160#define inet_ntoa_r(addr, buf, buflen) ip4addr_ntoa_r((const ip4_addr_t*)&(addr), buf, buflen)
161
162#endif /* LWIP_IPV4 */
163
164#if LWIP_IPV6
165#define inet6_addr_from_ip6addr(target_in6addr, source_ip6addr) {(target_in6addr)->un.u32_addr[0] = (source_ip6addr)->addr[0]; \
166 (target_in6addr)->un.u32_addr[1] = (source_ip6addr)->addr[1]; \
167 (target_in6addr)->un.u32_addr[2] = (source_ip6addr)->addr[2]; \
168 (target_in6addr)->un.u32_addr[3] = (source_ip6addr)->addr[3];}
169#define inet6_addr_to_ip6addr(target_ip6addr, source_in6addr) {(target_ip6addr)->addr[0] = (source_in6addr)->un.u32_addr[0]; \
170 (target_ip6addr)->addr[1] = (source_in6addr)->un.u32_addr[1]; \
171 (target_ip6addr)->addr[2] = (source_in6addr)->un.u32_addr[2]; \
172 (target_ip6addr)->addr[3] = (source_in6addr)->un.u32_addr[3]; \
173 ip6_addr_clear_zone(target_ip6addr);}
174
175/* directly map this to the lwip internal functions */
176#define inet6_aton(cp, addr) ip6addr_aton(cp, (ip6_addr_t*)addr)
177#define inet6_ntoa(addr) ip6addr_ntoa((const ip6_addr_t*)&(addr))
178#define inet6_ntoa_r(addr, buf, buflen) ip6addr_ntoa_r((const ip6_addr_t*)&(addr), buf, buflen)
179
180#endif /* LWIP_IPV6 */
181
182
183#ifdef __cplusplus
184}
185#endif
186
187#endif /* LWIP_SOCKET_EXTERNAL_HEADERS */
188
189#endif /* LWIP_HDR_INET_H */
const struct in6_addr in6addr_any