sdk-core
v2026.11.05
PS2 SDK - core tier (build-critical EE/IOP modules)
Toggle main menu visibility
Loading...
Searching...
No Matches
ip.c
Go to the documentation of this file.
1
23
24
/*
25
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
26
* All rights reserved.
27
*
28
* Redistribution and use in source and binary forms, with or without modification,
29
* are permitted provided that the following conditions are met:
30
*
31
* 1. Redistributions of source code must retain the above copyright notice,
32
* this list of conditions and the following disclaimer.
33
* 2. Redistributions in binary form must reproduce the above copyright notice,
34
* this list of conditions and the following disclaimer in the documentation
35
* and/or other materials provided with the distribution.
36
* 3. The name of the author may not be used to endorse or promote products
37
* derived from this software without specific prior written permission.
38
*
39
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
40
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
41
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
42
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
43
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
44
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
45
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
46
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
47
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
48
* OF SUCH DAMAGE.
49
*
50
* This file is part of the lwIP TCP/IP stack.
51
*
52
* Author: Adam Dunkels <adam@sics.se>
53
*
54
*/
55
56
#include "
lwip/opt.h
"
57
58
#if LWIP_IPV4 || LWIP_IPV6
59
60
#include "
lwip/ip_addr.h
"
61
#include "
lwip/ip.h
"
62
64
struct
ip_globals
ip_data;
65
66
#if LWIP_IPV4 && LWIP_IPV6
67
68
const
ip_addr_t ip_addr_any_type = IPADDR_ANY_TYPE_INIT;
69
79
char
*ipaddr_ntoa(
const
ip_addr_t *addr)
80
{
81
if
(addr == NULL) {
82
return
NULL;
83
}
84
if
(IP_IS_V6(addr)) {
85
return
ip6addr_ntoa(ip_2_ip6(addr));
86
}
else
{
87
return
ip4addr_ntoa
(ip_2_ip4(addr));
88
}
89
}
90
101
char
*ipaddr_ntoa_r(
const
ip_addr_t *addr,
char
*buf,
int
buflen)
102
{
103
if
(addr == NULL) {
104
return
NULL;
105
}
106
if
(IP_IS_V6(addr)) {
107
return
ip6addr_ntoa_r(ip_2_ip6(addr), buf, buflen);
108
}
else
{
109
return
ip4addr_ntoa_r(ip_2_ip4(addr), buf, buflen);
110
}
111
}
112
122
int
123
ipaddr_aton(
const
char
*cp, ip_addr_t *addr)
124
{
125
if
(cp != NULL) {
126
const
char
*c;
127
for
(c = cp; *c != 0; c++) {
128
if
(*c ==
':'
) {
129
/* contains a colon: IPv6 address */
130
if
(addr) {
131
IP_SET_TYPE_VAL(*addr,
IPADDR_TYPE_V6
);
132
}
133
return
ip6addr_aton(cp, ip_2_ip6(addr));
134
}
else
if
(*c ==
'.'
) {
135
/* contains a dot: IPv4 address */
136
break
;
137
}
138
}
139
/* call ip4addr_aton as fallback or if IPv4 was found */
140
if
(addr) {
141
IP_SET_TYPE_VAL(*addr,
IPADDR_TYPE_V4
);
142
}
143
return
ip4addr_aton(cp, ip_2_ip4(addr));
144
}
145
return
0;
146
}
147
153
err_t
154
ip_input(
struct
pbuf
*p,
struct
netif
*inp)
155
{
156
if
(p != NULL) {
157
if
(
IP_HDR_GET_VERSION
(p->payload) == 6) {
158
return
ip6_input(p, inp);
159
}
160
return
ip4_input(p, inp);
161
}
162
return
ERR_VAL
;
163
}
164
165
#endif
/* LWIP_IPV4 && LWIP_IPV6 */
166
167
#endif
/* LWIP_IPV4 || LWIP_IPV6 */
ERR_VAL
@ ERR_VAL
Definition
err.h:67
IPADDR_TYPE_V6
@ IPADDR_TYPE_V6
Definition
tcpip.h:684
IPADDR_TYPE_V4
@ IPADDR_TYPE_V4
Definition
tcpip.h:682
ip.h
ip_addr.h
opt.h
IP_HDR_GET_VERSION
#define IP_HDR_GET_VERSION(ptr)
Definition
ip.h:54
ip4addr_ntoa
char * ip4addr_ntoa(const ip4_addr_t *addr)
ip_globals
Definition
ip.h:119
netif
Definition
tcpip.h:1271
pbuf
Definition
tcpip.h:234
core
ps2ip
src
lwip
core
ip.c
Generated by
1.18.0