Replace ngap_pdu_t with byte_array_t

ngap_pdu_t has the same definition as byte_array_t, so it is
replaced by the latter. This simplify the stack and reduces
duplicated code.

Also, add function create_byte_array to copy from an
existing buffer to a new byte_array_t and replaced
allocCopy with create_byte_array, and adopted
OCTET_STRING_fromBuf whenever possible.
This commit is contained in:
Guido Casati
2025-05-28 12:59:50 +02:00
parent 4c179270c2
commit 8fb8713023
11 changed files with 121 additions and 137 deletions
+13 -19
View File
@@ -34,6 +34,7 @@
#include "common/platform_types.h"
#include "common/5g_platform_types.h"
#include "s1ap_messages_types.h"
#include "ds/byte_array.h"
// Defines to access message fields.
#define NGAP_REGISTER_GNB_REQ(mSGpTR) (mSGpTR)->ittiMsg.ngap_register_gnb_req
@@ -227,13 +228,6 @@ typedef struct ngap_ue_identity_s {
nr_guami_t guami;
} ngap_ue_identity_t;
typedef struct ngap_nas_pdu_s {
/* Octet string data */
uint8_t *buffer;
/* Length of the octet string */
uint32_t length;
} ngap_pdu_t;
typedef struct ngap_mobility_restriction_s{
ngap_plmn_identity_t serving_plmn;
}ngap_mobility_restriction_t;
@@ -249,8 +243,8 @@ typedef enum pdu_session_type_e {
typedef struct pdusession_s {
/* Unique pdusession_id for the UE. */
int pdusession_id;
ngap_pdu_t nas_pdu;
ngap_pdu_t pdusessionTransfer;
byte_array_t nas_pdu;
byte_array_t pdusessionTransfer;
uint8_t nb_qos;
/* Quality of service for this pdusession */
pdusession_level_qos_parameter_t qos[QOSFLOW_MAX_VALUE];
@@ -508,7 +502,7 @@ typedef struct ngap_nas_first_req_s {
ngap_rrc_establishment_cause_t establishment_cause;
/* NAS PDU */
ngap_pdu_t nas_pdu;
byte_array_t nas_pdu;
/* If this flag is set NGAP layer is expecting the GUAMI. If = 0,
* the temporary s-tmsi is used.
@@ -520,12 +514,12 @@ typedef struct ngap_uplink_nas_s {
/* Unique UE identifier within an gNB */
uint32_t gNB_ue_ngap_id;
/* NAS pdu */
ngap_pdu_t nas_pdu;
byte_array_t nas_pdu;
} ngap_uplink_nas_t;
typedef struct ngap_ue_cap_info_ind_s {
uint32_t gNB_ue_ngap_id;
ngap_pdu_t ue_radio_cap;
byte_array_t ue_radio_cap;
} ngap_ue_cap_info_ind_t;
typedef struct ngap_initial_context_setup_resp_s {
@@ -552,7 +546,7 @@ typedef struct ngap_initial_context_setup_fail_s {
typedef struct ngap_nas_non_delivery_ind_s {
uint32_t gNB_ue_ngap_id;
ngap_pdu_t nas_pdu;
byte_array_t nas_pdu;
/* TODO: add cause */
} ngap_nas_non_delivery_ind_t;
@@ -590,7 +584,7 @@ typedef struct ngap_downlink_nas_s {
/* UE id for initial connection to NGAP */
uint32_t gNB_ue_ngap_id;
/* NAS pdu */
ngap_pdu_t nas_pdu;
byte_array_t nas_pdu;
} ngap_downlink_nas_t;
@@ -627,7 +621,7 @@ typedef struct ngap_initial_context_setup_req_s {
/* Nas Pdu */
uint8_t nas_pdu_flag;
ngap_pdu_t nas_pdu;
byte_array_t nas_pdu;
} ngap_initial_context_setup_req_t;
@@ -656,8 +650,8 @@ typedef struct ngap_paging_ind_s {
typedef struct {
/* Unique pdusession_id for the UE. */
int pdusession_id;
ngap_pdu_t nas_pdu;
ngap_pdu_t pdusessionTransfer;
byte_array_t nas_pdu;
byte_array_t pdusessionTransfer;
} pdusession_setup_req_t;
typedef struct ngap_pdusession_setup_req_s {
@@ -783,7 +777,7 @@ typedef struct ngap_ue_release_command_s {
typedef struct pdusession_release_s {
/* Unique pdusession_id for the UE. */
uint8_t pdusession_id;
ngap_pdu_t data;
byte_array_t data;
} pdusession_release_t;
typedef struct ngap_ue_release_req_s {
@@ -831,7 +825,7 @@ typedef struct ngap_pdusession_release_command_s {
uint32_t gNB_ue_ngap_id;
/* The NAS PDU should be forwarded by the RRC layer to the NAS layer */
ngap_pdu_t nas_pdu;
byte_array_t nas_pdu;
/* Number of pdusession to be released in the list */
uint8_t nb_pdusessions_torelease;