[PATCH] libosmocore[master]: gsm0808 + ipa: fix compilation on systems without sys/socket.h

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/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Mon May 15 11:14:19 UTC 2017


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

gsm0808 + ipa: fix compilation on systems without sys/socket.h

Change-Id: I60f5d4982cd96ab29f9924ec11b46bf56fbfc346
---
M include/osmocom/gsm/gsm0808.h
M include/osmocom/gsm/gsm0808_utils.h
M src/gsm/gsm0808_utils.c
M src/gsm/ipa.c
4 files changed, 17 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/27/2627/1

diff --git a/include/osmocom/gsm/gsm0808.h b/include/osmocom/gsm/gsm0808.h
index a9f610a..9be229c 100644
--- a/include/osmocom/gsm/gsm0808.h
+++ b/include/osmocom/gsm/gsm0808.h
@@ -21,7 +21,7 @@
 
 #include "tlv.h"
 #include <osmocom/gsm/protocol/gsm_08_08.h>
-#include <sys/socket.h>
+struct sockaddr_storage;
 
 struct msgb;
 
diff --git a/include/osmocom/gsm/gsm0808_utils.h b/include/osmocom/gsm/gsm0808_utils.h
index e6e55a7..c11bf8d 100644
--- a/include/osmocom/gsm/gsm0808_utils.h
+++ b/include/osmocom/gsm/gsm0808_utils.h
@@ -19,7 +19,7 @@
  */
 #pragma once
 
-#include <sys/socket.h>
+struct sockaddr_storage;
 
 #include <osmocom/gsm/protocol/gsm_08_08.h>
 
diff --git a/src/gsm/gsm0808_utils.c b/src/gsm/gsm0808_utils.c
index 2fa265a..ff97b2d 100644
--- a/src/gsm/gsm0808_utils.c
+++ b/src/gsm/gsm0808_utils.c
@@ -18,12 +18,12 @@
  *
  */
 
+#include "config.h"
+
 #include <osmocom/core/utils.h>
 #include <osmocom/core/msgb.h>
 #include <osmocom/core/byteswap.h>
 #include <string.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
 #include <errno.h>
 #include <osmocom/gsm/protocol/gsm_08_08.h>
 
@@ -35,6 +35,10 @@
 #define CHANNEL_TYPE_ELEMENT_MINLEN 3
 #define ENCRYPT_INFO_ELEMENT_MINLEN 1
 
+#ifdef HAVE_SYS_SOCKET_H
+
+#include <sys/socket.h>
+#include <netinet/in.h>
 /* Encode AoIP transport address element */
 uint8_t gsm0808_enc_aoip_trasp_addr(struct msgb *msg,
 				    const struct sockaddr_storage *ss)
@@ -125,6 +129,8 @@
 	return (int)(elem - old_elem);
 }
 
+#endif /* HAVE_SYS_SOCKET_H */
+
 /* Helper function for gsm0808_enc_speech_codec()
  * and gsm0808_enc_speech_codec_list() */
 static uint8_t enc_speech_codec(struct msgb *msg,
diff --git a/src/gsm/ipa.c b/src/gsm/ipa.c
index 90cf0eb..fa6a8b0 100644
--- a/src/gsm/ipa.c
+++ b/src/gsm/ipa.c
@@ -21,13 +21,14 @@
  *
  */
 
+#include "config.h"
+
 #include <unistd.h>
 #include <stdint.h>
 #include <errno.h>
 #include <stdlib.h>
 
 #include <sys/types.h>
-#include <sys/socket.h>
 
 #include <osmocom/core/byteswap.h>
 #include <osmocom/core/msgb.h>
@@ -435,6 +436,9 @@
 	hh->proto = proto;
 }
 
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+
 int ipa_msg_recv(int fd, struct msgb **rmsg)
 {
 	int rc = ipa_msg_recv_buffered(fd, rmsg, NULL);
@@ -564,6 +568,8 @@
 	return ret;
 }
 
+#endif /* SYS_SOCKET_H */
+
 struct msgb *ipa_msg_alloc(int headroom)
 {
 	struct msgb *nmsg;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I60f5d4982cd96ab29f9924ec11b46bf56fbfc346
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