drop code dup between libosmo-mgcp-client and libosmo-mgcp

Remove mgcp_common.c and replace with mgcp_common.h.

Move mgcp_common.h from mgcp_client/ to mgcp/;
Place a compile-time copy of it back in mgcp_client/.

Add builddir/include to compiler -I paths to find generated header.

Rationale:
- Keep separate copies of the file for each of the library to not require
  debian dependencies between the two libraries.
- Avoid code dup by copying during 'make' (think: a generated header, BUILT_SOURCE).
- The copy does not have implications for linking (like mgcp_common.c did) nor
  is it a source for build confusion or fallout in other projects, because it
  does not reach across several git source trees (like gsm_data_shared.h did).

mgcp_connection_mode_strs are not actually used in libosmo-mgcp, so drop them.
(It would make semantic sense to have then in mgcp, but we can add it when it
is needed. A similar value string array remains in libosmo-mgcp-client.)

Change-Id: I7a5d3b9a2eb90be7e34b95efa529429f2e6c3ed8
diff --git a/include/Makefile.am b/include/Makefile.am
index 3cc4b1d..b52e5ea 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -9,6 +9,7 @@
 	osmocom/mgcp_client/mgcp_client.h \
 	osmocom/mgcp_client/mgcp_common.h \
 	osmocom/mgcp/mgcp.h \
+	osmocom/mgcp/mgcp_common.h \
 	osmocom/mgcp/mgcp_internal.h \
 	osmocom/mgcp/osmux.h \
 	$(NULL)
diff --git a/include/osmocom/mgcp/mgcp.h b/include/osmocom/mgcp/mgcp.h
index 67c499b..07d9516 100644
--- a/include/osmocom/mgcp/mgcp.h
+++ b/include/osmocom/mgcp/mgcp.h
@@ -28,6 +28,8 @@
 #include <osmocom/core/logging.h>
 #include <osmocom/mgcp/mgcp_ep.h>
 
+#include <osmocom/mgcp/mgcp_common.h>
+
 #include <arpa/inet.h>
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -167,21 +169,6 @@
 	MGCP_BSC_NAT,
 };
 
-enum mgcp_connection_mode {
-	MGCP_CONN_NONE = 0,
-	MGCP_CONN_RECV_ONLY = 1,
-	MGCP_CONN_SEND_ONLY = 2,
-	MGCP_CONN_RECV_SEND = MGCP_CONN_RECV_ONLY | MGCP_CONN_SEND_ONLY,
-	MGCP_CONN_LOOPBACK  = 4 | MGCP_CONN_RECV_SEND,
-};
-
-extern const struct value_string mgcp_connection_mode_strs[];
-
-static inline const char *mgcp_cmode_name(enum mgcp_connection_mode mode)
-{
-	return get_value_string(mgcp_connection_mode_strs, mode);
-}
-
 struct mgcp_config {
 	int source_port;
 	char *local_ip;
diff --git a/include/osmocom/mgcp_client/mgcp_common.h b/include/osmocom/mgcp/mgcp_common.h
similarity index 100%
rename from include/osmocom/mgcp_client/mgcp_common.h
rename to include/osmocom/mgcp/mgcp_common.h
diff --git a/include/osmocom/mgcp/mgcp_internal.h b/include/osmocom/mgcp/mgcp_internal.h
index 3a22d51..751aba5 100644
--- a/include/osmocom/mgcp/mgcp_internal.h
+++ b/include/osmocom/mgcp/mgcp_internal.h
@@ -330,5 +330,3 @@
 		return endp->cfg->net_ports.bind_addr;
 	return endp->cfg->source_addr;
 }
-
-int mgcp_msg_terminate_nul(struct msgb *msg);
diff --git a/include/osmocom/mgcp_client/Makefile.am b/include/osmocom/mgcp_client/Makefile.am
index 24401f1..0eaafcc 100644
--- a/include/osmocom/mgcp_client/Makefile.am
+++ b/include/osmocom/mgcp_client/Makefile.am
@@ -1,3 +1,11 @@
+BUILT_SOURCES = \
+	mgcp_common.h \
+	$(NULL)
+
 noinst_HEADERS = \
 	mgcp_client_internal.h \
 	$(NULL)
+
+mgcp_common.h: $(top_srcdir)/include/osmocom/mgcp/mgcp_common.h
+	echo -e "/*\n\n   DO NOT EDIT THIS FILE!\n   THIS IS OVERWRITTEN DURING BUILD\n   This is an automatic copy of <osmocom/mgcp/mgcp_common.h>\n\n */" > mgcp_common.h
+	cat $(top_srcdir)/include/osmocom/mgcp/mgcp_common.h >> mgcp_common.h