Merge branch 'master' of git.osmocom.org:libosmocore
diff --git a/include/osmocom/core/bitvec.h b/include/osmocom/core/bitvec.h
index bbe1641..7cb8a87 100644
--- a/include/osmocom/core/bitvec.h
+++ b/include/osmocom/core/bitvec.h
@@ -23,6 +23,7 @@
  *
  */
 
+#include <stdint.h>
 
 /* In GSM mac blocks, every bit can be 0 or 1, or L or H.  L/H are
  * defined relative to the 0x2b padding pattern */
diff --git a/include/osmocom/gsm/abis_nm.h b/include/osmocom/gsm/abis_nm.h
index dcc8d4b..3f5335e 100644
--- a/include/osmocom/gsm/abis_nm.h
+++ b/include/osmocom/gsm/abis_nm.h
@@ -2,8 +2,12 @@
 #define _OSMO_GSM_ABIS_NM_H
 
 #include <osmocom/gsm/tlv.h>
+#include <osmocom/gsm/gsm_utils.h>
 #include <osmocom/gsm/protocol/gsm_12_21.h>
 
+enum abis_nm_msgtype;
+enum gsm_phys_chan_config;
+
 const enum abis_nm_msgtype abis_nm_reports[4];
 const enum abis_nm_msgtype abis_nm_no_ack_nack[3];
 const enum abis_nm_msgtype abis_nm_sw_load_msgs[9];
diff --git a/include/osmocom/gsm/sysinfo.h b/include/osmocom/gsm/sysinfo.h
index a66f3f1..6c81134 100644
--- a/include/osmocom/gsm/sysinfo.h
+++ b/include/osmocom/gsm/sysinfo.h
@@ -1,6 +1,7 @@
 #ifndef _OSMO_GSM_SYSINFO_H
 #define _OSMO_GSM_SYSINFO_H
 
+#include <osmocom/core/utils.h>
 #include <osmocom/gsm/protocol/gsm_04_08.h>
 
 enum osmo_sysinfo_type {
diff --git a/src/gsm/sysinfo.c b/src/gsm/sysinfo.c
index 0dbff3a..9df1887 100644
--- a/src/gsm/sysinfo.c
+++ b/src/gsm/sysinfo.c
@@ -23,7 +23,6 @@
 #include <errno.h>
 #include <string.h>
 #include <stdio.h>
-#include <netinet/in.h>
 
 #include <osmocom/core/bitvec.h>
 #include <osmocom/core/utils.h>
@@ -71,7 +70,7 @@
 	[SYSINFO_TYPE_5ter]	= RSL_SYSTEM_INFO_5ter,
 };
 
-static const uint8_t rsl2sitype[0xff] = {
+static const uint8_t rsl2sitype[256] = {
 	[RSL_SYSTEM_INFO_1] = SYSINFO_TYPE_1,
 	[RSL_SYSTEM_INFO_2] = SYSINFO_TYPE_2,
 	[RSL_SYSTEM_INFO_3] = SYSINFO_TYPE_3,
diff --git a/src/gsmtap_util.c b/src/gsmtap_util.c
index 3d20bfc..9545865 100644
--- a/src/gsmtap_util.c
+++ b/src/gsmtap_util.c
@@ -197,16 +197,13 @@
 	rc = write(ofd->fd, msg->data, msg->len);
 	if (rc < 0) {
 		perror("writing msgb to gsmtap fd");
-		msgb_free(msg);
 		return rc;
 	}
 	if (rc != msg->len) {
 		perror("short write to gsmtap fd");
-		msgb_free(msg);
 		return -EIO;
 	}
 
-	msgb_free(msg);
 	return 0;
 }
 
diff --git a/src/socket.c b/src/socket.c
index 66907c8..0be98b9 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -6,10 +6,8 @@
 #include <osmocom/core/select.h>
 #include <osmocom/core/socket.h>
 
-#include <arpa/inet.h>
 #include <sys/socket.h>
 #include <sys/types.h>
-#include <netinet/in.h>
 
 #include <stdio.h>
 #include <unistd.h>
@@ -33,6 +31,9 @@
 	hints.ai_flags = 0;
 	hints.ai_protocol = proto;
 
+	if (connect0_bind1)
+		hints.ai_flags |= AI_PASSIVE;
+
 	rc = getaddrinfo(host, portbuf, &hints, &result);
 	if (rc != 0) {
 		perror("getaddrinfo returned NULL");
@@ -169,6 +170,8 @@
 	}
 
 	for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) {
+		if (!ifa->ifa_addr)
+			continue;
 		if (sockaddr_equal(ifa->ifa_addr, addr, addrlen))
 			return 1;
 	}