daniel has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/34184 )
Change subject: osmo_io: Add iofd_handle_recv() ......................................................................
osmo_io: Add iofd_handle_recv()
Handle msg reception in a common function that can be called from the different backends.
Change-Id: Ifc407d446805f885d37767f421ff710cb276a01f --- M src/core/osmo_io.c M src/core/osmo_io_internal.h M src/core/osmo_io_poll.c 3 files changed, 30 insertions(+), 12 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/84/34184/1
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. diff --git a/src/core/osmo_io_internal.h b/src/core/osmo_io_internal.h index d45b161..0f0465d 100644 --- a/src/core/osmo_io_internal.h +++ b/src/core/osmo_io_internal.h @@ -133,6 +133,7 @@ struct msgb *iofd_msgb_pending(struct osmo_io_fd *iofd); struct msgb *iofd_msgb_pending_or_alloc(struct osmo_io_fd *iofd);
+void iofd_handle_recv(struct osmo_io_fd *iofd, struct msgb *msg, int rc, struct iofd_msghdr *msghdr); void iofd_handle_segmented_read(struct osmo_io_fd *iofd, struct msgb *msg, int rc);
int iofd_txqueue_enqueue(struct osmo_io_fd *iofd, struct iofd_msghdr *msghdr); diff --git a/src/core/osmo_io_poll.c b/src/core/osmo_io_poll.c index 77a741a..c230188 100644 --- a/src/core/osmo_io_poll.c +++ b/src/core/osmo_io_poll.c @@ -67,18 +67,7 @@ if (rc > 0) msgb_put(msg, rc);
- 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; - } + iofd_handle_recv(iofd, msg, rc, &hdr); }
if (IOFD_FLAG_ISSET(iofd, IOFD_FLAG_CLOSED))