From 978e72e500ac5544ee9fbddbac03125f60fceef8 Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Wed, 12 Oct 2016 01:39:25 +0200 Subject: IuCS and IuPS: add VTY config for RAB Assignment address kind To accomodate the ip.access nano3G without having to recompile, make the RAB Assignment's Transport Layer Address IE's format configurable, in both osmo-msc and osmo-sgsn. The long term perspective is to somehow detect which address encoding a given 3G cell prefers, but for the time being just configure it globally and set each ue_conn_ctx to the global setting upon creation. Add VTY command to iu_vty.c, with args passed to iu_vty_init() to insert at an arbitrary VTY node, so that it can be used both for osmo-msc and osmo-sgsn. Add generic iu_vty_config_write() to write out the config. Call iu_vty_init() from msc_vty_init(); msc_vty_init() is in libmsc, hence linking of osmo-msc now needs libiu to come after libmsc, so move that further down. Change-Id: I93728314742b327336f3fb6de98e6457f687e1f9 --- openbsc/src/gprs/gprs_gmm.c | 4 +++ openbsc/src/gprs/gprs_sgsn.c | 1 + openbsc/src/gprs/sgsn_vty.c | 10 +++++++- openbsc/src/libiu/iu_vty.c | 55 +++++++++++++++++++++++++++++++++++++++- openbsc/src/libmsc/iucs.c | 1 + openbsc/src/libmsc/msc_vty.c | 5 +++- openbsc/src/osmo-msc/Makefile.am | 2 +- 7 files changed, 74 insertions(+), 4 deletions(-) (limited to 'openbsc/src') diff --git a/openbsc/src/gprs/gprs_gmm.c b/openbsc/src/gprs/gprs_gmm.c index cedd2da70..3350768db 100644 --- a/openbsc/src/gprs/gprs_gmm.c +++ b/openbsc/src/gprs/gprs_gmm.c @@ -297,6 +297,10 @@ static void msgid2mmctx(struct sgsn_mm_ctx *mm, const struct msgb *msg) mm->gb.nsei = msgb_nsei(msg); /* In case a Iu connection is reconnected we need to update the ue ctx */ mm->iu.ue_ctx = msg->dst; + if (mm->ran_type == MM_CTX_T_UTRAN_Iu + && mm->iu.ue_ctx) + mm->iu.ue_ctx->rab_assign_addr_enc = + sgsn->cfg.iu.rab_assign_addr_enc; } /* Store BVCI/NSEI in MM context */ diff --git a/openbsc/src/gprs/gprs_sgsn.c b/openbsc/src/gprs/gprs_sgsn.c index 5d9af7807..b4b5cebeb 100644 --- a/openbsc/src/gprs/gprs_sgsn.c +++ b/openbsc/src/gprs/gprs_sgsn.c @@ -247,6 +247,7 @@ struct sgsn_mm_ctx *sgsn_mm_ctx_alloc_iu(void *uectx) ctx->ran_type = MM_CTX_T_UTRAN_Iu; ctx->iu.ue_ctx = uectx; + ctx->iu.ue_ctx->rab_assign_addr_enc = sgsn->cfg.iu.rab_assign_addr_enc; ctx->iu.new_key = 1; ctx->gmm_state = GMM_DEREGISTERED; ctx->pmm_state = PMM_DETACHED; diff --git a/openbsc/src/gprs/sgsn_vty.c b/openbsc/src/gprs/sgsn_vty.c index 338e8049c..b6b827b14 100644 --- a/openbsc/src/gprs/sgsn_vty.c +++ b/openbsc/src/gprs/sgsn_vty.c @@ -44,6 +44,12 @@ #include +#include "../../bscconfig.h" + +#ifdef BUILD_IU +#include +#endif + static struct sgsn_config *g_cfg = NULL; const struct value_string sgsn_auth_pol_strs[] = { @@ -297,6 +303,8 @@ static int config_write_sgsn(struct vty *vty) } else vty_out(vty, " no compression v42bis%s", VTY_NEWLINE); + iu_vty_config_write(vty, " "); + return CMD_SUCCESS; } @@ -1285,7 +1293,7 @@ int sgsn_vty_init(struct sgsn_config *cfg) install_element(SGSN_NODE, &cfg_comp_v42bisp_cmd); #ifdef BUILD_IU - iu_vty_init(); + iu_vty_init(SGSN_NODE, &g_cfg->iu.rab_assign_addr_enc); #endif return 0; } diff --git a/openbsc/src/libiu/iu_vty.c b/openbsc/src/libiu/iu_vty.c index cfa02ea6c..73ad126ba 100644 --- a/openbsc/src/libiu/iu_vty.c +++ b/openbsc/src/libiu/iu_vty.c @@ -18,12 +18,16 @@ */ #include +#include +#include #include #include #include +static enum nsap_addr_enc *g_rab_assign_addr_enc = NULL; + DEFUN(logging_asn_debug, logging_asn_debug_cmd, "logging asn1-debug (1|0)", @@ -48,8 +52,57 @@ DEFUN(logging_asn_xer_print, return CMD_SUCCESS; } -void iu_vty_init(void) +DEFUN(cfg_iu_rab_assign_addr_enc, cfg_iu_rab_assign_addr_enc_cmd, + "iu rab-assign-addr-enc (x213|v4raw)", + "Iu interface protocol options\n" + "Choose RAB Assignment's Transport Layer Address encoding\n" + "ITU-T X.213 compliant address encoding (default)\n" + "32bit length raw IPv4 address (for ip.access nano3G)\n") { + if (!g_rab_assign_addr_enc) { + vty_out(vty, "%%RAB Assignment Transport Layer Address" + " encoding not available%s", VTY_NEWLINE); + return CMD_WARNING; + } + + if (strcmp(argv[0], "v4raw") == 0) + *g_rab_assign_addr_enc = NSAP_ADDR_ENC_V4RAW; + else + *g_rab_assign_addr_enc = NSAP_ADDR_ENC_X213; + return CMD_SUCCESS; +} + +int iu_vty_config_write(struct vty *vty, const char *indent) +{ + if (!g_rab_assign_addr_enc) { + vty_out(vty, "%%RAB Assignment Transport Layer Address" + " encoding not available%s", VTY_NEWLINE); + return CMD_WARNING; + } + + switch (*g_rab_assign_addr_enc) { + case NSAP_ADDR_ENC_V4RAW: + vty_out(vty, "%siu rab-assign-addr-enc v4raw%s", indent, + VTY_NEWLINE); + break; + case NSAP_ADDR_ENC_X213: + /* default value, no need to write anything */ + break; + default: + LOGP(0, LOGL_ERROR, "Invalid value for" + " net.iu.rab_assign_addr_enc: %d\n", + *g_rab_assign_addr_enc); + return CMD_WARNING; + } + + return CMD_SUCCESS; +} + +void iu_vty_init(int iu_parent_node, enum nsap_addr_enc *rab_assign_addr_enc) +{ + g_rab_assign_addr_enc = rab_assign_addr_enc; + install_element(CFG_LOG_NODE, &logging_asn_debug_cmd); install_element(CFG_LOG_NODE, &logging_asn_xer_print_cmd); + install_element(iu_parent_node, &cfg_iu_rab_assign_addr_enc_cmd); } diff --git a/openbsc/src/libmsc/iucs.c b/openbsc/src/libmsc/iucs.c index 3caaf07fb..469d3e0a7 100644 --- a/openbsc/src/libmsc/iucs.c +++ b/openbsc/src/libmsc/iucs.c @@ -50,6 +50,7 @@ static struct gsm_subscriber_connection *subscr_conn_allocate_iu(struct gsm_netw conn->network = network; conn->via_ran = RAN_UTRAN_IU; conn->iu.ue_ctx = ue; + conn->iu.ue_ctx->rab_assign_addr_enc = network->iu.rab_assign_addr_enc; conn->lac = lac; llist_add_tail(&conn->entry, &network->subscr_conns); diff --git a/openbsc/src/libmsc/msc_vty.c b/openbsc/src/libmsc/msc_vty.c index 0eb6efa3e..b6fff56af 100644 --- a/openbsc/src/libmsc/msc_vty.c +++ b/openbsc/src/libmsc/msc_vty.c @@ -26,11 +26,12 @@ #include #include -#include +#include #include #include #include +#include static struct cmd_node msc_node = { MSC_NODE, @@ -124,6 +125,7 @@ static int config_write_msc(struct vty *vty) gsmnet->vlr->cfg.assign_tmsi? "" : "no ", VTY_NEWLINE); mgcpgw_client_config_write(vty, " "); + iu_vty_config_write(vty, " "); return CMD_SUCCESS; } @@ -175,4 +177,5 @@ void msc_vty_init(struct gsm_network *msc_network) install_element(MSC_NODE, &cfg_msc_assign_tmsi_cmd); install_element(MSC_NODE, &cfg_msc_no_assign_tmsi_cmd); mgcpgw_client_vty_init(MSC_NODE, &msc_network->mgcpgw.conf); + iu_vty_init(MSC_NODE, &msc_network->iu.rab_assign_addr_enc); } diff --git a/openbsc/src/osmo-msc/Makefile.am b/openbsc/src/osmo-msc/Makefile.am index d3191424e..a606b58f6 100644 --- a/openbsc/src/osmo-msc/Makefile.am +++ b/openbsc/src/osmo-msc/Makefile.am @@ -37,10 +37,10 @@ osmo_msc_SOURCES = \ $(NULL) osmo_msc_LDADD = \ - $(top_builddir)/src/libiu/libiu.a \ $(top_builddir)/src/libmsc/libmsc.a \ $(top_builddir)/src/libvlr/libvlr.a \ $(top_builddir)/src/libcommon-cs/libcommon-cs.a \ + $(top_builddir)/src/libiu/libiu.a \ $(top_builddir)/src/libtrau/libtrau.a \ $(top_builddir)/src/libcommon/libcommon.a \ $(top_builddir)/src/libmgcp/libmgcp.a \ -- cgit v1.2.3