Commit 396896be authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Fix issue for malformed PDUSessionResourceSetupRequest

parent 5227afe5
...@@ -48,6 +48,10 @@ ...@@ -48,6 +48,10 @@
#include "Ngap_CauseRadioNetwork.h" #include "Ngap_CauseRadioNetwork.h"
#include "Ngap_TimeToWait.h" #include "Ngap_TimeToWait.h"
extern "C" {
#include "dynamic_memory_check.h"
}
using namespace amf_application; using namespace amf_application;
using namespace config; using namespace config;
extern itti_mw *itti_inst; extern itti_mw *itti_inst;
...@@ -573,10 +577,22 @@ void amf_n2::handle_itti_message(itti_pdu_session_resource_setup_request &itti_m ...@@ -573,10 +577,22 @@ void amf_n2::handle_itti_message(itti_pdu_session_resource_setup_request &itti_m
list.push_back(item); list.push_back(item);
psrsr->setPduSessionResourceSetupRequestList(list); psrsr->setPduSessionResourceSetupRequestList(list);
uint8_t buffer[5000]; size_t buffer_size = 512; //TODO: remove hardcoded value
int encoded_size = psrsr->encode2buffer(buffer, 5000); char *buffer = (char*) calloc(1, buffer_size);
int encoded_size = 0;
psrsr->encode2buffer_new(buffer, encoded_size);
#if DEBUG_IS_ON
Logger::amf_n2().debug("N2 SM buffer data: ");
for (int i = 0; i < encoded_size; i++)
printf("%02x ", (char) buffer[i]);
#endif
Logger::amf_n2().debug(" (%d bytes) \n", encoded_size);
bstring b = blk2bstr(buffer, encoded_size); bstring b = blk2bstr(buffer, encoded_size);
sctp_s_38412.sctp_send_msg(gc.get()->sctp_assoc_id, unc.get()->sctp_stream_send, &b); sctp_s_38412.sctp_send_msg(gc.get()->sctp_assoc_id, unc.get()->sctp_stream_send, &b);
//free memory
free_wrapper((void**) &buffer);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
......
...@@ -49,7 +49,7 @@ void statistics::display() { ...@@ -49,7 +49,7 @@ void statistics::display() {
//TODO: Show the list of common PLMNs //TODO: Show the list of common PLMNs
for (int i = 0; i < gnbs.size(); i++) { for (int i = 0; i < gnbs.size(); i++) {
Logger::amf_app().info("| %d | Connected | 0x%x | %s | %s, %d | ", i + 1, gnbs[i].gnb_id, gnbs[i].gnb_name.c_str(), (gnbs[i].mcc + gnbs[i].mnc).c_str(), gnbs[i].tac); Logger::amf_app().info("| %d | Connected | 0x%x | %s | %s, %d | ", i + 1, gnbs[i].gnb_id, gnbs[i].gnb_name.c_str(), (gnbs[i].mcc + gnbs[i].mnc).c_str(), gnbs[i].tac);
} }
Logger::amf_app().info("|----------------------------------------------------------------------------------------------------------------|"); Logger::amf_app().info("|----------------------------------------------------------------------------------------------------------------|");
Logger::amf_app().info(""); Logger::amf_app().info("");
......
...@@ -223,6 +223,17 @@ int PduSessionResourceSetupRequestMsg::encode2buffer(uint8_t *buf, int buf_size) ...@@ -223,6 +223,17 @@ int PduSessionResourceSetupRequestMsg::encode2buffer(uint8_t *buf, int buf_size)
return er.encoded; return er.encoded;
} }
//------------------------------------------------------------------------------
void PduSessionResourceSetupRequestMsg::encode2buffer_new(char *buf, int &encoded_size) {
char *buffer = (char*) calloc(1, 512); //TODO: remove hardcoded value
asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, pduSessionResourceSetupRequestPdu);
encoded_size = aper_encode_to_new_buffer(&asn_DEF_Ngap_NGAP_PDU, NULL, pduSessionResourceSetupRequestPdu, (void**)&buffer);
cout << "er.encoded(" << encoded_size << ")" << endl;
memcpy((void*) buf, (void*) buffer, encoded_size);
free(buffer);
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
//Decapsulation //Decapsulation
bool PduSessionResourceSetupRequestMsg::decodefrompdu(Ngap_NGAP_PDU_t *ngap_msg_pdu) { bool PduSessionResourceSetupRequestMsg::decodefrompdu(Ngap_NGAP_PDU_t *ngap_msg_pdu) {
......
...@@ -60,6 +60,7 @@ class PduSessionResourceSetupRequestMsg { ...@@ -60,6 +60,7 @@ class PduSessionResourceSetupRequestMsg {
void setPduSessionResourceSetupRequestList(std::vector<PDUSessionResourceSetupRequestItem_t> list); void setPduSessionResourceSetupRequestList(std::vector<PDUSessionResourceSetupRequestItem_t> list);
void setPduSessionAggregateMaximumBitRate(long bit_rate_downlink, long bit_rate_uplink); void setPduSessionAggregateMaximumBitRate(long bit_rate_downlink, long bit_rate_uplink);
int encode2buffer(uint8_t *buf, int buf_size); int encode2buffer(uint8_t *buf, int buf_size);
void encode2buffer_new(char *buf, int &encoded_size);
//Decapsulation //Decapsulation
bool decodefrompdu(Ngap_NGAP_PDU_t *ngap_msg_pdu); bool decodefrompdu(Ngap_NGAP_PDU_t *ngap_msg_pdu);
unsigned long getAmfUeNgapId(); unsigned long getAmfUeNgapId();
......
...@@ -62,7 +62,7 @@ void N1N2MessageCollectionDocumentApiImpl::n1_n2_message_transfer(const std::str ...@@ -62,7 +62,7 @@ void N1N2MessageCollectionDocumentApiImpl::n1_n2_message_transfer(const std::str
} }
bstring n1sm; bstring n1sm;
msg_str_2_msg_hex(n1sm_str.substr(0, n1sm_str.length()-2), n1sm); msg_str_2_msg_hex(n1sm_str.substr(0, n1sm_str.length()), n1sm);
bstring n2sm; bstring n2sm;
msg_str_2_msg_hex(n2sm_str, n2sm); msg_str_2_msg_hex(n2sm_str, n2sm);
......
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