migrate osmo-hnbgw to libosmo-sigtran's SCCP/M3UA

libosmo-sigtran now has a "proper" SCCP/M3UA stack, so we can make our hnb-gw
3GPP compliant by switching from the old SUA code to the new universal SCCP
user API with support for (currently) M3UA and SUA.

Main changes:

Use one cn_link to STP: We will connect to the core network using an (Osmo)STP
instance that routes to MSC and SGSN, so we want one SCCP link instead of two.
The only difference between IuCS and IuPS is a different remote osmo_sccp_addr.

This has various effects through the messaging code; the patch is a bit larger
than I would like, but it is hard to separate out truly independent smaller
changes.

CS or PS domain was previously flagged in the separate cn_link, as ctx pointer
for two separate sccp_sap_up()s. Now there's just one such ctx, so determine
is_ps from the RANAP Domain Indicator, or from the conn's hnbgw_context_map:

- Add is_ps to context_map_alloc_by_hnb().
- To find a matching context, the RUA ID alone is no longer sufficient, also
  match is_ps (possible optimization todo: separate lists).

We would send separate CS or PS Reset messages based on the cn_link, instead
send both CS and PS Reset at the same time for the single cn_link. This could
be adjusted to detect presence of MSC or SGSN instead.

Pending: adjust the VTY config to reflect that there is only one remote
address. Place a TODO comment for that.

Smaller changes:

rua_to_scu(): populate called and calling addresses for N_CONNECT and
N_UNITDATA.

Remove DSUA.

Don't build dummy_cn, which is still implemented on SUA. Mark todo to maybe
re-include it based on M3UA later.

In hnbgw_cnlink, place sccp related items in a separate sub-struct.

Do not keep an llist of cn_links, just have the one. Remove iteration and list
management.

Change jenkins script to build libosmo-sccp master.

Patch-by: hwelte, nhofmeyr
Change-Id: I8ac15fa2fd25bedb26297177e416976a5389b573
diff --git a/src/context_map.c b/src/context_map.c
index 052133c..0960cb9 100644
--- a/src/context_map.c
+++ b/src/context_map.c
@@ -58,6 +58,7 @@
 /* Map from a HNB + ContextID to the SCCP-side Connection ID */
 struct hnbgw_context_map *
 context_map_alloc_by_hnb(struct hnb_context *hnb, uint32_t rua_ctx_id,
+			 bool is_ps,
 			 struct hnbgw_cnlink *cn_if_new)
 {
 	struct hnbgw_context_map *map;
@@ -69,7 +70,8 @@
 		if (map->cn_link != cn_if_new) {
 			continue;
 		}
-		if (map->rua_ctx_id == rua_ctx_id) {
+		if (map->rua_ctx_id == rua_ctx_id
+		    && map->is_ps == is_ps) {
 			return map;
 		}
 	}
@@ -88,6 +90,7 @@
 	map->cn_link = cn_if_new;
 	map->hnb_ctx = hnb;
 	map->rua_ctx_id = rua_ctx_id;
+	map->is_ps = is_ps;
 	map->scu_conn_id = new_scu_conn_id;
 
 	/* put it into both lists */
@@ -134,31 +137,27 @@
 static void context_map_tmr_cb(void *data)
 {
 	struct hnb_gw *gw = data;
-	struct hnbgw_cnlink *cn;
+	struct hnbgw_cnlink *cn = gw->sccp.cnlink;
+	struct hnbgw_context_map *map;
 
 	DEBUGP(DMAIN, "Running context mapper garbage collection\n");
-	/* iterate over list of core network (links) */
-	llist_for_each_entry(cn, &gw->cn_list, list) {
-		struct hnbgw_context_map *map;
-
-		llist_for_each_entry(map, &cn->map_list, cn_list) {
-			switch (map->state) {
-			case MAP_S_RESERVED1:
-				/* first time we see this reserved
-				 * entry: mark it for stage 2 */
-				map->state = MAP_S_RESERVED2;
-				break;
-			case MAP_S_RESERVED2:
-				/* first time we see this reserved
-				 * entry: remove it */
-				map->state = MAP_S_NULL;
-				llist_del(&map->cn_list);
-				llist_del(&map->hnb_list);
-				talloc_free(map);
-				break;
-			default:
-				break;
-			}
+	llist_for_each_entry(map, &cn->map_list, cn_list) {
+		switch (map->state) {
+		case MAP_S_RESERVED1:
+			/* first time we see this reserved
+			 * entry: mark it for stage 2 */
+			map->state = MAP_S_RESERVED2;
+			break;
+		case MAP_S_RESERVED2:
+			/* first time we see this reserved
+			 * entry: remove it */
+			map->state = MAP_S_NULL;
+			llist_del(&map->cn_list);
+			llist_del(&map->hnb_list);
+			talloc_free(map);
+			break;
+		default:
+			break;
 		}
 	}
 	/* re-schedule this timer */