diff options
author | Dimitri Staessens <dimitri@ouroboros.rocks> | 2021-06-26 00:20:17 +0200 |
---|---|---|
committer | Sander Vrijders <sander@ouroboros.rocks> | 2021-06-28 15:29:16 +0200 |
commit | cb70b78c443de5f8b95c4469dd8eb7f77af880ed (patch) | |
tree | ae90c387087b5288fe4651db485c6cdd1ef80b7c /src | |
parent | 2a46ecf6e64f1a725a3660ea03d6c9946e74de0f (diff) | |
download | ouroboros-cb70b78c443de5f8b95c4469dd8eb7f77af880ed.tar.gz ouroboros-cb70b78c443de5f8b95c4469dd8eb7f77af880ed.zip |
build: Fix compilation with fuse (RIB) on FreeBSD
Compilation failed on FreeBSD 14 with fuse enabled because of some
missing definitions. __XSI_VISIBLE must be set before including
<ouroboros/rib.h> for some definitions in <sys/stat.h>. FreeBSD
doesn't know the MSG_CONFIRM flag to sendto() or
CLOCK_REALTIME_COARSE, which are Linux-specific.
Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks>
Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
Diffstat (limited to 'src')
-rw-r--r-- | src/ipcpd/udp/main.c | 12 | ||||
-rw-r--r-- | src/ipcpd/unicast/dt.c | 1 | ||||
-rw-r--r-- | src/ipcpd/unicast/fa.c | 5 | ||||
-rw-r--r-- | src/ipcpd/unicast/pol/link_state.c | 1 | ||||
-rw-r--r-- | src/lib/rib.c | 9 |
5 files changed, 21 insertions, 7 deletions
diff --git a/src/ipcpd/udp/main.c b/src/ipcpd/udp/main.c index 03de24ab..6a3fb24a 100644 --- a/src/ipcpd/udp/main.c +++ b/src/ipcpd/udp/main.c @@ -75,6 +75,12 @@ #define MGMT_FRAME_SIZE (sizeof(struct mgmt_msg)) #define MGMT_FRAME_BUF_SIZE 2048 +#ifdef __linux__ +#define SENDTO_FLAGS MSG_CONFIRM +#else +#define SENDTO_FLAGS 0 +#endif + struct ipcp ipcpi; /* Keep order for alignment. */ @@ -216,7 +222,7 @@ static int ipcp_udp_port_alloc(const struct sockaddr_in * r_saddr, memcpy(buf + len, data, dlen); if (sendto(udp_data.s_fd, msg, len + dlen, - MSG_CONFIRM, + SENDTO_FLAGS, (const struct sockaddr *) r_saddr, sizeof(*r_saddr)) < 0) { free(buf); return -1; @@ -249,7 +255,7 @@ static int ipcp_udp_port_alloc_resp(const struct sockaddr_in * r_saddr, memcpy(msg + 1, data, len); if (sendto(udp_data.s_fd, msg, sizeof(*msg) + len, - MSG_CONFIRM, + SENDTO_FLAGS, (const struct sockaddr *) r_saddr, sizeof(*r_saddr)) < 0 ) { free(msg); return -1; @@ -552,7 +558,7 @@ static void * ipcp_udp_packet_writer(void * o) pthread_cleanup_push(cleanup_sdb, sdb); if (sendto(udp_data.s_fd, buf, len + OUR_HEADER_LEN, - MSG_CONFIRM, + SENDTO_FLAGS, (const struct sockaddr *) &saddr, sizeof(saddr)) < 0) log_err("Failed to send packet."); diff --git a/src/ipcpd/unicast/dt.c b/src/ipcpd/unicast/dt.c index 92496e54..c57ce031 100644 --- a/src/ipcpd/unicast/dt.c +++ b/src/ipcpd/unicast/dt.c @@ -24,6 +24,7 @@ #define _DEFAULT_SOURCE #else #define _POSIX_C_SOURCE 200112L +#define __XSI_VISIBLE 500 #endif #include "config.h" diff --git a/src/ipcpd/unicast/fa.c b/src/ipcpd/unicast/fa.c index 71351d5a..14303a21 100644 --- a/src/ipcpd/unicast/fa.c +++ b/src/ipcpd/unicast/fa.c @@ -24,6 +24,7 @@ #define _DEFAULT_SOURCE #else #define _POSIX_C_SOURCE 200112L +#define __XSI_VISIBLE 500 #endif #include "config.h" @@ -51,6 +52,10 @@ #include <stdlib.h> #include <string.h> +#if defined (IPCP_FLOW_STATS) && !defined(CLOCK_REALTIME_COARSE) +#define CLOCK_REALTIME_COARSE CLOCK_REALTIME +#endif + #define TIMEOUT 10000 /* nanoseconds */ #define FLOW_REQ 0 diff --git a/src/ipcpd/unicast/pol/link_state.c b/src/ipcpd/unicast/pol/link_state.c index cca85d63..69044889 100644 --- a/src/ipcpd/unicast/pol/link_state.c +++ b/src/ipcpd/unicast/pol/link_state.c @@ -24,6 +24,7 @@ #define _DEFAULT_SOURCE #else #define _POSIX_C_SOURCE 200112L +#define __XSI_VISIBLE 500 #endif #include "config.h" diff --git a/src/lib/rib.c b/src/lib/rib.c index d9f59a3e..0418252b 100644 --- a/src/lib/rib.c +++ b/src/lib/rib.c @@ -24,6 +24,10 @@ #include "config.h" +#if defined (__FreeBSD__) +#define __XSI_VISIBLE 500 +#endif + #include <ouroboros/errno.h> #include <ouroboros/list.h> #include <ouroboros/rib.h> @@ -41,9 +45,7 @@ #define FUSE_USE_VERSION 26 #if defined (__linux__) #define __USE_XOPEN -#elif defined (__FreeBSD__) -#define __XSI_VISIBLE 500 -#endif +#endif /* __linux__ */ #include <fuse.h> #ifndef CLOCK_REALTIME_COARSE @@ -266,7 +268,6 @@ static void * fuse_thr(void * o) } #endif /* HAVE_FUSE */ - int rib_init(const char * mountpt) { #ifdef HAVE_FUSE |