IuPS: osmo-sgsn: add core IuPS impl, call iu_init()

Add main Iu entry points for IuPS:
* gsm0408_gprs_rcvmsg_iu()
* sgsn_ranap_iu_event()
* sgsn_ranap_rab_ass_resp()

Add main MM context management for IuPS:
* sgsn_mm_ctx_by_ue_ctx()
* sgsn_mm_ctx_alloc_iu()

Call iu_init() from sgsn_main.c.

Add asn_debug impl ("extern" from libasn1c).
Initialize asn_debug VTY command (iu_vty_init()).

osmo-sgsn build: add libiu and libasn1c, libosmo-sigtran, libosmo-ranap

Change-Id: I469ae6ca9ef254d04ee0d2d79bdd65aebcd027b5
diff --git a/openbsc/src/gprs/sgsn_main.c b/openbsc/src/gprs/sgsn_main.c
index 52fc985..7d533c0 100644
--- a/openbsc/src/gprs/sgsn_main.c
+++ b/openbsc/src/gprs/sgsn_main.c
@@ -56,6 +56,8 @@
 #include <openbsc/sgsn.h>
 #include <openbsc/gprs_llc.h>
 #include <openbsc/gprs_gmm.h>
+#include <openbsc/iu.h>
+
 #include <osmocom/ctrl/control_if.h>
 #include <osmocom/ctrl/ports.h>
 
@@ -300,6 +302,13 @@
 	.num_cat = ARRAY_SIZE(gprs_categories),
 };
 
+/* Implement the extern asn_debug from libasn1c to indicate whether the ASN.1
+ * binary code decoded and encoded during Iu communication should be logged to
+ * stderr. See osmocom's libasn1c, asn_internal.h, at "if (asn_debug)":
+ * http://git.osmocom.org/libasn1c/tree/include/asn1c/asn_internal.h */
+int asn_debug = 0;
+
+int sgsn_ranap_iu_event(struct ue_conn_ctx *ctx, enum iu_event_type type, void *data);
 
 int main(int argc, char **argv)
 {
@@ -326,6 +335,9 @@
 	osmo_stats_vty_add_cmds(&gprs_log_info);
 	sgsn_vty_init();
 	ctrl_vty_init(tall_bsc_ctx);
+#ifdef BUILD_IU
+	iu_vty_init(&asn_debug);
+#endif
 
 	handle_options(argc, argv);
 
@@ -417,6 +429,10 @@
 		}
 	}
 
+#ifdef BUILD_IU
+	iu_init(tall_bsc_ctx, "127.0.0.2", 14001, gsm0408_gprs_rcvmsg_iu, sgsn_ranap_iu_event);
+#endif
+
 	if (daemonize) {
 		rc = osmo_daemonize();
 		if (rc < 0) {