aboutsummaryrefslogtreecommitdiffstats
path: root/src/hnbgw_rua.c
diff options
context:
space:
mode:
authorNeels Hofmeyr <nhofmeyr@sysmocom.de>2017-07-03 16:49:43 +0200
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2017-07-05 13:04:15 +0200
commit0f88c110093935305143987638e46dc6db304a3e (patch)
tree1eb1f62c8c8e8d9ccbf37a24a84be57703ba65df /src/hnbgw_rua.c
parent12ed975996f41fe1218c06fca3755047475084a6 (diff)
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
Diffstat (limited to 'src/hnbgw_rua.c')
-rw-r--r--src/hnbgw_rua.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/src/hnbgw_rua.c b/src/hnbgw_rua.c
index 6190fd0..329f990 100644
--- a/src/hnbgw_rua.c
+++ b/src/hnbgw_rua.c
@@ -24,7 +24,6 @@
#include <osmocom/netif/stream.h>
#include <osmocom/sigtran/sccp_sap.h>
-#include <osmocom/sigtran/sua.h>
#include <unistd.h>
#include <errno.h>
@@ -170,15 +169,19 @@ static int rua_to_scu(struct hnb_context *hnb,
struct msgb *msg;
struct osmo_scu_prim *prim;
struct hnbgw_context_map *map;
- struct hnbgw_cnlink *cn;
+ struct hnbgw_cnlink *cn = hnb->gw->sccp.cnlink;
+ struct osmo_sccp_addr *remote_addr;
+ bool is_ps;
int rc;
switch (cN_DomainIndicator) {
case RUA_CN_DomainIndicator_cs_domain:
- cn = hnb->gw->cnlink_cs;
+ remote_addr = &hnb->gw->sccp.remote_addr_cs;
+ is_ps = false;
break;
case RUA_CN_DomainIndicator_ps_domain:
- cn = hnb->gw->cnlink_ps;
+ remote_addr = &hnb->gw->sccp.remote_addr_ps;
+ is_ps = true;
break;
default:
LOGP(DRUA, LOGL_ERROR, "Unsupported Domain %u\n",
@@ -191,16 +194,19 @@ static int rua_to_scu(struct hnb_context *hnb,
return 0;
}
+ msg = msgb_alloc(1500, "rua_to_sccp");
+
prim = (struct osmo_scu_prim *) msgb_put(msg, sizeof(*prim));
osmo_prim_init(&prim->oph, SCCP_SAP_USER, type, PRIM_OP_REQUEST, msg);
- map = context_map_alloc_by_hnb(hnb, context_id, cn);
+ map = context_map_alloc_by_hnb(hnb, context_id, is_ps, cn);
+ OSMO_ASSERT(map);
/* add primitive header */
switch (type) {
case OSMO_SCU_PRIM_N_CONNECT:
- prim->u.connect.called_addr;
- prim->u.connect.calling_addr;
+ prim->u.connect.called_addr = *remote_addr;
+ prim->u.connect.calling_addr = cn->gw->sccp.local_addr;
prim->u.connect.sccp_class = 2;
prim->u.connect.conn_id = map->scu_conn_id;
break;
@@ -212,8 +218,8 @@ static int rua_to_scu(struct hnb_context *hnb,
prim->u.disconnect.cause = cause;
break;
case OSMO_SCU_PRIM_N_UNITDATA:
- prim->u.unitdata.called_addr;
- prim->u.unitdata.calling_addr;
+ prim->u.unitdata.called_addr = *remote_addr;
+ prim->u.unitdata.calling_addr = cn->gw->sccp.local_addr;
break;
default:
return -EINVAL;
@@ -225,7 +231,7 @@ static int rua_to_scu(struct hnb_context *hnb,
memcpy(msg->l2h, data, len);
}
- rc = osmo_sua_user_link_down(cn->sua_link, &prim->oph);
+ rc = osmo_sccp_user_sap_down(cn->sccp_user, &prim->oph);
return rc;
}