stp: Create a M2UA link by hand and connect the SCCP routines

This is a hacked version that will just forward SCCP from one
linkset to another one. It is missing configuration and ISUP.
diff --git a/include/bsc_data.h b/include/bsc_data.h
index 932b229..2cd0257 100644
--- a/include/bsc_data.h
+++ b/include/bsc_data.h
@@ -81,6 +81,7 @@
 	int pcap_fd;
 	int udp_reset_timeout;
 	struct mtp_link_set *link_set;
+	struct mtp_link_set *m2ua_set;
 
 	const char *token;
 
diff --git a/src/Makefile.am b/src/Makefile.am
index dbed8fa..eb6ab11 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -22,6 +22,6 @@
 		   -lpthread -lnetsnmp -lcrypto -lm2ua -lsctp
 
 osmo_stp_SOURCES = main_stp.c mtp_layer3.c thread.c pcap.c link_udp.c snmp_mtp.c \
-		   debug.c vty_interface.c links.c isup.c
+		   debug.c vty_interface.c links.c isup.c sctp_m2ua.c
 osmo_stp_LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOSCCP_LIBS) $(LIBOSMOVTY_LIBS) $(NEXUSWARE_C7_LIBS) \
 		   -lpthread -lnetsnmp -lcrypto -lm2ua -lsctp
diff --git a/src/main_stp.c b/src/main_stp.c
index 568a4a6..c038b2b 100644
--- a/src/main_stp.c
+++ b/src/main_stp.c
@@ -27,6 +27,7 @@
 #include <bsc_data.h>
 #include <snmp_mtp.h>
 #include <cellmgr_debug.h>
+#include <sctp_m2ua.h>
 
 #include <osmocore/talloc.h>
 
@@ -68,6 +69,10 @@
  */
 void mtp_link_set_forward_sccp(struct mtp_link_set *link, struct msgb *_msg, int sls)
 {
+	struct mtp_link_set *target;
+
+	target = bsc.m2ua_set == link ? bsc.link_set : bsc.m2ua_set;
+	mtp_link_set_submit_sccp_data(target, sls, _msg->l2h, msgb_l2len(_msg));
 }
 
 void mtp_linkset_down(struct mtp_link_set *set)
@@ -167,6 +172,8 @@
 int main(int argc, char **argv)
 {
 	int rc;
+	struct mtp_link *data;
+	struct mtp_m2ua_link *lnk;
 	INIT_LLIST_HEAD(&bsc.sccp_connections);
 
 	bsc.dpc = 1;
@@ -224,6 +231,21 @@
 	if (link_init(&bsc) != 0)
 		return -1;
 
+	bsc.m2ua_set = mtp_link_set_alloc();
+	bsc.m2ua_set->dpc = 92;
+	bsc.m2ua_set->opc = 9;
+	bsc.m2ua_set->sccp_opc = 9;
+	bsc.m2ua_set->ni = 3;
+	bsc.m2ua_set->bsc = &bsc;
+
+	lnk = sctp_m2ua_transp_create("0.0.0.0", 2904);
+	lnk->base.pcap_fd = -1;
+	lnk->base.the_link = bsc.m2ua_set;
+	mtp_link_set_add_link(bsc.m2ua_set, (struct mtp_link *) lnk);
+
+	llist_for_each_entry(data, &bsc.m2ua_set->links, entry)
+		data->start(data);
+
         while (1) {
 		bsc_select_main(0);
         }