osmo_io: sendmsg/recvmsg support

Add support osmo_io operations resembling sendmsg() and recvmsg() socket
operations.  This is what will enable the implementation of higher-layer
functions like equivalents of sctp_recvmsg() and sctp_send() in
libosmo-netif and/or other users.

Change-Id: I89eb519b22d21011d61a7855b2364bc3c295df82
Related: OS#5751
diff --git a/src/core/osmo_io_internal.h b/src/core/osmo_io_internal.h
index 9c86e05..af47a3d 100644
--- a/src/core/osmo_io_internal.h
+++ b/src/core/osmo_io_internal.h
@@ -4,6 +4,7 @@
 
 #include <unistd.h>
 #include <stdbool.h>
+#include <netinet/sctp.h>
 
 #include <osmocom/core/osmo_io.h>
 #include <osmocom/core/linuxlist.h>
@@ -72,6 +73,9 @@
 	/*! private number, extending \a data */
 	unsigned int priv_nr;
 
+	/*! size of iofd_msghdr.cmsg[] when allocated in recvmsg path */
+	size_t cmsg_size;
+
 	struct {
 		/*! talloc context from which to allocate msgb when reading */
 		const void *ctx;
@@ -109,7 +113,8 @@
 	IOFD_ACT_WRITE,
 	IOFD_ACT_RECVFROM,
 	IOFD_ACT_SENDTO,
-	// TODO: SCTP_*
+	IOFD_ACT_RECVMSG,
+	IOFD_ACT_SENDMSG,
 };
 
 
@@ -132,6 +137,9 @@
 	struct msgb *msg;
 	/*! I/O file descriptor on which we perform this I/O operation */
 	struct osmo_io_fd *iofd;
+
+	/*! control message buffer for passing sctp_sndrcvinfo along */
+	char cmsg[0]; /* size is determined by iofd->cmsg_size on recvmsg, and by mcghdr->msg_controllen on sendmsg */
 };
 
 enum iofd_seg_act {
@@ -140,7 +148,7 @@
 	IOFD_SEG_ACT_DEFER,
 };
 
-struct iofd_msghdr *iofd_msghdr_alloc(struct osmo_io_fd *iofd, enum iofd_msg_action action, struct msgb *msg);
+struct iofd_msghdr *iofd_msghdr_alloc(struct osmo_io_fd *iofd, enum iofd_msg_action action, struct msgb *msg, size_t cmsg_size);
 void iofd_msghdr_free(struct iofd_msghdr *msghdr);
 
 struct msgb *iofd_msgb_alloc(struct osmo_io_fd *iofd);