This implements the functionality of getsockname(2) and getpeername(2) under a single operation. Signed-off-by: Gabriel Krisman Bertazi --- src/include/liburing.h | 13 +++++++++++++ src/include/liburing/io_uring.h | 1 + 2 files changed, 14 insertions(+) diff --git a/src/include/liburing.h b/src/include/liburing.h index 83819eb7..1626f3bb 100644 --- a/src/include/liburing.h +++ b/src/include/liburing.h @@ -1572,6 +1572,19 @@ IOURINGINLINE void io_uring_prep_cmd_sock(struct io_uring_sqe *sqe, sqe->level = level; } +IOURINGINLINE void io_uring_prep_cmd_getsockname(struct io_uring_sqe *sqe, + int fd, struct sockaddr *sockaddr, + socklen_t *sockaddr_len, + int peer) + LIBURING_NOEXCEPT +{ + io_uring_prep_uring_cmd(sqe, SOCKET_URING_OP_GETSOCKNAME, fd); + + sqe->addr = (uintptr_t) sockaddr; + sqe->addr3 = (unsigned long) (uintptr_t) sockaddr_len; + sqe->optlen = peer; +} + IOURINGINLINE void io_uring_prep_waitid(struct io_uring_sqe *sqe, idtype_t idtype, id_t id, diff --git a/src/include/liburing/io_uring.h b/src/include/liburing/io_uring.h index a54e5b42..8e8b8e6a 100644 --- a/src/include/liburing/io_uring.h +++ b/src/include/liburing/io_uring.h @@ -966,6 +966,7 @@ enum io_uring_socket_op { SOCKET_URING_OP_GETSOCKOPT, SOCKET_URING_OP_SETSOCKOPT, SOCKET_URING_OP_TX_TIMESTAMP, + SOCKET_URING_OP_GETSOCKNAME, }; /* -- 2.51.0