[PATCH] libosmocore[master]: stats: Build UDP socket code only if sys/socket.h exists

Harald Welte gerrit-no-reply at lists.osmocom.org
Sun Jan 15 17:07:24 UTC 2017


Review at  https://gerrit.osmocom.org/1607

stats: Build UDP socket code only if sys/socket.h exists

Change-Id: I6beb4fcc394ed7d3f8dd7a097b6e998245ecf401
---
M include/osmocom/core/stats.h
M src/stats.c
2 files changed, 17 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/07/1607/1

diff --git a/include/osmocom/core/stats.h b/include/osmocom/core/stats.h
index f754e41..cb5c62f 100644
--- a/include/osmocom/core/stats.h
+++ b/include/osmocom/core/stats.h
@@ -19,7 +19,11 @@
  */
 #pragma once
 
+#ifdef HAVE_SYS_SOCKET_H
 #include <sys/socket.h>
+#include <arpa/inet.h>
+#endif
+
 #include <osmocom/core/linuxlist.h>
 
 #include <stdint.h>
@@ -59,10 +63,12 @@
 
 	/* state */
 	int running;
+#ifdef HAVE_SYS_SOCKET_H
 	struct sockaddr dest_addr;
 	int dest_addr_len;
 	struct sockaddr bind_addr;
 	int bind_addr_len;
+#endif
 	int fd;
 	struct msgb *buffer;
 	int agg_enabled;
diff --git a/src/stats.c b/src/stats.c
index 1efc8cd..039f1cb 100644
--- a/src/stats.c
+++ b/src/stats.c
@@ -21,6 +21,8 @@
  *
  */
 
+#include "config.h"
+
 #include <osmocom/core/stats.h>
 
 #include <unistd.h>
@@ -29,9 +31,6 @@
 #include <errno.h>
 #include <stdio.h>
 #include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
 
 #include <osmocom/core/utils.h>
 #include <osmocom/core/logging.h>
@@ -162,6 +161,8 @@
 	return NULL;
 }
 
+#ifdef HAVE_SYS_SOCKET_H
+
 int osmo_stats_reporter_set_remote_addr(struct osmo_stats_reporter *srep, const char *addr)
 {
 	int rc;
@@ -239,6 +240,7 @@
 
 	return update_srep_config(srep);
 }
+#endif
 
 int osmo_stats_reporter_set_max_class(struct osmo_stats_reporter *srep,
 	enum osmo_stats_class class_id)
@@ -287,6 +289,11 @@
 }
 
 /*** i/o helper functions ***/
+
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
 
 int osmo_stats_reporter_udp_open(struct osmo_stats_reporter *srep)
 {
@@ -380,6 +387,7 @@
 
 	return rc;
 }
+#endif /* HAVE_SYS_SOCKET_H */
 
 /*** log reporter ***/
 

-- 
To view, visit https://gerrit.osmocom.org/1607
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6beb4fcc394ed7d3f8dd7a097b6e998245ecf401
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>


More information about the gerrit-log mailing list