diff mbox series

[RFC,liburing,v1,1/2] liburing: Add `io_uring_prep_sendto()`

Message ID 20230415165821.791763-2-ammarfaizi2@gnuweeb.org (mailing list archive)
State New
Headers show
Series io_uring sendto | expand

Commit Message

Ammar Faizi April 15, 2023, 4:58 p.m. UTC
A sendto(2) request can be done using:

   io_uring_prep_send() + io_uring_prep_send_set_addr()

Create a wrapper function, io_uring_prep_sendto().

Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
---
 src/include/liburing.h | 25 +++++++++++++++++--------
 src/liburing-ffi.map   |  1 +
 2 files changed, 18 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/src/include/liburing.h b/src/include/liburing.h
index fbc65b60788a4d44..70c177431faf9f75 100644
--- a/src/include/liburing.h
+++ b/src/include/liburing.h
@@ -758,6 +758,23 @@  IOURINGINLINE void io_uring_prep_send(struct io_uring_sqe *sqe, int sockfd,
 	sqe->msg_flags = (__u32) flags;
 }
 
+IOURINGINLINE void io_uring_prep_send_set_addr(struct io_uring_sqe *sqe,
+						const struct sockaddr *dest_addr,
+						__u16 addr_len)
+{
+	sqe->addr2 = (unsigned long)(const void *)dest_addr;
+	sqe->addr_len = addr_len;
+}
+
+IOURINGINLINE void io_uring_prep_sendto(struct io_uring_sqe *sqe, int sockfd,
+					const void *buf, size_t len, int flags,
+					const struct sockaddr *addr,
+					socklen_t addrlen)
+{
+	io_uring_prep_send(sqe, sockfd, buf, len, flags);
+	io_uring_prep_send_set_addr(sqe, addr, addrlen);
+}
+
 IOURINGINLINE void io_uring_prep_send_zc(struct io_uring_sqe *sqe, int sockfd,
 					 const void *buf, size_t len, int flags,
 					 unsigned zc_flags)
@@ -786,14 +803,6 @@  IOURINGINLINE void io_uring_prep_sendmsg_zc(struct io_uring_sqe *sqe, int fd,
 	sqe->opcode = IORING_OP_SENDMSG_ZC;
 }
 
-IOURINGINLINE void io_uring_prep_send_set_addr(struct io_uring_sqe *sqe,
-						const struct sockaddr *dest_addr,
-						__u16 addr_len)
-{
-	sqe->addr2 = (unsigned long)(const void *)dest_addr;
-	sqe->addr_len = addr_len;
-}
-
 IOURINGINLINE void io_uring_prep_recv(struct io_uring_sqe *sqe, int sockfd,
 				      void *buf, size_t len, int flags)
 {
diff --git a/src/liburing-ffi.map b/src/liburing-ffi.map
index c971bf8c858f3005..0a5e12ca764a2a1e 100644
--- a/src/liburing-ffi.map
+++ b/src/liburing-ffi.map
@@ -170,6 +170,7 @@  LIBURING_2.4 {
 		io_uring_prep_msg_ring_cqe_flags;
 		io_uring_prep_msg_ring_fd;
 		io_uring_prep_msg_ring_fd_alloc;
+		io_uring_prep_sendto;
 	local:
 		*;
 };