pespin has submitted this change. ( 
https://gerrit.osmocom.org/c/libosmo-netif/+/41952?usp=email )

Change subject: stream: Fix build with --disable-libsctp
......................................................................

stream: Fix build with --disable-libsctp

Guard SCTP-specific includes and code paths with HAVE_LIBSCTP to
allow building libosmo-netif without libsctp support.

This avoids unconditional inclusion of <osmocom/netif/sctp.h> and
ensures that SCTP-specific variables and send paths are only compiled
when SCTP support is enabled.

No functional change when HAVE_LIBSCTP is defined.

Change-Id: I07ef25f3fcc39f9bee023d9264a72c4381b82b65
---
M src/stream.c
M src/stream_cli.c
M src/stream_srv.c
3 files changed, 19 insertions(+), 7 deletions(-)

Approvals:
  pespin: Looks good to me, approved
  Jenkins Builder: Verified
  laforge: Looks good to me, but someone else must approve




diff --git a/src/stream.c b/src/stream.c
index e2aaf59..6773005 100644
--- a/src/stream.c
+++ b/src/stream.c
@@ -49,12 +49,12 @@

 #include "config.h"

-#include <osmocom/netif/sctp.h>
-
 /*! \cond private */

 #ifdef HAVE_LIBSCTP

+#include <osmocom/netif/sctp.h>
+
 /* is any of the bytes from offset .. u8_size in 'u8' non-zero? return offset 
or -1 if all zero */
 static int byte_nonzero(const uint8_t *u8, unsigned int offset, unsigned int 
u8_size)
 {
diff --git a/src/stream_cli.c b/src/stream_cli.c
index b098e4a..e59122b 100644
--- a/src/stream_cli.c
+++ b/src/stream_cli.c
@@ -49,7 +49,9 @@

 #include "config.h"

+#ifdef HAVE_LIBSCTP
 #include <osmocom/netif/sctp.h>
+#endif

 /*! \file stream_cli.c */

@@ -1243,9 +1245,8 @@
  *  \return negative on error, 0 on success */
 int osmo_stream_cli_open(struct osmo_stream_cli *cli)
 {
-       int ret, flags;
+       int ret;
        int fd = -1;
-       unsigned int local_addrcnt;

        /* we are reconfiguring this socket, close existing first. */
        if ((cli->flags & OSMO_STREAM_CLI_F_RECONF) && 
osmo_stream_cli_get_fd(cli) >= 0) {
@@ -1265,8 +1266,9 @@
                switch (cli->proto) {
 #ifdef HAVE_LIBSCTP
                case IPPROTO_SCTP:
-                       local_addrcnt = cli->local_addrcnt;
-                       flags = OSMO_SOCK_F_CONNECT | OSMO_SOCK_F_NONBLOCK |
+               {
+                       unsigned int local_addrcnt = cli->local_addrcnt;
+                       int flags = OSMO_SOCK_F_CONNECT | OSMO_SOCK_F_NONBLOCK |
                                OSMO_SOCK_F_DSCP(cli->ip_dscp) | 
OSMO_SOCK_F_PRIO(cli->sk_prio);
                        if (cli->local_addrcnt > 0 || cli->local_port > 0) { /* 
explicit bind required? */
                                flags |= OSMO_SOCK_F_BIND;
@@ -1279,6 +1281,7 @@
                                                        (const char 
**)cli->addr, cli->addrcnt, cli->port,
                                                        flags, &cli->ma_pars);
                        break;
+               }
 #endif
                default:
                        ret = osmo_sock_init2(cli->sk_domain, cli->sk_type, 
cli->proto,
@@ -1402,9 +1405,11 @@
        case OSMO_STREAM_MODE_OSMO_IO:
                /* whenever osmo_stream_cli_is_connected() [see above check], 
we should have an iofd */
                OSMO_ASSERT(cli->iofd);
+#ifdef HAVE_LIBSCTP
                if (cli->proto == IPPROTO_SCTP)
                        rc = stream_iofd_sctp_send_msgb(cli->iofd, msg, 
MSG_NOSIGNAL);
                else
+#endif
                        rc = osmo_iofd_write_msgb(cli->iofd, msg);
                if (rc < 0)
                        msgb_free(msg);
diff --git a/src/stream_srv.c b/src/stream_srv.c
index 3abc55a..140515f 100644
--- a/src/stream_srv.c
+++ b/src/stream_srv.c
@@ -50,7 +50,9 @@

 #include "config.h"

+#ifdef HAVE_LIBSCTP
 #include <osmocom/netif/sctp.h>
+#endif

 /*! \file stream_srv.c */

@@ -1045,12 +1047,15 @@

        osmo_sock_get_name_buf(conn->sockname, sizeof(conn->sockname), fd);

+#ifdef HAVE_LIBSCTP
        if (link->proto == IPPROTO_SCTP) {
                conn->iofd = osmo_iofd_setup(conn, fd, conn->sockname, 
OSMO_IO_FD_MODE_RECVMSG_SENDMSG,
                                             &srv_ioops_sctp, conn);
                if (conn->iofd)
                        osmo_iofd_set_cmsg_size(conn->iofd, 
CMSG_SPACE(sizeof(struct sctp_sndrcvinfo)));
-       } else {
+       } else
+#endif
+       {
                conn->iofd = osmo_iofd_setup(conn, fd, conn->sockname, 
OSMO_IO_FD_MODE_READ_WRITE,
                                             &srv_ioops, conn);
        }
@@ -1379,9 +1384,11 @@
                osmo_fd_write_enable(&conn->ofd);
                break;
        case OSMO_STREAM_MODE_OSMO_IO:
+#ifdef HAVE_LIBSCTP
                if (conn->srv->proto == IPPROTO_SCTP)
                        rc = stream_iofd_sctp_send_msgb(conn->iofd, msg, 
MSG_NOSIGNAL);
                else
+#endif
                        rc = osmo_iofd_write_msgb(conn->iofd, msg);
                if (rc < 0)
                        msgb_free(msg);

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

Gerrit-MessageType: merged
Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-Change-Id: I07ef25f3fcc39f9bee023d9264a72c4381b82b65
Gerrit-Change-Number: 41952
Gerrit-PatchSet: 4
Gerrit-Owner: Timur Davydov <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <[email protected]>
Gerrit-Reviewer: pespin <[email protected]>

Reply via email to