This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
laforge gerrit-no-reply at lists.osmocom.orglaforge has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-netif/+/16760 ) Change subject: configure.ac: Introduce --{enable,disable}-libsctp configure flag ...................................................................... configure.ac: Introduce --{enable,disable}-libsctp configure flag Similar to what we do in libosmocore already, we want to deterministically enable or disable support for the feature without having into account if the system has a libsctp. If libsctp is missing and support is enabled, then fail. Extra checks are also added: * Check netinet/sctp.h header * Check libosmocore was built with libsctp support (API osmo_sock_init2_multiaddr() we require). * In stream.c make sure it can be built without HAVE_LIBSCTP, and that set_addrs() fails for more than 1 address (since that feature is only supported through osmo_sock_init2_multiaddrs()). Change-Id: I4b3e1f1894f13ac1175a71a5139c02a2633be26d --- M configure.ac M src/stream.c 2 files changed, 38 insertions(+), 16 deletions(-) Approvals: Jenkins Builder: Verified laforge: Looks good to me, approved diff --git a/configure.ac b/configure.ac index 7af10ec..a96fb70 100644 --- a/configure.ac +++ b/configure.ac @@ -87,16 +87,24 @@ dnl FIXME: We depend on libosmoabis by now until we can move LAPD code here PKG_CHECK_MODULES(LIBOSMOABIS, libosmoabis >= 0.6.0) -old_LIBS=$LIBS -AC_SEARCH_LIBS([sctp_send], [sctp], [ - AC_DEFINE(HAVE_LIBSCTP, 1, [Define 1 to enable SCTP support]) - AC_SUBST(HAVE_LIBSCTP, [1]) - if test -n "$ac_lib"; then - AC_SUBST(LIBSCTP_LIBS, [-l$ac_lib]) - fi - ], [ - AC_MSG_ERROR([sctp_send not found in searched libs])]) -LIBS=$old_LIBS +AC_ARG_ENABLE([libsctp], [AS_HELP_STRING([--disable-libsctp], [Do not enable socket multiaddr APIs requiring libsctp])], + [ENABLE_LIBSCTP=$enableval], [ENABLE_LIBSCTP="yes"]) +AM_CONDITIONAL(ENABLE_LIBSCTP, test x"$ENABLE_LIBSCTP" = x"yes") +AS_IF([test "x$ENABLE_LIBSCTP" = "xyes"], [ + AC_CHECK_HEADERS(netinet/sctp.h,,AC_MSG_ERROR(netinet/sctp.h not found)) + old_LIBS=$LIBS + AC_CHECK_LIB(osmocore, osmo_sock_init2_multiaddr,, AC_MSG_ERROR(libosmocore built without libsctp support), $LIBOSMOCORE_LIBS) + LIBS=$old_LIBS + AC_SEARCH_LIBS([sctp_send], [sctp], [ + AC_DEFINE(HAVE_LIBSCTP, 1, [Define 1 to enable SCTP support]) + AC_SUBST(HAVE_LIBSCTP, [1]) + if test -n "$ac_lib"; then + AC_SUBST(LIBSCTP_LIBS, [-l$ac_lib]) + fi + ], [ + AC_MSG_ERROR([sctp_send not found in searched libs])]) + LIBS=$old_LIBS +]) AC_CHECK_HEADERS(dahdi/user.h,,AC_MSG_WARN(DAHDI input driver will not be built)) diff --git a/src/stream.c b/src/stream.c index 744a904..537fd28 100644 --- a/src/stream.c +++ b/src/stream.c @@ -106,9 +106,11 @@ int rc; switch (proto) { +#ifdef HAVE_LIBSCTP case IPPROTO_SCTP: rc = setsockopt(fd, IPPROTO_SCTP, SCTP_NODELAY, &on, sizeof(on)); break; +#endif case IPPROTO_TCP: rc = setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &on, sizeof(on)); break; @@ -143,15 +145,21 @@ #define OSMO_STREAM_CLI_F_RECONF (1 << 0) #define OSMO_STREAM_CLI_F_NODELAY (1 << 1) +#ifdef HAVE_LIBSCTP +#define OSMO_STREAM_MAX_ADDRS OSMO_SOCK_MAX_ADDRS +#else +#define OSMO_STREAM_MAX_ADDRS 1 +#endif + struct osmo_stream_cli { struct osmo_fd ofd; struct llist_head tx_queue; struct osmo_timer_list timer; enum osmo_stream_cli_state state; - char *addr[OSMO_SOCK_MAX_ADDRS]; + char *addr[OSMO_STREAM_MAX_ADDRS]; uint8_t addrcnt; uint16_t port; - char *local_addr[OSMO_SOCK_MAX_ADDRS]; + char *local_addr[OSMO_STREAM_MAX_ADDRS]; uint8_t local_addrcnt; uint16_t local_port; uint16_t proto; @@ -369,7 +377,7 @@ { int i = 0; - if (addrcnt > OSMO_SOCK_MAX_ADDRS) + if (addrcnt > OSMO_STREAM_MAX_ADDRS) return -EINVAL; for (; i < addrcnt; i++) @@ -426,7 +434,7 @@ { int i = 0; - if (addrcnt > OSMO_SOCK_MAX_ADDRS) + if (addrcnt > OSMO_STREAM_MAX_ADDRS) return -EINVAL; for (; i < addrcnt; i++) @@ -554,12 +562,14 @@ cli->flags &= ~OSMO_STREAM_CLI_F_RECONF; switch (cli->proto) { +#ifdef HAVE_LIBSCTP case IPPROTO_SCTP: ret = osmo_sock_init2_multiaddr(AF_INET, SOCK_STREAM, cli->proto, (const char **)cli->local_addr, cli->local_addrcnt, cli->local_port, (const char **)cli->addr, cli->addrcnt, cli->port, OSMO_SOCK_F_CONNECT|OSMO_SOCK_F_BIND|OSMO_SOCK_F_NONBLOCK); break; +#endif default: ret = osmo_sock_init2(AF_INET, SOCK_STREAM, cli->proto, cli->local_addr[0], cli->local_port, @@ -623,12 +633,14 @@ switch (cli->proto) { +#ifdef HAVE_LIBSCTP case IPPROTO_SCTP: ret = osmo_sock_init2_multiaddr(AF_INET, SOCK_STREAM, cli->proto, (const char **)cli->local_addr, cli->local_addrcnt, cli->local_port, (const char **)cli->addr, cli->addrcnt, cli->port, OSMO_SOCK_F_CONNECT|OSMO_SOCK_F_BIND|OSMO_SOCK_F_NONBLOCK); break; +#endif default: ret = osmo_sock_init2(AF_INET, SOCK_STREAM, cli->proto, cli->local_addr[0], cli->local_port, @@ -718,7 +730,7 @@ struct osmo_stream_srv_link { struct osmo_fd ofd; - char *addr[OSMO_SOCK_MAX_ADDRS]; + char *addr[OSMO_STREAM_MAX_ADDRS]; uint8_t addrcnt; uint16_t port; uint16_t proto; @@ -830,7 +842,7 @@ { int i = 0; - if (addrcnt > OSMO_SOCK_MAX_ADDRS) + if (addrcnt > OSMO_STREAM_MAX_ADDRS) return -EINVAL; for (; i < addrcnt; i++) @@ -950,11 +962,13 @@ link->flags &= ~OSMO_STREAM_SRV_F_RECONF; switch (link->proto) { +#ifdef HAVE_LIBSCTP case IPPROTO_SCTP: ret = osmo_sock_init2_multiaddr(AF_INET, SOCK_STREAM, link->proto, (const char **)link->addr, link->addrcnt, link->port, NULL, 0, 0, OSMO_SOCK_F_BIND); break; +#endif default: ret = osmo_sock_init(AF_INET, SOCK_STREAM, link->proto, link->addr[0], link->port, OSMO_SOCK_F_BIND); -- To view, visit https://gerrit.osmocom.org/c/libosmo-netif/+/16760 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmo-netif Gerrit-Branch: master Gerrit-Change-Id: I4b3e1f1894f13ac1175a71a5139c02a2633be26d Gerrit-Change-Number: 16760 Gerrit-PatchSet: 2 Gerrit-Owner: neels <nhofmeyr at sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge at osmocom.org> Gerrit-Reviewer: neels <nhofmeyr at sysmocom.de> Gerrit-Reviewer: pespin <pespin at sysmocom.de> Gerrit-MessageType: merged -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200112/474a02c6/attachment.htm>