diff options
author | Brian Gianforcaro <bgianf@serenityos.org> | 2021-12-20 01:26:55 -0800 |
---|---|---|
committer | Brian Gianforcaro <b.gianfo@gmail.com> | 2021-12-21 18:16:48 -0800 |
commit | 4484634d8a64b06b99ae006fb34ac258aeac2b83 (patch) | |
tree | 45a14eb94a1d53822f0364a14866301c4660fc37 /Userland/Libraries/LibC/sys | |
parent | 3c897d044303c203e04ffe6310615d51f82091c8 (diff) | |
download | serenity-4484634d8a64b06b99ae006fb34ac258aeac2b83.zip |
LibC: Add POSIX spec comments for socket APIs
Diffstat (limited to 'Userland/Libraries/LibC/sys')
-rw-r--r-- | Userland/Libraries/LibC/sys/socket.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Userland/Libraries/LibC/sys/socket.cpp b/Userland/Libraries/LibC/sys/socket.cpp index d6156b6bf8..3e78ff1486 100644 --- a/Userland/Libraries/LibC/sys/socket.cpp +++ b/Userland/Libraries/LibC/sys/socket.cpp @@ -14,24 +14,28 @@ extern "C" { +// https://pubs.opengroup.org/onlinepubs/9699919799/functions/socket.html int socket(int domain, int type, int protocol) { int rc = syscall(SC_socket, domain, type, protocol); __RETURN_WITH_ERRNO(rc, rc, -1); } +// https://pubs.opengroup.org/onlinepubs/9699919799/functions/bind.html int bind(int sockfd, const sockaddr* addr, socklen_t addrlen) { int rc = syscall(SC_bind, sockfd, addr, addrlen); __RETURN_WITH_ERRNO(rc, rc, -1); } +// https://pubs.opengroup.org/onlinepubs/9699919799/functions/listen.html int listen(int sockfd, int backlog) { int rc = syscall(SC_listen, sockfd, backlog); __RETURN_WITH_ERRNO(rc, rc, -1); } +// https://pubs.opengroup.org/onlinepubs/9699919799/functions/accept.html int accept(int sockfd, sockaddr* addr, socklen_t* addrlen) { return accept4(sockfd, addr, addrlen, 0); @@ -44,24 +48,28 @@ int accept4(int sockfd, sockaddr* addr, socklen_t* addrlen, int flags) __RETURN_WITH_ERRNO(rc, rc, -1); } +// https://pubs.opengroup.org/onlinepubs/9699919799/functions/connect.html int connect(int sockfd, const sockaddr* addr, socklen_t addrlen) { int rc = syscall(SC_connect, sockfd, addr, addrlen); __RETURN_WITH_ERRNO(rc, rc, -1); } +// https://pubs.opengroup.org/onlinepubs/9699919799/functions/shutdown.html int shutdown(int sockfd, int how) { int rc = syscall(SC_shutdown, sockfd, how); __RETURN_WITH_ERRNO(rc, rc, -1); } +// https://pubs.opengroup.org/onlinepubs/9699919799/functions/sendmsg.html ssize_t sendmsg(int sockfd, const struct msghdr* msg, int flags) { int rc = syscall(SC_sendmsg, sockfd, msg, flags); __RETURN_WITH_ERRNO(rc, rc, -1); } +// https://pubs.opengroup.org/onlinepubs/9699919799/functions/sendto.html ssize_t sendto(int sockfd, const void* data, size_t data_length, int flags, const struct sockaddr* addr, socklen_t addr_length) { iovec iov = { const_cast<void*>(data), data_length }; @@ -69,17 +77,20 @@ ssize_t sendto(int sockfd, const void* data, size_t data_length, int flags, cons return sendmsg(sockfd, &msg, flags); } +// https://pubs.opengroup.org/onlinepubs/9699919799/functions/send.html ssize_t send(int sockfd, const void* data, size_t data_length, int flags) { return sendto(sockfd, data, data_length, flags, nullptr, 0); } +// https://pubs.opengroup.org/onlinepubs/9699919799/functions/recvmsg.html ssize_t recvmsg(int sockfd, struct msghdr* msg, int flags) { int rc = syscall(SC_recvmsg, sockfd, msg, flags); __RETURN_WITH_ERRNO(rc, rc, -1); } +// https://pubs.opengroup.org/onlinepubs/9699919799/functions/recvfrom.html ssize_t recvfrom(int sockfd, void* buffer, size_t buffer_length, int flags, struct sockaddr* addr, socklen_t* addr_length) { if (!addr_length && addr) { @@ -98,11 +109,13 @@ ssize_t recvfrom(int sockfd, void* buffer, size_t buffer_length, int flags, stru return rc; } +// https://pubs.opengroup.org/onlinepubs/9699919799/functions/recv.html ssize_t recv(int sockfd, void* buffer, size_t buffer_length, int flags) { return recvfrom(sockfd, buffer, buffer_length, flags, nullptr, nullptr); } +// https://pubs.opengroup.org/onlinepubs/9699919799/functions/getsockopt.html int getsockopt(int sockfd, int level, int option, void* value, socklen_t* value_size) { Syscall::SC_getsockopt_params params { sockfd, level, option, value, value_size }; @@ -110,6 +123,7 @@ int getsockopt(int sockfd, int level, int option, void* value, socklen_t* value_ __RETURN_WITH_ERRNO(rc, rc, -1); } +// https://pubs.opengroup.org/onlinepubs/9699919799/functions/setsockopt.html int setsockopt(int sockfd, int level, int option, const void* value, socklen_t value_size) { Syscall::SC_setsockopt_params params { value, sockfd, level, option, value_size }; @@ -117,6 +131,7 @@ int setsockopt(int sockfd, int level, int option, const void* value, socklen_t v __RETURN_WITH_ERRNO(rc, rc, -1); } +// https://pubs.opengroup.org/onlinepubs/9699919799/functions/getsockname.html int getsockname(int sockfd, struct sockaddr* addr, socklen_t* addrlen) { Syscall::SC_getsockname_params params { sockfd, addr, addrlen }; @@ -124,6 +139,7 @@ int getsockname(int sockfd, struct sockaddr* addr, socklen_t* addrlen) __RETURN_WITH_ERRNO(rc, rc, -1); } +// https://pubs.opengroup.org/onlinepubs/9699919799/functions/getpeername.html int getpeername(int sockfd, struct sockaddr* addr, socklen_t* addrlen) { Syscall::SC_getpeername_params params { sockfd, addr, addrlen }; @@ -131,6 +147,7 @@ int getpeername(int sockfd, struct sockaddr* addr, socklen_t* addrlen) __RETURN_WITH_ERRNO(rc, rc, -1); } +// https://pubs.opengroup.org/onlinepubs/9699919799/functions/socketpair.html int socketpair(int domain, int type, int protocol, int sv[2]) { Syscall::SC_socketpair_params params { domain, type, protocol, sv }; |