Commit 0eed4679 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen
Browse files

remove dead code/add debug mode/update README

parent f7504a22
......@@ -6,21 +6,24 @@ The license information is distributed under LICENSE file in the same directory.
The OpenAirInterface CN SMF software is composed of the following parts:
openair-cn5g-smf
├── 3gpp-specs: Directory containing 3GPP specification files (YAML) used to implement SMF network function.
├── build: Build directory, contains targets and object files generated by compilation of network functions.
├── log: Directory containing build log files.
├── scripts: Directory containing scripts for building network functions
├── scripts: Directory containing scripts for building network functions.
└── smf: Directory containing CMakefile.txt and object files generated by compilation of SMF network function.
├── ci-scripts: Directory containing the script files for CI framework.
├── docs: Directory containing the documentation files.
├── etc: Directory containing the configuration file to be deployed for SMF.
└── src: Source files of SMF.
├── api-server: SMF services APIs.
├── common: Common header files
│   ├── msg: ITTI messages definitions.
│   └── utils: Common utilities.
├── gtpv1u: Generic GTPV1-U stack implementation
├── gtpv2c: Generic GTPV2-C stack implementation
├── itti: Inter task interface
├── nas: NAS protocol implememtation
├── mgap: NGAP protocol implememtation
├── gtpv1u: Generic GTPV1-U stack implementation.
├── gtpv2c: Generic GTPV2-C stack implementation.
├── itti: Inter task interface.
├── nas: NAS protocol implememtation.
├── ngap: NGAP protocol implememtation.
├── oai_smf: SMF main directory, contains the "main" CMakeLists.txt file.
├── pfcp: Generic PFCP stack implementation.
├── smf_app: SMF network functions procedures and contexts.
......
......@@ -89,12 +89,6 @@ SMF =
# Non standard feature, normally should be set to "no", but you may need to set to yes for UE that do not explicitly request a PDN address through NAS signalling
FORCE_PUSH_PROTOCOL_CONFIGURATION_OPTIONS = "no"; # STRING, {"yes", "no"}.
PCEF :
{
# Waiting for HSS APN-AMBR IE ...
APN_AMBR_UL = 500000; # Maximum UL bandwidth that can be used by non guaranteed bit rate traffic in Kbits/seconds.
APN_AMBR_DL = 500000; # Maximum DL bandwidth that can be used by non guaranteed bit rate traffic in Kbits/seconds.
};
AMF :
{
IPV4_ADDRESS="@AMF_IPV4_ADDRESS@";
......
......@@ -139,7 +139,7 @@ void IndividualSMContextApi::update_sm_context_handler(
Logger::smf_api_server().debug("");
Logger::smf_api_server().info(
"Received a SM context update request from AMF");
"Received a SM context update request from AMF.");
Logger::smf_api_server().debug("Request body: %s\n", request.body().c_str());
//find boundary
......@@ -174,7 +174,7 @@ void IndividualSMContextApi::update_sm_context_handler(
if ((multipartparser_execute(&parser, &g_callbacks,
reinterpret_cast<const char*>(data), str_len)
!= strlen(request.body().c_str())) or (!g_body_begin_called)) {
Logger::smf_api_server().warn(
Logger::smf_api_server().debug(
"The received message can not be parsed properly!");
//TODO: fix this issue
//response.send(Pistache::Http::Code::Bad_Request, "");
......
......@@ -41,7 +41,6 @@
#include <map>
#include <string>
#include "logger.hpp"
#include "Helpers.h"
extern "C" {
......@@ -83,8 +82,9 @@ void SMContextsCollectionApi::post_sm_contexts_handler(
const Pistache::Rest::Request &request,
Pistache::Http::ResponseWriter response) {
Logger::smf_api_server().debug("");
Logger::smf_api_server().info(
"\nReceived a SM context create request from AMF");
"Received a SM context create request from AMF.");
Logger::smf_api_server().debug("Request body: %s", request.body().c_str());
//find boundary
......@@ -120,7 +120,7 @@ void SMContextsCollectionApi::post_sm_contexts_handler(
if ((multipartparser_execute(&parser, &g_callbacks,
reinterpret_cast<const char*>(data), str_len)
!= strlen(request.body().c_str())) or (!g_body_begin_called)) {
Logger::smf_api_server().warn(
Logger::smf_api_server().debug(
"The received message can not be parsed properly!");
//TODO: fix this issue
//response.send(Pistache::Http::Code::Bad_Request, "");
......@@ -130,7 +130,7 @@ void SMContextsCollectionApi::post_sm_contexts_handler(
free_wrapper((void**) &data);
uint8_t size = g_parts.size();
Logger::smf_api_server().debug("Number of g_parts %d", g_parts.size());
Logger::smf_api_server().debug("Number of MIME parts %d", g_parts.size());
//at least 2 parts for Json data and N1 (+ N2)
if (g_parts.size() < 2) {
response.send(Pistache::Http::Code::Bad_Request, "");
......
......@@ -58,7 +58,7 @@ void SMContextsCollectionApiImpl::post_sm_contexts(
const SmContextMessage &smContextMessage,
Pistache::Http::ResponseWriter &response) {
Logger::smf_api_server().info("PDU Session Create SM Context Request ...");
Logger::smf_api_server().info("PDU Session Create SM Context Request.");
//Assign the necessary informations to smf::pdu_session_create_sm_context_request
//and pass this message to SMF to handle this message
......@@ -88,18 +88,18 @@ void SMContextsCollectionApiImpl::post_sm_contexts(
sm_context_req_msg.set_supi(supi);
sm_context_req_msg.set_supi_prefix(supi_prefix);
Logger::smf_api_server().debug(
"SmContextCreateData, supi %s, prefix %s, imsi %s",
"SmContextCreateData, SUPI %s, SUPI Prefix %s, IMSI %s",
smContextCreateData.getSupi().c_str(), supi_prefix.c_str(),
supi_str.c_str());
//dnn
Logger::smf_api_server().debug("SmContextCreateData, dnn %s",
Logger::smf_api_server().debug("SmContextCreateData, DNN %s",
smContextCreateData.getDnn().c_str());
sm_context_req_msg.set_dnn(smContextCreateData.getDnn().c_str());
//S-Nssai
Logger::smf_api_server().debug(
"SmContextCreateData, S-NSSAI sst %d, sd %s",
"SmContextCreateData, S-NSSAI SST %d, SD %s",
smContextCreateData.getSNssai().getSst(),
smContextCreateData.getSNssai().getSd().c_str());
snssai_t snssai(smContextCreateData.getSNssai().getSst(),
......@@ -107,7 +107,7 @@ void SMContextsCollectionApiImpl::post_sm_contexts(
sm_context_req_msg.set_snssai(snssai);
//PDU session ID
Logger::smf_api_server().debug("SmContextCreateData, PDU SessionID %d",
Logger::smf_api_server().debug("SmContextCreateData, PDU Session ID %d",
smContextCreateData.getPduSessionId());
sm_context_req_msg.set_pdu_session_id(smContextCreateData.getPduSessionId());
......
......@@ -331,14 +331,17 @@ static int _nas_message_header_encode(
//Security header type associated with a spare half octet;
ENCODE_U8(buffer + size, *((uint8_t* )(header) + 1), size);
//ENCODE_U8 (buffer+size,header->security_header_type,size);
#if DEBUG_IS_ON
printf("extended_protocol_discriminator %d, security_header_type %d \n",
header->extended_protocol_discriminator, header->security_header_type);
#endif
if (header->extended_protocol_discriminator
== EPD_5GS_MOBILITY_MANAGEMENT_MESSAGES) {
// header->extended_protocol_discriminator == EPD_5GS_SESSION_MANAGEMENT_MESSAGES) {
if (header->security_header_type != SECURITY_HEADER_TYPE_NOT_PROTECTED) {
#if DEBUG_IS_ON
printf("security_header_type != SECURITY_HEADER_TYPE_NOT_PROTECTED\n");
#endif
if (length < NAS_MESSAGE_SECURITY_HEADER_SIZE) {
/*
* The buffer is not big enough to contain security header
......@@ -357,7 +360,9 @@ static int _nas_message_header_encode(
*/
ENCODE_U8(buffer + size, header->sequence_number, size);
}
#if DEBUG_IS_ON
printf("security_header_type: SECURITY_HEADER_TYPE_NOT_PROTECTED\n");
#endif
}
return size;
//OAILOG_STREAM_HEX(OAILOG_LEVEL_DEBUG, LOG_NAS, "encode nas header Incoming NAS message: ", buffer, size)
......
......@@ -184,8 +184,9 @@ int encode_pdu_session_establishment_accept(
uint8_t *buffer, uint32_t len) {
uint32_t encoded = 0;
int encoded_result = 0;
#if DEBUG_IS_ON
printf("\nEncode PDU Session Establishment Accept\n");
#endif
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(
buffer, PDU_SESSION_ESTABLISHMENT_ACCEPT_MINIMUM_LENGTH, len);
......
......@@ -175,8 +175,9 @@ int fivegsm_msg_encode(SM_msg *msg, uint8_t *buffer, uint32_t len) {
buffer += header_result;
len -= header_result;
#if DEBUG_IS_ON
printf(", message type %d", msg->header.message_type);
#endif
switch (msg->header.message_type) {
case PDU_SESSION_ESTABLISHMENT_REQUEST:
encode_result = encode_pdu_session_establishment_request(
......
......@@ -599,7 +599,7 @@ void smf_app::handle_pdu_session_create_sm_context_request(
//check pdu session id
if ((pdu_session_id == PDU_SESSION_IDENTITY_UNASSIGNED )
|| (pdu_session_id > PDU_SESSION_IDENTITY_LAST )) {
Logger::smf_app().warn(" Invalid PDU Session ID value (psi = %d)",
Logger::smf_app().warn(" Invalid PDU Session ID value (%d)",
pdu_session_id);
//section 7.3.2@3GPP TS 24.501; NAS N1 SM message: ignore the message
return;
......@@ -697,7 +697,7 @@ void smf_app::handle_pdu_session_create_sm_context_request(
&& not is_supi_dnn_snssai_subscription_data(supi, dnn, snssai)) {
//uses a dummy UDM to test this part
Logger::smf_app().debug(
"Retrieve Session Management Subscription data from an UDM");
"Retrieve Session Management Subscription data from the UDM");
session_management_subscription *s = new session_management_subscription(
snssai);
std::shared_ptr<session_management_subscription> subscription =
......@@ -1058,11 +1058,13 @@ void smf_app::convert_string_2_hex(std::string &input_str,
memset(data, 0, input_str.length() + 1);
memcpy((void*) data, (void*) input_str.c_str(), input_str.length());
#if DEBUG_IS_ON
Logger::smf_app().debug("Input: ");
for (int i = 0; i < input_str.length(); i++) {
printf("%02x ", data[i]);
}
printf("\n");
#endif
char *datahex = (char*) malloc(input_str.length() * 2 + 1);
memset(datahex, 0, input_str.length() * 2 + 1);
......@@ -1091,11 +1093,11 @@ unsigned char* smf_app::format_string_as_hex(std::string &str) {
Logger::smf_app().debug("[Format string as Hex] Input string (%d bytes): %s ",
str_len, str.c_str());
Logger::smf_app().debug("Data (formatted):");
#if DEBUG_IS_ON
for (int i = 0; i < str_len / 2; i++)
printf(" %02x ", data_hex[i]);
printf("\n");
#endif
//free memory
free_wrapper((void**) &data);
......
......@@ -77,8 +77,6 @@ int smf_config::finalize() {
ue_pool_network[i].s_addr = htonl(network_hbo);
ue_pool_netmask[i].s_addr = htonl(netmask_hbo);
}
// "TODO"
//pgw_pcef_emulation_init(config_pP);
Logger::smf_app().info("Finalized config");
return 0;
}
......@@ -507,19 +505,6 @@ int smf_config::load(const string &config_file) {
}
smf_cfg.lookupValue(SMF_CONFIG_STRING_UE_MTU, ue_mtu);
const Setting &pcef_cfg = smf_cfg[SMF_CONFIG_STRING_PCEF];
unsigned int apn_ambr = 0;
if (!(pcef_cfg.lookupValue(SMF_CONFIG_STRING_APN_AMBR_UL, apn_ambr))) {
Logger::smf_app().error(SMF_CONFIG_STRING_APN_AMBR_UL "failed");
throw(SMF_CONFIG_STRING_APN_AMBR_UL "failed");
}
pcef.apn_ambr_ul = apn_ambr;
if (!(pcef_cfg.lookupValue(SMF_CONFIG_STRING_APN_AMBR_DL, apn_ambr))) {
Logger::smf_app().error(SMF_CONFIG_STRING_APN_AMBR_DL "failed");
//throw (SMF_CONFIG_STRING_APN_AMBR_DL "failed");
}
pcef.apn_ambr_dl = apn_ambr;
const Setting &amf_cfg = smf_cfg[SMF_CONFIG_STRING_AMF];
struct in_addr amf_ipv4_addr;
unsigned int amf_port = 0;
......@@ -680,11 +665,7 @@ void smf_config::display() {
apn[i].pool_id_iv6);
}
}
Logger::smf_app().info("- PCEF support (in development)");
Logger::smf_app().info(" APN AMBR UL ..........: %lu (Kilo bits/s)",
pcef.apn_ambr_ul);
Logger::smf_app().info(" APN AMBR DL ..........: %lu (Kilo bits/s)",
pcef.apn_ambr_dl);
Logger::smf_app().info("- Helpers:");
Logger::smf_app().info(" Push PCO (DNS+MTU) ........: %s",
force_push_pco == 0 ? "false" : "true");
......
......@@ -85,8 +85,6 @@
#define SMF_CONFIG_STRING_IPV4_POOL "IPV4_POOL"
#define SMF_CONFIG_STRING_IPV6_POOL "IPV6_POOL"
#define SMF_CONFIG_STRING_PCEF "PCEF"
#define SMF_CONFIG_STRING_PCEF_ENABLED "PCEF_ENABLED"
#define SMF_CONFIG_STRING_TCP_ECN_ENABLED "TCP_ECN_ENABLED"
#define SMF_CONFIG_STRING_AUTOMATIC_PUSH_DEDICATED_BEARER_PCC_RULE "AUTOMATIC_PUSH_DEDICATED_BEARER_PCC_RULE"
#define SMF_CONFIG_STRING_DEFAULT_BEARER_STATIC_PCC_RULE "DEFAULT_BEARER_STATIC_PCC_RULE"
......@@ -201,12 +199,6 @@ class smf_config {
bool force_push_pco;
uint ue_mtu;
struct {
bool tcp_ecn_enabled = false; // test for CoDel qdisc
unsigned int apn_ambr_ul;
unsigned int apn_ambr_dl;
} pcef;
struct {
struct in_addr ipv4_addr;
unsigned int port;
......@@ -222,7 +214,6 @@ class smf_config {
smf_config()
:
m_rw_lock(),
pcef(),
num_apn(0),
pid_dir(),
instance(0),
......
......@@ -1888,23 +1888,6 @@ void smf_context::handle_pdu_session_update_sm_context_request(
decoded_msg->dLQosFlowPerTNLInformation.uPTransportLayerInformation
.choice.gTPTunnel->transportLayerAddress.buf,
4);
printf("gTP_TEID:");
printf(
"%02x ",
decoded_msg->dLQosFlowPerTNLInformation.uPTransportLayerInformation
.choice.gTPTunnel->gTP_TEID.buf[0]);
printf(
"%02x ",
decoded_msg->dLQosFlowPerTNLInformation.uPTransportLayerInformation
.choice.gTPTunnel->gTP_TEID.buf[1]);
printf(
"%02x ",
decoded_msg->dLQosFlowPerTNLInformation.uPTransportLayerInformation
.choice.gTPTunnel->gTP_TEID.buf[2]);
printf(
"%02x \n",
decoded_msg->dLQosFlowPerTNLInformation.uPTransportLayerInformation
.choice.gTPTunnel->gTP_TEID.buf[3]);
Logger::smf_app().debug("gTP_TEID " "0x%" PRIx32 " ",
htonl(dl_teid.teid_gre_key));
Logger::smf_app().debug("uPTransportLayerInformation IP Addr %s",
......
......@@ -314,12 +314,12 @@ void smf_n1_n2::create_n1_sm_container(pdu_session_msg &msg,
//Encode NAS message
bytes = nas_message_encode(data, &nas_msg,
sizeof(data)/*don't know the size*/, nullptr);
#if DEBUG_IS_ON
Logger::smf_app().debug("Buffer Data: ");
for (int i = 0; i < bytes; i++)
printf("%02x ", data[i]);
printf(" (bytes %d)\n", bytes);
#endif
std::string n1Message((char*) data, bytes);
nas_msg_str = n1Message;
......@@ -425,11 +425,12 @@ void smf_n1_n2::create_n1_sm_container(pdu_session_msg &msg,
bytes = nas_message_encode(data, &nas_msg,
sizeof(data)/*don't know the size*/, nullptr);
#if DEBUG_IS_ON
Logger::smf_app().debug("Buffer Data: ");
for (int i = 0; i < bytes; i++)
printf("%02x ", data[i]);
printf(" (bytes %d)\n", bytes);
#endif
std::string n1Message((char*) data, bytes);
nas_msg_str = n1Message;
......@@ -543,10 +544,12 @@ void smf_n1_n2::create_n1_sm_container(pdu_session_msg &msg,
bytes = nas_message_encode(data, &nas_msg,
sizeof(data)/*don't know the size*/, nullptr);
#if DEBUG_IS_ON
Logger::smf_app().debug("Buffer Data: ");
for (int i = 0; i < bytes; i++)
printf("%02x ", data[i]);
printf(" (bytes %d)\n", bytes);
#endif
std::string n1Message((char*) data, bytes);
nas_msg_str = n1Message;
......@@ -599,10 +602,12 @@ void smf_n1_n2::create_n1_sm_container(pdu_session_msg &msg,
bytes = nas_message_encode(data, &nas_msg,
sizeof(data)/*don't know the size*/, nullptr);
#if DEBUG_IS_ON
Logger::smf_app().debug("Buffer Data: ");
for (int i = 0; i < bytes; i++)
printf("%02x ", data[i]);
printf(" (bytes %d)\n", bytes);
#endif
std::string n1Message((char*) data, bytes);
nas_msg_str = n1Message;
......@@ -639,10 +644,12 @@ void smf_n1_n2::create_n1_sm_container(pdu_session_msg &msg,
bytes = nas_message_encode(data, &nas_msg,
sizeof(data)/*don't know the size*/, nullptr);
#if DEBUG_IS_ON
Logger::smf_app().debug("Buffer Data: ");
for (int i = 0; i < bytes; i++)
printf("%02x ", data[i]);
printf(" (bytes %d)\n", bytes);
#endif
std::string n1Message((char*) data, bytes);
nas_msg_str = n1Message;
......@@ -903,10 +910,13 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg,
return;
}
#if DEBUG_IS_ON
Logger::smf_app().debug("N2 SM buffer data: ");
for (int i = 0; i < er.encoded; i++)
printf("%02x ", (char) buffer[i]);
printf(" (%d bytes)\n", (int) er.encoded);
#endif
std::string ngap_message((char*) buffer, er.encoded);
ngap_msg_str = ngap_message;
......@@ -1164,10 +1174,13 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg,
return;
}
#if DEBUG_IS_ON
Logger::smf_app().debug("N2 SM buffer data: ");
for (int i = 0; i < er.encoded; i++)
printf("%02x ", (char) buffer[i]);
printf(" (%d bytes)\n", (int) er.encoded);
#endif
std::string ngap_message((char*) buffer, er.encoded);
ngap_msg_str = ngap_message;
......@@ -1286,10 +1299,13 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg,
return;
}
#if DEBUG_IS_ON
Logger::smf_app().debug("N2 SM buffer data: ");
for (int i = 0; i < er.encoded; i++)
printf("%02x ", (char) buffer[i]);
Logger::smf_app().debug(" (%d bytes) \n", er.encoded);
#endif
std::string ngap_message((char*) buffer, er.encoded);
ngap_msg_str = ngap_message;
......@@ -1386,10 +1402,13 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg,
return;
}
#if DEBUG_IS_ON
Logger::smf_app().debug("N2 SM buffer data: ");
for (int i = 0; i < er.encoded; i++)
printf("%02x ", (char) buffer[i]);
Logger::smf_app().debug(" (%d bytes) \n", er.encoded);
#endif
std::string ngap_message((char*) buffer, er.encoded);
ngap_msg_str = ngap_message;
......@@ -1458,10 +1477,13 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg,
return;
}
#if DEBUG_IS_ON
Logger::smf_app().debug("N2 SM buffer data: ");
for (int i = 0; i < er.encoded; i++)
printf("%02x ", (char) buffer[i]);
Logger::smf_app().debug(" (%d bytes) \n", er.encoded);
#endif
std::string ngap_message((char*) buffer, er.encoded);
ngap_msg_str = ngap_message;
......@@ -1501,10 +1523,13 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg,
return;
}
#if DEBUG_IS_ON
Logger::smf_app().debug("N2 SM buffer data: ");
for (int i = 0; i < er.encoded; i++)
printf("%02x ", (char) buffer[i]);
Logger::smf_app().debug(" (%d bytes) \n", er.encoded);
#endif
std::string ngap_message((char*) buffer, er.encoded);
ngap_msg_str = ngap_message;
......@@ -1525,7 +1550,7 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg,
//------------------------------------------------------------------------------
int smf_n1_n2::decode_n1_sm_container(nas_message_t &nas_msg,
std::string &n1_sm_msg) {
Logger::smf_app().info("Decode NAS message from N1 SM Container");
Logger::smf_app().info("Decode NAS message from N1 SM Container.");
//step 1. Decode NAS message (for instance, ... only served as an example)
nas_message_decode_status_t decode_status = { 0 };
......@@ -1536,10 +1561,12 @@ int smf_n1_n2::decode_n1_sm_container(nas_message_t &nas_msg,
memset(data, 0, data_len + 1);
memcpy((void*) data, (void*) n1_sm_msg.c_str(), data_len);
#if DEBUG_IS_ON
printf("Content: ");
for (int i = 0; i < data_len; i++)
printf(" %02x ", data[i]);
printf("\n");
#endif
//decode the NAS message (using NAS lib)
decoder_rc = nas_message_decode(data, &nas_msg, data_len, nullptr,
......@@ -1577,10 +1604,12 @@ int smf_n1_n2::decode_n2_sm_information(
memset(data, 0, data_len + 1);
memcpy((void*) data, (void*) n2_sm_info.c_str(), data_len);
#if DEBUG_IS_ON
printf("Content: ");
for (int i = 0; i < data_len; i++)
printf(" %02x ", data[i]);
printf("\n");
#endif
//PDUSessionResourceSetupResponseTransfer
asn_dec_rval_t rc = asn_decode(
......
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