diff --git a/include/osmocom/hnbgw/hnbgw.h b/include/osmocom/hnbgw/hnbgw.h index d592c05..b0d3dde 100644 --- a/include/osmocom/hnbgw/hnbgw.h +++ b/include/osmocom/hnbgw/hnbgw.h @@ -254,6 +254,7 @@ struct hnbgw { /*! The UDP port where we receive multiplexed CS user * plane traffic from HNBs */ uint16_t iuh_cs_mux_port; + struct osmo_plmn_id plmn; uint16_t rnc_id; bool hnbap_allow_tmsi; /*! print hnb-id (true) or MCC-MNC-LAC-RAC-SAC (false) in logs */ diff --git a/src/osmo-hnbgw/cnlink.c b/src/osmo-hnbgw/cnlink.c index ba08f64..41304db 100644 --- a/src/osmo-hnbgw/cnlink.c +++ b/src/osmo-hnbgw/cnlink.c @@ -25,6 +25,7 @@ #include +#include #include #include @@ -127,6 +128,9 @@ static void tx_reset(struct hnbgw_cnlink *cnlink) .present = RANAP_Cause_PR_transmissionNetwork, .choice. transmissionNetwork = RANAP_CauseTransmissionNetwork_signalling_transport_resource_failure, }; + RANAP_GlobalRNC_ID_t grnc_id; + RANAP_GlobalRNC_ID_t *use_grnc_id = NULL; + uint8_t plmn_buf[3]; if (!cnlink) return; @@ -140,7 +144,20 @@ static void tx_reset(struct hnbgw_cnlink *cnlink) cnlink_is_cs(cnlink) ? "IuCS" : "IuPS", osmo_sccp_inst_addr_name(cnlink->hnbgw_sccp_inst->sccp, &cnlink->remote_addr)); - msg = ranap_new_msg_reset(cnlink->pool->domain, &cause); + /* If no PLMN is configured, omit the Global RNC Id from the RESET message */ + if (g_hnbgw->config.plmn.mcc) { + osmo_plmn_to_bcd(plmn_buf, &g_hnbgw->config.plmn); + grnc_id = (RANAP_GlobalRNC_ID_t){ + .pLMNidentity = { + .buf = plmn_buf, + .size = 3, + }, + .rNC_ID = g_hnbgw->config.rnc_id, + }; + use_grnc_id = &grnc_id; + } + + msg = ranap_new_msg_reset2(cnlink->pool->domain, &cause, use_grnc_id); osmo_sccp_tx_unitdata_msg(cnlink->hnbgw_sccp_inst->sccp_user, &cnlink->local_addr, diff --git a/src/osmo-hnbgw/hnbgw.c b/src/osmo-hnbgw/hnbgw.c index 3cad818..18dbca4 100644 --- a/src/osmo-hnbgw/hnbgw.c +++ b/src/osmo-hnbgw/hnbgw.c @@ -57,6 +57,9 @@ void g_hnbgw_alloc(void *ctx) g_hnbgw->config.iuh_local_port = IUH_DEFAULT_SCTP_PORT; g_hnbgw->config.log_prefix_hnb_id = true; + /* Set zero PLMN to detect a missing PLMN when transmitting RESET */ + g_hnbgw->config.plmn = (struct osmo_plmn_id){ 0, 0, false }; + g_hnbgw->next_ue_ctx_id = 23; INIT_LLIST_HEAD(&g_hnbgw->hnb_list); INIT_LLIST_HEAD(&g_hnbgw->ue_list); diff --git a/src/osmo-hnbgw/hnbgw_vty.c b/src/osmo-hnbgw/hnbgw_vty.c index d05677c..6444765 100644 --- a/src/osmo-hnbgw/hnbgw_vty.c +++ b/src/osmo-hnbgw/hnbgw_vty.c @@ -281,6 +281,28 @@ DEFUN(show_talloc, show_talloc_cmd, "show talloc", SHOW_STR "Display talloc info return CMD_SUCCESS; } +DEFUN(cfg_hnbgw_plmn, cfg_hnbgw_plmn_cmd, + "plmn <1-999> <0-999>", + "Configure the HNBGW's PLMN. The PLMN is transmitted in RANAP RESET towards the CN.\n" + "MCC, Mobile Country Code\n" + "MNC, Mobile Network Code\n") +{ + struct osmo_plmn_id plmn; + + if (osmo_mcc_from_str(argv[0], &plmn.mcc)) { + vty_out(vty, "%% Error decoding MCC: %s%s", argv[0], VTY_NEWLINE); + return CMD_WARNING; + } + + if (osmo_mnc_from_str(argv[1], &plmn.mnc, &plmn.mnc_3_digits)) { + vty_out(vty, "%% Error decoding MNC: %s%s", argv[1], VTY_NEWLINE); + return CMD_WARNING; + } + + g_hnbgw->config.plmn = plmn; + return CMD_SUCCESS; +} + DEFUN(cfg_hnbgw_rnc_id, cfg_hnbgw_rnc_id_cmd, "rnc-id <0-65535>", "Configure the HNBGW's RNC Id, the common RNC Id used for all connected hNodeB. It is sent to" @@ -950,6 +972,7 @@ void hnbgw_vty_init(void) install_element(CONFIG_NODE, &cfg_hnbgw_cmd); install_node(&hnbgw_node, config_write_hnbgw); + install_element(HNBGW_NODE, &cfg_hnbgw_plmn_cmd); install_element(HNBGW_NODE, &cfg_hnbgw_rnc_id_cmd); install_element(HNBGW_NODE, &cfg_hnbgw_log_prefix_cmd); install_element(HNBGW_NODE, &cfg_hnbgw_max_sccp_cr_payload_len_cmd);