From 5f3e337c8d545e6b4fe968b196d0fcf8c9d75c89 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-cscn 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-cscn and osmo-sgsn. Add generic iu_vty_config_write() to write out the config. Call iu_vty_init() from cscn_vty_init(); cscn_vty_init() is in libmsc, hence linking of osmo-cscn now needs libiu to come after libmsc, so move that further down. Change-Id: I93728314742b327336f3fb6de98e6457f687e1f9 --- openbsc/include/openbsc/gsm_data.h | 5 ++++ openbsc/include/openbsc/iu.h | 5 +++- openbsc/include/openbsc/sgsn.h | 5 ++++ 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/cscn_vty.c | 5 +++- openbsc/src/libmsc/iucs.c | 1 + openbsc/src/osmo-cscn/Makefile.am | 2 +- 10 files changed, 88 insertions(+), 5 deletions(-) (limited to 'openbsc') diff --git a/openbsc/include/openbsc/gsm_data.h b/openbsc/include/openbsc/gsm_data.h index b161de33d..8a3b0f8c0 100644 --- a/openbsc/include/openbsc/gsm_data.h +++ b/openbsc/include/openbsc/gsm_data.h @@ -13,6 +13,7 @@ #include +#include #include #include #include @@ -424,6 +425,10 @@ struct gsm_network { struct mgcpgw_client_conf conf; struct mgcpgw_client *client; } mgcpgw; + + struct { + enum nsap_addr_enc rab_assign_addr_enc; + } iu; }; struct osmo_esme; diff --git a/openbsc/include/openbsc/iu.h b/openbsc/include/openbsc/iu.h index a82d53066..0ef2f82f6 100644 --- a/openbsc/include/openbsc/iu.h +++ b/openbsc/include/openbsc/iu.h @@ -6,6 +6,8 @@ #include #include +#include + struct sgsn_pdp_ctx; struct msgb; struct osmo_sccp_link; @@ -72,4 +74,5 @@ int iu_tx_sec_mode_cmd(struct ue_conn_ctx *uectx, struct gsm_auth_tuple *tp, int iu_tx_common_id(struct ue_conn_ctx *ue_ctx, const char *imsi); int iu_tx_release(struct ue_conn_ctx *ctx, const struct RANAP_Cause *cause); -void iu_vty_init(void); +void iu_vty_init(int iu_parent_node, enum nsap_addr_enc *rab_assign_addr_enc); +int iu_vty_config_write(struct vty *vty, const char *indent); diff --git a/openbsc/include/openbsc/sgsn.h b/openbsc/include/openbsc/sgsn.h index 6c558aaaf..ad2547af0 100644 --- a/openbsc/include/openbsc/sgsn.h +++ b/openbsc/include/openbsc/sgsn.h @@ -7,6 +7,7 @@ #include #include #include +#include #include @@ -109,6 +110,10 @@ struct sgsn_config { int p1; int p2; } dcomp_v42bis; + + struct { + enum nsap_addr_enc rab_assign_addr_enc; + } iu; }; struct sgsn_instance { diff --git a/openbsc/src/gprs/gprs_gmm.c b/openbsc/src/gprs/gprs_gmm.c index 7a1245927..1392d9daa 100644 --- a/openbsc/src/gprs/gprs_gmm.c +++ b/openbsc/src/gprs/gprs_gmm.c @@ -268,6 +268,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 e5a54d9b4..03ca5c885 100644 --- a/openbsc/src/gprs/gprs_sgsn.c +++ b/openbsc/src/gprs/gprs_sgsn.c @@ -244,6 +244,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->mm_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 421d17fbe..05310cbf5 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; } @@ -1254,7 +1262,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/cscn_vty.c b/openbsc/src/libmsc/cscn_vty.c index f93c5602b..abe49c40d 100644 --- a/openbsc/src/libmsc/cscn_vty.c +++ b/openbsc/src/libmsc/cscn_vty.c @@ -26,10 +26,11 @@ #include #include -#include +#include #include #include +#include static struct cmd_node cscn_node = { CSCN_NODE, @@ -123,6 +124,7 @@ static int config_write_cscn(struct vty *vty) gsmnet->avoid_tmsi ? "no " : "", VTY_NEWLINE); mgcpgw_client_config_write(vty, " "); + iu_vty_config_write(vty, " "); return CMD_SUCCESS; } @@ -175,4 +177,5 @@ void cscn_vty_init(struct gsm_network *cscn_network) install_element(CSCN_NODE, &cfg_cscn_assign_tmsi_cmd); install_element(CSCN_NODE, &cfg_cscn_no_assign_tmsi_cmd); mgcpgw_client_vty_init(CSCN_NODE, &cscn_network->mgcpgw.conf); + iu_vty_init(CSCN_NODE, &cscn_network->iu.rab_assign_addr_enc); } diff --git a/openbsc/src/libmsc/iucs.c b/openbsc/src/libmsc/iucs.c index 6f9643d76..9ec8da4bd 100644 --- a/openbsc/src/libmsc/iucs.c +++ b/openbsc/src/libmsc/iucs.c @@ -25,6 +25,7 @@ static struct gsm_subscriber_connection *subscr_conn_allocate_iu(struct gsm_netw conn->network = network; conn->via_iface = IFACE_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/osmo-cscn/Makefile.am b/openbsc/src/osmo-cscn/Makefile.am index 2f9c31a10..23df584fb 100644 --- a/openbsc/src/osmo-cscn/Makefile.am +++ b/openbsc/src/osmo-cscn/Makefile.am @@ -36,9 +36,9 @@ osmo_cscn_SOURCES = \ $(NULL) osmo_cscn_LDADD = \ - $(top_builddir)/src/libiu/libiu.a \ $(top_builddir)/src/libmsc/libmsc.a \ $(top_builddir)/src/libxsc/libxsc.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