Commit d5978496 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Fix padding issue for NGAP messages

parent e08a5729
...@@ -203,7 +203,7 @@ install_nlohmann_from_git() { ...@@ -203,7 +203,7 @@ install_nlohmann_from_git() {
install_nghttp2_from_git() { install_nghttp2_from_git() {
if [ $1 -eq 0 ]; then if [ $1 -eq 0 ]; then
read -p "Do you want to install nghttp2 ? <y/N> " prompt read -p "Do you want to install nghttp2 ? <y/N> " prompt
OPTION="-y" OPTION=""
else else
prompt='y' prompt='y'
OPTION="-y" OPTION="-y"
...@@ -260,8 +260,7 @@ install_nghttp2_from_git() { ...@@ -260,8 +260,7 @@ install_nghttp2_from_git() {
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
popd popd
fi fi
return 0 return 0
} }
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
...@@ -401,8 +400,6 @@ check_install_smf_deps() { ...@@ -401,8 +400,6 @@ check_install_smf_deps() {
install_nghttp2_from_git $1 $2 install_nghttp2_from_git $1 $2
ret=$?;[[ $ret -ne 0 ]] && return $ret ret=$?;[[ $ret -ne 0 ]] && return $ret
$SUDO /sbin/ldconfig -v
ret=$?;[[ $ret -ne 0 ]] && return $ret
return 0 return 0
} }
......
...@@ -41,8 +41,8 @@ Based on document **3GPP TS 23.501 v16.0.0 §6.2.2**. ...@@ -41,8 +41,8 @@ Based on document **3GPP TS 23.501 v16.0.0 §6.2.2**.
| 1 | Session Management (Session Establishment/Modification/Release) | :heavy_check_mark: | | | 1 | Session Management (Session Establishment/Modification/Release) | :heavy_check_mark: | |
| 2 | UE IP address allocation & management​ | :heavy_check_mark: | Only support static ipv4 address allocation | | 2 | UE IP address allocation & management​ | :heavy_check_mark: | Only support static ipv4 address allocation |
| 3 | DHCPv4 (server and client) and DHCPv6 (server and client) function | :x: | | | 3 | DHCPv4 (server and client) and DHCPv6 (server and client) function | :x: | |
| 4 | Respond to ARP requests and/or IPv6 Neighbour Solicitation requests | :x: | Local configuration in SMF | | 4 | Respond to ARP requests and/or IPv6 Neighbour Solicitation requests | :x: | |
| 5 | Selection of UPF function​ | :x: | | | 5 | Selection of UPF function​ | :heavy_check_mark: | Local configuration in SMF |
| 6 | Configures traffic steering at UPF | :x: | | | 6 | Configures traffic steering at UPF | :x: | |
| 7 | Termination of interfaces towards PCFs | :x: | | | 7 | Termination of interfaces towards PCFs | :x: | |
| 8 | Lawful intercept | :x: | | | 8 | Lawful intercept | :x: | |
...@@ -55,5 +55,3 @@ Based on document **3GPP TS 23.501 v16.0.0 §6.2.2**. ...@@ -55,5 +55,3 @@ Based on document **3GPP TS 23.501 v16.0.0 §6.2.2**.
| 15 | Support of header compression. ​ | :x: | | | 15 | Support of header compression. ​ | :x: | |
| 16 | Act as I-SMF in deployments | :x: | | | 16 | Act as I-SMF in deployments | :x: | |
| 17 | Provisioning of external parameters | :x: | | | 17 | Provisioning of external parameters | :x: | |
...@@ -19,6 +19,14 @@ ...@@ -19,6 +19,14 @@
* contact@openairinterface.org * contact@openairinterface.org
*/ */
/*! \file smf_http2-server.cpp
\brief
\author Tien-Thinh NGUYEN
\company Eurecom
\date 2020
\email: tien-thinh.nguyen@eurecom.fr
*/
#include "smf-http2-server.h" #include "smf-http2-server.h"
#include <string> #include <string>
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
......
...@@ -19,6 +19,14 @@ ...@@ -19,6 +19,14 @@
* contact@openairinterface.org * contact@openairinterface.org
*/ */
/*! \file smf_http2-server.h
\brief
\author Tien-Thinh NGUYEN
\company Eurecom
\date 2020
\email: tien-thinh.nguyen@eurecom.fr
*/
#ifndef FILE_SMF_HTTP2_SERVER_SEEN #ifndef FILE_SMF_HTTP2_SERVER_SEEN
#define FILE_SMF_HTTP2_SERVER_SEEN #define FILE_SMF_HTTP2_SERVER_SEEN
......
...@@ -64,10 +64,8 @@ void mime_parser::get_mime_parts(std::vector<mime_part> &parts) const { ...@@ -64,10 +64,8 @@ void mime_parser::get_mime_parts(std::vector<mime_part> &parts) const {
for (auto it : mime_parts) { for (auto it : mime_parts) {
parts.push_back(it); parts.push_back(it);
} }
} }
//--------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------
unsigned char* mime_parser::format_string_as_hex(const std::string &str) { unsigned char* mime_parser::format_string_as_hex(const std::string &str) {
unsigned int str_len = str.length(); unsigned int str_len = str.length();
...@@ -101,6 +99,8 @@ void mime_parser::create_multipart_related_content(std::string &body, ...@@ -101,6 +99,8 @@ void mime_parser::create_multipart_related_content(std::string &body,
const std::string &n1_message, const std::string &n1_message,
const std::string &n2_message) { const std::string &n2_message) {
//TODO: provide Content-Ids as function parameters
//format string as hex //format string as hex
unsigned char *n1_msg_hex = format_string_as_hex(n1_message); unsigned char *n1_msg_hex = format_string_as_hex(n1_message);
unsigned char *n2_msg_hex = format_string_as_hex(n2_message); unsigned char *n2_msg_hex = format_string_as_hex(n2_message);
...@@ -131,6 +131,7 @@ void mime_parser::create_multipart_related_content( ...@@ -131,6 +131,7 @@ void mime_parser::create_multipart_related_content(
std::string &body, const std::string &json_part, const std::string boundary, std::string &body, const std::string &json_part, const std::string boundary,
const std::string &message, const multipart_related_content_part_e content_type) { const std::string &message, const multipart_related_content_part_e content_type) {
//TODO: provide Content-Id as function parameters
//format string as hex //format string as hex
unsigned char *msg_hex = format_string_as_hex(message); unsigned char *msg_hex = format_string_as_hex(message);
......
...@@ -24,8 +24,8 @@ typedef struct asn_per_constraint_s { ...@@ -24,8 +24,8 @@ typedef struct asn_per_constraint_s {
} flags; } flags;
int range_bits; /* Full number of bits in the range */ int range_bits; /* Full number of bits in the range */
int effective_bits; /* Effective bits */ int effective_bits; /* Effective bits */
long lower_bound; /* "lb" value */ long long lower_bound; /* "lb" value */
long upper_bound; /* "ub" value */ long long upper_bound; /* "ub" value */
} asn_per_constraint_t; } asn_per_constraint_t;
typedef struct asn_per_constraints_s { typedef struct asn_per_constraints_s {
asn_per_constraint_t value; asn_per_constraint_t value;
......
...@@ -46,6 +46,7 @@ itti_mw *itti_inst = nullptr; ...@@ -46,6 +46,7 @@ itti_mw *itti_inst = nullptr;
async_shell_cmd *async_shell_cmd_inst = nullptr; async_shell_cmd *async_shell_cmd_inst = nullptr;
smf_app *smf_app_inst = nullptr; smf_app *smf_app_inst = nullptr;
smf_config smf_cfg; smf_config smf_cfg;
SMFApiServer *smf_api_server_1 = nullptr;
void send_heartbeat_to_tasks(const uint32_t sequence); void send_heartbeat_to_tasks(const uint32_t sequence);
...@@ -73,7 +74,9 @@ void my_app_signal_handler(int s) ...@@ -73,7 +74,9 @@ void my_app_signal_handler(int s)
if (itti_inst) delete itti_inst; itti_inst = nullptr; if (itti_inst) delete itti_inst; itti_inst = nullptr;
std::cout << "ITTI memory done." << std::endl; std::cout << "ITTI memory done." << std::endl;
if (smf_app_inst) delete smf_app_inst; smf_app_inst = nullptr; if (smf_app_inst) delete smf_app_inst; smf_app_inst = nullptr;
std::cout << "PGW APP memory done." << std::endl; std::cout << "SMF APP memory done." << std::endl;
smf_api_server_1->shutdown();
if (smf_api_server_1) delete smf_api_server_1; smf_api_server_1 = nullptr;
std::cout << "Freeing Allocated memory done" << std::endl; std::cout << "Freeing Allocated memory done" << std::endl;
exit(0); exit(0);
} }
...@@ -124,13 +127,15 @@ int main(int argc, char **argv) ...@@ -124,13 +127,15 @@ int main(int argc, char **argv)
//SMF Pistache API server (HTTP1) //SMF Pistache API server (HTTP1)
Pistache::Address addr(std::string(inet_ntoa (*((struct in_addr *)&smf_cfg.sbi.addr4))) , Pistache::Port(smf_cfg.sbi.port)); Pistache::Address addr(std::string(inet_ntoa (*((struct in_addr *)&smf_cfg.sbi.addr4))) , Pistache::Port(smf_cfg.sbi.port));
SMFApiServer smfApiServer(addr, smf_app_inst); SMFApiServer *smf_api_server_1 = new SMFApiServer(addr, smf_app_inst);
smfApiServer.init(2); smf_api_server_1->init(2);
std::thread smf_api_manager(&SMFApiServer::start, smfApiServer); smf_api_server_1->start();
//std::thread smf_api_manager(&SMFApiServer::start, smf_api_server_1);
//SMF NGHTTP API server (HTTP2) //SMF NGHTTP API server (HTTP2)
smf_http2_server *smf_server = new smf_http2_server(conv::toString(smf_cfg.sbi.addr4), smf_cfg.sbi_http2_port, smf_app_inst); smf_http2_server *smf_api_server_2 = new smf_http2_server(conv::toString(smf_cfg.sbi.addr4), smf_cfg.sbi_http2_port, smf_app_inst);
std::thread smf_api(&smf_http2_server::start, smf_server); smf_api_server_2->start();
//std::thread smf_api(&smf_http2_server::start, smf_api_server_2);
FILE *fp = NULL; FILE *fp = NULL;
std::string filename = fmt::format("/tmp/smf_{}.status", getpid()); std::string filename = fmt::format("/tmp/smf_{}.status", getpid());
......
...@@ -77,9 +77,7 @@ void smf_n1_n2::create_n1_sm_container(pdu_session_msg &msg, ...@@ -77,9 +77,7 @@ void smf_n1_n2::create_n1_sm_container(pdu_session_msg &msg,
n1_msg_type); n1_msg_type);
int bytes = { 0 }; int bytes = { 0 };
unsigned char data[BUF_LEN] = { '\0' }; unsigned char data[BUF_LEN] = { '\0' };
memset(data, 0, sizeof(data));
nas_message_t nas_msg = { }; nas_message_t nas_msg = { };
memset(&nas_msg, 0, sizeof(nas_message_t));
nas_msg.header.extended_protocol_discriminator = nas_msg.header.extended_protocol_discriminator =
EPD_5GS_SESSION_MANAGEMENT_MESSAGES; EPD_5GS_SESSION_MANAGEMENT_MESSAGES;
...@@ -187,7 +185,6 @@ void smf_n1_n2::create_n1_sm_container(pdu_session_msg &msg, ...@@ -187,7 +185,6 @@ void smf_n1_n2::create_n1_sm_container(pdu_session_msg &msg,
//Presence //Presence
sm_msg->pdu_session_establishment_accept.presence = 0xffff; //TODO: To be updated sm_msg->pdu_session_establishment_accept.presence = 0xffff; //TODO: To be updated
//_5GSMCause //_5GSMCause
//sm_msg->pdu_session_establishment_accept._5gsmcause = sm_context_res.get_cause();
sm_msg->pdu_session_establishment_accept._5gsmcause = sm_msg->pdu_session_establishment_accept._5gsmcause =
static_cast<uint8_t>(sm_cause); static_cast<uint8_t>(sm_cause);
Logger::smf_app().debug( Logger::smf_app().debug(
...@@ -581,7 +578,6 @@ void smf_n1_n2::create_n1_sm_container(pdu_session_msg &msg, ...@@ -581,7 +578,6 @@ void smf_n1_n2::create_n1_sm_container(pdu_session_msg &msg,
std::string n1Message((char*) data, bytes); std::string n1Message((char*) data, bytes);
nas_msg_str = n1Message; nas_msg_str = n1Message;
} }
break; break;
...@@ -623,7 +619,6 @@ void smf_n1_n2::create_n1_sm_container(pdu_session_msg &msg, ...@@ -623,7 +619,6 @@ void smf_n1_n2::create_n1_sm_container(pdu_session_msg &msg,
std::string n1Message((char*) data, bytes); std::string n1Message((char*) data, bytes);
nas_msg_str = n1Message; nas_msg_str = n1Message;
} }
break; break;
...@@ -631,9 +626,7 @@ void smf_n1_n2::create_n1_sm_container(pdu_session_msg &msg, ...@@ -631,9 +626,7 @@ void smf_n1_n2::create_n1_sm_container(pdu_session_msg &msg,
Logger::smf_app().debug("Unknown PDU Session Type"); Logger::smf_app().debug("Unknown PDU Session Type");
//TODO: //TODO:
} }
} //end Switch } //end Switch
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
...@@ -641,7 +634,6 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg, ...@@ -641,7 +634,6 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg,
uint8_t ngap_msg_type, uint8_t ngap_msg_type,
n2_sm_info_type_e ngap_ie_type, n2_sm_info_type_e ngap_ie_type,
std::string &ngap_msg_str) { std::string &ngap_msg_str) {
//TODO: To be filled with the correct parameters
Logger::smf_app().info( Logger::smf_app().info(
"Create N2 SM Information, NGAP message type %d, IE type %d", "Create N2 SM Information, NGAP message type %d, IE type %d",
ngap_msg_type, ngap_ie_type); ngap_msg_type, ngap_ie_type);
...@@ -725,6 +717,7 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg, ...@@ -725,6 +717,7 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg,
pduSessionAggregateMaximumBitRate->criticality = Ngap_Criticality_reject; pduSessionAggregateMaximumBitRate->criticality = Ngap_Criticality_reject;
pduSessionAggregateMaximumBitRate->value.present = pduSessionAggregateMaximumBitRate->value.present =
Ngap_PDUSessionResourceSetupRequestTransferIEs__value_PR_PDUSessionAggregateMaximumBitRate; Ngap_PDUSessionResourceSetupRequestTransferIEs__value_PR_PDUSessionAggregateMaximumBitRate;
asn_set_empty(&ngap_IEs->protocolIEs.list);
//SessionAMBR //SessionAMBR
supi_t supi = msg.get_supi(); supi_t supi = msg.get_supi();
...@@ -743,6 +736,7 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg, ...@@ -743,6 +736,7 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg,
"SMF context with SUPI " SUPI_64_FMT " does not exist!", supi64); "SMF context with SUPI " SUPI_64_FMT " does not exist!", supi64);
//TODO: //TODO:
} }
ASN_SEQUENCE_ADD(&ngap_IEs->protocolIEs.list, ASN_SEQUENCE_ADD(&ngap_IEs->protocolIEs.list,
pduSessionAggregateMaximumBitRate); pduSessionAggregateMaximumBitRate);
...@@ -867,6 +861,8 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg, ...@@ -867,6 +861,8 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg,
Ngap_Pre_emptionVulnerability_pre_emptable; Ngap_Pre_emptionVulnerability_pre_emptable;
} }
asn_set_empty(
&qosFlowSetupRequestList->value.choice.QosFlowSetupRequestList.list);
ASN_SEQUENCE_ADD( ASN_SEQUENCE_ADD(
&qosFlowSetupRequestList->value.choice.QosFlowSetupRequestList.list, &qosFlowSetupRequestList->value.choice.QosFlowSetupRequestList.list,
ngap_QosFlowSetupRequestItem); ngap_QosFlowSetupRequestItem);
...@@ -874,30 +870,32 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg, ...@@ -874,30 +870,32 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg,
Logger::smf_app().info( Logger::smf_app().info(
"QoS parameters: QFI %d, ARP priority level %d, qos_flow.qos_profile.arp.preempt_cap %s, qos_flow.qos_profile.arp.preempt_vuln %s", "QoS parameters: QFI %d, ARP priority level %d, qos_flow.qos_profile.arp.preempt_cap %s, qos_flow.qos_profile.arp.preempt_vuln %s",
qos_flow.qfi.qfi, qos_flow.qos_profile.arp.priority_level,qos_flow.qos_profile.arp.preempt_cap.c_str(), qos_flow.qos_profile.arp.preempt_vuln.c_str()); qos_flow.qfi.qfi, qos_flow.qos_profile.arp.priority_level,
qos_flow.qos_profile.arp.preempt_cap.c_str(),
qos_flow.qos_profile.arp.preempt_vuln.c_str());
//encode //encode
size_t buffer_size = BUF_LEN; size_t buffer_size = BUF_LEN;
char *buffer = (char*) calloc(1, buffer_size); char *buffer = (char*) calloc(1, buffer_size);
asn_enc_rval_t er = aper_encode_to_buffer( ssize_t encoded_size = aper_encode_to_new_buffer(
&asn_DEF_Ngap_PDUSessionResourceSetupRequestTransfer, nullptr, &asn_DEF_Ngap_PDUSessionResourceSetupRequestTransfer, nullptr,
ngap_IEs, (void*) buffer, buffer_size); ngap_IEs, (void**) &buffer);
if (er.encoded < 0) { if (encoded_size < 0) {
Logger::smf_app().warn( Logger::smf_app().warn(
"NGAP PDU Session Resource Setup Request Transfer encode failed, er.encoded: %d", "NGAP PDU Session Resource Setup Request Transfer encode failed (encode size %d)",
er.encoded); encoded_size);
return; return;
} }
#if DEBUG_IS_ON #if DEBUG_IS_ON
Logger::smf_app().debug("N2 SM buffer data: "); Logger::smf_app().debug("N2 SM buffer data: ");
for (int i = 0; i < er.encoded; i++) for (int i = 0; i < encoded_size; i++)
printf("%02x ", (char) buffer[i]); printf("%02x ", (char) buffer[i]);
printf(" (%d bytes)\n", (int) er.encoded); printf(" (%d bytes)\n", (int) encoded_size);
#endif #endif
std::string ngap_message((char*) buffer, er.encoded); std::string ngap_message((char*) buffer, encoded_size);
ngap_msg_str = ngap_message; ngap_msg_str = ngap_message;
//free memory //free memory
...@@ -921,7 +919,6 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg, ...@@ -921,7 +919,6 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg,
free_wrapper((void**) &ngap_QosFlowSetupRequestItem); free_wrapper((void**) &ngap_QosFlowSetupRequestItem);
free_wrapper((void**) &ngap_IEs); free_wrapper((void**) &ngap_IEs);
free_wrapper((void**) &buffer); free_wrapper((void**) &buffer);
} }
break; break;
...@@ -1157,24 +1154,24 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg, ...@@ -1157,24 +1154,24 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg,
size_t buffer_size = BUF_LEN; size_t buffer_size = BUF_LEN;
char *buffer = (char*) calloc(1, buffer_size); char *buffer = (char*) calloc(1, buffer_size);
asn_enc_rval_t er = aper_encode_to_buffer( ssize_t encoded_size = aper_encode_to_new_buffer(
&asn_DEF_Ngap_PDUSessionResourceModifyRequestTransfer, nullptr, &asn_DEF_Ngap_PDUSessionResourceModifyRequestTransfer, nullptr,
ngap_IEs, (void*) buffer, buffer_size); ngap_IEs, (void**) &buffer);
if (er.encoded < 0) { if (encoded_size < 0) {
Logger::smf_app().warn( Logger::smf_app().warn(
"[Create N2 SM Information] NGAP PDU Session Resource Modify Request Transfer encode failed, er.encoded: %d", "NGAP PDU Session Resource Modify Request Transfer encode failed (encoded size %d)",
er.encoded); encoded_size);
return; return;
} }
#if DEBUG_IS_ON #if DEBUG_IS_ON
Logger::smf_app().debug("N2 SM buffer data: "); Logger::smf_app().debug("N2 SM buffer data: ");
for (int i = 0; i < er.encoded; i++) for (int i = 0; i < encoded_size; i++)
printf("%02x ", (char) buffer[i]); printf("%02x ", (char) buffer[i]);
printf(" (%d bytes)\n", (int) er.encoded); printf(" (%d bytes)\n", (int) encoded_size);
#endif #endif
std::string ngap_message((char*) buffer, er.encoded); std::string ngap_message((char*) buffer, encoded_size);
ngap_msg_str = ngap_message; ngap_msg_str = ngap_message;
//free memory //free memory
...@@ -1208,8 +1205,7 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg, ...@@ -1208,8 +1205,7 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg,
break; break;
case n2_sm_info_type_e::PDU_RES_SETUP_RSP: { case n2_sm_info_type_e::PDU_RES_SETUP_RSP: {
//PDU Session Resource Setup Response Transfer //PDU Session Resource Setup Response Transfer for testing purpose
//for testing purpose
Logger::smf_app().debug( Logger::smf_app().debug(
"[Create N2 SM Information] NGAP PDU Session Resource Setup Response Transfer"); "[Create N2 SM Information] NGAP PDU Session Resource Setup Response Transfer");
...@@ -1282,24 +1278,24 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg, ...@@ -1282,24 +1278,24 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg,
size_t buffer_size = BUF_LEN; size_t buffer_size = BUF_LEN;
char *buffer = (char*) calloc(1, buffer_size); char *buffer = (char*) calloc(1, buffer_size);
asn_enc_rval_t er = aper_encode_to_buffer( ssize_t encoded_size = aper_encode_to_new_buffer(
&asn_DEF_Ngap_PDUSessionResourceSetupResponseTransfer, nullptr, &asn_DEF_Ngap_PDUSessionResourceSetupResponseTransfer, nullptr,
ngap_resource_response_transfer, (void*) buffer, buffer_size); ngap_resource_response_transfer, (void**) &buffer);
if (er.encoded < 0) { if (encoded_size < 0) {
Logger::smf_app().warn( Logger::smf_app().warn(
"[Create N2 SM Information] NGAP PDU Session Resource Setup Response Transfer encode failed, er.encoded: %d", "NGAP PDU Session Resource Setup Response Transfer encode failed (encoded size %d)",
er.encoded); encoded_size);
return; return;
} }
#if DEBUG_IS_ON #if DEBUG_IS_ON
Logger::smf_app().debug("N2 SM buffer data: "); Logger::smf_app().debug("N2 SM buffer data: ");
for (int i = 0; i < er.encoded; i++) for (int i = 0; i < encoded_size; i++)
printf("%02x ", (char) buffer[i]); printf("%02x ", (char) buffer[i]);
Logger::smf_app().debug(" (%d bytes) \n", er.encoded); Logger::smf_app().debug(" (%d bytes) \n", encoded_size);
#endif #endif
std::string ngap_message((char*) buffer, er.encoded); std::string ngap_message((char*) buffer, encoded_size);
ngap_msg_str = ngap_message; ngap_msg_str = ngap_message;
//free memory //free memory
...@@ -1320,12 +1316,10 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg, ...@@ -1320,12 +1316,10 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg,
break; break;
case n2_sm_info_type_e::PDU_RES_MOD_RSP: { case n2_sm_info_type_e::PDU_RES_MOD_RSP: {
//PDU Session Resource Modify Response Transfer IE //PDU Session Resource Modify Response Transfer IE for testing purpose
//for testing purpose
Logger::smf_app().debug( Logger::smf_app().debug(
"[Create N2 SM Information] NGAP PDU Session Resource Modify Response Transfer"); "[Create N2 SM Information] NGAP PDU Session Resource Modify Response Transfer");
//struct Ngap_UPTransportLayerInformation *dL_NGU_UP_TNLInformation; /* OPTIONAL */ //struct Ngap_UPTransportLayerInformation *dL_NGU_UP_TNLInformation; /* OPTIONAL */
//struct Ngap_UPTransportLayerInformation *uL_NGU_UP_TNLInformation; /* OPTIONAL */ //struct Ngap_UPTransportLayerInformation *uL_NGU_UP_TNLInformation; /* OPTIONAL */
//struct Ngap_QosFlowAddOrModifyResponseList *qosFlowAddOrModifyResponseList; /* OPTIONAL */ //struct Ngap_QosFlowAddOrModifyResponseList *qosFlowAddOrModifyResponseList; /* OPTIONAL */
...@@ -1394,24 +1388,24 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg, ...@@ -1394,24 +1388,24 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg,
size_t buffer_size = BUF_LEN; size_t buffer_size = BUF_LEN;
char *buffer = (char*) calloc(1, buffer_size); char *buffer = (char*) calloc(1, buffer_size);
asn_enc_rval_t er = aper_encode_to_buffer( ssize_t encoded_size = aper_encode_to_new_buffer(
&asn_DEF_Ngap_PDUSessionResourceModifyResponseTransfer, nullptr, &asn_DEF_Ngap_PDUSessionResourceModifyResponseTransfer, nullptr,
ngap_resource_response_transfer, (void*) buffer, buffer_size); ngap_resource_response_transfer, (void**) &buffer);
if (er.encoded < 0) { if (encoded_size < 0) {
Logger::smf_app().warn( Logger::smf_app().warn(
"[Create N2 SM Information] NGAP PDU Session Resource Modify Response Transfer encode failed, er.encoded: %d", " NGAP PDU Session Resource Modify Response Transfer encode failed (encoded size %d)",
er.encoded); encoded_size);
return; return;
} }
#if DEBUG_IS_ON #if DEBUG_IS_ON
Logger::smf_app().debug("N2 SM buffer data: "); Logger::smf_app().debug("N2 SM buffer data: ");
for (int i = 0; i < er.encoded; i++) for (int i = 0; i < encoded_size; i++)
printf("%02x ", (char) buffer[i]); printf("%02x ", (char) buffer[i]);
Logger::smf_app().debug(" (%d bytes) \n", er.encoded); Logger::smf_app().debug(" (%d bytes) \n", encoded_size);
#endif #endif
std::string ngap_message((char*) buffer, er.encoded); std::string ngap_message((char*) buffer, encoded_size);
ngap_msg_str = ngap_message; ngap_msg_str = ngap_message;
//free memory //free memory
...@@ -1439,7 +1433,6 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg, ...@@ -1439,7 +1433,6 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg,
//This IE is included in the following messages: //This IE is included in the following messages:
//1 - PDU Session Update SM Context Response (PDU Session Release UE-Initiated: section 4.3.4@3GPP TS 23.502, step 1) //1 - PDU Session Update SM Context Response (PDU Session Release UE-Initiated: section 4.3.4@3GPP TS 23.502, step 1)
//2 - N1N2MessageTransfer Request​ (PDU Session Release SMF-Requested, step 1) //2 - N1N2MessageTransfer Request​ (PDU Session Release SMF-Requested, step 1)
//TODO:
Ngap_PDUSessionResourceReleaseCommandTransfer_t *ngap_resource_release_command_transfer = Ngap_PDUSessionResourceReleaseCommandTransfer_t *ngap_resource_release_command_transfer =
nullptr; nullptr;
...@@ -1471,31 +1464,29 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg, ...@@ -1471,31 +1464,29 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg,
size_t buffer_size = BUF_LEN; size_t buffer_size = BUF_LEN;
char *buffer = (char*) calloc(1, buffer_size); char *buffer = (char*) calloc(1, buffer_size);
asn_enc_rval_t er = aper_encode_to_buffer( ssize_t encoded_size = aper_encode_to_new_buffer(
&asn_DEF_Ngap_PDUSessionResourceReleaseCommandTransfer, nullptr, &asn_DEF_Ngap_PDUSessionResourceReleaseCommandTransfer, nullptr,
ngap_resource_release_command_transfer, (void*) buffer, buffer_size); ngap_resource_release_command_transfer, (void**) &buffer);
if (encoded_size < 0) {
if (er.encoded < 0) {
Logger::smf_app().warn( Logger::smf_app().warn(
"[Create N2 SM Information] NGAP PDU Session Release Command encode failed, er.encoded: %d", "NGAP PDU Session Release Command encode failed (encoded size %d)",
er.encoded); encoded_size);
return; return;
} }
#if DEBUG_IS_ON #if DEBUG_IS_ON
Logger::smf_app().debug("N2 SM buffer data: "); Logger::smf_app().debug("N2 SM buffer data: ");
for (int i = 0; i < er.encoded; i++) for (int i = 0; i < encoded_size; i++)
printf("%02x ", (char) buffer[i]); printf("%02x ", (char) buffer[i]);
Logger::smf_app().debug(" (%d bytes) \n", er.encoded); Logger::smf_app().debug(" (%d bytes) \n", encoded_size);
#endif #endif
std::string ngap_message((char*) buffer, er.encoded); std::string ngap_message((char*) buffer, encoded_size);
ngap_msg_str = ngap_message; ngap_msg_str = ngap_message;
//free memory //free memory
free_wrapper((void**) &ngap_resource_release_command_transfer); free_wrapper((void**) &ngap_resource_release_command_transfer);
free_wrapper((void**) &buffer); free_wrapper((void**) &buffer);
} }
break; break;
...@@ -1517,31 +1508,29 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg, ...@@ -1517,31 +1508,29 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg,
size_t buffer_size = BUF_LEN; size_t buffer_size = BUF_LEN;
char *buffer = (char*) calloc(1, buffer_size); char *buffer = (char*) calloc(1, buffer_size);
asn_enc_rval_t er = aper_encode_to_buffer( ssize_t encoded_size = aper_encode_to_new_buffer(
&asn_DEF_Ngap_PDUSessionResourceReleaseResponseTransfer, nullptr, &asn_DEF_Ngap_PDUSessionResourceReleaseResponseTransfer, nullptr,
ngap_resource_release_response_transfer, (void*) buffer, buffer_size); ngap_resource_release_response_transfer, (void**) &buffer);
if (encoded_size < 0) {
if (er.encoded < 0) {
Logger::smf_app().warn( Logger::smf_app().warn(
"[Create N2 SM Information] NGAP PDU Session Release Command encode failed, er.encoded: %d", "NGAP PDU Session Release Command encode failed (encoded size %d)",
er.encoded); encoded_size);
return; return;
} }
#if DEBUG_IS_ON #if DEBUG_IS_ON
Logger::smf_app().debug("N2 SM buffer data: "); Logger::smf_app().debug("N2 SM buffer data: ");
for (int i = 0; i < er.encoded; i++) for (int i = 0; i < encoded_size; i++)
printf("%02x ", (char) buffer[i]); printf("%02x ", (char) buffer[i]);
Logger::smf_app().debug(" (%d bytes) \n", er.encoded); Logger::smf_app().debug(" (%d bytes) \n", encoded_size);
#endif #endif
std::string ngap_message((char*) buffer, er.encoded); std::string ngap_message((char*) buffer, encoded_size);
ngap_msg_str = ngap_message; ngap_msg_str = ngap_message;
//free memory //free memory
free_wrapper((void**) &ngap_resource_release_response_transfer); free_wrapper((void**) &ngap_resource_release_response_transfer);
free_wrapper((void**) &buffer); free_wrapper((void**) &buffer);
} }
break; break;
...@@ -1549,7 +1538,6 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg, ...@@ -1549,7 +1538,6 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg,
Logger::smf_app().warn("Unknown NGAP IE type: %s \n", Logger::smf_app().warn("Unknown NGAP IE type: %s \n",
n2_sm_info_type_e2str[(uint8_t) ngap_ie_type]); n2_sm_info_type_e2str[(uint8_t) ngap_ie_type]);
} }
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
...@@ -1618,10 +1606,9 @@ int smf_n1_n2::decode_n2_sm_information( ...@@ -1618,10 +1606,9 @@ int smf_n1_n2::decode_n2_sm_information(
if (rc.code != RC_OK) { if (rc.code != RC_OK) {
Logger::smf_app().warn("asn_decode failed with code %d", rc.code); Logger::smf_app().warn("asn_decode failed with code %d", rc.code);
return RETURNerror ; return RETURNerror;
} }
return RETURNok ; return RETURNok;
} }
//--------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------
...@@ -1648,10 +1635,9 @@ int smf_n1_n2::decode_n2_sm_information( ...@@ -1648,10 +1635,9 @@ int smf_n1_n2::decode_n2_sm_information(
if (rc.code != RC_OK) { if (rc.code != RC_OK) {
Logger::smf_app().warn("asn_decode failed with code %d", rc.code); Logger::smf_app().warn("asn_decode failed with code %d", rc.code);
return RETURNerror ; return RETURNerror;
} }
return RETURNok ; return RETURNok;
} }
//--------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------
...@@ -1678,14 +1664,11 @@ int smf_n1_n2::decode_n2_sm_information( ...@@ -1678,14 +1664,11 @@ int smf_n1_n2::decode_n2_sm_information(
if (rc.code != RC_OK) { if (rc.code != RC_OK) {
Logger::smf_app().warn("asn_decode failed with code %d", rc.code); Logger::smf_app().warn("asn_decode failed with code %d", rc.code);
return RETURNerror ; return RETURNerror;
} }
return RETURNok ; return RETURNok;
} }
//--------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------
int smf_n1_n2::decode_n2_sm_information( int smf_n1_n2::decode_n2_sm_information(
std::shared_ptr<Ngap_PDUSessionResourceSetupUnsuccessfulTransfer_t> &ngap_IE, std::shared_ptr<Ngap_PDUSessionResourceSetupUnsuccessfulTransfer_t> &ngap_IE,
...@@ -1710,8 +1693,7 @@ int smf_n1_n2::decode_n2_sm_information( ...@@ -1710,8 +1693,7 @@ int smf_n1_n2::decode_n2_sm_information(
if (rc.code != RC_OK) { if (rc.code != RC_OK) {
Logger::smf_app().warn("asn_decode failed with code %d", rc.code); Logger::smf_app().warn("asn_decode failed with code %d", rc.code);
return RETURNerror ; return RETURNerror;
} }
return RETURNok ; return RETURNok;
} }
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