aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2012-07-12 14:13:41 +0200
committerHolger Hans Peter Freyther <zecke@selfish.org>2012-07-12 14:13:41 +0200
commit3c16de295480f269a1610c6d2cc559718c39c202 (patch)
tree3eb64f911521cf102d80a27f8062af5de0bfb1d2
parent3c6a2cef5ed692ba20a925357bbbae13ae8d80db (diff)
freebsd: Make libgb compile on FreeBSD
Include header files for recfrom/AF_INET and include a struct ip_hdr as it is not available on *BSD.
-rw-r--r--src/gb/gprs_ns.c2
-rw-r--r--src/gb/gprs_ns_frgre.c36
2 files changed, 38 insertions, 0 deletions
diff --git a/src/gb/gprs_ns.c b/src/gb/gprs_ns.c
index cdee8338..aa7ff939 100644
--- a/src/gb/gprs_ns.c
+++ b/src/gb/gprs_ns.c
@@ -66,6 +66,8 @@
#include <errno.h>
#include <stdint.h>
+#include <sys/types.h>
+#include <sys/socket.h>
#include <arpa/inet.h>
#include <osmocom/core/msgb.h>
diff --git a/src/gb/gprs_ns_frgre.c b/src/gb/gprs_ns_frgre.c
index be5f0f6c..23443812 100644
--- a/src/gb/gprs_ns_frgre.c
+++ b/src/gb/gprs_ns_frgre.c
@@ -48,6 +48,42 @@ struct gre_hdr {
uint16_t ptype;
} __attribute__ ((packed));
+#if defined(__FreeBSD__)
+/**
+ * On BSD the IPv4 struct is called struct ip and instead of iXX
+ * the members are called ip_XX. One could change this code to use
+ * struct ip but that would require to define _BSD_SOURCE and that
+ * might have other complications. Instead make sure struct iphdr
+ * is present on FreeBSD. The below is taken from GLIBC.
+ *
+ * The GNU C Library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ */
+struct iphdr
+ {
+#if BYTE_ORDER == LITTLE_ENDIAN
+ unsigned int ihl:4;
+ unsigned int version:4;
+#elif BYTE_ORDER == BIG_ENDIAN
+ unsigned int version:4;
+ unsigned int ihl:4;
+#endif
+ u_int8_t tos;
+ u_int16_t tot_len;
+ u_int16_t id;
+ u_int16_t frag_off;
+ u_int8_t ttl;
+ u_int8_t protocol;
+ u_int16_t check;
+ u_int32_t saddr;
+ u_int32_t daddr;
+ /*The options start here. */
+ };
+#endif
+
+
/* IPv4 messages inside the GRE tunnel might be GRE keepalives */
static int handle_rx_gre_ipv4(struct osmo_fd *bfd, struct msgb *msg,
struct iphdr *iph, struct gre_hdr *greh)