free memory to reduce the memory leaks
This commit is contained in:
@@ -550,7 +550,7 @@ int main( int argc, char **argv ) {
|
||||
|
||||
// Sleep a while before checking all parameters have been used
|
||||
// Some are used directly in external threads, asynchronously
|
||||
sleep(20);
|
||||
sleep(200);
|
||||
config_check_unknown_cmdlineopt(CONFIG_CHECKALLSECTIONS);
|
||||
|
||||
while(true)
|
||||
|
||||
@@ -350,9 +350,12 @@ typedef enum ngap_Cause_e {
|
||||
NGAP_CAUSE_NAS,
|
||||
NGAP_CAUSE_PROTOCOL,
|
||||
NGAP_CAUSE_MISC,
|
||||
/* Extensions may appear below */
|
||||
|
||||
} ngap_Cause_t;
|
||||
NGAP_Cause_PR_choice_ExtensionS,
|
||||
//Evilish manual duplicate of asn.1 grammar
|
||||
//because it is human work, whereas it can be generated by machine
|
||||
//and because humans manual copy creates bugs
|
||||
//and we create multiple names for the same thing, that is a source of confusion
|
||||
} ngap_Cause_t;
|
||||
|
||||
typedef enum ngap_Cause_radio_network_e {
|
||||
NGAP_CAUSE_RADIO_NETWORK_UNSPECIFIED,
|
||||
|
||||
@@ -119,7 +119,7 @@ typedef struct sctp_data_ind_s {
|
||||
/* Buffer to send over SCTP */
|
||||
uint32_t buffer_length;
|
||||
uint8_t *buffer;
|
||||
|
||||
bool freeAfterSend;
|
||||
/* Streams on which data will be sent/received */
|
||||
uint16_t stream;
|
||||
} sctp_data_ind_t;
|
||||
|
||||
@@ -227,6 +227,7 @@ int e1ap_encode_send(E1_t type, e1ap_setup_req_t *setupReq, E1AP_E1AP_PDU_t *pdu
|
||||
s->buffer = buffer;
|
||||
s->buffer_length = encoded;
|
||||
s->stream = stream;
|
||||
s->freeAfterSend=true;
|
||||
LOG_I(E1AP, "%s: Sending ITTI message to SCTP Task\n", func);
|
||||
itti_send_msg_to_task(TASK_SCTP, 0 /*unused by callee*/, message);
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ void f1ap_itti_send_sctp_data_req(bool isCu, instance_t instance, uint8_t *buffe
|
||||
sctp_data_req->buffer = buffer;
|
||||
sctp_data_req->buffer_length = buffer_length;
|
||||
sctp_data_req->stream = stream;
|
||||
sctp_data_req->freeAfterSend=true;
|
||||
LOG_D(F1AP, "Sending ITTI message to SCTP Task\n");
|
||||
itti_send_msg_to_task(TASK_SCTP, instance, message_p);
|
||||
}
|
||||
|
||||
@@ -2799,7 +2799,13 @@ void nr_mac_update_timers(module_id_t module_id,
|
||||
(void **)&cg,
|
||||
(uint8_t *)UE->cg_buf,
|
||||
(UE->enc_rval.encoded+7)/8, 0, 0);
|
||||
UE->CellGroup = cg;
|
||||
if (UE->CellGroup) {
|
||||
NR_CellGroupConfig_t *tmp=UE->CellGroup;
|
||||
UE->CellGroup = cg;
|
||||
ASN_STRUCT_FREE(asn_DEF_NR_CellGroupConfig,tmp);
|
||||
} else
|
||||
UE->CellGroup = cg;
|
||||
|
||||
|
||||
if (LOG_DEBUGFLAG(DEBUG_ASN1)) {
|
||||
xer_fprint(stdout, &asn_DEF_NR_CellGroupConfig, (const void *) UE->CellGroup);
|
||||
|
||||
@@ -1298,27 +1298,24 @@ uint8_t do_NR_SecurityModeCommand(
|
||||
uint8_t *const buffer,
|
||||
const uint8_t Transaction_id,
|
||||
const uint8_t cipheringAlgorithm,
|
||||
NR_IntegrityProtAlgorithm_t *integrityProtAlgorithm
|
||||
NR_IntegrityProtAlgorithm_t integrityProtAlgorithm
|
||||
)
|
||||
//------------------------------------------------------------------------------
|
||||
{
|
||||
NR_DL_DCCH_Message_t dl_dcch_msg;
|
||||
NR_DL_DCCH_Message_t dl_dcch_msg={0};
|
||||
asn_enc_rval_t enc_rval;
|
||||
memset(&dl_dcch_msg,0,sizeof(NR_DL_DCCH_Message_t));
|
||||
dl_dcch_msg.message.present = NR_DL_DCCH_MessageType_PR_c1;
|
||||
dl_dcch_msg.message.choice.c1=CALLOC(1,sizeof(struct NR_DL_DCCH_MessageType__c1));
|
||||
dl_dcch_msg.message.choice.c1->present = NR_DL_DCCH_MessageType__c1_PR_securityModeCommand;
|
||||
dl_dcch_msg.message.choice.c1->choice.securityModeCommand = CALLOC(1, sizeof(struct NR_SecurityModeCommand));
|
||||
dl_dcch_msg.message.choice.c1->choice.securityModeCommand->rrc_TransactionIdentifier = Transaction_id;
|
||||
dl_dcch_msg.message.choice.c1->choice.securityModeCommand->criticalExtensions.present = NR_SecurityModeCommand__criticalExtensions_PR_securityModeCommand;
|
||||
asn1cCalloc(dl_dcch_msg.message.choice.c1, c1);
|
||||
c1->present = NR_DL_DCCH_MessageType__c1_PR_securityModeCommand;
|
||||
asn1cCalloc(c1->choice.securityModeCommand,scm);
|
||||
scm->rrc_TransactionIdentifier = Transaction_id;
|
||||
scm->criticalExtensions.present = NR_SecurityModeCommand__criticalExtensions_PR_securityModeCommand;
|
||||
|
||||
dl_dcch_msg.message.choice.c1->choice.securityModeCommand->criticalExtensions.choice.securityModeCommand =
|
||||
CALLOC(1, sizeof(struct NR_SecurityModeCommand_IEs));
|
||||
asn1cCalloc(scm->criticalExtensions.choice.securityModeCommand,scmIE);
|
||||
// the two following information could be based on the mod_id
|
||||
dl_dcch_msg.message.choice.c1->choice.securityModeCommand->criticalExtensions.choice.securityModeCommand->securityConfigSMC.securityAlgorithmConfig.cipheringAlgorithm
|
||||
scmIE->securityConfigSMC.securityAlgorithmConfig.cipheringAlgorithm
|
||||
= (NR_CipheringAlgorithm_t)cipheringAlgorithm;
|
||||
dl_dcch_msg.message.choice.c1->choice.securityModeCommand->criticalExtensions.choice.securityModeCommand->securityConfigSMC.securityAlgorithmConfig.integrityProtAlgorithm
|
||||
= integrityProtAlgorithm;
|
||||
asn1cCallocOne(scmIE->securityConfigSMC.securityAlgorithmConfig.integrityProtAlgorithm, integrityProtAlgorithm);
|
||||
|
||||
if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) {
|
||||
xer_fprint(stdout, &asn_DEF_NR_DL_DCCH_Message, (void *)&dl_dcch_msg);
|
||||
@@ -1332,7 +1329,7 @@ uint8_t do_NR_SecurityModeCommand(
|
||||
|
||||
AssertFatal(enc_rval.encoded >0 , "ASN1 message encoding failed (%s, %lu)!\n",
|
||||
enc_rval.failed_type->name, enc_rval.encoded);
|
||||
|
||||
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_NR_DL_DCCH_Message,&dl_dcch_msg);
|
||||
LOG_D(NR_RRC, "[gNB %d] securityModeCommand for UE %lx Encoded %zd bits (%zd bytes)\n", ctxt_pP->module_id, ctxt_pP->rntiMaybeUEid, enc_rval.encoded, (enc_rval.encoded + 7) / 8);
|
||||
|
||||
// rrc_ue_process_ueCapabilityEnquiry(0,1000,&dl_dcch_msg.message.choice.c1.choice.ueCapabilityEnquiry,0);
|
||||
@@ -1751,29 +1748,26 @@ do_NR_DLInformationTransfer(
|
||||
//------------------------------------------------------------------------------
|
||||
{
|
||||
ssize_t encoded;
|
||||
NR_DL_DCCH_Message_t dl_dcch_msg;
|
||||
memset(&dl_dcch_msg, 0, sizeof(NR_DL_DCCH_Message_t));
|
||||
NR_DL_DCCH_Message_t dl_dcch_msg={0};
|
||||
dl_dcch_msg.message.present = NR_DL_DCCH_MessageType_PR_c1;
|
||||
dl_dcch_msg.message.choice.c1 = CALLOC(1, sizeof(struct NR_DL_DCCH_MessageType__c1));
|
||||
dl_dcch_msg.message.choice.c1->present = NR_DL_DCCH_MessageType__c1_PR_dlInformationTransfer;
|
||||
asn1cCalloc(dl_dcch_msg.message.choice.c1, c1);
|
||||
c1->present = NR_DL_DCCH_MessageType__c1_PR_dlInformationTransfer;
|
||||
|
||||
dl_dcch_msg.message.choice.c1->choice.dlInformationTransfer = CALLOC(1, sizeof(NR_DLInformationTransfer_t));
|
||||
dl_dcch_msg.message.choice.c1->choice.dlInformationTransfer->rrc_TransactionIdentifier = transaction_id;
|
||||
dl_dcch_msg.message.choice.c1->choice.dlInformationTransfer->criticalExtensions.present =
|
||||
asn1cCalloc(c1->choice.dlInformationTransfer, infoTransfer);
|
||||
infoTransfer->rrc_TransactionIdentifier = transaction_id;
|
||||
infoTransfer->criticalExtensions.present =
|
||||
NR_DLInformationTransfer__criticalExtensions_PR_dlInformationTransfer;
|
||||
|
||||
dl_dcch_msg.message.choice.c1->choice.dlInformationTransfer->
|
||||
criticalExtensions.choice.dlInformationTransfer = CALLOC(1, sizeof(NR_DLInformationTransfer_IEs_t));
|
||||
dl_dcch_msg.message.choice.c1->choice.dlInformationTransfer->
|
||||
criticalExtensions.choice.dlInformationTransfer->dedicatedNAS_Message = CALLOC(1, sizeof(NR_DedicatedNAS_Message_t));
|
||||
dl_dcch_msg.message.choice.c1->choice.dlInformationTransfer->
|
||||
criticalExtensions.choice.dlInformationTransfer->dedicatedNAS_Message->buf = pdu_buffer;
|
||||
dl_dcch_msg.message.choice.c1->choice.dlInformationTransfer->
|
||||
criticalExtensions.choice.dlInformationTransfer->dedicatedNAS_Message->size = pdu_length;
|
||||
asn1cCalloc(infoTransfer->criticalExtensions.choice.dlInformationTransfer, dlInfoTransfer);
|
||||
asn1cCalloc(dlInfoTransfer->dedicatedNAS_Message,msg);
|
||||
// we will free the caller buffer
|
||||
msg->buf = pdu_buffer;
|
||||
msg->size = pdu_length;
|
||||
|
||||
encoded = uper_encode_to_new_buffer (&asn_DEF_NR_DL_DCCH_Message, NULL, (void *) &dl_dcch_msg, (void **)buffer);
|
||||
AssertFatal(encoded > 0,"ASN1 message encoding failed (%s, %ld)!\n",
|
||||
"DLInformationTransfer", encoded);
|
||||
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_NR_DL_DCCH_Message,&dl_dcch_msg );
|
||||
LOG_D(NR_RRC,"DLInformationTransfer Encoded %zd bytes\n", encoded);
|
||||
//for (int i=0;i<encoded;i++) printf("%02x ",(*buffer)[i]);
|
||||
return encoded;
|
||||
|
||||
@@ -113,7 +113,7 @@ uint8_t do_NR_SecurityModeCommand(
|
||||
uint8_t *const buffer,
|
||||
const uint8_t Transaction_id,
|
||||
const uint8_t cipheringAlgorithm,
|
||||
NR_IntegrityProtAlgorithm_t *integrityProtAlgorithm);
|
||||
NR_IntegrityProtAlgorithm_t integrityProtAlgorithm);
|
||||
|
||||
uint8_t do_NR_SA_UECapabilityEnquiry( const protocol_ctxt_t *const ctxt_pP,
|
||||
uint8_t *const buffer,
|
||||
|
||||
@@ -3868,7 +3868,7 @@ rrc_gNB_generate_SecurityModeCommand(
|
||||
|
||||
T(T_ENB_RRC_SECURITY_MODE_COMMAND, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rntiMaybeUEid));
|
||||
NR_IntegrityProtAlgorithm_t integrity_algorithm = (NR_IntegrityProtAlgorithm_t)ue_p->integrity_algorithm;
|
||||
size = do_NR_SecurityModeCommand(ctxt_pP, buffer, rrc_gNB_get_next_transaction_identifier(ctxt_pP->module_id), ue_p->ciphering_algorithm, &integrity_algorithm);
|
||||
size = do_NR_SecurityModeCommand(ctxt_pP, buffer, rrc_gNB_get_next_transaction_identifier(ctxt_pP->module_id), ue_p->ciphering_algorithm, integrity_algorithm);
|
||||
LOG_DUMPMSG(NR_RRC,DEBUG_RRC,(char *)buffer,size,"[MSG] RRC Security Mode Command\n");
|
||||
LOG_I(NR_RRC, "UE %04x Logical Channel DL-DCCH, Generate SecurityModeCommand (bytes %d)\n", ue_p->rnti, size);
|
||||
|
||||
|
||||
@@ -279,6 +279,9 @@ static void fill_qos(NGAP_QosFlowSetupRequestList_t *qos, pdusession_t *session)
|
||||
static int decodePDUSessionResourceSetup(pdusession_t *session)
|
||||
{
|
||||
NGAP_PDUSessionResourceSetupRequestTransfer_t *pdusessionTransfer;
|
||||
for (int i=0; i<session->pdusessionTransfer.length; i++)
|
||||
printf("%02x:",session->pdusessionTransfer.buffer[i]);
|
||||
printf("\n");
|
||||
asn_codec_ctx_t st = {.max_stack_size = 100 * 1000};
|
||||
asn_dec_rval_t dec_rval =
|
||||
aper_decode(&st, &asn_DEF_NGAP_PDUSessionResourceSetupRequestTransfer, (void **)&pdusessionTransfer, session->pdusessionTransfer.buffer, session->pdusessionTransfer.length, 0, 0);
|
||||
@@ -345,6 +348,8 @@ static int decodePDUSessionResourceSetup(pdusession_t *session)
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
ASN_STRUCT_FREE(asn_DEF_NGAP_PDUSessionResourceSetupRequestTransfer,pdusessionTransfer );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -629,6 +634,7 @@ int rrc_gNB_process_NGAP_DOWNLINK_NAS(MessageDef *msg_p, instance_t instance, mu
|
||||
AssertFatal(srb_id > 0 && srb_id < maxSRBs, "");
|
||||
/* Transfer data to PDCP */
|
||||
nr_rrc_data_req(&ctxt, srb_id, (*rrc_gNB_mui)++, SDU_CONFIRM_NO, length, buffer, PDCP_TRANSMISSION_MODE_CONTROL);
|
||||
free(buffer); // nr_rrc_data_req do a second malloc and copy
|
||||
} break;
|
||||
|
||||
case ngran_gNB_DU:
|
||||
@@ -924,6 +930,7 @@ static void decodePDUSessionResourceModify(pdusession_t *param, const ngap_pdu_t
|
||||
return;
|
||||
}
|
||||
}
|
||||
ASN_STRUCT_FREE(asn_DEF_NGAP_PDUSessionResourceModifyRequestTransfer,pdusessionTransfer );
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
@@ -44,6 +44,7 @@ void x2ap_eNB_itti_send_sctp_data_req(instance_t instance, int32_t assoc_id, uin
|
||||
sctp_data_req->buffer = buffer;
|
||||
sctp_data_req->buffer_length = buffer_length;
|
||||
sctp_data_req->stream = stream;
|
||||
sctp_data_req->freeAfterSend=true;
|
||||
|
||||
itti_send_msg_to_task(TASK_SCTP, instance, message_p);
|
||||
}
|
||||
|
||||
@@ -187,7 +187,7 @@ int ngap_ue_context_release_req(instance_t instance,
|
||||
ie->id = NGAP_ProtocolIE_ID_id_Cause;
|
||||
ie->criticality = NGAP_Criticality_ignore;
|
||||
ie->value.present = NGAP_UEContextReleaseRequest_IEs__value_PR_Cause;
|
||||
DevAssert(ue_release_req_p->cause <= NGAP_Cause_PR_choice_Extensions);
|
||||
DevAssert(ue_release_req_p->cause <= NGAP_Cause_PR_choice_ExtensionS);
|
||||
ie->value.choice.Cause.present = ue_release_req_p->cause;
|
||||
ie->value.choice.Cause.choice.misc = ue_release_req_p->cause_value;
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ void ngap_gNB_itti_send_sctp_data_req(instance_t instance, int32_t assoc_id, uin
|
||||
sctp_data_req->buffer = buffer;
|
||||
sctp_data_req->buffer_length = buffer_length;
|
||||
sctp_data_req->stream = stream;
|
||||
sctp_data_req->freeAfterSend=true;
|
||||
|
||||
itti_send_msg_to_task(TASK_SCTP, instance, message_p);
|
||||
}
|
||||
|
||||
@@ -650,7 +650,8 @@ static void sctp_send_data(sctp_data_req_t *sctp_data_req_p)
|
||||
/* TODO: notify upper layer */
|
||||
return;
|
||||
}
|
||||
|
||||
if ( sctp_data_req_p->freeAfterSend)
|
||||
free(sctp_data_req_p->buffer);
|
||||
SCTP_DEBUG("Successfully sent %u bytes on stream %d for assoc_id %u\n",
|
||||
sctp_data_req_p->buffer_length, sctp_data_req_p->stream,
|
||||
sctp_cnx->assoc_id);
|
||||
|
||||
Reference in New Issue
Block a user