sdk-core
v2026.11.05
PS2 SDK - core tier (build-critical EE/IOP modules)
Toggle main menu visibility
Loading...
Searching...
No Matches
ps2ip_rpc.h
Go to the documentation of this file.
1
7
8
#ifndef __PS2IP_RPC_H__
9
#define __PS2IP_RPC_H__
10
11
#include <
tamtypes.h
>
12
/* sys/socket.h is libcglue's own POSIX-named header - EE-only, doesn't
13
* exist for an IOP build at all (no libcglue there). The one real IOP
14
* consumer of this file (core/ps2ips-iop's ps2ips.c) always includes
15
* <ps2ip.h> first, which already includes the real, still-present
16
* common/tcpip.h (see ps2ip.h's own comment - never actually deleted,
17
* just no longer auto-included from libcglue) and so already provides
18
* struct sockaddr/socklen_t/etc by the time this header is reached -
19
* this include is both unavailable and unnecessary for _IOP. */
20
#ifndef _IOP
21
#include <sys/socket.h>
22
#endif
23
#include <
sys/time.h
>
24
25
/* Used to be a blanket #include <tcpip.h> - see libcglue's own
26
* sys/socket.h for the full story on why that header is real,
27
* pre-lwip-migration technical debt that conflicts with ps2ip's real
28
* lwip headers. struct sockaddr/sa_family_t/socklen_t now come from
29
* <sys/socket.h> above (byte-identical layout to what tcpip.h used to
30
* provide, verified for real against tcpip.h's own struct sockaddr).
31
*
32
* ip4_addr_t/ip_addr_t need a real, COMPLETE definition here (embedded
33
* by value in the RPC packet structs below, not just a pointer) -
34
* matches lwip's own real struct ip4_addr { u32_t addr; } exactly, and
35
* is a safe re-declaration if lwip's own header is ever also reached
36
* in the same TU (same real tag name, same real single-field layout). */
37
#ifndef LWIP_HDR_IP4_ADDR_H
38
struct
ip4_addr
{
39
u32 addr;
40
};
41
typedef
struct
ip4_addr
ip4_addr_t
;
42
typedef
struct
ip4_addr
ip_addr_t;
43
#endif
44
45
/* MEMP_NUM_NETCONN: the real wire size of ps2ip_rpc_fd_set below
46
* depends on this exactly matching whatever lwip was actually built
47
* with - real config lives in ps2ip's own lwipopts.h (currently the
48
* plain lwip default, unoverridden: MEMP_NUM_TCP_PCB=5,
49
* MEMP_NUM_UDP_PCB=4, verified against lwip/opt.h directly). Guarded,
50
* not hardcoded unconditionally, so an already-active real lwip config
51
* in this TU always wins over this fallback default. */
52
#ifndef MEMP_NUM_UDP_PCB
53
#define MEMP_NUM_UDP_PCB 4
54
#endif
55
#ifndef MEMP_NUM_TCP_PCB
56
#define MEMP_NUM_TCP_PCB 5
57
#endif
58
#ifndef MEMP_NUM_NETCONN
59
#define MEMP_NUM_NETCONN (MEMP_NUM_TCP_PCB + MEMP_NUM_UDP_PCB)
60
#endif
61
62
#define PS2IP_IRX 0xB0125F2
63
64
enum
PS2IPS_RPC_ID {
65
PS2IPS_ID_ACCEPT = 1,
66
PS2IPS_ID_BIND,
67
PS2IPS_ID_DISCONNECT,
68
PS2IPS_ID_CONNECT,
69
PS2IPS_ID_LISTEN,
70
PS2IPS_ID_RECV,
71
PS2IPS_ID_RECVFROM,
72
PS2IPS_ID_SEND,
73
PS2IPS_ID_SENDTO,
74
PS2IPS_ID_SOCKET,
75
PS2IPS_ID_SETCONFIG,
76
PS2IPS_ID_GETCONFIG,
77
PS2IPS_ID_SELECT,
78
PS2IPS_ID_IOCTL,
79
PS2IPS_ID_GETSOCKNAME,
80
PS2IPS_ID_GETPEERNAME,
81
PS2IPS_ID_GETSOCKOPT,
82
PS2IPS_ID_SETSOCKOPT,
83
PS2IPS_ID_GETHOSTBYNAME,
84
#ifdef PS2IP_DNS
85
/* Not implemented:
86
gethostbyname_r -> Redudant because it gets called over the RPC.
87
freeaddrinfo -> too complicated and probably nobody uses it?
88
getaddrinfo -> too complicated and probably nobody uses it? */
89
90
PS2IPS_ID_DNS_SETSERVER,
91
PS2IPS_ID_DNS_GETSERVER,
92
#endif
93
94
PS2IPS_ID_COUNT
95
};
96
97
typedef
struct
98
{
99
s32 domain;
100
s32 type;
101
s32 protocol;
102
}
socket_pkt
;
103
104
typedef
struct
105
{
106
s32 ssize;
107
s32 esize;
108
u8 *sbuf;
109
u8 *ebuf;
110
u8 sbuffer[64];
111
u8 ebuffer[64];
112
}
rests_pkt
;
113
114
typedef
struct
115
{
116
s32 socket;
117
s32 length;
118
s32 flags;
119
void
*ee_addr;
120
struct
sockaddr sockaddr;
// sizeof = 16
121
s32 malign;
123
u8
malign_buff
[64];
124
}
send_pkt
;
125
126
typedef
struct
127
{
128
s32 socket;
129
s32 length;
130
s32 flags;
131
void
*ee_addr;
132
void
*intr_data;
133
}
s_recv_pkt
;
134
135
typedef
struct
136
{
137
s32 ret;
138
struct
sockaddr sockaddr;
139
}
r_recv_pkt
;
140
141
typedef
struct
142
{
143
s32 socket;
144
struct
sockaddr sockaddr;
145
s32 len;
146
}
cmd_pkt
;
147
148
typedef
struct
149
{
150
s32 retval;
151
struct
sockaddr sockaddr;
152
}
ret_pkt
;
153
154
typedef
struct
155
{
156
s32 s;
157
s32 backlog;
158
}
listen_pkt
;
159
160
typedef
struct
161
{
162
s32 s;
163
s32 level;
164
s32 optname;
165
}
getsockopt_pkt
;
166
167
typedef
struct
168
{
169
s32 result;
170
s32 optlen;
171
u8 buffer[128];
172
}
getsockopt_res_pkt
;
173
174
typedef
struct
175
{
176
s32 s;
177
s32 level;
178
s32 optname;
179
s32 optlen;
180
u8 buffer[128];
181
}
setsockopt_pkt
;
182
183
/* On-the-wire fd_set for the select RPC. The struct fd_set seen on EE
184
* (newlib, ~128 bytes) and IOP (lwIP, MEMP_NUM_NETCONN/8 bytes) compile
185
* units differs in size, which used to scramble select_pkt's layout
186
* across the SIF RPC boundary — IOP would only touch the first few
187
* bytes of EE's wider readset and never see writeset/exceptset at the
188
* right offsets. Using a fixed-size struct here keeps select_pkt
189
* byte-identical on both sides regardless of which struct fd_set is
190
* in scope at the include site. */
191
typedef
struct
192
{
193
unsigned
char
fd_bits[(MEMP_NUM_NETCONN + 7) / 8];
194
}
ps2ip_rpc_fd_set
;
195
196
/* struct timeval differs across the boundary too — newlib's tv_sec/tv_usec
197
* are 64-bit on EE while the IOP defines them as 32-bit longs. Carry
198
* explicit 32-bit fields here so the layout is byte-identical on both
199
* sides; each end reconstructs its native struct timeval. */
200
typedef
struct
201
{
202
union
203
{
204
s32 maxfdp1;
205
s32 result;
206
};
207
void
*timeout_p;
/* opaque NULL/non-NULL flag */
208
s32 timeout_sec;
209
s32 timeout_usec;
210
void
*readset_p;
/* opaque: only NULL/non-NULL is meaningful across RPC */
211
void
*writeset_p;
212
void
*exceptset_p;
213
ps2ip_rpc_fd_set
readset;
214
ps2ip_rpc_fd_set
writeset;
215
ps2ip_rpc_fd_set
exceptset;
216
}
select_pkt
;
217
218
typedef
struct
219
{
220
union
221
{
222
s32 s;
223
s32 result;
224
};
225
u32 cmd;
226
void
*argp;
227
u32 value;
228
}
ioctl_pkt
;
229
230
#ifdef PS2IP_DNS
231
struct
hostent_res
232
{
233
s16 h_addrtype;
234
s16 h_length;
235
ip_addr_t h_addr;
236
};
237
238
typedef
struct
239
{
240
s32 result;
241
struct
hostent_res
hostent
;
242
} gethostbyname_res_pkt;
243
244
typedef
struct
245
{
246
ip_addr_t dnsserver;
247
u8 numdns;
248
} dns_setserver_pkt;
249
250
typedef
struct
251
{
252
ip_addr_t dnsserver;
253
} dns_getserver_res_pkt;
254
255
#endif
256
257
#endif
/* __PS2IP_RPC_H__ */
ip4_addr_t
struct ip4_addr ip4_addr_t
Definition
ps2ip_rpc.h:41
cmd_pkt
Definition
ps2ip_rpc.h:142
getsockopt_pkt
Definition
ps2ip_rpc.h:161
getsockopt_res_pkt
Definition
ps2ip_rpc.h:168
hostent
Definition
tcpip.h:1949
ioctl_pkt
Definition
ps2ip_rpc.h:219
ip4_addr
Definition
ps2ip_rpc.h:38
listen_pkt
Definition
ps2ip_rpc.h:155
ps2ip_rpc_fd_set
Definition
ps2ip_rpc.h:192
r_recv_pkt
Definition
ps2ip_rpc.h:136
rests_pkt
Definition
fileXio.h:71
ret_pkt
Definition
ps2ip_rpc.h:149
s_recv_pkt
Definition
ps2ip_rpc.h:127
select_pkt
Definition
ps2ip_rpc.h:201
send_pkt
Definition
ps2ip_rpc.h:115
send_pkt::malign_buff
u8 malign_buff[64]
Definition
ps2ip_rpc.h:123
setsockopt_pkt
Definition
ps2ip_rpc.h:175
socket_pkt
Definition
ps2ip_rpc.h:98
tamtypes.h
time.h
core
common
include
ps2ip_rpc.h
Generated by
1.18.0