jolly has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/libosmocore/+/36056?usp=email )


Change subject: Make osmo-io compile without libsctp support (--disable-libsctp)
......................................................................

Make osmo-io compile without libsctp support (--disable-libsctp)

Change-Id: Ief8ca40c0e85efe340eaecb866a10f76ac2bfc98
---
M src/core/osmo_io.c
M src/core/osmo_io_internal.h
M src/core/osmo_io_poll.c
M src/core/osmo_io_uring.c
4 files changed, 24 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/56/36056/1

diff --git a/src/core/osmo_io.c b/src/core/osmo_io.c
index 61d2641..34d4b00 100644
--- a/src/core/osmo_io.c
+++ b/src/core/osmo_io.c
@@ -330,7 +330,6 @@
  *  \param[in] hdr serialized msghdr containing state of completed I/O */
 void iofd_handle_recv(struct osmo_io_fd *iofd, struct msgb *msg, int rc, 
struct iofd_msghdr *hdr)
 {
-       struct cmsghdr *cmsg = NULL;

        talloc_steal(iofd->msgb_alloc.ctx, msg);
        switch (iofd->mode) {
@@ -340,11 +339,13 @@
        case OSMO_IO_FD_MODE_RECVFROM_SENDTO:
                iofd->io_ops.recvfrom_cb(iofd, rc, msg, &hdr->osa);
                break;
+#ifdef HAVE_LIBSCTP
        case OSMO_IO_FD_MODE_SCTP_RECVMSG_SEND:
                msgb_sctp_msg_flags(msg) = 0;
                if (hdr->hdr.msg_flags & MSG_NOTIFICATION) {
                        msgb_sctp_msg_flags(msg) = 
OSMO_STREAM_SCTP_MSG_FLAGS_NOTIFICATION;
                } else {
+                       struct cmsghdr *cmsg = NULL;
                        for (cmsg = CMSG_FIRSTHDR(&hdr->hdr); cmsg != NULL;
                             cmsg = CMSG_NXTHDR(&hdr->hdr, cmsg)) {
                                if (cmsg->cmsg_level == IPPROTO_SCTP && 
cmsg->cmsg_type == SCTP_SNDRCV) {
@@ -359,6 +360,7 @@
                }
                iofd->io_ops.read_cb(iofd, rc, msg);
                break;
+#endif
        default:
                OSMO_ASSERT(false);
                break;
@@ -505,6 +507,7 @@
        return 0;
 }

+#ifdef HAVE_LIBSCTP
 /*! Send a message through a connected SCTP socket, similar to sctp_sendmsg().
  *
  *  Appends the message to the internal transmit queue.
@@ -566,6 +569,7 @@
        return 0;

 }
+#endif

 /*! Allocate and setup a new iofd.
  *  \param[in] ctx the parent context from which to allocate
@@ -585,7 +589,9 @@
        switch (mode) {
        case OSMO_IO_FD_MODE_READ_WRITE:
        case OSMO_IO_FD_MODE_RECVFROM_SENDTO:
+#ifdef HAVE_LIBSCTP
        case OSMO_IO_FD_MODE_SCTP_RECVMSG_SEND:
+#endif
                break;
        default:
                return NULL;
diff --git a/src/core/osmo_io_internal.h b/src/core/osmo_io_internal.h
index 77ed142..822f3fb 100644
--- a/src/core/osmo_io_internal.h
+++ b/src/core/osmo_io_internal.h
@@ -4,7 +4,9 @@

 #include <unistd.h>
 #include <stdbool.h>
+#ifdef HAVE_LIBSCTP
 #include <netinet/sctp.h>
+#endif

 #include <osmocom/core/osmo_io.h>
 #include <osmocom/core/linuxlist.h>
@@ -129,8 +131,10 @@
        /*! io-vector we need to pass as argument to sendmsg/recvmsg; is set up
         * to point into msg below */
        struct iovec iov[1];
+#ifdef HAVE_LIBSCTP
        /*! control message buffer for passing sctp_sndrcvinfo along */
        char cmsg[CMSG_SPACE(sizeof(struct sctp_sndrcvinfo))];
+#endif
        /*! flags we pass as argument to sendmsg / recvmsg */
        int flags;

diff --git a/src/core/osmo_io_poll.c b/src/core/osmo_io_poll.c
index ea3e3cc..aea0bbc 100644
--- a/src/core/osmo_io_poll.c
+++ b/src/core/osmo_io_poll.c
@@ -64,10 +64,12 @@
                        .msg_name = &hdr.osa.u.sa,
                        .msg_namelen = sizeof(struct osmo_sockaddr),
                };
+#ifdef HAVE_LIBSCTP
                if (iofd->mode == OSMO_IO_FD_MODE_SCTP_RECVMSG_SEND) {
                        hdr.hdr.msg_control = hdr.cmsg;
                        hdr.hdr.msg_controllen = sizeof(hdr.cmsg);
                }
+#endif

                rc = recvmsg(ofd->fd, &hdr.hdr, flags);
                if (rc > 0)
diff --git a/src/core/osmo_io_uring.c b/src/core/osmo_io_uring.c
index 1e1e987..b47f0a3 100644
--- a/src/core/osmo_io_uring.c
+++ b/src/core/osmo_io_uring.c
@@ -37,7 +37,6 @@
 #include <errno.h>

 #include <netinet/in.h>
-#include <netinet/sctp.h>
 #include <sys/eventfd.h>
 #include <liburing.h>

@@ -129,10 +128,12 @@
        switch (action) {
        case IOFD_ACT_READ:
                break;
+#ifdef HAVE_LIBSCTP
        case IOFD_ACT_SCTP_RECVMSG:
                msghdr->hdr.msg_control = msghdr->cmsg;
                msghdr->hdr.msg_controllen = sizeof(msghdr->cmsg);
                /* fall-through */
+#endif
        case IOFD_ACT_RECVFROM:
                msghdr->hdr.msg_iov = &msghdr->iov[0];
                msghdr->hdr.msg_iovlen = 1;

--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/36056?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Ief8ca40c0e85efe340eaecb866a10f76ac2bfc98
Gerrit-Change-Number: 36056
Gerrit-PatchSet: 1
Gerrit-Owner: jolly <[email protected]>
Gerrit-MessageType: newchange

Reply via email to