Introduce netns API

Write a new API and implementation to manage network namespace related
operations.

This will be used by the upcoming tundev module.

Change-Id: I0f2fba2fa42250a07211a7b7f479498f27c529da
diff --git a/include/osmocom/core/Makefile.am b/include/osmocom/core/Makefile.am
index 1b0a1ce..e88ce89 100644
--- a/include/osmocom/core/Makefile.am
+++ b/include/osmocom/core/Makefile.am
@@ -35,6 +35,7 @@
 	stats.h \
 	macaddr.h \
 	msgb.h \
+	netns.h \
 	panic.h \
 	prbs.h \
 	prim.h \
diff --git a/include/osmocom/core/netns.h b/include/osmocom/core/netns.h
new file mode 100644
index 0000000..5bbf224
--- /dev/null
+++ b/include/osmocom/core/netns.h
@@ -0,0 +1,24 @@
+/*! \file netns.h
+ *  Network namespace convenience functions. */
+
+#pragma once
+#if (!EMBEDDED)
+
+#if defined(__linux__)
+
+#include <signal.h>
+
+struct osmo_netns_switch_state {
+	sigset_t prev_sigmask;
+	int prev_nsfd;
+};
+
+int osmo_netns_open_fd(const char *name);
+int osmo_netns_switch_enter(int nsfd, struct osmo_netns_switch_state *state);
+int osmo_netns_switch_exit(struct osmo_netns_switch_state *state);
+
+
+#endif /* defined(__linux__) */
+
+#endif /* (!EMBEDDED) */
+/*! @} */