sdk-core v2026.11.05
PS2 SDK - core tier (build-critical EE/IOP modules)
Loading...
Searching...
No Matches
ps2ip.h
Go to the documentation of this file.
1/*
2# _____ ___ ____ ___ ____
3# ____| | ____| | | |____|
4# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5#-----------------------------------------------------------------------
6# Copyright (c) 2003 Marcus R. Brown <mrbrown@0xd6.org>
7# Licenced under Academic Free License version 2.0
8# Review ps2sdk README & LICENSE files for further details.
9*/
10
16
17#ifndef __PS2IP_H__
18#define __PS2IP_H__
19
20#ifndef LIBCGLUE_SYS_SOCKET_ALIASES
21#define LIBCGLUE_SYS_SOCKET_ALIASES 1
22#endif
23
24#include <tamtypes.h>
25#include <stddef.h>
26#include <sys/socket.h>
27#include <time.h>
28
29/* err_t (used by ps2ip_input's own real signature below) used to be
30 * reached transitively via <sys/socket.h> - fragile for an EXTERNAL
31 * consumer (anything outside this same sdk-core workspace, e.g. a
32 * plain CMake project globbing packages/core/*\/include
33 * alphabetically): whether <sys/socket.h> resolves to lwip's own real
34 * one (which reaches lwip/err.h) or libcglue's minimal one (which
35 * doesn't) depends on include-path search order, which such a
36 * consumer has no control over - found for real fixing ps2_drivers,
37 * whose own ps2_eeip_driver.c hit "unknown type name 'err_t'" here.
38 * Included directly instead - unambiguous regardless of resolution
39 * order, since this package's own include_dirs always exposes
40 * lwip_include (see package.yaml). */
41#include <lwip/err.h>
42
43#ifdef __cplusplus
44extern "C" {
45#endif
46
48extern int ps2ipInit(struct ip4_addr *ip_address, struct ip4_addr *subnet_mask, struct ip4_addr *gateway);
49extern void ps2ipDeinit(void);
50
51/* ps2ip_getconfig/ps2ip_setconfig: real, previously-missing
52 * declarations. Both are implemented in src/ps2ip.c and linked into
53 * libps2ip.a, but neither was ever re-declared here, so no consumer's
54 * #include <ps2ip.h> could actually see them (found for real:
55 * nettest's DHCP bring-up, unbuildable without this).
56 *
57 * t_ip_info itself is NOT redefined here - libcglue's ps2sdkapi.h
58 * already defines the one real, canonical t_ip_info behind a
59 * T_IP_INFO_DEFINED guard for exactly this "more than one header wants
60 * to supply it" situation (see its own comment). Guarding this copy
61 * the same way means whichever header a consumer reaches first wins,
62 * instead of a hard redefinition conflict - found for real rebuilding
63 * this package after first pasting an unconditional copy here, which
64 * broke ps2ip's own ps2ip_ps2sdk.c (reaches ps2sdkapi.h's copy first). */
65#ifndef T_IP_INFO_DEFINED
66#define T_IP_INFO_DEFINED
67typedef struct
68{
69 char netif_name[4];
70 struct in_addr ipaddr;
71 struct in_addr netmask;
72 struct in_addr gw;
73 u32 dhcp_enabled;
74 u32 dhcp_status;
75 u8 hw_addr[8];
76} t_ip_info;
77#endif
78
79extern int ps2ip_getconfig(char *pszName, t_ip_info *pInfo);
80extern int ps2ip_setconfig(const t_ip_info *pInfo);
81
82/* Real, ps2sdk-specific t_ip_info.dhcp_status values (not lwip's own -
83 * lwip 2.2.1's internal DHCP state machine isn't part of its public
84 * API at all). Used to live in the legacy common/include/tcpip.h -
85 * real, previously-latent gap for any consumer needing to interpret
86 * ps2ip_getconfig()'s own t_ip_info output, found for real fixing
87 * ps2_drivers's ps2_eeip_driver.c. */
88#ifndef DHCP_STATE_OFF
89#define DHCP_STATE_OFF 0
90#define DHCP_STATE_REQUESTING 1
91#define DHCP_STATE_INIT 2
92#define DHCP_STATE_REBOOTING 3
93#define DHCP_STATE_REBINDING 4
94#define DHCP_STATE_RENEWING 5
95#define DHCP_STATE_SELECTING 6
96#define DHCP_STATE_INFORMING 7
97#define DHCP_STATE_CHECKING 8
98#define DHCP_STATE_PERMANENT 9 /* not yet implemented */
99#define DHCP_STATE_BOUND 10
100#define DHCP_STATE_RELEASING 11 /* not yet implemented */
101#define DHCP_STATE_BACKING_OFF 12
102#endif
108extern void ps2ipSetHsyncTicksPerMSec(unsigned char ticks);
109
110extern err_t ps2ip_input(struct pbuf *p, struct netif *inp);
111
112/* etharp_output, tcpip_input, the netif_ functions, and the pbuf_
113 * functions used to be hand-copied forward declarations here (each
114 * with a "From include/lwip/X.h:"
115 * comment saying so) - a stand-in from whenever this header didn't
116 * itself pull in the real lwip headers. Removed 2026-09-03: once
117 * <sys/socket.h> (now on this header's own include chain - see
118 * ps2ip's package.yaml) transitively includes the real lwip/netif.h,
119 * lwip/pbuf.h, lwip/etharp.h and lwip/tcpip.h, these stand-ins
120 * conflict outright with the real declarations (some had drifted -
121 * e.g. this file's own pbuf_clen was typed "u8", lwip/pbuf.h's real
122 * one is "u16_t"). Found building sdk-world/aalib, the first real
123 * consumer to include this header far enough to hit them.
124 */
125
126#ifdef __cplusplus
127}
128#endif
129
130#endif /* __PS2IP_H__ */
int ps2ipInit(struct ip4_addr *ip_address, struct ip4_addr *subnet_mask, struct ip4_addr *gateway)
Definition ps2ip.c:321
void ps2ipSetHsyncTicksPerMSec(unsigned char ticks)
Definition ps2ip.c:356
Definition tcpip.h:234