Refactor (F1AP/RRC): convert SIB containers to byte_array_t
Unify SIB container handling by introducing a typed SIB enum and storing SIB payloads as byte_array_t across common NR types, F1AP helpers, MAC, and RRC DU setup code. Changes: - Include byte_array support in nr_common.h, add nr_sib_type_t (NR_SIB_1–NR_SIB_21), and change nr_SIBs_t to hold only nr_sib_type_t SIB_type. - Switch f1ap_sib_msg_t in f1ap_messages_types.h to use a byte_array_t SI_container instead of raw pointer and length fields. - Update F1AP encode/decode, equality, copy, and free helpers in f1ap_interface_management.c to work on SI_container.buf / SI_container.len and use eq_byte_array, copy_byte_array, and free_byte_array. - Adapt F1AP tests in f1ap_lib_test.c to build and inspect SIB containers via SI_container.buf and SI_container.len. - Replace magic SIB numbers with nr_sib_type_t values in gnb_config.c (get_sys_info and fill_du_sibs) to validate and configure DU SIBs. - Rework nr_mac_configure_other_sib in NR_MAC_gNB/config.c to decode SIB2 from a byte_array_t container, fix freeing by releasing the decoded sib2 on failure, and use NR_SIB_2 / NR_SIB_19 for CU/DU SIB selection. - Add an add_si_msg helper in rrc_gNB_du.c and refactor the SIB2 branch of rrc_gNB_process_f1_setup_req to populate cell->SI_msg from encoded local byte array while iterating SIBs with FOR_EACH_SEQ_ARR.
This commit is contained in:
@@ -627,10 +627,10 @@ static void encode_cells_to_activate(const served_cells_to_activate_t *cell, F1A
|
||||
F1AP_GNB_CUSystemInformation_t *gNB_CUSystemInformation =
|
||||
&cells_to_be_activated_itemExtIEs->extensionValue.choice.GNB_CUSystemInformation;
|
||||
const f1ap_sib_msg_t *SI_msg = &cell->SI_msg[n];
|
||||
if (SI_msg->SI_container != NULL) {
|
||||
if (SI_msg->SI_container.buf != NULL) {
|
||||
asn1cSequenceAdd(gNB_CUSystemInformation->sibtypetobeupdatedlist.list, F1AP_SibtypetobeupdatedListItem_t, sib_item);
|
||||
sib_item->sIBtype = SI_msg->SI_type;
|
||||
OCTET_STRING_fromBuf(&sib_item->sIBmessage, (const char *)SI_msg->SI_container, SI_msg->SI_container_length);
|
||||
OCTET_STRING_fromBuf(&sib_item->sIBmessage, (const char *)SI_msg->SI_container.buf, SI_msg->SI_container.len);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -670,7 +670,7 @@ static bool decode_cells_to_activate(served_cells_to_activate_t *out, const F1AP
|
||||
F1AP_SibtypetobeupdatedListItem_t *sib_item = gNB_CUSystemInformation->sibtypetobeupdatedlist.list.array[s];
|
||||
/* SI container */
|
||||
f1ap_sib_msg_t *SI_msg = &out->SI_msg[s];
|
||||
SI_msg->SI_container = cp_octet_string(&sib_item->sIBmessage, &SI_msg->SI_container_length);
|
||||
SI_msg->SI_container.buf = cp_octet_string(&sib_item->sIBmessage, (int *)&SI_msg->SI_container.len);
|
||||
/* SIB type */
|
||||
SI_msg->SI_type = sib_item->sIBtype;
|
||||
}
|
||||
@@ -1163,8 +1163,8 @@ bool eq_f1ap_setup_response(const f1ap_setup_resp_t *a, const f1ap_setup_resp_t
|
||||
for (int j = 0; j < b->cells_to_activate[i].num_SI; j++) {
|
||||
const f1ap_sib_msg_t *a_SI_msg = &a->cells_to_activate[i].SI_msg[j];
|
||||
const f1ap_sib_msg_t *b_SI_msg = &b->cells_to_activate[i].SI_msg[j];
|
||||
_EQ_CHECK_INT(*a_SI_msg->SI_container, *b_SI_msg->SI_container);
|
||||
_EQ_CHECK_INT(a_SI_msg->SI_container_length, b_SI_msg->SI_container_length);
|
||||
if (!eq_byte_array(&a_SI_msg->SI_container, &b_SI_msg->SI_container))
|
||||
return false;
|
||||
_EQ_CHECK_INT(a_SI_msg->SI_type, b_SI_msg->SI_type);
|
||||
}
|
||||
}
|
||||
@@ -1201,9 +1201,7 @@ f1ap_setup_resp_t cp_f1ap_setup_response(const f1ap_setup_resp_t *msg)
|
||||
for (int j = 0; j < cp_cell->num_SI; j++) {
|
||||
f1ap_sib_msg_t *cp_SI_msg = &cp_cell->SI_msg[j];
|
||||
const f1ap_sib_msg_t *b_SI_msg = &msg_cell->SI_msg[j];
|
||||
cp_SI_msg->SI_container_length = b_SI_msg->SI_container_length;
|
||||
cp_SI_msg->SI_container = malloc_or_fail(cp_SI_msg->SI_container_length);
|
||||
memcpy(cp_SI_msg->SI_container, b_SI_msg->SI_container, b_SI_msg->SI_container_length);
|
||||
cp_SI_msg->SI_container = copy_byte_array(b_SI_msg->SI_container);
|
||||
cp_SI_msg->SI_type = b_SI_msg->SI_type;
|
||||
}
|
||||
}
|
||||
@@ -1221,8 +1219,7 @@ void free_f1ap_setup_response(const f1ap_setup_resp_t *msg)
|
||||
free(msg->gNB_CU_name);
|
||||
for (int i = 0; i < msg->num_cells_to_activate; i++)
|
||||
for (int j = 0; j < msg->cells_to_activate[i].num_SI; j++)
|
||||
if (msg->cells_to_activate[i].SI_msg[j].SI_container_length > 0)
|
||||
free(msg->cells_to_activate[i].SI_msg[j].SI_container);
|
||||
free_byte_array(msg->cells_to_activate[i].SI_msg[j].SI_container);
|
||||
free(msg->cells_to_activate);
|
||||
}
|
||||
|
||||
@@ -1798,7 +1795,7 @@ void free_f1ap_cu_configuration_update(const f1ap_gnb_cu_configuration_update_t
|
||||
{
|
||||
for (int i = 0; i < msg->num_cells_to_activate; i++)
|
||||
for (int j = 0; j < msg->cells_to_activate[i].num_SI; j++)
|
||||
free(msg->cells_to_activate[i].SI_msg[j].SI_container);
|
||||
free_byte_array(msg->cells_to_activate[i].SI_msg[j].SI_container);
|
||||
free(msg->cells_to_activate);
|
||||
}
|
||||
|
||||
@@ -1819,8 +1816,8 @@ bool eq_f1ap_cu_configuration_update(const f1ap_gnb_cu_configuration_update_t *a
|
||||
for (int s = 0; s < a->cells_to_activate[i].num_SI; s++) {
|
||||
f1ap_sib_msg_t *a_sib_msg = &a->cells_to_activate[i].SI_msg[s];
|
||||
f1ap_sib_msg_t *b_sib_msg = &b->cells_to_activate[i].SI_msg[s];
|
||||
_EQ_CHECK_INT(*a_sib_msg->SI_container, *b_sib_msg->SI_container);
|
||||
_EQ_CHECK_INT(a_sib_msg->SI_container_length, b_sib_msg->SI_container_length);
|
||||
if (!eq_byte_array(&a_sib_msg->SI_container, &b_sib_msg->SI_container))
|
||||
return false;
|
||||
_EQ_CHECK_INT(a_sib_msg->SI_type, b_sib_msg->SI_type);
|
||||
}
|
||||
}
|
||||
@@ -1842,9 +1839,7 @@ f1ap_gnb_cu_configuration_update_t cp_f1ap_cu_configuration_update(const f1ap_gn
|
||||
for (int s = 0; s < cp.cells_to_activate[i].num_SI; s++) {
|
||||
cp.cells_to_activate[i].SI_msg[s] = msg->cells_to_activate[i].SI_msg[s];
|
||||
f1ap_sib_msg_t *SI_msg = &cp.cells_to_activate[i].SI_msg[s];
|
||||
SI_msg->SI_container = calloc_or_fail(SI_msg->SI_container_length, sizeof(*SI_msg->SI_container));
|
||||
for (int j = 0; j < SI_msg->SI_container_length; j++)
|
||||
SI_msg->SI_container[j] = msg->cells_to_activate[i].SI_msg[s].SI_container[j];
|
||||
SI_msg->SI_container = copy_byte_array(msg->cells_to_activate[i].SI_msg[s].SI_container);
|
||||
}
|
||||
}
|
||||
return cp;
|
||||
@@ -2153,8 +2148,8 @@ bool eq_f1ap_du_configuration_update_acknowledge(const f1ap_gnb_du_configuration
|
||||
return false;
|
||||
_EQ_CHECK_INT(a->cells_to_activate[i].num_SI, b->cells_to_activate[i].num_SI);
|
||||
for (int s = 0; s < a->cells_to_activate[i].num_SI; s++) {
|
||||
_EQ_CHECK_INT(*a->cells_to_activate[i].SI_msg[s].SI_container, *b->cells_to_activate[i].SI_msg[s].SI_container);
|
||||
_EQ_CHECK_INT(a->cells_to_activate[i].SI_msg[s].SI_container_length, b->cells_to_activate[i].SI_msg[s].SI_container_length);
|
||||
if (!eq_byte_array(&a->cells_to_activate[i].SI_msg[s].SI_container, &b->cells_to_activate[i].SI_msg[s].SI_container))
|
||||
return false;
|
||||
_EQ_CHECK_INT(a->cells_to_activate[i].SI_msg[s].SI_type, b->cells_to_activate[i].SI_msg[s].SI_type);
|
||||
}
|
||||
}
|
||||
@@ -2180,9 +2175,7 @@ f1ap_gnb_du_configuration_update_acknowledge_t cp_f1ap_du_configuration_update_a
|
||||
f1ap_sib_msg_t *cp_sib = &cp.cells_to_activate[i].SI_msg[s];
|
||||
const f1ap_sib_msg_t *msg_sib = &msg->cells_to_activate[i].SI_msg[s];
|
||||
cp_sib->SI_type = msg_sib->SI_type;
|
||||
cp_sib->SI_container_length = msg_sib->SI_container_length;
|
||||
cp_sib->SI_container = calloc_or_fail(cp_sib->SI_container_length, sizeof(*cp_sib->SI_container));
|
||||
memcpy(cp_sib->SI_container, msg_sib->SI_container, cp_sib->SI_container_length);
|
||||
cp_sib->SI_container = copy_byte_array(msg_sib->SI_container);
|
||||
}
|
||||
}
|
||||
return cp;
|
||||
@@ -2196,9 +2189,7 @@ void free_f1ap_du_configuration_update_acknowledge(const f1ap_gnb_du_configurati
|
||||
// SI_container
|
||||
for (int i = 0; i < msg->num_cells_to_activate; i++) {
|
||||
for (int j = 0; j < msg->cells_to_activate[i].num_SI; j++) {
|
||||
if (msg->cells_to_activate[i].SI_msg[j].SI_container) {
|
||||
free(msg->cells_to_activate[i].SI_msg[j].SI_container);
|
||||
}
|
||||
free_byte_array(msg->cells_to_activate[i].SI_msg[j].SI_container);
|
||||
}
|
||||
}
|
||||
free(msg->cells_to_activate);
|
||||
|
||||
@@ -313,9 +313,9 @@ static void test_f1ap_setup_response(void)
|
||||
int SI_container_length = strlen(s) + 1;
|
||||
orig.cells_to_activate[0].num_SI = 1;
|
||||
f1ap_sib_msg_t *SI_msg = &orig.cells_to_activate[0].SI_msg[0];
|
||||
SI_msg->SI_container = malloc_or_fail(SI_container_length);
|
||||
memcpy(SI_msg->SI_container, (uint8_t *)s, SI_container_length);
|
||||
SI_msg->SI_container_length = SI_container_length;
|
||||
SI_msg->SI_container.buf = malloc_or_fail(SI_container_length);
|
||||
memcpy(SI_msg->SI_container.buf, s, SI_container_length);
|
||||
SI_msg->SI_container.len = SI_container_length;
|
||||
SI_msg->SI_type = 7;
|
||||
}
|
||||
F1AP_F1AP_PDU_t *f1enc = encode_f1ap_setup_response(&orig);
|
||||
@@ -609,10 +609,10 @@ static void test_f1ap_du_configuration_update_acknowledge(void)
|
||||
orig.cells_to_activate[0].plmn.mnc_digit_length = 2;
|
||||
orig.cells_to_activate[0].num_SI = 1;
|
||||
orig.cells_to_activate[0].SI_msg[0].SI_type = 7;
|
||||
orig.cells_to_activate[0].SI_msg[0].SI_container_length = 10;
|
||||
orig.cells_to_activate[0].SI_msg[0].SI_container = malloc(sizeof(uint8_t) * 10);
|
||||
for (int i = 0; i < orig.cells_to_activate[0].SI_msg[0].SI_container_length; i++) {
|
||||
orig.cells_to_activate[0].SI_msg[0].SI_container[i] = i;
|
||||
orig.cells_to_activate[0].SI_msg[0].SI_container.len = 10;
|
||||
orig.cells_to_activate[0].SI_msg[0].SI_container.buf = malloc(sizeof(uint8_t) * 10);
|
||||
for (int i = 0; i < (int)orig.cells_to_activate[0].SI_msg[0].SI_container.len; i++) {
|
||||
orig.cells_to_activate[0].SI_msg[0].SI_container.buf[i] = i;
|
||||
}
|
||||
// ASN.1 enc/dec
|
||||
F1AP_F1AP_PDU_t *f1enc = encode_f1ap_du_configuration_update_acknowledge(&orig);
|
||||
@@ -655,8 +655,8 @@ static void test_f1ap_cu_configuration_update(void)
|
||||
orig.cells_to_activate[0].plmn.mnc_digit_length = 2;
|
||||
orig.cells_to_activate[0].num_SI = 1;
|
||||
orig.cells_to_activate[0].SI_msg[0].SI_type = 7;
|
||||
orig.cells_to_activate[0].SI_msg[0].SI_container_length = 10;
|
||||
orig.cells_to_activate[0].SI_msg[0].SI_container = malloc(sizeof(uint8_t) * 10);
|
||||
orig.cells_to_activate[0].SI_msg[0].SI_container.len = 10;
|
||||
orig.cells_to_activate[0].SI_msg[0].SI_container.buf = malloc(sizeof(uint8_t) * 10);
|
||||
F1AP_F1AP_PDU_t *f1enc = encode_f1ap_cu_configuration_update(&orig);
|
||||
F1AP_F1AP_PDU_t *f1dec = f1ap_encode_decode(f1enc);
|
||||
f1ap_msg_free(f1enc);
|
||||
|
||||
Reference in New Issue
Block a user