cfg: add 'hnbgw' / 'plmn MCC MNC'

According to 3GPP TS 25.413 8.26.2.2, "The RNC shall include the Global
RNC-ID IE in the RESET message." To be able to do that, osmo-hnbgw needs
to know the local PLMN.

Introduce explicit knowledge of the local PLMN by config, and use this
configured local PLMN in places where the local PLMN was so far derived
otherwise.

Subsequent patches will separately add the RNC-ID to the RANAP RESET
messages.

Since the PLMN is required to send correct RESET and RESET ACK, include
the new 'plmn' config item in all example configurations.

Related: SYS#6441
Change-Id: If404c3859acdfba274c719c7cb7d16f97d831a2a
This commit is contained in:
Neels Hofmeyr 2023-05-11 21:43:18 +02:00
parent 1b45792cbd
commit d482f8666c
9 changed files with 91 additions and 6 deletions

View File

@ -19,6 +19,7 @@ cs7 instance 0
point-code 0.2.0
hnbgw
plmn 001 01
iucs
nri bitlen 10
nri null add 0 7

View File

@ -10,6 +10,7 @@ cs7 instance 0
point-code 1.4.2
hnbgw
plmn 001 01
iuh
local-ip 0.0.0.0
hnbap-allow-tmsi 1

View File

@ -8,6 +8,7 @@ log stderr
logging print extended-timestamp 1
logging level set-all notice
hnbgw
plmn 001 01
iuh
local-ip 0.0.0.0
hnbap-allow-tmsi 1

View File

@ -8,6 +8,7 @@ log stderr
logging print extended-timestamp 1
logging level set-all notice
hnbgw
plmn 001 01
iuh
local-ip 0.0.0.0
hnbap-allow-tmsi 1

View File

@ -6,6 +6,7 @@
#include <osmocom/core/write_queue.h>
#include <osmocom/core/timer.h>
#include <osmocom/core/rate_ctr.h>
#include <osmocom/gsm/gsm23003.h>
#include <osmocom/sigtran/sccp_sap.h>
#include <osmocom/sigtran/osmo_ss7.h>
#include <osmocom/ctrl/control_if.h>
@ -253,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 */

View File

@ -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);

View File

@ -279,15 +279,21 @@ static int peek_l3_nas(struct hnbgw_context_map *map, const uint8_t *nas_pdu, si
static int peek_l3_initial_ue(struct hnbgw_context_map *map, const RANAP_InitialUE_MessageIEs_t *ies)
{
struct osmo_plmn_id plmn;
struct osmo_plmn_id local_plmn;
if (ies->lai.pLMNidentity.size < 3) {
LOGP(DCN, LOGL_ERROR, "Missing PLMN in RANAP InitialUE message\n");
return -EINVAL;
if (g_hnbgw->config.plmn.mcc) {
/* The user has configured a PLMN */
local_plmn = g_hnbgw->config.plmn;
} else {
/* The user has not configured a PLMN, guess from the InitialUE message's LAI IE's PLMN */
if (ies->lai.pLMNidentity.size < 3) {
LOGP(DCN, LOGL_ERROR, "Missing PLMN in RANAP InitialUE message\n");
return -EINVAL;
}
osmo_plmn_from_bcd(ies->lai.pLMNidentity.buf, &local_plmn);
}
osmo_plmn_from_bcd(ies->lai.pLMNidentity.buf, &plmn);
return peek_l3_nas(map, ies->nas_pdu.buf, ies->nas_pdu.size, &plmn);
return peek_l3_nas(map, ies->nas_pdu.buf, ies->nas_pdu.size, &local_plmn);
}
/* Extract a Layer 3 message (NAS PDU) from the RANAP message, and put the info obtained in map->l3. This is relevant

View File

@ -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"
@ -849,6 +871,12 @@ static int config_write_hnbgw(struct vty *vty)
{
vty_out(vty, "hnbgw%s", VTY_NEWLINE);
if (g_hnbgw->config.plmn.mcc)
vty_out(vty, " plmn %s %s%s",
osmo_mcc_name_c(OTC_SELECT, g_hnbgw->config.plmn.mcc),
osmo_mnc_name_c(OTC_SELECT, g_hnbgw->config.plmn.mnc, g_hnbgw->config.plmn.mnc_3_digits),
VTY_NEWLINE);
vty_out(vty, " rnc-id %u%s", g_hnbgw->config.rnc_id, VTY_NEWLINE);
vty_out(vty, " log-prefix %s%s", g_hnbgw->config.log_prefix_hnb_id ? "hnb-id" : "umts-cell-id",
@ -941,6 +969,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);

View File

@ -11,6 +11,7 @@ OsmoHNBGW(config)# hnbgw?
OsmoHNBGW(config)# hnbgw
OsmoHNBGW(config-hnbgw)# list
...
plmn <1-999> <0-999>
rnc-id <0-65535>
log-prefix (hnb-id|umts-cell-id)
iuh
@ -18,6 +19,46 @@ OsmoHNBGW(config-hnbgw)# list
iups
...
OsmoHNBGW(config-hnbgw)# plmn?
plmn Configure the HNBGW's PLMN. The PLMN is transmitted in RANAP RESET towards the CN.
OsmoHNBGW(config-hnbgw)# plmn ?
<1-999> MCC, Mobile Country Code
OsmoHNBGW(config-hnbgw)# plmn 1 ?
<0-999> MNC, Mobile Network Code
OsmoHNBGW(config-hnbgw)# show running-config
... !plmn
OsmoHNBGW(config-hnbgw)# plmn 001 01
OsmoHNBGW(config-hnbgw)# show running-config
...
hnbgw
...
plmn 001 01
...
OsmoHNBGW(config-hnbgw)# plmn 001 001
OsmoHNBGW(config-hnbgw)# show running-config
...
hnbgw
...
plmn 001 001
...
OsmoHNBGW(config-hnbgw)# plmn 999 999
OsmoHNBGW(config-hnbgw)# show running-config
...
hnbgw
...
plmn 999 999
...
OsmoHNBGW(config-hnbgw)# plmn 23 42
OsmoHNBGW(config-hnbgw)# show running-config
...
hnbgw
...
plmn 023 42
...
OsmoHNBGW(config-hnbgw)# rnc-id?
rnc-id Configure the HNBGW's RNC Id, the common RNC Id used for all connected hNodeB. It is sent to each hNodeB upon HNBAP HNB-Register-Accept, and the hNodeB will subsequently send this as RANAP InitialUE Messages' GlobalRNC-ID IE. Takes effect as soon as the hNodeB re-registers.