neels has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-hnbgw/+/33178 )


Change subject: cfg: add 'hnbgw' / 'plmn MCC MNC'
......................................................................

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.

Related: SYS#6441
Change-Id: If404c3859acdfba274c719c7cb7d16f97d831a2a
---
M include/osmocom/hnbgw/hnbgw.h
M src/osmo-hnbgw/hnbgw.c
M src/osmo-hnbgw/hnbgw_l3.c
M src/osmo-hnbgw/hnbgw_vty.c
M tests/osmo-hnbgw.vty
5 files changed, 108 insertions(+), 6 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-hnbgw refs/changes/78/33178/1

diff --git a/include/osmocom/hnbgw/hnbgw.h b/include/osmocom/hnbgw/hnbgw.h
index ed3cd62..e62fc71 100644
--- a/include/osmocom/hnbgw/hnbgw.h
+++ b/include/osmocom/hnbgw/hnbgw.h
@@ -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 @@
                /*! 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/hnbgw.c b/src/osmo-hnbgw/hnbgw.c
index fdd6a86..61a8542 100644
--- a/src/osmo-hnbgw/hnbgw.c
+++ b/src/osmo-hnbgw/hnbgw.c
@@ -57,6 +57,9 @@
        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_l3.c b/src/osmo-hnbgw/hnbgw_l3.c
index 607bfc5..ccb4bac 100644
--- a/src/osmo-hnbgw/hnbgw_l3.c
+++ b/src/osmo-hnbgw/hnbgw_l3.c
@@ -267,15 +267,21 @@

 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, gues 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
diff --git a/src/osmo-hnbgw/hnbgw_vty.c b/src/osmo-hnbgw/hnbgw_vty.c
index bee34f1..8cbe249 100644
--- a/src/osmo-hnbgw/hnbgw_vty.c
+++ b/src/osmo-hnbgw/hnbgw_vty.c
@@ -281,6 +281,28 @@
        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 @@
 {
        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 @@
        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);
diff --git a/tests/osmo-hnbgw.vty b/tests/osmo-hnbgw.vty
index 72916fb..41bcb73 100644
--- a/tests/osmo-hnbgw.vty
+++ b/tests/osmo-hnbgw.vty
@@ -11,6 +11,7 @@
 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 @@
   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.


--
To view, visit https://gerrit.osmocom.org/c/osmo-hnbgw/+/33178
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-hnbgw
Gerrit-Branch: master
Gerrit-Change-Id: If404c3859acdfba274c719c7cb7d16f97d831a2a
Gerrit-Change-Number: 33178
Gerrit-PatchSet: 1
Gerrit-Owner: neels <nhofm...@sysmocom.de>
Gerrit-MessageType: newchange

Reply via email to