PS2SDK
PS2 Homebrew Libraries
ps2ip_rpc.h
Go to the documentation of this file.
1 
7 #ifndef __PS2IP_RPC_H__
8 #define __PS2IP_RPC_H__
9 
10 #include <tamtypes.h>
11 #include <tcpip.h>
12 #include <sys/time.h>
13 
14 #define PS2IP_IRX 0xB0125F2
15 
16 enum PS2IPS_RPC_ID {
17  PS2IPS_ID_ACCEPT = 1,
18  PS2IPS_ID_BIND,
19  PS2IPS_ID_DISCONNECT,
20  PS2IPS_ID_CONNECT,
21  PS2IPS_ID_LISTEN,
22  PS2IPS_ID_RECV,
23  PS2IPS_ID_RECVFROM,
24  PS2IPS_ID_SEND,
25  PS2IPS_ID_SENDTO,
26  PS2IPS_ID_SOCKET,
27  PS2IPS_ID_SETCONFIG,
28  PS2IPS_ID_GETCONFIG,
29  PS2IPS_ID_SELECT,
30  PS2IPS_ID_IOCTL,
31  PS2IPS_ID_GETSOCKNAME,
32  PS2IPS_ID_GETPEERNAME,
33  PS2IPS_ID_GETSOCKOPT,
34  PS2IPS_ID_SETSOCKOPT,
35  PS2IPS_ID_GETHOSTBYNAME,
36 #ifdef PS2IP_DNS
37  /* Not implemented:
38  gethostbyname_r -> Redudant because it gets called over the RPC.
39  freeaddrinfo -> too complicated and probably nobody uses it?
40  getaddrinfo -> too complicated and probably nobody uses it? */
41 
42  PS2IPS_ID_DNS_SETSERVER,
43  PS2IPS_ID_DNS_GETSERVER,
44 #endif
45 
46  PS2IPS_ID_COUNT
47 };
48 
49 typedef struct
50 {
51  s32 domain;
52  s32 type;
53  s32 protocol;
54 } socket_pkt;
55 
56 typedef struct
57 {
58  s32 ssize;
59  s32 esize;
60  u8 *sbuf;
61  u8 *ebuf;
62  u8 sbuffer[64];
63  u8 ebuffer[64];
64 } rests_pkt;
65 
66 typedef struct
67 {
68  s32 socket;
69  s32 length;
70  s32 flags;
71  void *ee_addr;
72  struct sockaddr sockaddr; // sizeof = 16
73  s32 malign;
75  u8 malign_buff[64];
76 } send_pkt;
77 
78 typedef struct
79 {
80  s32 socket;
81  s32 length;
82  s32 flags;
83  void *ee_addr;
84  void *intr_data;
85 } s_recv_pkt;
86 
87 typedef struct
88 {
89  s32 ret;
90  struct sockaddr sockaddr;
91 } r_recv_pkt;
92 
93 typedef struct
94 {
95  s32 socket;
96  struct sockaddr sockaddr;
97  s32 len;
98 } cmd_pkt;
99 
100 typedef struct
101 {
102  s32 retval;
103  struct sockaddr sockaddr;
104 } ret_pkt;
105 
106 typedef struct
107 {
108  s32 s;
109  s32 backlog;
110 } listen_pkt;
111 
112 typedef struct
113 {
114  s32 s;
115  s32 level;
116  s32 optname;
118 
119 typedef struct
120 {
121  s32 result;
122  s32 optlen;
123  u8 buffer[128];
125 
126 typedef struct
127 {
128  s32 s;
129  s32 level;
130  s32 optname;
131  s32 optlen;
132  u8 buffer[128];
134 
135 /* On-the-wire fd_set for the select RPC. The struct fd_set seen on EE
136  * (newlib, ~128 bytes) and IOP (lwIP, MEMP_NUM_NETCONN/8 bytes) compile
137  * units differs in size, which used to scramble select_pkt's layout
138  * across the SIF RPC boundary — IOP would only touch the first few
139  * bytes of EE's wider readset and never see writeset/exceptset at the
140  * right offsets. Using a fixed-size struct here keeps select_pkt
141  * byte-identical on both sides regardless of which struct fd_set is
142  * in scope at the include site. */
143 typedef struct
144 {
145  unsigned char fd_bits[(MEMP_NUM_NETCONN + 7) / 8];
147 
148 /* struct timeval differs across the boundary too — newlib's tv_sec/tv_usec
149  * are 64-bit on EE while the IOP defines them as 32-bit longs. Carry
150  * explicit 32-bit fields here so the layout is byte-identical on both
151  * sides; each end reconstructs its native struct timeval. */
152 typedef struct
153 {
154  union
155  {
156  s32 maxfdp1;
157  s32 result;
158  };
159  void *timeout_p; /* opaque NULL/non-NULL flag */
160  s32 timeout_sec;
161  s32 timeout_usec;
162  void *readset_p; /* opaque: only NULL/non-NULL is meaningful across RPC */
163  void *writeset_p;
164  void *exceptset_p;
165  ps2ip_rpc_fd_set readset;
166  ps2ip_rpc_fd_set writeset;
167  ps2ip_rpc_fd_set exceptset;
168 } select_pkt;
169 
170 typedef struct
171 {
172  union
173  {
174  s32 s;
175  s32 result;
176  };
177  u32 cmd;
178  void *argp;
179  u32 value;
180 } ioctl_pkt;
181 
182 #ifdef PS2IP_DNS
183 struct hostent_res
184 {
185  s16 h_addrtype;
186  s16 h_length;
187  ip_addr_t h_addr;
188 };
189 
190 typedef struct
191 {
192  s32 result;
193  struct hostent_res hostent;
194 } gethostbyname_res_pkt;
195 
196 typedef struct
197 {
198  ip_addr_t dnsserver;
199  u8 numdns;
200 } dns_setserver_pkt;
201 
202 typedef struct
203 {
204  ip_addr_t dnsserver;
205 } dns_getserver_res_pkt;
206 
207 #endif
208 
209 #endif /* __PS2IP_RPC_H__ */
r_recv_pkt
Definition: ps2ip_rpc.h:87
setsockopt_pkt
Definition: ps2ip_rpc.h:126
tcpip.h
getsockopt_pkt
Definition: ps2ip_rpc.h:112
cmd_pkt
Definition: ps2ip_rpc.h:93
socket_pkt
Definition: ps2ip_rpc.h:49
s_recv_pkt
Definition: ps2ip_rpc.h:78
select_pkt
Definition: ps2ip_rpc.h:152
rests_pkt
Definition: fileXio.h:69
send_pkt
Definition: ps2ip_rpc.h:66
time.h
ip4_addr
Definition: tcpip.h:266
tamtypes.h
ret_pkt
Definition: ps2ip_rpc.h:100
hostent
Definition: tcpip.h:1940
getsockopt_res_pkt
Definition: ps2ip_rpc.h:119
ps2ip_rpc_fd_set
Definition: ps2ip_rpc.h:143
ioctl_pkt
Definition: ps2ip_rpc.h:170
listen_pkt
Definition: ps2ip_rpc.h:106
sockaddr
Definition: tcpip.h:1562