/ppu/include/net/socket.h

https://github.com/bigboss-ps3dev/PSL1GHT · C Header · 121 lines · 102 code · 19 blank · 0 comment · 0 complexity · 77fbfc9aca8e6f2c22d8265285a743f5 MD5 · raw file

  1. #ifndef __SOCKET_H__
  2. #define __SOCKET_H__
  3. #include <unistd.h> // for ssize_t
  4. #include <ppu-types.h>
  5. typedef u32 socklen_t;
  6. typedef u8 sa_family_t;
  7. struct sockaddr
  8. {
  9. u8 sa_len;
  10. sa_family_t sa_family;
  11. char sa_data[];
  12. };
  13. struct iovec
  14. {
  15. void* iov_base;
  16. size_t iov_len;
  17. };
  18. struct msghdr
  19. {
  20. void* msg_name;
  21. socklen_t msg_namelen;
  22. struct iovec* msg_iov;
  23. int msg_iovlen;
  24. void* msg_control;
  25. socklen_t msg_controllen;
  26. int msg_flags;
  27. };
  28. struct cmsghdr
  29. {
  30. socklen_t cmsg_len;
  31. int cmsg_level;
  32. int cmsg_type;
  33. };
  34. struct linger
  35. {
  36. int l_onoff;
  37. int l_linger;
  38. };
  39. #define SOCK_STREAM 0x0001
  40. #define SOCK_DGRAM 0x0002
  41. #define SOCK_RAW 0x0003
  42. #define SOL_SOCKET 0xFFFF
  43. #define SO_REUSEADDR 0x0004
  44. #define SO_KEEPALIVE 0x0008
  45. #define SO_BROADCAST 0x0020
  46. #define SO_LINGER 0x0080
  47. #define SO_OOBINLINE 0x0100
  48. #define SO_REUSEPORT 0x0200
  49. #define SO_SNDBUF 0x1001
  50. #define SO_RCVBUF 0x1002
  51. #define SO_SNDLOWAT 0x1003
  52. #define SO_RCVLOWAT 0x1004
  53. #define SO_SNDTIMEO 0x1005
  54. #define SO_RCVTIMEO 0x1006
  55. #define SO_ERROR 0x1007
  56. #define SO_TYPE 0x1008
  57. #define SO_NBIO 0x1100
  58. #define MSG_OOB 0x0001
  59. #define MSG_PEEK 0x0002
  60. #define MSG_DONTROUTE 0x0004
  61. #define MSG_EOR 0x0008
  62. #define MSG_TRUNC 0x0010
  63. #define MSG_CTRUNC 0x0020
  64. #define MSG_WAITALL 0x0040
  65. #define MSG_DONTWAIT 0x0080
  66. #define MSG_BCAST 0x0100
  67. #define MSG_MCAST 0x0200
  68. #define AF_UNSPEC 0x0000
  69. #define AF_UNIX 0x0001
  70. #define AF_INET 0x0002
  71. #define AF_INET6 0x0018
  72. #define AF_MAX 0x0020
  73. #define SHUT_RD 0x0000
  74. #define SHUT_WR 0x0001
  75. #define SHUT_RDWR 0x0002
  76. #define PF_INET AF_INET
  77. #define PF_INET6 AF_INET6
  78. #define SOCKET_FD_MASK 0x40000000
  79. #ifdef __cplusplus
  80. extern "C" {
  81. #endif
  82. int accept(int socket, struct sockaddr* address, socklen_t* address_len);
  83. int bind(int socket, const struct sockaddr* address, socklen_t address_len);
  84. int connect(int socket, const struct sockaddr* address, socklen_t address_len);
  85. int getpeername(int socket, struct sockaddr* address, socklen_t* address_len);
  86. int getsockname(int socket, struct sockaddr* address, socklen_t* address_len);
  87. int getsockopt(int socket, int level, int option_name, void* option_value,socklen_t* option_len);
  88. int listen(int socket, int backlog);
  89. ssize_t recv(int socket, void* buffer, size_t length, int flags);
  90. ssize_t recvfrom(int socket, void* buffer, size_t length, int flags,struct sockaddr* from, socklen_t* fromlen);
  91. ssize_t recvmsg(int socket, struct msghdr* message, int flags);
  92. ssize_t send(int socket, const void* message, size_t length, int flags);
  93. ssize_t sendto(int socket, const void* message, size_t length, int flags,const struct sockaddr* dest_addr, socklen_t dest_len);
  94. ssize_t sendmsg(int socket, const struct msghdr* message, int flags);
  95. int setsockopt(int socket, int level, int option_name, const void* option_value,socklen_t option_len);
  96. int shutdown(int socket, int how);
  97. int socket(int domain, int type, int protocol);
  98. int socketpair(int domain, int type, int protocol, int socket_vector[2]);
  99. #ifdef __cplusplus
  100. }
  101. #endif
  102. #endif