Configure CI,LAC,RAC,SAC over VTY and use it in HnbRegisterRequest

Change-Id: I06f21758e361b7d4d7141086d758893bee434e5c
This commit is contained in:
Pau Espin 2021-10-28 19:11:36 +02:00
parent 3423fada07
commit e2c17101be
3 changed files with 69 additions and 9 deletions

View File

@ -56,6 +56,10 @@ struct hnb_chan {
struct hnb {
struct osmo_plmn_id plmn;
uint16_t cell_identity;
uint16_t lac;
uint8_t rac;
uint16_t sac;
struct {
char *local_addr;
uint16_t local_port;

View File

@ -162,15 +162,10 @@ void hnb_send_register_req(struct hnb *hnb)
HNBAP_HNBRegisterRequestIEs_t request;
memset(&request, 0, sizeof(request));
lac = 0xc0fe;
sac = 0xabab;
rac = 0x42;
cid = 0xadceaab;
asn1_u16_to_str(&request.lac, &lac, lac);
asn1_u16_to_str(&request.sac, &sac, sac);
asn1_u8_to_str(&request.rac, &rac, rac);
asn1_u28_to_bitstring(&request.cellIdentity, &cid, cid);
asn1_u16_to_str(&request.lac, &lac, hnb->lac);
asn1_u16_to_str(&request.sac, &sac, hnb->sac);
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);

View File

@ -27,6 +27,8 @@
#include <osmocom/vty/command.h>
#include <osmocom/core/msgb.h>
#include <osmocom/gsm/protocol/gsm_04_08.h>
#include <osmocom/rua/rua_msg_factory.h>
#include <osmocom/ranap/ranap_common.h>
@ -127,6 +129,57 @@ DEFUN_USRATTR(cfg_hnodeb_mnc,
return CMD_SUCCESS;
}
DEFUN_USRATTR(cfg_hnodeb_ci,
cfg_hnodeb_ci_cmd,
0,
"cell_identity <0-65535>",
"Set the Cell identity of this HnodeB\n" "Cell Identity\n")
{
struct hnb *hnb = (struct hnb *)vty->index;
hnb->cell_identity = atoi(argv[0]);
return CMD_SUCCESS;
}
DEFUN_USRATTR(cfg_hnodeb_lac,
cfg_hnodeb_lac_cmd,
0,
"location_area_code <0-65535>",
"Set the Location Area Code (LAC) of this HnodeB\n" "LAC\n")
{
struct hnb *hnb = (struct hnb *)vty->index;
int lac = atoi(argv[0]);
if (lac == GSM_LAC_RESERVED_DETACHED || lac == GSM_LAC_RESERVED_ALL_BTS) {
vty_out(vty, "%% LAC %d is reserved by GSM 04.08%s",
lac, VTY_NEWLINE);
return CMD_WARNING;
}
hnb->lac = lac;
return CMD_SUCCESS;
}
DEFUN_USRATTR(cfg_hnodeb_rac,
cfg_hnodeb_rac_cmd,
0,
"routing_area_code <0-255>",
"Set the Routing Area Code (RAC) of this HnodeB\n" "RAC\n")
{
struct hnb *hnb = (struct hnb *)vty->index;
hnb->rac = atoi(argv[0]);
return CMD_SUCCESS;
}
DEFUN_USRATTR(cfg_hnodeb_sac,
cfg_hnodeb_sac_cmd,
0,
"service_area_code <0-255>",
"Set the Service Area Code (RAC) of this HnodeB\n" "SAC\n")
{
struct hnb *hnb = (struct hnb *)vty->index;
hnb->sac = atoi(argv[0]);
return CMD_SUCCESS;
}
static struct cmd_node iuh_node = {
IUH_NODE,
"%s(config-iuh)# ",
@ -189,6 +242,10 @@ static int config_write_hnodeb(struct vty *vty)
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);
vty_out(vty, " cell_identity %u%s", g_hnb->cell_identity, VTY_NEWLINE);
vty_out(vty, " location_area_code %u%s", g_hnb->lac, VTY_NEWLINE);
vty_out(vty, " routing_area_code %u%s", g_hnb->rac, VTY_NEWLINE);
vty_out(vty, " service_area_code %u%s", g_hnb->sac, VTY_NEWLINE);
vty_out(vty, " iuh%s", VTY_NEWLINE);
if (g_hnb->iuh.local_addr)
vty_out(vty, " local-ip %s%s", g_hnb->iuh.local_addr, VTY_NEWLINE);
@ -306,6 +363,10 @@ void hnb_vty_init(void)
install_node(&hnodeb_node, config_write_hnodeb);
install_element(HNODEB_NODE, &cfg_hnodeb_ncc_cmd);
install_element(HNODEB_NODE, &cfg_hnodeb_mnc_cmd);
install_element(HNODEB_NODE, &cfg_hnodeb_ci_cmd);
install_element(HNODEB_NODE, &cfg_hnodeb_lac_cmd);
install_element(HNODEB_NODE, &cfg_hnodeb_rac_cmd);
install_element(HNODEB_NODE, &cfg_hnodeb_sac_cmd);
install_element(HNODEB_NODE, &cfg_hnodeb_iuh_cmd);
install_node(&iuh_node, NULL);
install_element(IUH_NODE, &cfg_hnodeb_iuh_local_ip_cmd);