#pragma once
#include <string>
#include <cstdint>
enum {
ERROR_NET_NO_SPACE = 0x80410001,
ERROR_NET_INTERNAL = 0x80410002,
ERROR_NET_INVALID_ARG = 0x80410003,
ERROR_NET_NO_ENTRY = 0x80410004,
ERROR_NET_CORE_NOT_TERMINATED = 0x80410101,
ERROR_NET_CORE_INTERFACE_BUSY = 0x80410102,
ERROR_NET_CORE_INVALID_ARG = 0x80410103,
ERROR_NET_CORE_THREAD_NOT_FOUND = 0x80410104,
ERROR_NET_CORE_THREAD_BUSY = 0x80410105,
ERROR_NET_CORE_80211_NO_BSS = 0x80410106,
ERROR_NET_CORE_80211_NO_AVAIL_BSS = 0x80410107,
ERROR_NET_POECLIENT_INIT = 0x80410301,
ERROR_NET_POECLIENT_NO_PADO = 0x80410302,
ERROR_NET_POECLIENT_NO_PADS = 0x80410303,
ERROR_NET_POECLIENT_GET_PADT = 0x80410304,
ERROR_NET_POECLIENT_SERVICE_NAME = 0x80410305,
ERROR_NET_POECLIENT_AC_SYSTEM = 0x80410306,
ERROR_NET_POECLIENT_GENERIC = 0x80410307,
ERROR_NET_POECLIENT_AUTH = 0x80410308,
ERROR_NET_POECLIENT_NETWORK = 0x80410309,
ERROR_NET_POECLIENT_TERMINATE = 0x8041030a,
ERROR_NET_POECLIENT_NOT_STARTED = 0x8041030b,
ERROR_NET_DHCP_INVALID_PACKET = 0x80410501,
ERROR_NET_DHCP_NO_SERVER = 0x80410502,
ERROR_NET_DHCP_SENT_DECLINE = 0x80410503,
ERROR_NET_DHCP_LEASE_TIME = 0x80410504,
ERROR_NET_DHCP_GET_NAK = 0x80410505,
ERROR_NET_WLAN_ALREADY_JOINED = 0x80410d01,
ERROR_NET_WLAN_TRY_JOIN = 0x80410d02,
ERROR_NET_WLAN_SCANNING = 0x80410d03,
ERROR_NET_WLAN_INVALID_PARAMETER = 0x80410d04,
ERROR_NET_WLAN_NOT_SUPPORTED = 0x80410d05,
ERROR_NET_WLAN_NOT_JOIN_BSS = 0x80410d06,
ERROR_NET_WLAN_ASSOC_TIMEOUT = 0x80410d07,
ERROR_NET_WLAN_ASSOC_REFUSED = 0x80410d08,
ERROR_NET_WLAN_ASSOC_FAIL = 0x80410d09,
ERROR_NET_WLAN_DISASSOC_FAIL = 0x80410d0a,
ERROR_NET_WLAN_JOIN_FAIL = 0x80410d0b,
ERROR_NET_WLAN_POWER_OFF = 0x80410d0c,
ERROR_NET_WLAN_INTERNAL_FAIL = 0x80410d0d,
ERROR_NET_WLAN_DEVICE_NOT_READY = 0x80410d0e,
ERROR_NET_WLAN_ALREADY_ATTACHED = 0x80410d0f,
ERROR_NET_WLAN_NOT_SET_WEP = 0x80410d10,
ERROR_NET_WLAN_TIMEOUT = 0x80410d11,
ERROR_NET_WLAN_NO_SPACE = 0x80410d12,
ERROR_NET_WLAN_INVALID_ARG = 0x80410D13,
ERROR_NET_WLAN_NOT_IN_GAMEMODE = 0x80410d14,
ERROR_NET_WLAN_LEAVE_FAIL = 0x80410d15,
ERROR_NET_WLAN_SUSPENDED = 0x80410d16,
};
#define PSP_NET_INET_SOCK_STREAM 1
#define PSP_NET_INET_SOCK_DGRAM 2
#define PSP_NET_INET_SOCK_RAW 3
#define PSP_NET_INET_SOCK_RDM 4
#define PSP_NET_INET_SOCK_SEQPACKET 5
#define PSP_NET_INET_SOCK_CONN_DGRAM 6
#define PSP_NET_INET_SOCK_DCCP PSP_NET_INET_SOCK_CONN_DGRAM
#define PSP_NET_INET_SOCK_PACKET 10
#define PSP_NET_INET_SOCK_TYPE_MASK 0x000F
#define PSP_NET_INET_SOCK_CLOEXEC 0x10000000
#define PSP_NET_INET_SOCK_NONBLOCK 0x20000000
#define PSP_NET_INET_SOCK_NOSIGPIPE 0x40000000
#define PSP_NET_INET_SOCK_FLAGS_MASK 0xf0000000
#define PSP_NET_INET_SO_DEBUG 0x0001
#define PSP_NET_INET_SO_ACCEPTCONN 0x0002
#define PSP_NET_INET_SO_REUSEADDR 0x0004
#define PSP_NET_INET_SO_KEEPALIVE 0x0008
#define PSP_NET_INET_SO_DONTROUTE 0x0010
#define PSP_NET_INET_SO_BROADCAST 0x0020
#define PSP_NET_INET_SO_USELOOPBACK 0x0040
#define PSP_NET_INET_SO_LINGER 0x0080
#define PSP_NET_INET_SO_OOBINLINE 0x0100
#define PSP_NET_INET_SO_REUSEPORT 0x0200
#define PSP_NET_INET_SO_TIMESTAMP 0x0400
#define PSP_NET_INET_SO_ONESBCAST 0x0800
#define PSP_NET_INET_SO_SNDBUF 0x1001
#define PSP_NET_INET_SO_RCVBUF 0x1002
#define PSP_NET_INET_SO_SNDLOWAT 0x1003
#define PSP_NET_INET_SO_RCVLOWAT 0x1004
#define PSP_NET_INET_SO_SNDTIMEO 0x1005
#define PSP_NET_INET_SO_RCVTIMEO 0x1006
#define PSP_NET_INET_SO_ERROR 0x1007
#define PSP_NET_INET_SO_TYPE 0x1008
#define PSP_NET_INET_SO_NBIO 0x1009
#define PSP_NET_INET_SO_BIO 0x100a
#define PSP_NET_INET_SO_NOSIGPIPE 0x1022
#define PSP_NET_INET_TCP_NODELAY 0x01
#define PSP_NET_INET_TCP_MAXSEG 0x02
#define PSP_NET_INET_IP_OPTIONS 1
#define PSP_NET_INET_IP_HDRINCL 2
#define PSP_NET_INET_IP_TOS 3
#define PSP_NET_INET_IP_TTL 4
#define PSP_NET_INET_IP_RECVOPTS 5
#define PSP_NET_INET_IP_RECVRETOPTS 6
#define PSP_NET_INET_IP_RECVDSTADDR 7
#define PSP_NET_INET_IP_RETOPTS 8
#define PSP_NET_INET_IP_MULTICAST_IF 9
#define PSP_NET_INET_IP_MULTICAST_TTL 10
#define PSP_NET_INET_IP_MULTICAST_LOOP 11
#define PSP_NET_INET_IP_ADD_MEMBERSHIP 12
#define PSP_NET_INET_IP_DROP_MEMBERSHIP 13
#define PSP_NET_INET_IP_PORTRANGE 19
#define PSP_NET_INET_IP_RECVIF 20
#define PSP_NET_INET_IP_ERRORMTU 21
#define PSP_NET_INET_IP_IPSEC_POLICY 22
#define PSP_NET_INET_SOL_SOCKET 0xffff
#define PSP_NET_INET_SCM_RIGHTS 0x01
#define PSP_NET_INET_SCM_CREDS 0x04
#define PSP_NET_INET_SCM_TIMESTAMP 0x08
#define PSP_NET_INET_IPPROTO_IP 0
#define PSP_NET_INET_IPPROTO_HOPOPTS 0
#define PSP_NET_INET_IPPROTO_UNSPEC 0
#define PSP_NET_INET_IPPROTO_ICMP 1
#define PSP_NET_INET_IPPROTO_IGMP 2
#define PSP_NET_INET_IPPROTO_GGP 3
#define PSP_NET_INET_IPPROTO_IPV4 4
#define PSP_NET_INET_IPPROTO_IPIP 4
#define PSP_NET_INET_IPPROTO_TCP 6
#define PSP_NET_INET_IPPROTO_EGP 8
#define PSP_NET_INET_IPPROTO_PUP 12
#define PSP_NET_INET_IPPROTO_UDP 17
#define PSP_NET_INET_IPPROTO_IDP 22
#define PSP_NET_INET_IPPROTO_TP 29
#define PSP_NET_INET_IPPROTO_IPV6 41
#define PSP_NET_INET_IPPROTO_ROUTING 43
#define PSP_NET_INET_IPPROTO_FRAGMENT 44
#define PSP_NET_INET_IPPROTO_RSVP 46
#define PSP_NET_INET_IPPROTO_GRE 47
#define PSP_NET_INET_IPPROTO_ESP 50
#define PSP_NET_INET_IPPROTO_AH 51
#define PSP_NET_INET_IPPROTO_MOBILE 55
#define PSP_NET_INET_IPPROTO_IPV6_ICMP 58
#define PSP_NET_INET_IPPROTO_ICMPV6 58
#define PSP_NET_INET_IPPROTO_NONE 59
#define PSP_NET_INET_IPPROTO_DSTOPTS 60
#define PSP_NET_INET_IPPROTO_EON 80
#define PSP_NET_INET_IPPROTO_ENCAP 98
#define PSP_NET_INET_IPPROTO_PIM 103
#define PSP_NET_INET_IPPROTO_IPCOMP 108
#define PSP_NET_INET_IPPROTO_RAW 255
#define PSP_NET_INET_IPPROTO_MAX 256
#define PSP_NET_INET_IPPROTO_DONE 257
#define PSP_NET_INET_AF_UNSPEC 0
#define PSP_NET_INET_AF_LOCAL 1
#define PSP_NET_INET_AF_UNIX PSP_NET_INET_AF_LOCAL
#define PSP_NET_INET_AF_INET 2
#define PSP_NET_INET_AF_IMPLINK 3
#define PSP_NET_INET_AF_PUP 4
#define PSP_NET_INET_AF_CHAOS 5
#define PSP_NET_INET_AF_NS 6
#define PSP_NET_INET_AF_ISO 7
#define PSP_NET_INET_AF_OSI PSP_NET_INET_AF_ISO
#define PSP_NET_INET_AF_ECMA 8
#define PSP_NET_INET_AF_DATAKIT 9
#define PSP_NET_INET_AF_CCITT 10
#define PSP_NET_INET_AF_SNA 11
#define PSP_NET_INET_AF_DECnet 12
#define PSP_NET_INET_AF_DLI 13
#define PSP_NET_INET_AF_LAT 14
#define PSP_NET_INET_AF_HYLINK 15
#define PSP_NET_INET_AF_APPLETALK 16
#define PSP_NET_INET_AF_ROUTE 17
#define PSP_NET_INET_AF_LINK 18
#define PSP_NET_INET_AF_COIP 20
#define PSP_NET_INET_AF_CNT 21
#define PSP_NET_INET_AF_IPX 23
#define PSP_NET_INET_AF_INET6 24
#define PSP_NET_INET_AF_ISDN 26
#define PSP_NET_INET_AF_E164 PSP_NET_INET_AF_ISDN
#define PSP_NET_INET_AF_NATM 27
#define PSP_NET_INET_AF_ARP 28
#define PSP_NET_INET_AF_MAX 31
#define ERROR_INET_EINTR 4
#define ERROR_INET_EBADF 9
#define ERROR_INET_EAGAIN 11
#define ERROR_INET_EWOULDBLOCK ERROR_INET_EAGAIN
#define ERROR_INET_EACCES 13
#define ERROR_INET_EFAULT 14
#define ERROR_INET_EINVAL 22
#define ERROR_INET_ENOSPC 28
#define ERROR_INET_EPIPE 32
#define ERROR_INET_ENOMSG 35
#define ERROR_INET_ENOLINK 67
#define ERROR_INET_EPROTO 71
#define ERROR_INET_EBADMSG 77
#define ERROR_INET_EOPNOTSUPP 95
#define ERROR_INET_EPFNOSUPPORT 96
#define ERROR_INET_ECONNRESET 104
#define ERROR_INET_ENOBUFS 105
#define ERROR_INET_EAFNOSUPPORT 106
#define ERROR_INET_EPROTOTYPE 107
#define ERROR_INET_ENOTSOCK 108
#define ERROR_INET_ENOPROTOOPT 109
#define ERROR_INET_ESHUTDOWN 110
#define ERROR_INET_ECONNREFUSED 111
#define ERROR_INET_EADDRINUSE 112
#define ERROR_INET_ECONNABORTED 113
#define ERROR_INET_ENETUNREACH 114
#define ERROR_INET_ENETDOWN 115
#define ERROR_INET_ETIMEDOUT 116
#define ERROR_INET_EHOSTDOWN 117
#define ERROR_INET_EHOSTUNREACH 118
#define ERROR_INET_EINPROGRESS 119
#define ERROR_INET_EALREADY 120
#define ERROR_INET_EDESTADDRREQ 121
#define ERROR_INET_EMSGSIZE 122
#define ERROR_INET_EPROTONOSUPPORT 123
#define ERROR_INET_ESOCKTNOSUPPORT 124
#define ERROR_INET_EADDRNOTAVAIL 125
#define ERROR_INET_ENETRESET 126
#define ERROR_INET_EISCONN 127
#define ERROR_INET_ENOTCONN 128
#define ERROR_INET_ETOOMANYREFS 129
#define ERROR_INET_ENOTSUP 134
#define PSP_NET_INET_SOMAXCONN 128
#define PSP_NET_INET_MSG_OOB 0x1
#define PSP_NET_INET_MSG_PEEK 0x2
#define PSP_NET_INET_MSG_DONTROUTE 0x4
#define PSP_NET_INET_MSG_EOR 0x8
#define PSP_NET_INET_MSG_TRUNC 0x10
#define PSP_NET_INET_MSG_CTRUNC 0x20
#define PSP_NET_INET_MSG_WAITALL 0x40
#define PSP_NET_INET_MSG_DONTWAIT 0x80
#define PSP_NET_INET_MSG_BCAST 0x100
#define PSP_NET_INET_MSG_MCAST 0x200
#define INET_POLLIN 0x001
#define INET_POLLPRI 0x002
#define INET_POLLOUT 0x004
#define INET_POLLRDNORM 0x040
#define INET_POLLWRNORM 0x100
#define INET_POLLRDBAND 0x080
#define INET_POLLWRBAND 0x200
#define INET_POLLERR 0x008
#define INET_POLLHUP 0x010
#define INET_POLLNVAL 0x020
#define PSP_NET_INET_SHUT_RD 0
#define PSP_NET_INET_SHUT_WR 1
#define PSP_NET_INET_SHUT_RDWR 2
#ifndef SHUT_RD
#define SHUT_RD SD_RECEIVE
#endif
#ifndef SHUT_WR
#define SHUT_WR SD_SEND
#endif
#ifndef SHUT_RDWR
#define SHUT_RDWR SD_BOTH
#endif
int convertMsgFlagPSP2Host(int flag);
int convertMsgFlagHost2PSP(int flag);
int convertMSGFlagsPSP2Host(int flags);
int convertMSGFlagsHost2PSP(int flags);
int convertSocketDomainPSP2Host(int domain);
int convertSocketDomainHost2PSP(int domain);
std::string inetSocketDomain2str(int domain);
int convertSocketTypePSP2Host(int type);
int convertSocketTypeHost2PSP(int type);
std::string inetSocketType2str(int type);
int convertSocketProtoPSP2Host(int protocol);
int convertSocketProtoHost2PSP(int protocol);
std::string inetSocketProto2str(int protocol);
int convertCMsgTypePSP2Host(int type, int level);
int convertCMsgTypeHost2PSP(int type, int level);
int convertSockoptLevelPSP2Host(int level);
int convertSockoptLevelHost2PSP(int level);
std::string inetSockoptLevel2str(int level);
int convertSockoptNamePSP2Host(int optname, int level);
int convertSockoptNameHost2PSP(int optname, int level);
std::string inetSockoptName2str(int optname, int level);
int convertInetErrnoHost2PSP(int error);
int convertInetErrno2PSPError(int error);
const char *convertInetErrno2str(int error);
std::string convertNetError2str(uint32_t errorCode);