add 3G CN: osmo-hlr, osmocom-3g, osmo-iuh, libasn1c

Copy openbsc to osmocom-3g (for lack of a better name) to build the vlr_3G
branch of openbsc.git, producing osmo-msc, osmo-sgsn with Iu capabilities and
osmo-bsc_mgcp (now a misnomer) to direct RTP streams.

Add osmo-hlr.

Add osmo-iuh for osmo-hnbgw, and libosmo-ranap dependency of osmocom-3g.

Add libasn1c.
diff --git a/recipes-osmocom/osmocom-3g/.osmo-msc_git.bb.swp b/recipes-osmocom/osmocom-3g/.osmo-msc_git.bb.swp
new file mode 100644
index 0000000..042d535
--- /dev/null
+++ b/recipes-osmocom/osmocom-3g/.osmo-msc_git.bb.swp
Binary files differ
diff --git a/recipes-osmocom/osmocom-3g/osmocom-3g.inc b/recipes-osmocom/osmocom-3g/osmocom-3g.inc
new file mode 100644
index 0000000..b9d4197
--- /dev/null
+++ b/recipes-osmocom/osmocom-3g/osmocom-3g.inc
@@ -0,0 +1,82 @@
+DESCRIPTION = "OsmoMSC, OsmoSGSN, OsmoMGCP"
+DEPENDS = "libdbi libosmocore libosmo-sccp libosmo-abis libosmo-netif openggsn libsmpp34 bcg729 libgsm libpcap c-ares libasn1c osmo-iuh"
+HOMEPAGE = "http://osmocom.org/projects/osmomsc"
+LICENSE = "AGPLv3+"
+LIC_FILES_CHKSUM = "file://COPYING;md5=73f1eb20517c55bf9493b7dd6e480788"
+
+RDEPENDS_osmo-msc = "libdbd-sqlite3"
+
+SRC_URI = "file://osmo-msc.init \
+	   file://osmo-bsc_mgcp.init \
+	   file://osmo-sgsn.init"
+
+INC_PR = "r1.${META_TELEPHONY_OSMO_INC}"
+
+
+EXTRA_OECONF += " --enable-iu --enable-smpp --enable-mgcp-transcoding --with-g729"
+
+inherit autotools update-rc.d pkgconfig
+
+# because "${WORKDIR}/git" is not a git repo, it can't figure out the version
+do_configure_prepend() {
+	echo "${PV}" > ${S}/.tarball-version
+}
+
+do_install_append() {
+	install -d ${D}${sysconfdir}/osmocom
+	install -m 0660 ${S}/doc/examples/osmo-msc/osmo-msc.cfg ${D}${sysconfdir}/osmocom/osmo-msc.cfg
+	install -m 0660 ${S}/doc/examples/osmo-bsc_mgcp/mgcp.cfg ${D}${sysconfdir}/osmocom/osmo-bsc-mgcp.cfg
+	install -m 0660 ${S}/doc/examples/osmo-sgsn/osmo-sgsn.cfg ${D}${sysconfdir}/osmocom/osmo-sgsn.cfg
+
+	# Install sysv-init files
+	install -d ${D}${sysconfdir}/init.d
+	install -d ${D}${sysconfdir}/rc5.d
+	install -m 0775 ${WORKDIR}/osmo-msc.init ${D}${sysconfdir}/init.d/osmo-msc
+	install -m 0775 ${WORKDIR}/osmo-bsc_mgcp.init ${D}${sysconfdir}/init.d/osmo-bsc-mgcp
+	install -m 0775 ${WORKDIR}/osmo-sgsn.init ${D}${sysconfdir}/init.d/osmo-sgsn
+
+	# Install systemd files and enable on sysinit
+	install -d ${D}${systemd_unitdir}/system
+	for i in `ls ${S}/contrib/systemd`; do
+		install -m 0644 ${S}/contrib/systemd/$i ${D}${systemd_unitdir}/system/
+	done
+
+	install -d ${D}/var/lib/osmocom
+}
+
+PACKAGES =+ "osmo-msc osmo-sgsn osmo-bsc-mgcp ipaccess-utils"
+
+INITSCRIPT_PACKAGES = "osmo-msc osmo-sgsn osmo-bsc-mgcp"
+
+# Do not start any of the services by default
+SYSTEMD_AUTO_ENABLE = "disable"
+
+CONFFILES_osmo-msc = "${sysconfdir}/osmocom/osmo-msc.cfg"
+INITSCRIPT_NAME_osmo-msc = "osmo-msc"
+INITSCRIPT_PARAMS_osmo-msc = "defaults 30 30"
+FILES_osmo-msc = " ${bindir}/osmo-msc \
+		/var/lib/osmocom \
+		${sysconfdir}/init.d/osmo-msc \
+		${sysconfdir}/osmocom/osmo-msc.cfg \
+		${systemd_unitdir}/system/osmo-msc.service \
+		"
+
+CONFFILES_osmo-sgsn = "${sysconfdir}/osmocom/osmo-sgsn.cfg"
+INITSCRIPT_NAME_osmo-sgsn = "osmo-sgsn"
+INITSCRIPT_PARAMS_osmo-sgsn = "defaults 30 30"
+FILES_osmo-sgsn = " ${bindir}/osmo-sgsn \
+		${sysconfdir}/init.d/osmo-sgsn \
+		${sysconfdir}/osmocom/osmo-sgsn.cfg \
+		${systemd_unitdir}/system/osmo-sgsn.service \
+		"
+
+CONFFILES_osmo-bsc-mgcp = "${sysconfdir}/osmocom/osmo-bsc-mgcp.cfg"
+INITSCRIPT_NAME_osmo-bsc-mgcp = "osmo-bsc-mgcp"
+INITSCRIPT_PARAMS_osmo-bsc-mgcp = "defaults 30 30"
+FILES_osmo-bsc-mgcp = " ${bindir}/osmo-bsc_mgcp \
+		${sysconfdir}/osmocom/osmo-bsc-mgcp.cfg \
+		${sysconfdir}/init.d/osmo-bsc-mgcp \
+		${systemd_unitdir}/system/osmo-bsc-mgcp.service \
+		"
+
+FILES_ipaccess-utils = " ${bindir}/ipaccess-find ${bindir}/ipaccess-config ${bindir}/ipaccess-proxy "
diff --git a/recipes-osmocom/osmocom-3g/osmocom-3g/osmo-bsc_mgcp.init b/recipes-osmocom/osmocom-3g/osmocom-3g/osmo-bsc_mgcp.init
new file mode 100755
index 0000000..058ec80
--- /dev/null
+++ b/recipes-osmocom/osmocom-3g/osmocom-3g/osmo-bsc_mgcp.init
@@ -0,0 +1,48 @@
+#!/bin/sh
+### BEGIN INIT INFO
+# Provides:		osmo-bsc_mgcp
+# Required-Start:	$syslog $networking
+# Required-Stop:	$syslog
+# Default-Start:	5
+# Default-Stop:		1
+# Short-Description:	Osmocom MGCP proxy
+### END INIT INFO
+
+DAEMON=/usr/bin/osmo-bsc_mgcp
+NAME=osmo-bsc_mgcp
+DESC="Osmocom MGCP proxy"
+NORMAL_ARGS="-D -c /etc/osmocom/osmo-bsc-mgcp.cfg"
+
+OSMOBSCMGCP_EXTRA_ARGS=""
+NO_START=1
+
+set -e
+
+test ! -r /etc/default/osmo-bsc_mgcp || . /etc/default/osmo-bsc_mgcp
+test "$NO_START" = "0" || exit 0
+test -x "$DAEMON" || exit 0
+
+case "$1" in
+  start)
+	echo -n "Starting $DESC: "
+	start-stop-daemon -S \
+	  -x "$DAEMON" -- $NORMAL_ARGS $OSMOBSCMGCP_EXTRA_ARGS
+	echo "$NAME."
+	;;
+  stop)
+	echo -n "Stopping $DESC: "
+	start-stop-daemon -K -x "$DAEMON"
+	echo "$NAME."
+	;;
+  restart)
+	$0 stop
+	$0 start
+	;;
+  *)
+	N=/etc/init.d/$NAME
+	echo "Usage: $N {start|stop|restart}" >&2
+	exit 1
+	;;
+esac
+
+exit 0
diff --git a/recipes-osmocom/osmocom-3g/osmocom-3g/osmo-msc.init b/recipes-osmocom/osmocom-3g/osmocom-3g/osmo-msc.init
new file mode 100755
index 0000000..6369bbf
--- /dev/null
+++ b/recipes-osmocom/osmocom-3g/osmocom-3g/osmo-msc.init
@@ -0,0 +1,48 @@
+!/bin/sh
+### BEGIN INIT INFO
+# Provides:		osmo-msc
+# Required-Start:	$syslog $networking
+# Required-Stop:	$syslog
+# Default-Start:	5
+# Default-Stop:		1
+# Short-Description:	Osmocom MSC
+### END INIT INFO
+
+DAEMON=/usr/bin/osmo-msc
+NAME=osmo-msc
+DESC="Osmocom MSC"
+NORMAL_ARGS="-C -D -c /etc/osmocom/osmo-msc.cfg -l /var/lib/osmocom/sms.db"
+
+OSMOMSC_EXTRA_ARGS=""
+NO_START=1
+
+set -e
+
+test ! -r /etc/default/osmo-msc || . /etc/default/osmo-msc
+test "$NO_START" = "0" || exit 0
+test -x "$DAEMON" || exit 0
+
+case "$1" in
+  start)
+	echo -n "Starting $DESC: "
+	start-stop-daemon -S \
+	  -x "$DAEMON" -- $NORMAL_ARGS $OSMOMSC_EXTRA_ARGS
+	echo "$NAME."
+	;;
+  stop)
+	echo -n "Stopping $DESC: "
+	start-stop-daemon -K -x "$DAEMON"
+	echo "$NAME."
+	;;
+  restart|force-reload)
+	$0 stop
+	$0 start
+	;;
+  *)
+	N=/etc/init.d/$NAME
+	echo "Usage: $N {start|stop|restart}" >&2
+	exit 1
+	;;
+esac
+
+exit 0
diff --git a/recipes-osmocom/osmocom-3g/osmocom-3g/osmo-sgsn.init b/recipes-osmocom/osmocom-3g/osmocom-3g/osmo-sgsn.init
new file mode 100755
index 0000000..4481135
--- /dev/null
+++ b/recipes-osmocom/osmocom-3g/osmocom-3g/osmo-sgsn.init
@@ -0,0 +1,48 @@
+#!/bin/sh
+### BEGIN INIT INFO
+# Provides:		osmo-sgsn
+# Required-Start:	$syslog $networking
+# Required-Stop:	$syslog
+# Default-Start:	5
+# Default-Stop:		1
+# Short-Description:	Osmocom Serving GPRS Support Node
+### END INIT INFO
+
+DAEMON=/usr/bin/osmo-sgsn
+NAME=osmo-sgsn
+DESC="Osmocom Serving GPRS Support Node"
+NORMAL_ARGS="-D -c /etc/osmocom/osmo-sgsn.cfg"
+
+OSMOSGSN_EXTRA_ARGS=""
+NO_START=0
+
+set -e
+
+test ! -r /etc/default/osmo-sgsn || . /etc/default/osmo-sgsn
+test "$NO_START" = "0" || exit 0
+test -x "$DAEMON" || exit 0
+
+case "$1" in
+  start)
+	echo -n "Starting $DESC: "
+	start-stop-daemon -S \
+	  -x "$DAEMON" -- $NORMAL_ARGS $OSMOSGSN_EXTRA_ARGS
+	echo "$NAME."
+	;;
+  stop)
+	echo -n "Stopping $DESC: "
+	start-stop-daemon -K -x "$DAEMON"
+	echo "$NAME."
+	;;
+  restart|force-reload)
+	$0 stop
+	$0 start
+	;;
+  *)
+	N=/etc/init.d/$NAME
+	echo "Usage: $N {start|stop|restart}" >&2
+	exit 1
+	;;
+esac
+
+exit 0
diff --git a/recipes-osmocom/osmocom-3g/osmocom-3g/upgrade-mncc-version.patch b/recipes-osmocom/osmocom-3g/osmocom-3g/upgrade-mncc-version.patch
new file mode 100644
index 0000000..b856cc3
--- /dev/null
+++ b/recipes-osmocom/osmocom-3g/osmocom-3g/upgrade-mncc-version.patch
@@ -0,0 +1,17 @@
+lcr uses MNCC_SOCK_VERSION 5, but this is binary compatible to
+what openbsc thinks is version 4.  The only difference is the added
+RTP related commands, which are optional.
+
+Index: openbsc/include/openbsc/mncc.h
+===================================================================
+--- openbsc.orig/include/openbsc/mncc.h
++++ openbsc/include/openbsc/mncc.h
+@@ -163,7 +163,7 @@ struct gsm_data_frame {
+ 	unsigned char	data[0];
+ };
+ 
+-#define MNCC_SOCK_VERSION	4
++#define MNCC_SOCK_VERSION	5
+ struct gsm_mncc_hello {
+ 	uint32_t	msg_type;
+ 	uint32_t	version;
diff --git a/recipes-osmocom/osmocom-3g/osmocom-3g_git.bb b/recipes-osmocom/osmocom-3g/osmocom-3g_git.bb
new file mode 100644
index 0000000..b31d290
--- /dev/null
+++ b/recipes-osmocom/osmocom-3g/osmocom-3g_git.bb
@@ -0,0 +1,12 @@
+require ${PN}.inc
+
+PV = "0.14.0+gitr${SRCPV}"
+PRINC = "0"
+PR = "${INC_PR}.6"
+
+# openbsc.git branch vlr_3G
+SRCREV = "2e8ecf3af3c1ffab29357f45e4576b2d3b9268e4"
+SRC_URI += "git://git.osmocom.org/openbsc.git;protocol=git \
+    file://upgrade-mncc-version.patch"
+
+S = "${WORKDIR}/git/osmocom-3g"