From c475158e0c49aa49eed14aa37f8c72c7190f3788 Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Thu, 28 Oct 2021 19:28:14 +0200 Subject: [PATCH] Configure HNB-Identity over VTY and use it in HnbRegisterRequest Change-Id: Ida47bbb85b5438a2ec9805005bc2ab834c79b765 --- include/osmocom/hnodeb/hnodeb.h | 1 + src/osmo-hnodeb/hnb.c | 1 + src/osmo-hnodeb/hnbap.c | 5 ++--- src/osmo-hnodeb/vty.c | 13 +++++++++++++ 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/include/osmocom/hnodeb/hnodeb.h b/include/osmocom/hnodeb/hnodeb.h index a82c662..5d6d088 100644 --- a/include/osmocom/hnodeb/hnodeb.h +++ b/include/osmocom/hnodeb/hnodeb.h @@ -55,6 +55,7 @@ struct hnb_chan { }; struct hnb { + char *identity; /* HNB-Identity */ struct osmo_plmn_id plmn; uint16_t cell_identity; uint16_t lac; diff --git a/src/osmo-hnodeb/hnb.c b/src/osmo-hnodeb/hnb.c index b0628e5..34ff426 100644 --- a/src/osmo-hnodeb/hnb.c +++ b/src/osmo-hnodeb/hnb.c @@ -116,6 +116,7 @@ struct hnb *hnb_alloc(void *tall_ctx) if (!hnb) return NULL; + hnb->identity = talloc_strdup(hnb, "OsmoHNodeB"); hnb->plmn = (struct osmo_plmn_id){ .mcc = 1, .mnc = 1, diff --git a/src/osmo-hnodeb/hnbap.c b/src/osmo-hnodeb/hnbap.c index 167ec50..bcddfb3 100644 --- a/src/osmo-hnodeb/hnbap.c +++ b/src/osmo-hnodeb/hnbap.c @@ -157,7 +157,6 @@ void hnb_send_register_req(struct hnb *hnb) uint8_t rac; uint32_t cid; uint8_t plmn[3]; - char identity[50] = "ATestHNB@"; HNBAP_HNBRegisterRequestIEs_t request; memset(&request, 0, sizeof(request)); @@ -167,8 +166,8 @@ void hnb_send_register_req(struct hnb *hnb) asn1_u8_to_str(&request.rac, &rac, hnb->rac); asn1_u28_to_bitstring(&request.cellIdentity, &cid, hnb->cell_identity); - request.hnB_Identity.hNB_Identity_Info.buf = (uint8_t*) identity; - request.hnB_Identity.hNB_Identity_Info.size = strlen(identity); + request.hnB_Identity.hNB_Identity_Info.buf = (uint8_t*) hnb->identity; + request.hnB_Identity.hNB_Identity_Info.size = strlen(hnb->identity); osmo_plmn_to_bcd(plmn, &hnb->plmn); request.plmNidentity.buf = plmn; diff --git a/src/osmo-hnodeb/vty.c b/src/osmo-hnodeb/vty.c index 1adc7ba..714e00d 100644 --- a/src/osmo-hnodeb/vty.c +++ b/src/osmo-hnodeb/vty.c @@ -83,6 +83,17 @@ DEFUN(cfg_hnodeb, return CMD_SUCCESS; } +DEFUN_USRATTR(cfg_hnodeb_identity, + cfg_hnodeb_identity_cmd, + 0, + "identity TEXT", + "Set the HNB-identity of this HnodeB\n" "HNB-Identity\n") +{ + struct hnb *hnb = (struct hnb *)vty->index; + osmo_talloc_replace_string(g_hnb, &hnb->identity, argv[0]); + return CMD_SUCCESS; +} + DEFUN_USRATTR(cfg_hnodeb_ncc, cfg_hnodeb_ncc_cmd, 0, @@ -239,6 +250,7 @@ DEFUN(cfg_hnodeb_iuh_remote_port, cfg_hnodeb_iuh_remote_port_cmd, static int config_write_hnodeb(struct vty *vty) { vty_out(vty, "hnodeb%s", VTY_NEWLINE); + vty_out(vty, " identity %s%s", g_hnb->identity, VTY_NEWLINE); vty_out(vty, " network country code %s%s", osmo_mcc_name(g_hnb->plmn.mcc), VTY_NEWLINE); vty_out(vty, " mobile network code %s%s", osmo_mnc_name(g_hnb->plmn.mnc, g_hnb->plmn.mnc_3_digits), VTY_NEWLINE); @@ -361,6 +373,7 @@ void hnb_vty_init(void) { install_element(CONFIG_NODE, &cfg_hnodeb_cmd); install_node(&hnodeb_node, config_write_hnodeb); + install_element(HNODEB_NODE, &cfg_hnodeb_identity_cmd); install_element(HNODEB_NODE, &cfg_hnodeb_ncc_cmd); install_element(HNODEB_NODE, &cfg_hnodeb_mnc_cmd); install_element(HNODEB_NODE, &cfg_hnodeb_ci_cmd);