osmo_io: Add iofd_handle_recv()

Handle msg reception in a common function that can be called from the
different backends.

Change-Id: Ifc407d446805f885d37767f421ff710cb276a01f
diff --git a/src/core/osmo_io.c b/src/core/osmo_io.c
index db1b5ad..5fed19e 100644
--- a/src/core/osmo_io.c
+++ b/src/core/osmo_io.c
@@ -302,6 +302,22 @@
 	iofd->pending = pending;
 }
 
+void iofd_handle_recv(struct osmo_io_fd *iofd, struct msgb *msg, int rc, struct iofd_msghdr *hdr)
+{
+	switch (iofd->mode) {
+	case OSMO_IO_FD_MODE_READ_WRITE:
+		iofd_handle_segmented_read(iofd, msg, rc);
+		break;
+	case OSMO_IO_FD_MODE_RECVFROM_SENDTO:
+		iofd->io_ops.recvfrom_cb(iofd, rc, msg, &hdr->osa);
+		break;
+	case OSMO_IO_FD_MODE_SCTP_RECVMSG_SENDMSG:
+		/* TODO Implement */
+		OSMO_ASSERT(false);
+		break;
+	}
+}
+
 /* Public functions */
 
 /*! Send a message through a connected socket.