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:
Guido Casati
2026-04-10 10:22:50 +02:00
parent 7606a93f57
commit e27f8c24cf
7 changed files with 78 additions and 58 deletions
+9 -9
View File
@@ -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);