pespin has submitted this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/41895?usp=email )

Change subject: core: always build osmo_sock_multiaddr_* helpers
......................................................................

core: always build osmo_sock_multiaddr_* helpers

Always build the public osmo_sock_multiaddr_* helper functions,
independent of HAVE_LIBSCTP.

Move the HAVE_LIBSCTP checks inside the functions and limit them
to the SCTP-specific code paths: when IPPROTO_SCTP is requested
without libsctp support, return -ENOTSUP, while non-SCTP protocols
continue to work as before.

This fixes link failures in libosmo-netif when building with
--disable-libsctp.

Change-Id: I3e70b7cd6cb4d022252e6ddc70a42ca5eea72bb1
---
M src/core/socket.c
1 file changed, 6 insertions(+), 4 deletions(-)

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




diff --git a/src/core/socket.c b/src/core/socket.c
index 2de4bb3..6cd82f0 100644
--- a/src/core/socket.c
+++ b/src/core/socket.c
@@ -1895,7 +1895,6 @@
        return 0;
 }

-#ifdef HAVE_LIBSCTP
 /*! Get multiple IP addresses and/or port number on socket in separate string 
buffers
  *  \param[in] fd file descriptor of socket.
  *  \param[out] ip_proto IPPROTO of the socket, eg: IPPROTO_SCTP.
@@ -1926,10 +1925,12 @@
 int osmo_sock_multiaddr_get_ip_and_port(int fd, int ip_proto, char *ip, size_t 
*ip_cnt, size_t ip_len,
                                        char *port, size_t port_len, bool local)
 {
+#ifdef HAVE_LIBSCTP
        struct sockaddr *addrs = NULL;
        unsigned int n_addrs, i;
        void *addr_buf;
        int rc;
+#endif /* HAVE_LIBSCTP */

        switch (ip_proto) {
        case IPPROTO_SCTP:
@@ -1943,6 +1944,7 @@
                return osmo_sock_get_ip_and_port(fd, ip, ip_len, port, 
port_len, local);
        }

+#ifdef HAVE_LIBSCTP
        rc = local ? sctp_getladdrs(fd, 0, &addrs) : sctp_getpaddrs(fd, 0, 
&addrs);
        if (rc < 0)
                return rc;
@@ -1983,8 +1985,10 @@
 free_addrs_ret:
        local ? sctp_freeladdrs(addrs) : sctp_freepaddrs(addrs);
        return rc;
+#else
+       return -ENOTSUP;
+#endif /* HAVE_LIBSCTP */
 }
-#endif

 /*! Get local IP address on socket
  *  \param[in] fd file descriptor of socket
@@ -2047,7 +2051,6 @@
        return talloc_asprintf(ctx, "(%s)", str);
 }

-#ifdef HAVE_LIBSCTP
 /*! Format multiple IP addresses and/or port number into a combined string 
buffer
  *  \param[out] str  Destination string buffer.
  *  \param[in] str_len  sizeof(str), usually 
OSMO_SOCK_MULTIADDR_PEER_STR_MAXLEN.
@@ -2153,7 +2156,6 @@

        return sb.chars_needed;
 }
-#endif

 /*! Get address/port information on socket in provided string buffer, like 
"r=1.2.3.4:5<->l=6.7.8.9:10".
  * This does not include braces like osmo_sock_get_name().

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

Gerrit-MessageType: merged
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I3e70b7cd6cb4d022252e6ddc70a42ca5eea72bb1
Gerrit-Change-Number: 41895
Gerrit-PatchSet: 5
Gerrit-Owner: Timur Davydov <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <[email protected]>
Gerrit-Reviewer: pespin <[email protected]>

Reply via email to