11#define LIBCGLUE_SYS_SOCKET_NO_ALIASES
12#define LIBCGLUE_ARPA_INET_NO_ALIASES
21extern void __ps2ipcOpsInitializeImpl(
void);
24static void __ps2ipcOpsInitialize(
void)
26 __ps2ipcOpsInitializeImpl();
33 iop_fd = ps2ipc_socket(domain, type, protocol);
38 info->userdata = (
void *)(uiptr)(u32)iop_fd;
39 info->ops = &__ps2ipc_fdman_ops_socket;
43int __ps2ipcGetFdHelper(
void *userdata)
45 return (
int)(u32)(uiptr)userdata;
48int __ps2ipcFcntlfsetflHelper(
void *userdata,
int newfl)
53 fd = __ps2ipcGetFdHelper(userdata);
60 val = (newfl & O_NONBLOCK) ? 1 : 0;
61 res = ps2ipc_ioctl(fd, FIONBIO, &val);
73 fd = __ps2ipcGetFdHelper(userdata);
80 new_fd = ps2ipc_accept(fd, addr, addrlen);
85 info->userdata = (
void *)(uiptr)(u32)new_fd;
86 info->ops = &__ps2ipc_fdman_ops_socket;
90int __ps2ipcBindHelper(
void *userdata,
const struct sockaddr *name,
int namelen)
94 fd = __ps2ipcGetFdHelper(userdata);
101 res = ps2ipc_bind(fd, name, namelen);
109int __ps2ipcCloseHelper(
void *userdata)
113 fd = __ps2ipcGetFdHelper(userdata);
120 res = ps2ipc_disconnect(fd);
128int __ps2ipcConnectHelper(
void *userdata,
const struct sockaddr *name,
int namelen)
132 fd = __ps2ipcGetFdHelper(userdata);
139 res = ps2ipc_connect(fd, name, namelen);
147int __ps2ipcListenHelper(
void *userdata,
int backlog)
151 fd = __ps2ipcGetFdHelper(userdata);
158 res = ps2ipc_listen(fd, backlog);
166int __ps2ipcRecvHelper(
void *userdata,
void *mem,
size_t len,
int flags)
170 fd = __ps2ipcGetFdHelper(userdata);
177 res = ps2ipc_recv(fd, mem, len, flags);
185int __ps2ipcRecvfromHelper(
void *userdata,
void *mem,
size_t len,
int flags,
struct sockaddr *from,
int *fromlen)
189 fd = __ps2ipcGetFdHelper(userdata);
196 res = ps2ipc_recvfrom(fd, mem, len, flags, from, fromlen);
204int __ps2ipcRecvmsgHelper(
void *userdata,
struct msghdr *msg,
int flags)
210int __ps2ipcSendHelper(
void *userdata,
const void *dataptr,
size_t len,
int flags)
214 fd = __ps2ipcGetFdHelper(userdata);
221 res = ps2ipc_send(fd, dataptr, len, flags);
229int __ps2ipcSendtoHelper(
void *userdata,
const void *dataptr,
size_t len,
int flags,
const struct sockaddr *to,
int tolen)
233 fd = __ps2ipcGetFdHelper(userdata);
240 res = ps2ipc_sendto(fd, dataptr, len, flags, to, tolen);
248int __ps2ipcSendmsgHelper(
void *userdata,
const struct msghdr *msg,
int flags) {
254int __ps2ipcIoctlHelper(
void *userdata,
int cmd,
void *argp)
258 fd = __ps2ipcGetFdHelper(userdata);
265 res = ps2ipc_ioctl(fd, cmd, argp);
273int __ps2ipcGetsocknameHelper(
void *userdata,
struct sockaddr* name,
int* namelen)
277 fd = __ps2ipcGetFdHelper(userdata);
284 res = ps2ipc_getsockname(fd, name, namelen);
292int __ps2ipcGetpeernameHelper(
void *userdata,
struct sockaddr *name,
int *namelen)
296 fd = __ps2ipcGetFdHelper(userdata);
303 res = ps2ipc_getpeername(fd, name, namelen);
311int __ps2ipcGetsockoptHelper(
void *userdata,
int level,
int optname,
void* optval, socklen_t* optlen)
315 fd = __ps2ipcGetFdHelper(userdata);
322 res = ps2ipc_getsockopt(fd, level, optname, optval, optlen);
330int __ps2ipcSetsockoptHelper(
void *userdata,
int level,
int optname,
const void *optval, socklen_t optlen)
334 fd = __ps2ipcGetFdHelper(userdata);
341 res = ps2ipc_setsockopt(fd, level, optname, optval, optlen);
349struct hostent *ps2ipc_gethostbyaddr(
const void *addr,
int len,
int type) {
354void __ps2ipcOpsInitializeImpl(
void)
356 memset(&__ps2ipc_fdman_socket_ops, 0,
sizeof(__ps2ipc_fdman_socket_ops));
357 __ps2ipc_fdman_socket_ops.setconfig = ps2ipc_ps2ip_setconfig;
358 __ps2ipc_fdman_socket_ops.getconfig = ps2ipc_ps2ip_getconfig;
359 __ps2ipc_fdman_socket_ops.dns_setserver = ps2ipc_dns_setserver;
360 __ps2ipc_fdman_socket_ops.dns_getserver = ps2ipc_dns_getserver;
361 __ps2ipc_fdman_socket_ops.socket = __ps2ipcSocketHelper;
362 __ps2ipc_fdman_socket_ops.select = ps2ipc_select;
363 __ps2ipc_fdman_socket_ops.gethostbyaddr = ps2ipc_gethostbyaddr;
364 __ps2ipc_fdman_socket_ops.gethostbyname = ps2ipc_gethostbyname;
366 memset(&__ps2ipc_fdman_ops_socket, 0,
sizeof(__ps2ipc_fdman_ops_socket));
367 __ps2ipc_fdman_ops_socket.getfd = __ps2ipcGetFdHelper;
368 __ps2ipc_fdman_ops_socket.fcntl_f_setfl = __ps2ipcFcntlfsetflHelper;
369 __ps2ipc_fdman_ops_socket.accept = __ps2ipcAcceptHelper;
370 __ps2ipc_fdman_ops_socket.bind = __ps2ipcBindHelper;
371 __ps2ipc_fdman_ops_socket.close = __ps2ipcCloseHelper;
372 __ps2ipc_fdman_ops_socket.connect = __ps2ipcConnectHelper;
373 __ps2ipc_fdman_ops_socket.listen = __ps2ipcListenHelper;
374 __ps2ipc_fdman_ops_socket.recv = __ps2ipcRecvHelper;
375 __ps2ipc_fdman_ops_socket.recvfrom = __ps2ipcRecvfromHelper;
376 __ps2ipc_fdman_ops_socket.recvmsg = __ps2ipcRecvmsgHelper;
377 __ps2ipc_fdman_ops_socket.send = __ps2ipcSendHelper;
378 __ps2ipc_fdman_ops_socket.sendto = __ps2ipcSendtoHelper;
379 __ps2ipc_fdman_ops_socket.sendmsg = __ps2ipcSendmsgHelper;
380 __ps2ipc_fdman_ops_socket.ioctl = __ps2ipcIoctlHelper;
381 __ps2ipc_fdman_ops_socket.getsockname = __ps2ipcGetsocknameHelper;
382 __ps2ipc_fdman_ops_socket.getpeername = __ps2ipcGetpeernameHelper;
383 __ps2ipc_fdman_ops_socket.getsockopt = __ps2ipcGetsockoptHelper;
384 __ps2ipc_fdman_ops_socket.setsockopt = __ps2ipcSetsockoptHelper;
390void _ps2sdk_ps2ipc_init()
392 _backup_libcglue_fdman_socket_ops = _libcglue_fdman_socket_ops;
393 _libcglue_fdman_socket_ops = &__ps2ipc_fdman_socket_ops;
396void _ps2sdk_ps2ipc_deinit()
398 _libcglue_fdman_socket_ops = _backup_libcglue_fdman_socket_ops;