11#define LIBCGLUE_SYS_SOCKET_NO_ALIASES
12#define LIBCGLUE_ARPA_INET_NO_ALIASES
22extern void __ps2ipeeOpsInitializeImpl(
void);
25static void __ps2ipeeOpsInitialize(
void)
27 __ps2ipeeOpsInitializeImpl();
34 iop_fd = lwip_socket(domain, type, protocol);
39 info->userdata = (
void *)(uiptr)(u32)iop_fd;
40 info->ops = &__ps2ipee_fdman_ops_socket;
44int __ps2ipeeGetFdHelper(
void *userdata)
46 return (
int)(u32)(uiptr)userdata;
49int __ps2ipeeFcntlfsetflHelper(
void *userdata,
int newfl)
54 fd = __ps2ipeeGetFdHelper(userdata);
61 val = (newfl & O_NONBLOCK) ? 1 : 0;
62 res = lwip_ioctl(fd, FIONBIO, &val);
74 fd = __ps2ipeeGetFdHelper(userdata);
81 new_fd = lwip_accept(fd, addr, addrlen);
86 info->userdata = (
void *)(uiptr)(u32)new_fd;
87 info->ops = &__ps2ipee_fdman_ops_socket;
91int __ps2ipeeBindHelper(
void *userdata,
const struct sockaddr *name,
int namelen)
95 fd = __ps2ipeeGetFdHelper(userdata);
102 res = lwip_bind(fd, name, namelen);
110int __ps2ipeeCloseHelper(
void *userdata)
114 fd = __ps2ipeeGetFdHelper(userdata);
121 res = lwip_close(fd);
129int __ps2ipeeConnectHelper(
void *userdata,
const struct sockaddr *name,
int namelen)
133 fd = __ps2ipeeGetFdHelper(userdata);
140 res = lwip_connect(fd, name, namelen);
148int __ps2ipeeListenHelper(
void *userdata,
int backlog)
152 fd = __ps2ipeeGetFdHelper(userdata);
159 res = lwip_listen(fd, backlog);
167int __ps2ipeeRecvHelper(
void *userdata,
void *mem,
size_t len,
int flags)
171 fd = __ps2ipeeGetFdHelper(userdata);
178 res = lwip_recv(fd, mem, len, flags);
186int __ps2ipeeRecvfromHelper(
void *userdata,
void *mem,
size_t len,
int flags,
struct sockaddr *from,
int *fromlen)
190 fd = __ps2ipeeGetFdHelper(userdata);
197 res = lwip_recvfrom(fd, mem, len, flags, from, fromlen);
205int __ps2ipeeRecvmsgHelper(
void *userdata,
struct msghdr *msg,
int flags)
211int __ps2ipeeSendHelper(
void *userdata,
const void *dataptr,
size_t size,
int flags)
215 fd = __ps2ipeeGetFdHelper(userdata);
222 res = lwip_send(fd, dataptr, size, flags);
230int __ps2ipeeSendtoHelper(
void *userdata,
const void *dataptr,
size_t size,
int flags,
const struct sockaddr *to,
int tolen)
234 fd = __ps2ipeeGetFdHelper(userdata);
241 res = lwip_sendto(fd, dataptr, size, flags, to, tolen);
249int __ps2ipeeSendmsgHelper(
void *userdata,
const struct msghdr *msg,
int flags) {
254int __ps2ipeeIoctlHelper(
void *userdata,
int cmd,
void *argp)
258 fd = __ps2ipeeGetFdHelper(userdata);
265 res = lwip_ioctl(fd, cmd, argp);
273int __ps2ipeeGetsocknameHelper(
void *userdata,
struct sockaddr* name,
int* namelen)
277 fd = __ps2ipeeGetFdHelper(userdata);
284 res = lwip_getsockname(fd, name, namelen);
292int __ps2ipeeGetpeernameHelper(
void *userdata,
struct sockaddr *name,
int *namelen)
296 fd = __ps2ipeeGetFdHelper(userdata);
303 res = lwip_getpeername(fd, name, namelen);
311int __ps2ipeeGetsockoptHelper(
void *userdata,
int level,
int optname,
void* optval, socklen_t* optlen)
315 fd = __ps2ipeeGetFdHelper(userdata);
322 res = lwip_getsockopt(fd, level, optname, optval, optlen);
330int __ps2ipeeSetsockoptHelper(
void *userdata,
int level,
int optname,
const void *optval, socklen_t optlen)
334 fd = __ps2ipeeGetFdHelper(userdata);
341 res = lwip_setsockopt(fd, level, optname, optval, optlen);
349int __ps2ipeeShutdownHelper(
void *userdata,
int how)
353 fd = __ps2ipeeGetFdHelper(userdata);
360 res = lwip_shutdown(fd, how);
368int __ps2ipeeReadHelper(
void *userdata,
void *mem,
int len)
372 fd = __ps2ipeeGetFdHelper(userdata);
379 res = lwip_read(fd, mem, len);
387int __ps2ipeeWriteHelper(
void *userdata,
const void *mem,
int len)
391 fd = __ps2ipeeGetFdHelper(userdata);
398 res = lwip_write(fd, mem, len);
406struct hostent *ps2ip_gethostbyaddr(
const void *addr,
int len,
int type) {
412void __ps2ipeeOpsInitializeImpl(
void)
414 memset(&__ps2ipee_fdman_socket_ops, 0,
sizeof(__ps2ipee_fdman_socket_ops));
415 __ps2ipee_fdman_socket_ops.setconfig = ps2ip_setconfig;
416 __ps2ipee_fdman_socket_ops.getconfig = ps2ip_getconfig;
417 __ps2ipee_fdman_socket_ops.dns_setserver = dns_setserver;
418 __ps2ipee_fdman_socket_ops.dns_getserver = dns_getserver;
419 __ps2ipee_fdman_socket_ops.socket = __ps2ipeeSocketHelper;
420 __ps2ipee_fdman_socket_ops.select = lwip_select;
421 __ps2ipee_fdman_socket_ops.gethostbyaddr = ps2ip_gethostbyaddr;
422 __ps2ipee_fdman_socket_ops.gethostbyname = lwip_gethostbyname;
423 __ps2ipee_fdman_socket_ops.gethostbyname_r = lwip_gethostbyname_r;
424 __ps2ipee_fdman_socket_ops.freeaddrinfo = lwip_freeaddrinfo;
425 __ps2ipee_fdman_socket_ops.getaddrinfo = lwip_getaddrinfo;
427 memset(&__ps2ipee_fdman_inet_ops, 0,
sizeof(__ps2ipee_fdman_inet_ops));
428 __ps2ipee_fdman_inet_ops.inet_addr = ipaddr_addr;
429 __ps2ipee_fdman_inet_ops.inet_ntoa = ip4addr_ntoa;
430 __ps2ipee_fdman_inet_ops.inet_ntoa_r = ip4addr_ntoa_r;
431 __ps2ipee_fdman_inet_ops.inet_aton = ip4addr_aton;
433 memset(&__ps2ipee_fdman_ops_socket, 0,
sizeof(__ps2ipee_fdman_ops_socket));
434 __ps2ipee_fdman_ops_socket.getfd = __ps2ipeeGetFdHelper;
435 __ps2ipee_fdman_ops_socket.fcntl_f_setfl = __ps2ipeeFcntlfsetflHelper;
437 __ps2ipee_fdman_ops_socket.accept = __ps2ipeeAcceptHelper;
438 __ps2ipee_fdman_ops_socket.bind = __ps2ipeeBindHelper;
439 __ps2ipee_fdman_ops_socket.close = __ps2ipeeCloseHelper;
440 __ps2ipee_fdman_ops_socket.connect = __ps2ipeeConnectHelper;
441 __ps2ipee_fdman_ops_socket.listen = __ps2ipeeListenHelper;
442 __ps2ipee_fdman_ops_socket.recv = __ps2ipeeRecvHelper;
443 __ps2ipee_fdman_ops_socket.recvfrom = __ps2ipeeRecvfromHelper;
444 __ps2ipee_fdman_ops_socket.recvmsg = __ps2ipeeRecvmsgHelper;
445 __ps2ipee_fdman_ops_socket.send = __ps2ipeeSendHelper;
446 __ps2ipee_fdman_ops_socket.sendto = __ps2ipeeSendtoHelper;
447 __ps2ipee_fdman_ops_socket.sendmsg = __ps2ipeeSendmsgHelper;
448 __ps2ipee_fdman_ops_socket.ioctl = __ps2ipeeIoctlHelper;
449 __ps2ipee_fdman_ops_socket.getsockname = __ps2ipeeGetsocknameHelper;
450 __ps2ipee_fdman_ops_socket.getpeername = __ps2ipeeGetpeernameHelper;
451 __ps2ipee_fdman_ops_socket.getsockopt = __ps2ipeeGetsockoptHelper;
452 __ps2ipee_fdman_ops_socket.setsockopt = __ps2ipeeSetsockoptHelper;
453 __ps2ipee_fdman_ops_socket.shutdown = __ps2ipeeShutdownHelper;
454 __ps2ipee_fdman_ops_socket.read = __ps2ipeeReadHelper;
455 __ps2ipee_fdman_ops_socket.write = __ps2ipeeWriteHelper;
461void _ps2sdk_ps2ipee_init(
void)
463 _backup_libcglue_fdman_socket_ops = _libcglue_fdman_socket_ops;
464 _libcglue_fdman_socket_ops = &__ps2ipee_fdman_socket_ops;
467void _ps2sdk_ps2ipee_deinit(
void)
469 _libcglue_fdman_socket_ops = _backup_libcglue_fdman_socket_ops;