Commit 51596029 authored by winckel's avatar winckel
Browse files

Modified asn1 function to let them handle memory allocation.

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4481 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent 731f75c5
......@@ -1826,13 +1826,13 @@ uint8_t do_MeasurementReport(uint8_t *buffer,int measid,int phy_id,int rsrp_s,in
return((enc_rval.encoded+7)/8);
}
uint8_t do_DLInformationTransfer(uint32_t length, uint8_t *buffer, uint8_t transaction_id, uint32_t pdu_length, uint8_t *pdu_buffer)
uint8_t do_DLInformationTransfer(uint8_t **buffer, uint8_t transaction_id, uint32_t pdu_length, uint8_t *pdu_buffer)
{
asn_enc_rval_t enc_rval;
ssize_t encoded;
DL_DCCH_Message_t dl_dcch_msg;
memset(&dl_dcch_msg,0,sizeof(DL_DCCH_Message_t));
memset(&dl_dcch_msg, 0, sizeof(DL_DCCH_Message_t));
dl_dcch_msg.message.present = DL_DCCH_MessageType_PR_c1;
dl_dcch_msg.message.choice.c1.present = DL_DCCH_MessageType__c1_PR_dlInformationTransfer;
......@@ -1843,18 +1843,18 @@ uint8_t do_DLInformationTransfer(uint32_t length, uint8_t *buffer, uint8_t trans
dl_dcch_msg.message.choice.c1.choice.dlInformationTransfer.criticalExtensions.choice.c1.choice.dlInformationTransfer_r8.dedicatedInfoType.choice.dedicatedInfoNAS.size = pdu_length;
dl_dcch_msg.message.choice.c1.choice.dlInformationTransfer.criticalExtensions.choice.c1.choice.dlInformationTransfer_r8.dedicatedInfoType.choice.dedicatedInfoNAS.buf = pdu_buffer;
enc_rval = uper_encode_to_buffer (&asn_DEF_DL_DCCH_Message, (void*) &dl_dcch_msg, buffer, length);
encoded = uper_encode_to_new_buffer (&asn_DEF_DL_DCCH_Message, (void*) &dl_dcch_msg, NULL, (void **) buffer);
return((enc_rval.encoded+7)/8);
return((encoded + 7) / 8);
}
uint8_t do_ULInformationTransfer(uint32_t length, uint8_t *buffer, uint32_t pdu_length, uint8_t *pdu_buffer)
uint8_t do_ULInformationTransfer(uint8_t **buffer, uint32_t pdu_length, uint8_t *pdu_buffer)
{
asn_enc_rval_t enc_rval;
ssize_t encoded;
UL_DCCH_Message_t ul_dcch_msg;
memset(&ul_dcch_msg,0,sizeof(UL_DCCH_Message_t));
memset(&ul_dcch_msg, 0, sizeof(UL_DCCH_Message_t));
ul_dcch_msg.message.present = UL_DCCH_MessageType_PR_c1;
ul_dcch_msg.message.choice.c1.present = UL_DCCH_MessageType__c1_PR_ulInformationTransfer;
......@@ -1864,9 +1864,9 @@ uint8_t do_ULInformationTransfer(uint32_t length, uint8_t *buffer, uint32_t pdu_
ul_dcch_msg.message.choice.c1.choice.ulInformationTransfer.criticalExtensions.choice.c1.choice.ulInformationTransfer_r8.dedicatedInfoType.choice.dedicatedInfoNAS.size = pdu_length;
ul_dcch_msg.message.choice.c1.choice.ulInformationTransfer.criticalExtensions.choice.c1.choice.ulInformationTransfer_r8.dedicatedInfoType.choice.dedicatedInfoNAS.buf = pdu_buffer;
enc_rval = uper_encode_to_buffer (&asn_DEF_UL_DCCH_Message, (void*) &ul_dcch_msg, buffer, length);
encoded = uper_encode_to_new_buffer (&asn_DEF_UL_DCCH_Message, (void*) &ul_dcch_msg, NULL, (void **) buffer);
return((enc_rval.encoded+7)/8);
return((encoded + 7) / 8);
}
OAI_UECapability_t *fill_ue_capability() {
......
......@@ -195,9 +195,9 @@ uint8_t do_MBSFNAreaConfig(LTE_DL_FRAME_PARMS *frame_parms,
uint8_t do_MeasurementReport(uint8_t *buffer,int measid,int phy_id,int rsrp_s,int rsrq_s,long rsrp_t,long rsrq_t);
uint8_t do_DLInformationTransfer(uint32_t length, uint8_t *buffer, uint8_t transaction_id, uint32_t pdu_length, uint8_t *pdu_buffer);
uint8_t do_DLInformationTransfer(uint8_t **buffer, uint8_t transaction_id, uint32_t pdu_length, uint8_t *pdu_buffer);
uint8_t do_ULInformationTransfer(uint32_t length, uint8_t *buffer, uint32_t pdu_length, uint8_t *pdu_buffer);
uint8_t do_ULInformationTransfer(uint8_t **buffer, uint32_t pdu_length, uint8_t *pdu_buffer);
OAI_UECapability_t *fill_ue_capability();
......
......@@ -2354,13 +2354,8 @@ void *rrc_ue_task(void *args_p) {
LOG_D(RRC, "Received %s: instance %d, UEid %d\n", msg_name, instance, NAS_UPLINK_DATA_REQ (msg_p).UEid);
/* Allocate a buffer for the NAS PDU payload plus some space for the encapsulation */
length = NAS_UPLINK_DATA_REQ (msg_p).nasMsg.length + 20;
buffer = malloc (length);
/* Create message for PDCP (ULInformationTransfer_t) */
length = do_ULInformationTransfer(length, buffer,
NAS_UPLINK_DATA_REQ (msg_p).nasMsg.length, NAS_UPLINK_DATA_REQ (msg_p).nasMsg.data);
length = do_ULInformationTransfer(&buffer, NAS_UPLINK_DATA_REQ (msg_p).nasMsg.length, NAS_UPLINK_DATA_REQ (msg_p).nasMsg.data);
/* Transfer data to PDCP */
pdcp_rrc_data_req (instance, 0 /* TODO put frame number ! */, 0, DCCH, rrc_mui++, 0, length, buffer, 1);
......
......@@ -3299,12 +3299,8 @@ void *rrc_enb_task(void *args_p) {
}
else
{
/* Allocate a buffer for the NAS PDU payload plus some space for the encapsulation */
length = S1AP_DOWNLINK_NAS (msg_p).nas_pdu.length + 20;
buffer = malloc (length);
/* Create message for PDCP (DLInformationTransfer_t) */
length = do_DLInformationTransfer(length, buffer, get_next_rrc_transaction_identifier(instance),
length = do_DLInformationTransfer(&buffer, get_next_rrc_transaction_identifier(instance),
S1AP_DOWNLINK_NAS (msg_p).nas_pdu.length, S1AP_DOWNLINK_NAS (msg_p).nas_pdu.buffer);
/* Transfer data to PDCP */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment