Commit 4e2e3a1e authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Merge branch 'update_open_api' into 'develop'

Update open api

See merge request oai/cn5g/oai-cn5g-smf!38
parents 862d1d1d a9935948
......@@ -31,6 +31,7 @@
#include "HsmfUpdatedData.h"
#include "ProblemDetails.h"
#include "ReleaseData.h"
#include "smf.h"
namespace oai {
namespace smf_server {
......@@ -44,7 +45,7 @@ class IndividualPDUSessionHSMFApi {
virtual ~IndividualPDUSessionHSMFApi() {}
void init();
const std::string base = "/nsmf-pdusession/";
const std::string base = NSMF_PDU_SESSION_BASE;
private:
void setupRoutes();
......
......@@ -59,6 +59,7 @@
#include "SmContextMessage.h"
#include "SmContextCreateError.h"
#include "SmContextCreatedData.h"
#include "smf.h"
namespace oai {
namespace smf_server {
......@@ -72,7 +73,7 @@ class IndividualSMContextApi {
virtual ~IndividualSMContextApi() {}
void init();
const std::string base = "/nsmf-pdusession/";
const std::string base = NSMF_PDU_SESSION_BASE;
private:
void setupRoutes();
......
......@@ -29,6 +29,7 @@
#include "PduSessionCreateError.h"
#include "PduSessionCreatedData.h"
#include "ProblemDetails.h"
#include "smf.h"
namespace oai {
namespace smf_server {
......@@ -42,7 +43,7 @@ class PDUSessionsCollectionApi {
virtual ~PDUSessionsCollectionApi() {}
void init();
const std::string base = "/nsmf-pdusession/";
const std::string base = NSMF_PDU_SESSION_BASE;
private:
void setupRoutes();
......
......@@ -69,7 +69,8 @@ void SMContextsCollectionApi::setupRoutes() {
using namespace Pistache::Rest;
Routes::Post(
*router, base + smf_cfg.sbi_api_version + "/sm-contexts",
*router,
base + smf_cfg.sbi_api_version + NSMF_PDU_SESSION_SM_CONTEXT_CREATE_URL,
Routes::bind(&SMContextsCollectionApi::post_sm_contexts_handler, this));
// Default handler, called when a route is not found
......@@ -116,13 +117,11 @@ void SMContextsCollectionApi::post_sm_contexts_handler(
this->post_sm_contexts(smContextMessage, response);
} catch (nlohmann::detail::exception& e) {
// send a 400 error
Logger::smf_api_server().warn(
"Can not parse the json data (error: %s)!", e.what());
response.send(Pistache::Http::Code::Bad_Request, e.what());
return;
} catch (std::exception& e) {
// send a 500 error
Logger::smf_api_server().warn("Error: %s!", e.what());
response.send(Pistache::Http::Code::Internal_Server_Error, e.what());
return;
......
......@@ -50,6 +50,7 @@
#include "ProblemDetails.h"
#include "SmContextCreateError.h"
#include "SmContextCreatedData.h"
#include "smf.h"
namespace oai {
namespace smf_server {
......@@ -63,7 +64,7 @@ class SMContextsCollectionApi {
virtual ~SMContextsCollectionApi() {}
void init();
const std::string base = "/nsmf-pdusession/";
const std::string base = NSMF_PDU_SESSION_BASE;
private:
void setupRoutes();
......
......@@ -35,6 +35,7 @@
#include "IndividualSMContextApiImpl.h"
#include <nghttp2/asio_http2_server.h>
#include "mime_parser.hpp"
#include "3gpp_conversions.hpp"
namespace oai {
namespace smf_server {
......@@ -58,31 +59,11 @@ void IndividualSMContextApiImpl::release_sm_context(
"Received a PDUSession_ReleaseSMContext Request from AMF.");
smf::pdu_session_release_sm_context_request sm_context_req_msg = {};
SmContextReleaseData smContextReleaseData =
smContextReleaseMessage.getJsonData();
if (smContextReleaseData.n2SmInfoIsSet()) {
// N2 SM (for Session establishment)
std::string n2_sm_information =
smContextReleaseMessage.getBinaryDataN2SmInformation();
Logger::smf_api_server().debug(
"N2 SM Information %s", n2_sm_information.c_str());
std::string n2_sm_info_type = smContextReleaseData.getN2SmInfoType();
sm_context_req_msg.set_n2_sm_information(n2_sm_information);
sm_context_req_msg.set_n2_sm_info_type(n2_sm_info_type);
}
// Step 2. TODO: initialize necessary values for sm context req from
// smContextReleaseData
// cause:
// ngApCause:
// 5gMmCauseValue:
// ueLocation:
// ueTimeZone:
// addUeLocation:
// vsmfReleaseOnly:
// ismfReleaseOnly:
// convert from SmContextReleaseMessage to
// pdu_session_release_sm_context_request
xgpp_conv::sm_context_release_from_openapi(
smContextReleaseMessage, sm_context_req_msg);
boost::shared_ptr<
boost::promise<smf::pdu_session_release_sm_context_response> >
......@@ -96,7 +77,7 @@ void IndividualSMContextApiImpl::release_sm_context(
Logger::smf_api_server().debug("Promise ID generated %d", promise_id);
m_smf_app->add_promise(promise_id, p);
// Step 3. Handle the itti_n11_release_sm_context_request message in smf_app
// Handle the itti_n11_release_sm_context_request message in smf_app
std::shared_ptr<itti_n11_release_sm_context_request> itti_msg =
std::make_shared<itti_n11_release_sm_context_request>(
TASK_SMF_N11, TASK_SMF_APP, promise_id, smContextRef);
......@@ -104,11 +85,11 @@ void IndividualSMContextApiImpl::release_sm_context(
itti_msg->http_version = 1;
m_smf_app->handle_pdu_session_release_sm_context_request(itti_msg);
// wait for the result from APP and send reply to AMF
// Wait for the result from APP and send reply to AMF
smf::pdu_session_release_sm_context_response sm_context_response = f.get();
Logger::smf_api_server().debug("Got result for promise ID %d", promise_id);
// TODO: process the response
// TODO: Process the response
response.send(Pistache::Http::Code(sm_context_response.get_http_code()));
}
......@@ -131,72 +112,12 @@ void IndividualSMContextApiImpl::update_sm_context(
"Received a PDUSession_UpdateSMContext Request from AMF.");
smf::pdu_session_update_sm_context_request sm_context_req_msg = {};
SmContextUpdateData smContextUpdateData =
smContextUpdateMessage.getJsonData();
if (smContextUpdateData.n2SmInfoIsSet()) {
// N2 SM (for Session establishment)
std::string n2_sm_information =
smContextUpdateMessage.getBinaryDataN2SmInformation();
Logger::smf_api_server().debug(
"N2 SM Information %s", n2_sm_information.c_str());
std::string n2_sm_info_type = smContextUpdateData.getN2SmInfoType();
sm_context_req_msg.set_n2_sm_information(n2_sm_information);
sm_context_req_msg.set_n2_sm_info_type(n2_sm_info_type);
}
if (smContextUpdateData.n1SmMsgIsSet()) {
// N1 SM (for session modification)
std::string n1_sm_message =
smContextUpdateMessage.getBinaryDataN1SmMessage();
Logger::smf_api_server().debug("N1 SM message %s", n1_sm_message.c_str());
sm_context_req_msg.set_n1_sm_message(n1_sm_message);
}
// Step 2. TODO: initialize necessary values for sm context req from
// smContextUpdateData
/* UE-initiated Service Request Operation, section 4.2.3.2@3GPP TS 23.502 */
// Step 4: PDU Session IDs, Operation Type, UE location Info, Access Type, RAT
// Type, UE presence in LADN service area, Indication of Access Type can be
// changed PDU Session IDs UpCnxState, for activation of user plane
// (see 5.2.2.3.2.2@3GPP TS 29.502, step 1)
if (smContextUpdateData.upCnxStateIsSet())
sm_context_req_msg.set_upCnx_state(smContextUpdateData.getUpCnxState());
// Access Type (step 1 and 2)
if (smContextUpdateData.anTypeIsSet())
sm_context_req_msg.set_an_type(smContextUpdateData.getAnType());
// RAT Type (step 1 and 2)
if (smContextUpdateData.ratTypeIsSet())
sm_context_req_msg.set_rat_type(smContextUpdateData.getRatType());
// TODO:
// UE presence in LADN service area
// UE location information
// Indication of Access Type can be changed
// if (smContextUpdateData.anTypeCanBeChangedIsSet())
// sm_context_req_msg.set_access_type_can_be_changed(smContextUpdateData.isAnTypeCanBeChanged());
// Step 15: N2 SM Info (AN Tunnel Info, List of accepted QoS Flow, List of
// rejected Qos Flows, PDU Session ID), RAT Type, Access Type
/* UE-initiated PDU Session Establishment Operation - section 4.3.2.2.1@3GPP
* TS 23.502 */
// TODO: Existing PDU session, step 3, SUPI, DNN, S-NSSAIs, SM Context ID, AMF
// ID, Request Type, N1 SM Container (PDU Session Establishment Request), User
// location, Access Type, RAT Type, PEI step 15. (SM Context ID -> SCID, N2 SM,
// Request Type)(Initial Request)
// TODO: verify why Request Type is not define in smContextUpdateData
/* AMF-initiated with a release indication to request the release of the PDU
* Session (step 3.d, section 4.3.4.2@3GPP TS 23.502)*/
if (smContextUpdateData.releaseIsSet()) {
sm_context_req_msg.set_release(smContextUpdateData.isRelease());
}
// convert from SmContextUpdateMessage to
// pdu_session_update_sm_context_request
xgpp_conv::sm_context_update_from_openapi(
smContextUpdateMessage, sm_context_req_msg);
/* PDU Session Modification (SM Context ID -> SCID, N1/N2),
* section 4.3.3.2@3GPP TS 23.502: */
// step 1.a,UE-initiated: SM Context ID + N1 (PDU Session Modification
// Request) step 1.e (AN initiated modification): SM Context ID, N2 SM
// information (QFI, User location Information and an indication that the QoS
// Flow is released) step 7a, SM Context ID, N2 SM information, UE location
// information Step 11, SM Context ID, N1 SM (PDU Session Modification Command
// ACK), User location
boost::shared_ptr<
boost::promise<smf::pdu_session_update_sm_context_response> >
p = boost::make_shared<
......@@ -209,7 +130,7 @@ void IndividualSMContextApiImpl::update_sm_context(
Logger::smf_api_server().debug("Promise ID generated %d", promise_id);
m_smf_app->add_promise(promise_id, p);
// Step 3. Handle the itti_n11_update_sm_context_request message in smf_app
// Handle the itti_n11_update_sm_context_request message in smf_app
std::shared_ptr<itti_n11_update_sm_context_request> itti_msg =
std::make_shared<itti_n11_update_sm_context_request>(
TASK_SMF_N11, TASK_SMF_APP, promise_id, smContextRef);
......@@ -217,7 +138,7 @@ void IndividualSMContextApiImpl::update_sm_context(
itti_msg->http_version = 1;
m_smf_app->handle_pdu_session_update_sm_context_request(itti_msg);
// wait for the result from APP and send reply to AMF
// Wait for the result from APP and send reply to AMF
smf::pdu_session_update_sm_context_response sm_context_response = f.get();
Logger::smf_api_server().debug("Got result for promise ID %d", promise_id);
......
......@@ -32,7 +32,6 @@
* contact@openairinterface.org
*/
#include "IndividualSubscriptionDocumentApiImpl.h"
namespace oai {
......
......@@ -38,6 +38,7 @@
#include "smf_msg.hpp"
#include "itti_msg_sbi.hpp"
#include "smf_config.hpp"
#include "3gpp_conversions.hpp"
extern smf::smf_config smf_cfg;
......@@ -59,21 +60,10 @@ void NFStatusNotifyApiImpl::receive_nf_status_notification(
"NFStatusNotifyApiImpl, received a NF status notification...");
smf::data_notification_msg notification_msg = {};
notification_msg.set_notification_event_type(notificationData.getEvent());
notification_msg.set_nf_instance_uri(notificationData.getNfInstanceUri());
// convert from NotificationData to data_notification_msg
xgpp_conv::data_notification_from_openapi(notificationData, notification_msg);
std::shared_ptr<smf::nf_profile> p = {};
// Only support UPF for now
if (notificationData.getNfProfile().getNfType() == "UPF")
p = std::make_shared<smf::upf_profile>();
nlohmann::json pj = {};
to_json(pj, notificationData.getNfProfile());
p.get()->from_json(pj);
notification_msg.set_profile(p);
// Step 2. Handle the message in smf_app
// Handle the message in smf_app
std::shared_ptr<itti_sbi_notification_data> itti_msg =
std::make_shared<itti_sbi_notification_data>(TASK_SMF_N11, TASK_SMF_APP);
itti_msg->notification_msg = notification_msg;
......
......@@ -38,7 +38,6 @@
* contact@openairinterface.org
*/
#ifndef NF_STATUS_NOTIFY_API_IMPL_H_
#define NF_STATUS_NOTIFY_API_IMPL_H_
......
......@@ -32,7 +32,6 @@
* contact@openairinterface.org
*/
#include "PDUSessionsCollectionApiImpl.h"
namespace oai {
......
......@@ -39,6 +39,7 @@
#include "3gpp_29.502.h"
#include <nghttp2/asio_http2_server.h>
#include "smf_config.hpp"
#include "3gpp_conversions.hpp"
extern smf::smf_config smf_cfg;
......@@ -60,102 +61,21 @@ void SMContextsCollectionApiImpl::post_sm_contexts(
Pistache::Http::ResponseWriter& response) {
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 decode NAS should be done in SMF APP
SmContextCreateData smContextCreateData = smContextMessage.getJsonData();
std::string n1_sm_msg = smContextMessage.getBinaryDataN1SmMessage();
Logger::smf_api_server().debug("N1 SM message: %s", n1_sm_msg.c_str());
// Step 2. Create a pdu_session_create_sm_context_request message and store
// Create a pdu_session_create_sm_context_request message and store
// the necessary information
Logger::smf_api_server().debug(
"Create a pdu_session_create_sm_context_request message and store the "
"necessary information");
smf::pdu_session_create_sm_context_request sm_context_req_msg = {};
// set N1 SM Message
sm_context_req_msg.set_n1_sm_message(n1_sm_msg);
// set api root to be used as location header in HTTP response
sm_context_req_msg.set_api_root(
m_address + base + smf_cfg.sbi_api_version + "/sm-contexts");
// supi
supi_t supi = {.length = 0};
std::size_t pos = smContextCreateData.getSupi().find("-");
std::string supi_str = smContextCreateData.getSupi().substr(pos + 1);
std::string supi_prefix = smContextCreateData.getSupi().substr(0, pos);
smf_string_to_supi(&supi, supi_str.c_str());
sm_context_req_msg.set_supi(supi);
sm_context_req_msg.set_supi_prefix(supi_prefix);
Logger::smf_api_server().debug(
"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(
"DNN %s", smContextCreateData.getDnn().c_str());
sm_context_req_msg.set_dnn(smContextCreateData.getDnn().c_str());
// S-Nssai
Logger::smf_api_server().debug(
"S-NSSAI SST %d, SD %s", smContextCreateData.getSNssai().getSst(),
smContextCreateData.getSNssai().getSd().c_str());
snssai_t snssai(
smContextCreateData.getSNssai().getSst(),
smContextCreateData.getSNssai().getSd());
sm_context_req_msg.set_snssai(snssai);
// PDU session ID
Logger::smf_api_server().debug(
"PDU Session ID %d", smContextCreateData.getPduSessionId());
sm_context_req_msg.set_pdu_session_id(smContextCreateData.getPduSessionId());
// AMF ID (ServingNFId)
Logger::smf_api_server().debug(
"ServingNfId %s", smContextCreateData.getServingNfId().c_str());
sm_context_req_msg.set_serving_nf_id(
smContextCreateData.getServingNfId()
.c_str()); // TODO: should be verified that AMF ID is stored in GUAMI
// or ServingNfId
// Request Type
Logger::smf_api_server().debug(
"RequestType %s", smContextCreateData.getRequestType().c_str());
sm_context_req_msg.set_request_type(smContextCreateData.getRequestType());
// PCF ID
// Priority Access
// User Location Information
// Access Type
// PEI
// GPSI
// UE presence in LADN service area
// Guami
// servingNetwork
// anType
// UETimeZone
// SMContextStatusUri
sm_context_req_msg.set_sm_context_status_uri(
smContextCreateData.getSmContextStatusUri());
// PCFId
// DNN Selection Mode
Logger::smf_api_server().debug(
"SelMode %s", smContextCreateData.getSelMode().c_str());
sm_context_req_msg.set_dnn_selection_mode(
smContextCreateData.getSelMode().c_str());
// convert from SmContextMessage to pdu_session_create_sm_context_request
xgpp_conv::sm_context_create_from_openapi(
smContextMessage, sm_context_req_msg);
// Subscription for PDU Session Status Notification
// Trace requirement
// SSC mode (Optional)
// 5GSM capability (Optional)
// Maximum number of supported (Optional)
// Maximum number of supported packet filters (Optional)
// Always-on PDU session requested (Optional)
// SM PDU DN request container (Optional)
// Extended protocol configuration options (Optional) e.g, FOR DHCP
// Set API Root to be used as location header in HTTP response
sm_context_req_msg.set_api_root(
m_address + base + smf_cfg.sbi_api_version +
NSMF_PDU_SESSION_SM_CONTEXT_CREATE_URL);
boost::shared_ptr<
boost::promise<smf::pdu_session_create_sm_context_response> >
......@@ -169,7 +89,7 @@ void SMContextsCollectionApiImpl::post_sm_contexts(
Logger::smf_api_server().debug("Promise ID generated %d", promise_id);
m_smf_app->add_promise(promise_id, p);
// Step 3. Handle the pdu_session_create_sm_context_request message in smf_app
// Handle the pdu_session_create_sm_context_request message in smf_app
std::shared_ptr<itti_n11_create_sm_context_request> itti_msg =
std::make_shared<itti_n11_create_sm_context_request>(
TASK_SMF_N11, TASK_SMF_APP, promise_id);
......@@ -177,7 +97,7 @@ void SMContextsCollectionApiImpl::post_sm_contexts(
itti_msg->http_version = 1;
m_smf_app->handle_pdu_session_create_sm_context_request(itti_msg);
// wait for the result from APP and send reply to AMF
// Wait for the result from APP and send reply to AMF
smf::pdu_session_create_sm_context_response sm_context_response = f.get();
Logger::smf_api_server().debug("Got result for promise ID %d", promise_id);
......
......@@ -39,6 +39,7 @@
#include "3gpp_29.508.h"
#include "itti_msg_sbi.hpp"
#include "smf_config.hpp"
#include "3gpp_conversions.hpp"
extern smf::smf_config smf_cfg;
......@@ -61,51 +62,16 @@ void SubscriptionsCollectionApiImpl::create_individual_subcription(
Logger::smf_api_server().info(
"SubscriptionsCollectionApiImpl::create_individual_subcription...");
// Step1. Create a message and store the necessary information
// Create a message and store the necessary information
Logger::smf_api_server().debug(
"Create a Event Exposure message and store the necessary information");
smf::event_exposure_msg event_exposure = {};
// Supi
if (nsmfEventExposure.supiIsSet()) {
supi_t supi = {.length = 0};
std::size_t pos = nsmfEventExposure.getSupi().find("-");
std::string supi_str = nsmfEventExposure.getSupi().substr(pos + 1);
std::string supi_prefix = nsmfEventExposure.getSupi().substr(0, pos);
smf_string_to_supi(&supi, supi_str.c_str());
event_exposure.set_supi(supi);
event_exposure.set_supi_prefix(supi_prefix);
Logger::smf_api_server().debug(
"SUPI %s, SUPI Prefix %s, IMSI %s", nsmfEventExposure.getSupi().c_str(),
supi_prefix.c_str(), supi_str.c_str());
}
// PDU session ID
if (nsmfEventExposure.pduSeIdIsSet()) {
Logger::smf_api_server().debug(
"PDU Session ID %d", nsmfEventExposure.getPduSeId());
event_exposure.set_pdu_session_id(nsmfEventExposure.getPduSeId());
}
event_exposure.set_notif_id(nsmfEventExposure.getNotifId()); // NotifId
event_exposure.set_notif_uri(nsmfEventExposure.getNotifUri()); // NotifUri
// EventSubscription: TODO
event_subscription_t event_subscription = {};
event_subscription.smf_event = smf_event_t::SMF_EVENT_PDU_SES_REL;
std::vector<event_subscription_t> event_subscriptions = {};
event_subscriptions.push_back(event_subscription);
event_exposure.set_event_subs(event_subscriptions);
// std::vector<EventSubscription> eventSubscriptions;
// for (auto it: nsmfEventExposure.getEventSubs()){
// event_subscription.smf_event = it.getEvent();
// getDnaiChgType
// event_subscriptions.push_back(event_subscription);
//}
// Convert from NsmfEventExposure to event_exposure_msg
xgpp_conv::smf_event_exposure_notification_from_openapi(
nsmfEventExposure, event_exposure);
// Step 2. Handle the message in smf_app
// Handle the message in smf_app
std::shared_ptr<itti_sbi_event_exposure_request> itti_msg =
std::make_shared<itti_sbi_event_exposure_request>(
TASK_SMF_N11, TASK_SMF_APP);
......@@ -114,7 +80,7 @@ void SubscriptionsCollectionApiImpl::create_individual_subcription(
evsub_id_t sub_id = m_smf_app->handle_event_exposure_subscription(itti_msg);
// send response
// Send response
nlohmann::json json_data = {};
to_json(json_data, nsmfEventExposure);
......
This diff is collapsed.
......@@ -34,7 +34,7 @@
#include <nghttp2/asio_http2_server.h>
#include "SmContextUpdateMessage.h"
#include "SmContextMessage.h"
#include "SmContextReleaseData.h"
#include "SmContextReleaseMessage.h"
#include "uint_generator.hpp"
#include "smf.h"
......@@ -57,7 +57,7 @@ class smf_http2_server {
void release_sm_context_handler(
const std::string& smf_ref,
const SmContextReleaseData& smContextReleaseData,
const SmContextReleaseMessage& smContextReleaseMessage,
const response& response);
void stop();
......
......@@ -45,7 +45,7 @@ typedef struct plmn_s {
#define INVALID_TMSI \
UINT32_MAX /*!< \brief The network shall not allocate a TMSI with all 32 \
bits equal to 1 (this is because the TMSI must be stored in \
bits equal to 1 (this is because the TMSI must be stored in \
the SIM, and the SIM uses 4 octets with all bits \
equal to 1 to indicate that no valid TMSI is \
available). */
......
......@@ -28,8 +28,11 @@
#ifndef FILE_3GPP_24_008_SEEN
#define FILE_3GPP_24_008_SEEN
#include <arpa/inet.h>
#include <iostream>
#include <stdint.h>
#include <string>
#include <vector>
//------------------------------------------------------------------------------
// 10.5.1.3 Location Area Identification
......@@ -40,12 +43,12 @@
#define INVALID_LAC_0000 \
(uint16_t) 0x0000 /*!< \brief This LAC can be coded using a full \
hexadecimal representation except for the following \
hexadecimal representation except for the following \
reserved hexadecimal values: 0000, and FFFE. */
#define INVALID_LAC_FFFE \
(uint16_t) 0xFFFE /*!< \brief This LAC can be coded using a full \
hexadecimal representation except for the following \
hexadecimal representation except for the following \
reserved hexadecimal values: 0000, and FFFE. */
//------------------------------------------------------------------------------
......@@ -94,12 +97,19 @@
#define PCO_CONTAINER_IDENTIFIER_ADDITIONAL_APN_RATE_CONTROL_FOR_EXCEPTION_DATA_SUPPORT_INDICATOR \
(0X0019)
#define PCO_CONTAINER_IDENTIFIER_PDU_SESSION_ID (0X001A)
// RESERVED (0x001B..001F)
#define PCO_CONTAINER_IDENTIFIER_ETHERNET_FRAME_PAYLOAD_MTU_REQUEST (0X0020)
#define PCO_CONTAINER_IDENTIFIER_UNSTRUCTURED_LINK_MTU_REQUEST (0X0021)
// RESERVED (0xFF00..FFFF)
#define PCO_CONTAINER_IDENTIFIER_5GSM_CAUSE_VALUE (0X0022)
#define PCO_CONTAINER_IDENTIFIER_QOS_RULES_WITH_THE_LENGTH_OF_TWO_OCTETS_SUPPORT_INDICATOR \
(0X0023)
#define PCO_CONTAINER_IDENTIFIER_QOS_FLOW_DESCRIPTIONS_WITH_THE_LENGTH_OF_TWO_OCTETS_SUPPORT_INDICATOR \
(0X0024)
// RESERVED FOR OPERATOR SPECIFIC USE (0x0024..FFFF)
/* CONTAINER IDENTIFIER Network to MS direction:*/
#define PCO_CONTAINER_IDENTIFIER_P_CSCF_IPV6_ADDRESS (0x0001)
#define PCO_CONTAINER_IDENTIFIER_IM_CN_SUBSYSTEM_SIGNALING_FLAG (0x0002)
#define PCO_CONTAINER_IDENTIFIER_DNS_SERVER_IPV6_ADDRESS (0x0003)
#define PCO_CONTAINER_IDENTIFIER_POLICY_CONTROL_REJECTION_CODE (0x0004)
#define PCO_CONTAINER_IDENTIFIER_SELECTED_BEARER_CONTROL_MODE (0x0005)
......@@ -114,9 +124,9 @@
#define PCO_CONTAINER_IDENTIFIER_MSISDN (0x000E)
#define PCO_CONTAINER_IDENTIFIER_IFOM_SUPPORT (0x000F)
#define PCO_CONTAINER_IDENTIFIER_IPV4_LINK_MTU (0x0010)
// RESERVED (0xFF00..FFFF)
#define PCO_CONTAINER_IDENTIFIER_NETWORK_SUPPORT_OF_LOCAL_ADDRESS_IN_TFT_INDICATOR \
(0x0011)
// RESERVED (0x0012)
#define PCO_CONTAINER_IDENTIFIER_NBIFOM_ACCEPTED_INDICATOR (0x0013)
//#define PCO_CONTAINER_IDENTIFIER_NBIFOM_MODE (0x0014)
#define PCO_CONTAINER_IDENTIFIER_NON_IP_LINK_MTU (0x0015)
......@@ -126,7 +136,7 @@
(0x0018)
#define PCO_CONTAINER_IDENTIFIER_ADDITIONAL_APN_RATE_CONTROL_FOR_EXCEPTION_DATA_PARAMETERS \
(0x0019)
#define PCO_CONTAINER_IDENTIFIER_RESERVED (0x001A)
// RESERVED (0x001A)
#define PCO_CONTAINER_IDENTIFIER_S_NSSAI (0x001B)
#define PCO_CONTAINER_IDENTIFIER_QOS_RULES (0x001C)
#define PCO_CONTAINER_IDENTIFIER_SESSION_AMBR (0x001D)
......@@ -134,6 +144,12 @@
#define PCO_CONTAINER_IDENTIFIER_QOS_FLOW_DESCRIPTIONS (0x001F)
#define PCO_CONTAINER_IDENTIFIER_ETHERNET_FRAME_PAYLOAD_MTU (0x0020)
#define PCO_CONTAINER_IDENTIFIER_UNSTRUCTURED_LINK_MTU (0x0021)
// RESERVED (0x0022)
#define PCO_CONTAINER_IDENTIFIER_QOS_RULES_WITH_THE_LENGTH_OF_TWO_OCTETS \
(0x0023)
#define PCO_CONTAINER_IDENTIFIER_QOS_FLOW_DESCRIPTIONS_WITH_THE_LENGTH_OF_TWO_OCTETS \
(0x0024) // RESERVED FOR OPERATOR SPECIFIC USE (0xFF00..FFFF)
/*_Both_directions:*/
#define PCO_CI_IM_CN_SUBSYSTEM_SIGNALING_FLAG (0x0002)
......@@ -148,10 +164,7 @@ typedef struct protocol_configuration_options_s {
uint8_t spare : 4;
uint8_t configuration_protocol : 3;
uint8_t num_protocol_or_container_id;
// arbitrary value, can be greater than defined (250/3)
#define PCO_UNSPEC_MAXIMUM_PROTOCOL_ID_OR_CONTAINER_ID 8
pco_protocol_or_container_id_t
protocol_or_container_ids[PCO_UNSPEC_MAXIMUM_PROTOCOL_ID_OR_CONTAINER_ID];
std::vector<pco_protocol_or_container_id_t> protocol_or_container_ids;
} protocol_configuration_options_t;
//------------------------------------------------------------------------------
......
......@@ -30,7 +30,6 @@
#define FILE_3GPP_29_274_SEEN
#include "common_root_types.h"
#include "3gpp_24.008.h"
#include "3gpp_commons.h"
#include "conversions.hpp"
#include "logger.hpp" // for fmt::format in spdlog
......
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the
* License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file 3gpp_29.281.h
\brief
\author Lionel Gauthier
\company Eurecom
\email: lionel.gauthier@eurecom.fr
*/
#ifndef FILE_3GPP_29_281_SEEN
#define FILE_3GPP_29_281_SEEN
#include "3gpp_29.274.h"
#include "3gpp_commons.h"
#include "common_root_types.h"
#include "logger.hpp" // for fmt::format in spdlog
#include <arpa/inet.h>
#include <stdint.h>
#include <string>
#include <vector>
// 8.2 Recovery
// 8.3 Tunnel Endpoint Identifier Data I
typedef struct tunnel_endpoint_identifier_data_i_s {
uint32_t tunnel_endpoint_identifier_data_i;
} tunnel_endpoint_identifier_data_i_t;
// 8.4 GTP-U Peer Address
typedef struct gtp_u_peer_address_s {
// may use variant if can stay with C++17
struct in_addr ipv4_address;
struct in6_addr ipv6_address;
bool is_v4;
} gtp_u_peer_address_t;
// 8.5 Extension Header Type List
typedef struct extension_header_type_list_s {
uint8_t length;
std::vector<uint8_t> extension_types_list;
} extension_header_type_list_t;
// 8.6 Private Extension defined in 3gpp_29.274.h
// typedef struct private_extension_s {
// uint16_t extension_identifier;
// std::string extension_value;
//} private_extension_t;
#endif /* FILE_3GPP_29_281_SEEN */
......@@ -110,14 +110,14 @@ enum class n2_sm_info_type_e {
PDU_RES_NTY_REL = 10, // PDU Session Resource Notify Released Transfer
PDU_RES_MOD_IND = 11, // PDU Session Resource Modify Indication Transfer
PDU_RES_MOD_CFM = 12, // PDU Session Resource Modify Confirm Transfer
PATH_SWITCH_REQ = 13, // Path Switch Request Transfer
PATH_SWITCH_REQ = 13, // Path Switch Request Transfer
PATH_SWITCH_SETUP_FAIL = 14, // Path Switch Request Setup Failed Transfer
PATH_SWITCH_REQ_ACK = 15, // Path Switch Request Acknowledge Transfer
PATH_SWITCH_REQ_FAIL = 16, // Path Switch Request Unsuccessful Transfer
HANDOVER_REQUIRED = 17, // Handover Required Transfer
HANDOVER_CMD = 18, // Handover Command Transfer
HANDOVER_PREP_FAIL = 19, // Handover Preparation Unsuccessful Transfer
HANDOVER_REQ_ACK = 20, // Handover Request Acknowledge Transfer
HANDOVER_REQUIRED = 17, // Handover Required Transfer
HANDOVER_CMD = 18, // Handover Command Transfer
HANDOVER_PREP_FAIL = 19, // Handover Preparation Unsuccessful Transfer
HANDOVER_REQ_ACK = 20, // Handover Request Acknowledge Transfer
HANDOVER_RES_ALLOC_FAIL =
21, // Handover Resource Allocation Unsuccessful Transfer
SECONDARY_RAT_USAGE = 22 // Secondary RAT Data Usage Report Transfer
......
......@@ -3,9 +3,9 @@
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
* the OAI Public License, Version 1.1 (the "License"); you may not use this
*file except in compliance with the License. You may obtain a copy of the
*License at
*
* http://www.openairinterface.org/?page_id=698
*
......@@ -41,67 +41,50 @@ class endpoint {
struct sockaddr_storage addr_storage;
socklen_t addr_storage_len;
endpoint()
:
addr_storage(),
addr_storage_len(sizeof(struct sockaddr_storage)) {
}
;
endpoint(const endpoint &e)
:
addr_storage(e.addr_storage),
addr_storage_len(e.addr_storage_len) {
}
;
endpoint(const struct sockaddr_storage &addr, const socklen_t len)
:
addr_storage(addr),
addr_storage_len(len) {
}
;
endpoint(const struct in_addr &addr, const uint16_t port) {
struct sockaddr_in *addr_in = (struct sockaddr_in*) &addr_storage;
addr_in->sin_family = AF_INET;
addr_in->sin_port = htons(port);
addr_in->sin_addr.s_addr = addr.s_addr;
: addr_storage(), addr_storage_len(sizeof(struct sockaddr_storage)){};
endpoint(const endpoint& e)
: addr_storage(e.addr_storage), addr_storage_len(e.addr_storage_len){};
endpoint(const struct sockaddr_storage& addr, const socklen_t len)
: addr_storage(addr), addr_storage_len(len){};
endpoint(const struct in_addr& addr, const uint16_t port) {
struct sockaddr_in* addr_in = (struct sockaddr_in*) &addr_storage;
addr_in->sin_family = AF_INET;
addr_in->sin_port = htons(port);
addr_in->sin_addr.s_addr = addr.s_addr;
addr_storage_len = sizeof(struct sockaddr_in);
}
;
};
endpoint(const struct in6_addr &addr6, const uint16_t port) {
struct sockaddr_in6 *addr_in6 = (struct sockaddr_in6*) &addr_storage;
addr_in6->sin6_family = AF_INET6;
addr_in6->sin6_port = htons(port);
addr_in6->sin6_flowinfo = 0;
endpoint(const struct in6_addr& addr6, const uint16_t port) {
struct sockaddr_in6* addr_in6 = (struct sockaddr_in6*) &addr_storage;
addr_in6->sin6_family = AF_INET6;
addr_in6->sin6_port = htons(port);
addr_in6->sin6_flowinfo = 0;
memcpy(&addr_in6->sin6_addr, &addr6, sizeof(struct in6_addr));
addr_in6->sin6_scope_id = 0;
addr_storage_len = sizeof(struct sockaddr_in6);
}
;
};
uint16_t port() const {
return ntohs(((struct sockaddr_in*) &addr_storage)->sin_port);
}
sa_family_t family() const {
return addr_storage.ss_family;
}
sa_family_t family() const { return addr_storage.ss_family; }
std::string toString() const {
std::string str;
if (addr_storage.ss_family == AF_INET) {
struct sockaddr_in *addr_in = (struct sockaddr_in*) &addr_storage;
struct sockaddr_in* addr_in = (struct sockaddr_in*) &addr_storage;
str.append(conv::toString(addr_in->sin_addr));
str.append(":").append(std::to_string(ntohs(addr_in->sin_port)));
} else if (addr_storage.ss_family == AF_INET6) {
struct sockaddr_in6 *addr_in6 = (struct sockaddr_in6*) &addr_storage;
struct sockaddr_in6* addr_in6 = (struct sockaddr_in6*) &addr_storage;
str.append(conv::toString(addr_in6->sin6_addr));
str.append(":").append(std::to_string(ntohs(addr_in6->sin6_port)));
}
return str;
}
};
#endif
......@@ -21,144 +21,104 @@
#include <stdexcept>
#include <vector>
//#define SPDLOG_LEVEL_NAMES { "trace", "debug", "info", "warning", "error", "critical", "off" };
#define SPDLOG_LEVEL_NAMES { "trace", "debug", "info ", "start", "warn ", "error", "off " };
//#define SPDLOG_LEVEL_NAMES { "trace", "debug", "info", "warning", "error",
//"critical", "off" };
#define SPDLOG_LEVEL_NAMES \
{"trace", "debug", "info ", "start", "warn ", "error", "off "};
#define SPDLOG_ENABLE_SYSLOG
#include "spdlog/spdlog.h"
class LoggerException : public std::runtime_error {
public:
explicit LoggerException(const char *m)
:
std::runtime_error(m) {
}
explicit LoggerException(const std::string &m)
:
std::runtime_error(m) {
}
explicit LoggerException(const char* m) : std::runtime_error(m) {}
explicit LoggerException(const std::string& m) : std::runtime_error(m) {}
};
class _Logger {
public:
_Logger(const char *category, std::vector<spdlog::sink_ptr> &sinks,
const char *pattern);
void trace(const char *format, ...);
void trace(const std::string &format, ...);
void debug(const char *format, ...);
void debug(const std::string &format, ...);
void info(const char *format, ...);
void info(const std::string &format, ...);
void startup(const char *format, ...);
void startup(const std::string &format, ...);
void warn(const char *format, ...);
void warn(const std::string &format, ...);
void error(const char *format, ...);
void error(const std::string &format, ...);
_Logger(
const char* category, std::vector<spdlog::sink_ptr>& sinks,
const char* pattern);
void trace(const char* format, ...);
void trace(const std::string& format, ...);
void debug(const char* format, ...);
void debug(const std::string& format, ...);
void info(const char* format, ...);
void info(const std::string& format, ...);
void startup(const char* format, ...);
void startup(const std::string& format, ...);
void warn(const char* format, ...);
void warn(const std::string& format, ...);
void error(const char* format, ...);
void error(const std::string& format, ...);
private:
_Logger();
enum _LogType {
_ltTrace,
_ltDebug,
_ltInfo,
_ltStartup,
_ltWarn,
_ltError
};
enum _LogType { _ltTrace, _ltDebug, _ltInfo, _ltStartup, _ltWarn, _ltError };
void log(_LogType lt, const char *format, va_list &args);
void log(_LogType lt, const char* format, va_list& args);
spdlog::logger m_log;
};
class Logger {
public:
static void init(const char *app, const bool log_stdout,
const bool log_rot_file) {
static void init(
const char* app, const bool log_stdout, const bool log_rot_file) {
singleton()._init(app, log_stdout, log_rot_file);
}
static void init(const std::string &app, const bool log_stdout,
const bool log_rot_file) {
static void init(
const std::string& app, const bool log_stdout, const bool log_rot_file) {
init(app.c_str(), log_stdout, log_rot_file);
}
static _Logger& async_cmd() {
return *singleton().m_async_cmd;
}
static _Logger& itti() {
return *singleton().m_itti;
}
static _Logger& smf_app() {
return *singleton().m_smf_app;
}
static _Logger& system() {
return *singleton().m_system;
}
static _Logger& udp() {
return *singleton().m_udp;
}
static _Logger& pfcp() {
return *singleton().m_pfcp;
}
static _Logger& pfcp_switch() {
return *singleton().m_pfcp_switch;
}
static _Logger& async_cmd() { return *singleton().m_async_cmd; }
static _Logger& itti() { return *singleton().m_itti; }
static _Logger& smf_app() { return *singleton().m_smf_app; }
static _Logger& system() { return *singleton().m_system; }
static _Logger& udp() { return *singleton().m_udp; }
static _Logger& pfcp() { return *singleton().m_pfcp; }
static _Logger& pfcp_switch() { return *singleton().m_pfcp_switch; }
static _Logger& smf_n1() {
return *singleton().m_smf_n1;
}
static _Logger& smf_n2() {
return *singleton().m_smf_n2;
}
static _Logger& smf_n4() {
return *singleton().m_smf_n4;
}
static _Logger& smf_n10() {
return *singleton().m_smf_n10;
}
static _Logger& smf_n11() {
return *singleton().m_smf_n11;
}
static _Logger& smf_api_server() {
return *singleton().m_smf_api_server;
}
static _Logger& smf_n1() { return *singleton().m_smf_n1; }
static _Logger& smf_n2() { return *singleton().m_smf_n2; }
static _Logger& smf_n4() { return *singleton().m_smf_n4; }
static _Logger& smf_n10() { return *singleton().m_smf_n10; }
static _Logger& smf_n11() { return *singleton().m_smf_n11; }
static _Logger& smf_api_server() { return *singleton().m_smf_api_server; }
private:
static Logger *m_singleton;
static Logger* m_singleton;
static Logger& singleton() {
if (!m_singleton)
m_singleton = new Logger();
if (!m_singleton) m_singleton = new Logger();
return *m_singleton;
}
Logger() {
}
~Logger() {
}
Logger() {}
~Logger() {}
void _init(const char *app, const bool log_stdout, const bool log_rot_file);
void _init(const char* app, const bool log_stdout, const bool log_rot_file);
std::vector<spdlog::sink_ptr> m_sinks;
std::string m_pattern;
_Logger *m_async_cmd;
_Logger *m_itti;
_Logger *m_smf_app;
_Logger *m_system;
_Logger *m_udp;
_Logger *m_pfcp;
_Logger *m_pfcp_switch;
_Logger *m_smf_n1;
_Logger *m_smf_n2;
_Logger *m_smf_n4;
_Logger *m_smf_n10;
_Logger *m_smf_n11;
_Logger *m_smf_api_server;
_Logger* m_async_cmd;
_Logger* m_itti;
_Logger* m_smf_app;
_Logger* m_system;
_Logger* m_udp;
_Logger* m_pfcp;
_Logger* m_pfcp_switch;
_Logger* m_smf_n1;
_Logger* m_smf_n2;
_Logger* m_smf_n4;
_Logger* m_smf_n10;
_Logger* m_smf_n11;
_Logger* m_smf_api_server;
};
#endif // __LOGGER_H
#endif // __LOGGER_H
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the
* License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file 3gpp_33.401.h
\brief
\author Lionel Gauthier
\company Eurecom
\email: lionel.gauthier@eurecom.fr
*/
#include "security_types.h"
#ifndef FILE_3GPP_33_401_SEEN
#define FILE_3GPP_33_401_SEEN
//------------------------------------------------------------------------------
// 5.1.3.2 Algorithm Identifier Values
//------------------------------------------------------------------------------
#define EEA0_ALG_ID 0b000
#define EEA1_128_ALG_ID 0b001
#define EEA2_128_ALG_ID 0b010
//------------------------------------------------------------------------------
// 5.1.4.2 Algorithm Identifier Values
//------------------------------------------------------------------------------
#define EIA0_ALG_ID 0b000
#define EIA1_128_ALG_ID 0b001
#define EIA2_128_ALG_ID 0b010
//------------------------------------------------------------------------------
// 6.1.2 Distribution of authentication data from HSS to serving network
//------------------------------------------------------------------------------
/* NOTE 2: It is recommended that the MME fetch only one EPS authentication
* vector at a time as the need to perform AKA runs has been reduced in EPS
* through the use of a more elaborate key hierarchy. In particular, service
* requests can be authenticated using a stored K ASME without the need to
* perform AKA. Furthermore, the sequence number management schemes in
* TS 33.102, Annex C [4], designed to avoid re-synchronisation problems caused
* by interleaving use of batches of authentication vectors, are only optional.
* Re-synchronisation problems in EPS can be avoided, independently of the
* sequence number management scheme, by immediately using an authentication
* vector retrieved from the HSS in an authentication procedure between UE and
* MME.
*/
#define MAX_EPS_AUTH_VECTORS 1
//----------------------------
typedef struct mm_ue_eps_authentication_quadruplet_s {
uint8_t rand[16];
uint8_t xres_len;
uint8_t xres[XRES_LENGTH_MAX];
uint8_t autn_len;
uint8_t autn[AUTN_LENGTH_OCTETS];
uint8_t k_asme[32];
} mm_ue_eps_authentication_quadruplet_t;
typedef struct mm_ue_eps_authentication_quintuplet_s {
uint8_t rand[16];
uint8_t xres_len;
uint8_t xres[XRES_LENGTH_MAX];
uint8_t ck[16];
uint8_t ik[16];
uint8_t autn_len;
uint8_t autn[AUTN_LENGTH_OCTETS];
} mm_ue_eps_authentication_quintuplet_t;
#endif /* FILE_3GPP_33_401_SEEN */
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the
* License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file 3gpp_36.401.h
\brief
\author Lionel Gauthier
\company Eurecom
\email: lionel.gauthier@eurecom.fr
*/
#ifndef FILE_3GPP_36_401_SEEN
#define FILE_3GPP_36_401_SEEN
//------------------------------------------------------------------------------
// 6.2 E-UTRAN Identifiers
//------------------------------------------------------------------------------
typedef uint32_t enb_ue_s1ap_id_t; /*!< \brief An eNB UE S1AP ID shall be
allocated so as to uniquely identify the UE over the S1 interface within an
eNB. When an MME receives an eNB UE S1AP ID it shall store it for the duration
of the UE-associated logical S1-connection for this UE. Once known to an MME
this IE is included in all UE associated S1-AP signalling. The eNB UE S1AP ID
shall be unique within the eNB logical node. */
typedef uint32_t mme_ue_s1ap_id_t; /*!< \brief A MME UE S1AP ID shall be
allocated so as to uniquely identify the UE over the S1 interface within the
MME. When an eNB receives MME UE S1AP ID it shall store it for the duration of
the UE-associated logical S1-connection for this UE. Once known to an eNB this
IE is included in all UE associated S1-AP signalling.
The MME UE S1AP ID shall be unique within the MME logical node.*/
#endif /* FILE_3GPP_36_401_SEEN */
......@@ -19,21 +19,26 @@
* contact@openairinterface.org
*/
/*! \file 3gpp_commons.h
\brief
\author Lionel Gauthier
\company Eurecom
\email: lionel.gauthier@eurecom.fr
*/
#ifndef FILE_3GPP_COMMONS_SEEN
#define FILE_3GPP_COMMONS_SEEN
#include <stdint.h>
#ifndef FILE_NAS_LIB_SEEN
#define FILE_NAS_LIB_SEEN
#include "bstrlib.h"
// 8.2 Recovery
typedef struct recovery_s {
uint8_t restart_counter;
} recovery_t;
typedef struct pco_protocol_or_container_id_nas_s {
uint16_t id;
uint8_t length;
bstring contents;
} pco_protocol_or_container_id_nas_t;
#endif /* FILE_3GPP_COMMONS_SEEN */
typedef struct protocol_configuration_options_nas_s {
uint8_t ext : 1;
uint8_t spare : 4;
uint8_t configuration_protocol : 3;
uint8_t num_protocol_or_container_id;
// arbitrary value, can be greater than defined (250/3)
// Setting this value to 30 to support maximum possible number of protocol id
// or container id defined in 24.008 release 13
#define PCO_UNSPEC_MAXIMUM_PROTOCOL_ID_OR_CONTAINER_ID 30
pco_protocol_or_container_id_nas_t
protocol_or_container_ids[PCO_UNSPEC_MAXIMUM_PROTOCOL_ID_OR_CONTAINER_ID];
} protocol_configuration_options_nas_t;
#endif
......@@ -53,14 +53,6 @@
#define AUTN_LENGTH_BITS (128)
#define AUTN_LENGTH_OCTETS (AUTN_LENGTH_BITS / 8)
/* Some methods to convert a string to an int64_t */
/*
#define STRING_TO_64BITS(sTRING, cONTAINER) \
sscanf(sTRING, "%" SCN64, cONTAINER)
#define STRING_TO_U64BITS(sTRING, cONTAINER) \
sscanf(sTRING, "%" SCNu64, cONTAINER)
*/
/* Converts a string to 128 bits gmplib integer holder */
#define STRING_TO_XBITS(sTRING, lENGTH, cONTAINER, rET) \
do { \
......
......@@ -34,9 +34,9 @@
class stream_serializable {
public:
virtual void dump_to(std::ostream &os) = 0;
virtual void load_from(std::istream &is) = 0;
//virtual ~serializable() = 0;
virtual void dump_to(std::ostream& os) = 0;
virtual void load_from(std::istream& is) = 0;
// virtual ~serializable() = 0;
};
#endif /* FILE_SERIALIZABLE_HPP_SEEN */
......@@ -247,12 +247,33 @@ typedef struct nf_service_version_s {
}
} nf_service_version_t;
typedef struct ip_endpoint_s {
std::vector<struct in_addr> ipv4_addresses;
// std::vector<struct in6_addr> ipv6_addresses;
std::string transport; // TCP
unsigned int port;
std::string to_string() const {
std::string s = {};
s.append("Ipv4 Addresses: ");
for (auto ipv4 : ipv4_addresses) {
s.append(inet_ntoa(ipv4));
}
s.append(", TransportProtocol: ");
s.append(transport);
s.append(", Port: ");
s.append(std::to_string(port));
return s;
}
} ip_endpoint_t;
typedef struct nf_service_s {
std::string service_instance_id;
std::string service_name;
std::vector<nf_service_version_t> versions;
std::string scheme;
std::string nf_service_status;
std::vector<ip_endpoint_t> ip_endpoints;
std::string to_string() const {
std::string s = {};
......@@ -267,6 +288,10 @@ typedef struct nf_service_s {
s.append(scheme);
s.append(", Service status: ");
s.append(nf_service_status);
s.append(", IpEndPoints: ");
for (auto endpoint : ip_endpoints) {
s.append(endpoint.to_string());
}
return s;
}
} nf_service_t;
......
This diff is collapsed.
......@@ -30,18 +30,145 @@
#define FILE_3GPP_CONVERSIONS_HPP_SEEN
#include "3gpp_29.274.h"
#include "3gpp_29.244.h"
#include "3gpp_29.281.h"
#include "3gpp_24.501.h"
#include "endpoint.hpp"
#include "3gpp_24.008.h"
#include "nas_lib.h"
#include "SmContextMessage.h"
#include "SmContextUpdateMessage.h"
#include "SmContextReleaseMessage.h"
#include "NotificationData.h"
#include "NsmfEventExposure.h"
#include "smf_msg.hpp"
#include "itti_msg_n11.hpp"
extern "C" {
#include "nas_message.h"
}
namespace xgpp_conv {
/*
* Convert PAA to PFCP UE IP Addr
* @param [const paa_t&] paa: paa
* @param [pfcp::ue_ip_address_t&] ue_ip_address: UE IP Addr
* @return void
*/
void paa_to_pfcp_ue_ip_address(
const paa_t& paa, pfcp::ue_ip_address_t& ue_ip_address);
/*
* Convert PDN IP to PFCP UE IP Addr
* @param [const pdu_session_type_t&] pdu_session_type: PDU Session Type
* @param [const struct in_addr&] ipv4_address: IPv4 Addr
* @param [const struct in6_addr] ipv6_address: IPv6 Addr
* @param [pfcp::ue_ip_address_t&] ue_ip_address: UE IP Addr
* @return void
*/
void pdn_ip_to_pfcp_ue_ip_address(
const pdu_session_type_t& pdu_session_type,
const struct in_addr& ipv4_address, const struct in6_addr ipv6_address,
pfcp::ue_ip_address_t& ue_ip_address);
/*
* Convert PCO in NAS into core type
* @param [const protocol_configuration_options_nas_t&] pco_nas: PCO in NAS msg
* @param [protocol_configuration_options_t&] pco: PCO in core type
* @return void
*/
void pco_nas_to_core(
const protocol_configuration_options_nas_t& pco_nas,
protocol_configuration_options_t& pco);
/*
* Convert PCO in core type to NAS type
* @param [const protocol_configuration_options_t&] pco: PCO in cpre type
* @param [protocol_configuration_options_nas_t&] pco_nas: PCO in NAS type
* @return void
*/
void pco_core_to_nas(
const protocol_configuration_options_t& pco,
protocol_configuration_options_nas_t& pco_nas);
/*
* Convert SM Context Create Msg from OpenAPI into PDU
* SessionCreateSMContextRequest msg
* @param [const oai::smf_server::model::SmContextMessage&] scm: SM Context
* Create Msg in OpenAPI
* @param [smf::pdu_session_create_sm_context_request&] pcr: PDU
* SessionCreateSMContextRequest msg
* @return void
*/
void sm_context_create_from_openapi(
const oai::smf_server::model::SmContextMessage& scm,
smf::pdu_session_create_sm_context_request& pcr);
/*
* Convert SM Context Update Msg from OpenAPI into PDU
* SessionUpdateSMContextRequest msg
* @param [const oai::smf_server::model::SmContextUpdateMessage&] scu: SM
* Context Update Msg in OpenAPI
* @param [smf::pdu_session_update_sm_context_request&] pur: PDU
* SessionUpdateSMContextRequest msg
* @return void
*/
void sm_context_update_from_openapi(
const oai::smf_server::model::SmContextUpdateMessage& scu,
smf::pdu_session_update_sm_context_request& pur);
/*
* Convert SM Context Release Msg from OpenAPI into PDU
* SessionReleaseSMContextRequest msg
* @param [const oai::smf_server::model::SmContextReleaseMessage&] srm: SM
* Context Release Msg in OpenAPI
* @param [smf::pdu_session_release_sm_context_request&] prr: PDU
* SessionReleaseSMContextRequest msg
* @return void
*/
void sm_context_release_from_openapi(
const oai::smf_server::model::SmContextReleaseMessage& srm,
smf::pdu_session_release_sm_context_request& prr);
/*
* Convert Data Notification from OpenAPI into Data Notification Msg
* @param [const oai::smf_server::model::NotificationData&] nd: Data
* Notification in OpenAPI
* @param [smf::data_notification_msg&] dn_msg: Data Notification msg
* @return void
*/
void data_notification_from_openapi(
const oai::smf_server::model::NotificationData& nd,
smf::data_notification_msg& dn_msg);
/*
* Convert NsmfEventExposure from OpenAPI into Event Exposure Msg
* @param [const oai::smf_server::model::NsmfEventExposure&] nee:
* NsmfEventExposure in OpenAPI
* @param [smf::event_exposure_msg&] eem: Event Exposure Msg
* @return void
*/
void smf_event_exposure_notification_from_openapi(
const oai::smf_server::model::NsmfEventExposure& nee,
smf::event_exposure_msg& eem);
/*
* Convert NAS to SM Context Request msg
* @param [const nas_message_t&] nm: NAS msg
* @param [smf::pdu_session_create_sm_context_request&] pcr: PDU
* SessionCreateSMContextRequest msg
* @return void
*/
void sm_context_request_from_nas(
const nas_message_t& nm, smf::pdu_session_create_sm_context_request& pcr);
void create_sm_context_response_from_ct_request(
const std::shared_ptr<itti_n11_create_sm_context_request>& ct_request,
std::shared_ptr<itti_n11_create_sm_context_response>& ct_response);
void update_sm_context_response_from_ct_request(
const std::shared_ptr<itti_n11_update_sm_context_request>& ct_request,
std::shared_ptr<itti_n11_update_sm_context_response>& ct_response);
} // namespace xgpp_conv
#endif /* FILE_3GPP_CONVERSIONS_HPP_SEEN */
......@@ -24,15 +24,25 @@ include_directories(${SRC_TOP_DIR}/common/msg)
include_directories(${SRC_TOP_DIR}/common/utils)
include_directories(${SRC_TOP_DIR}/common/utils/bstr)
include_directories(${SRC_TOP_DIR}/itti)
include_directories(${SRC_TOP_DIR}/common/nas)
include_directories(${SRC_TOP_DIR}/api-server/model)
include_directories(${SRC_TOP_DIR}/smf_app)
include_directories(${SRC_TOP_DIR}/nas)
include_directories(${SRC_TOP_DIR}/nas/ies)
include_directories(${SRC_TOP_DIR}/nas/sm/msg)
include_directories(${SRC_TOP_DIR}/nas/mm)
include_directories(${SRC_TOP_DIR}/nas/mm/msg)
include_directories(${SRC_TOP_DIR}/nas/sm)
include_directories(${SRC_TOP_DIR}/nas/sm/msg)
#include_directories(${SRC_TOP_DIR}/nas/security)
include_directories(${SRC_TOP_DIR}/ngap/asn1c)
include_directories(${SRC_TOP_DIR}/../build/ext/spdlog/include)
set(CN_UTILS_SRC STATIC
${CMAKE_CURRENT_SOURCE_DIR}/3gpp_conversions.cpp
${CMAKE_CURRENT_SOURCE_DIR}/async_shell_cmd.cpp
${CMAKE_CURRENT_SOURCE_DIR}/conversions.cpp
${CMAKE_CURRENT_SOURCE_DIR}/epc.cpp
${CMAKE_CURRENT_SOURCE_DIR}/get_gateway_netlink.cpp
${CMAKE_CURRENT_SOURCE_DIR}/if.cpp
${CMAKE_CURRENT_SOURCE_DIR}/pid_file.cpp
${CMAKE_CURRENT_SOURCE_DIR}/string.cpp
......@@ -40,7 +50,4 @@ set(CN_UTILS_SRC STATIC
${CMAKE_CURRENT_SOURCE_DIR}/mime_parser.cpp
)
add_library(CN_UTILS ${CN_UTILS_SRC})
add_library(CN_UTILS ${CN_UTILS_SRC})
\ No newline at end of file
......@@ -20,65 +20,70 @@
static int bsafeShouldExit = 1;
char * strcpy (char *dst, const char *src);
char * strcat (char *dst, const char *src);
char* strcpy(char* dst, const char* src);
char* strcat(char* dst, const char* src);
char * strcpy (char *dst, const char *src) {
(void) dst;
(void) src;
fprintf (stderr, "bsafe error: strcpy() is not safe, use bstrcpy instead.\n");
if (bsafeShouldExit) exit (-1);
return NULL;
char* strcpy(char* dst, const char* src) {
(void) dst;
(void) src;
fprintf(stderr, "bsafe error: strcpy() is not safe, use bstrcpy instead.\n");
if (bsafeShouldExit) exit(-1);
return NULL;
}
char * strcat (char *dst, const char *src) {
(void) dst;
(void) src;
fprintf (stderr, "bsafe error: strcat() is not safe, use bstrcat instead.\n");
if (bsafeShouldExit) exit (-1);
return NULL;
char* strcat(char* dst, const char* src) {
(void) dst;
(void) src;
fprintf(stderr, "bsafe error: strcat() is not safe, use bstrcat instead.\n");
if (bsafeShouldExit) exit(-1);
return NULL;
}
#if !defined (__GNUC__) && (!defined(_MSC_VER) || (_MSC_VER <= 1310))
char * (gets) (char * buf) {
(void) buf;
fprintf (stderr, "bsafe error: gets() is not safe, use bgets.\n");
if (bsafeShouldExit) exit (-1);
return NULL;
#if !defined(__GNUC__) && (!defined(_MSC_VER) || (_MSC_VER <= 1310))
char*(gets)(char* buf) {
(void) buf;
fprintf(stderr, "bsafe error: gets() is not safe, use bgets.\n");
if (bsafeShouldExit) exit(-1);
return NULL;
}
#endif
char * (strncpy) (char *dst, const char *src, size_t n) {
(void) dst;
(void) src;
(void) n;
fprintf (stderr, "bsafe error: strncpy() is not safe, use bmidstr instead.\n");
//if (bsafeShouldExit) exit (-1);
return NULL;
char*(strncpy)(char* dst, const char* src, size_t n) {
(void) dst;
(void) src;
(void) n;
fprintf(stderr, "bsafe error: strncpy() is not safe, use bmidstr instead.\n");
// if (bsafeShouldExit) exit (-1);
return NULL;
}
char * (strncat) (char *dst, const char *src, size_t n) {
(void) dst;
(void) src;
(void) n;
fprintf (stderr, "bsafe error: strncat() is not safe, use bstrcat then btrunc\n\tor cstr2tbstr, btrunc then bstrcat instead.\n");
if (bsafeShouldExit) exit (-1);
return NULL;
char*(strncat)(char* dst, const char* src, size_t n) {
(void) dst;
(void) src;
(void) n;
fprintf(
stderr,
"bsafe error: strncat() is not safe, use bstrcat then btrunc\n\tor "
"cstr2tbstr, btrunc then bstrcat instead.\n");
if (bsafeShouldExit) exit(-1);
return NULL;
}
char * (strtok) (char *s1, const char *s2) {
(void) s1;
(void) s2;
fprintf (stderr, "bsafe error: strtok() is not safe, use bsplit or bsplits instead.\n");
if (bsafeShouldExit) exit (-1);
return NULL;
char*(strtok)(char* s1, const char* s2) {
(void) s1;
(void) s2;
fprintf(
stderr,
"bsafe error: strtok() is not safe, use bsplit or bsplits instead.\n");
if (bsafeShouldExit) exit(-1);
return NULL;
}
/*
//TODO: temporary solution for Release mode
char * (strdup) (const char *s) {
(void) s;
fprintf (stderr, "bsafe error: strdup() is not safe, use bstrcpy.\n");
if (bsafeShouldExit) exit (-1);
return NULL;
(void) s;
fprintf (stderr, "bsafe error: strdup() is not safe, use bstrcpy.\n");
if (bsafeShouldExit) exit (-1);
return NULL;
}
*/
/*
* This source file is part of the bstring string library. This code was
* written by Paul Hsieh in 2002-2004, and is covered by the BSD open source
* license. Refer to the accompanying documentation for details on usage and
* written by Paul Hsieh in 2002-2004, and is covered by the BSD open source
* license. Refer to the accompanying documentation for details on usage and
* license.
*/
......@@ -21,20 +21,20 @@
extern "C" {
#endif
#if !defined (__GNUC__) && (!defined(_MSC_VER) || (_MSC_VER <= 1310))
#if !defined(__GNUC__) && (!defined(_MSC_VER) || (_MSC_VER <= 1310))
/* This is caught in the linker, so its not necessary for gcc. */
extern char * (gets) (char * buf);
extern char*(gets)(char* buf);
#endif
extern char * (strncpy) (char *dst, const char *src, size_t n);
extern char * (strncat) (char *dst, const char *src, size_t n);
extern char * (strtok) (char *s1, const char *s2);
//extern char * (strdup) (const char *s);
extern char*(strncpy)(char* dst, const char* src, size_t n);
extern char*(strncat)(char* dst, const char* src, size_t n);
extern char*(strtok)(char* s1, const char* s2);
// extern char * (strdup) (const char *s);
#undef strcpy
#undef strcat
#define strcpy(a,b) bsafe_strcpy(a,b)
#define strcat(a,b) bsafe_strcat(a,b)
#define strcpy(a, b) bsafe_strcpy(a, b)
#define strcat(a, b) bsafe_strcat(a, b)
#ifdef __cplusplus
}
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -22,16 +22,17 @@
extern "C" {
#endif
extern int buIsUTF8Content (const_bstring bu);
extern int buAppendBlkUcs4 (bstring b, const cpUcs4* bu, int len, cpUcs4 errCh);
extern int buIsUTF8Content(const_bstring bu);
extern int buAppendBlkUcs4(bstring b, const cpUcs4* bu, int len, cpUcs4 errCh);
/* For those unfortunate enough to be stuck supporting UTF16. */
extern int buGetBlkUTF16 (/* @out */ cpUcs2* ucs2, int len, cpUcs4 errCh, const_bstring bu, int pos);
extern int buAppendBlkUTF16 (bstring bu, const cpUcs2* utf16, int len, cpUcs2* bom, cpUcs4 errCh);
extern int buGetBlkUTF16(
/* @out */ cpUcs2* ucs2, int len, cpUcs4 errCh, const_bstring bu, int pos);
extern int buAppendBlkUTF16(
bstring bu, const cpUcs2* utf16, int len, cpUcs2* bom, cpUcs4 errCh);
#ifdef __cplusplus
}
#endif
#endif /* BSTRLIB_UNICODE_UTILITIES */
This diff is collapsed.
......@@ -21,39 +21,45 @@ extern "C" {
#endif
#if INT_MAX >= 0x7fffffffUL
typedef int cpUcs4;
typedef int cpUcs4;
#elif LONG_MAX >= 0x7fffffffUL
typedef long cpUcs4;
typedef long cpUcs4;
#else
#error This compiler is not supported
#endif
#if UINT_MAX == 0xFFFF
typedef unsigned int cpUcs2;
typedef unsigned int cpUcs2;
#elif USHRT_MAX == 0xFFFF
typedef unsigned short cpUcs2;
typedef unsigned short cpUcs2;
#elif UCHAR_MAX == 0xFFFF
typedef unsigned char cpUcs2;
typedef unsigned char cpUcs2;
#else
#error This compiler is not supported
#endif
#define isLegalUnicodeCodePoint(v) ((((v) < 0xD800L) || ((v) > 0xDFFFL)) && (((unsigned long)(v)) <= 0x0010FFFFL) && (((v)|0x1F0001) != 0x1FFFFFL))
#define isLegalUnicodeCodePoint(v) \
((((v) < 0xD800L) || ((v) > 0xDFFFL)) && \
(((unsigned long) (v)) <= 0x0010FFFFL) && (((v) | 0x1F0001) != 0x1FFFFFL))
struct utf8Iterator {
unsigned char* data;
int slen;
int start, next;
int error;
unsigned char* data;
int slen;
int start, next;
int error;
};
#define utf8IteratorNoMore(it) (!(it) || (it)->next >= (it)->slen)
extern void utf8IteratorInit (struct utf8Iterator* iter, unsigned char* data, int slen);
extern void utf8IteratorUninit (struct utf8Iterator* iter);
extern cpUcs4 utf8IteratorGetNextCodePoint (struct utf8Iterator* iter, cpUcs4 errCh);
extern cpUcs4 utf8IteratorGetCurrCodePoint (struct utf8Iterator* iter, cpUcs4 errCh);
extern int utf8ScanBackwardsForCodePoint (unsigned char* msg, int len, int pos, cpUcs4* out);
extern void utf8IteratorInit(
struct utf8Iterator* iter, unsigned char* data, int slen);
extern void utf8IteratorUninit(struct utf8Iterator* iter);
extern cpUcs4 utf8IteratorGetNextCodePoint(
struct utf8Iterator* iter, cpUcs4 errCh);
extern cpUcs4 utf8IteratorGetCurrCodePoint(
struct utf8Iterator* iter, cpUcs4 errCh);
extern int utf8ScanBackwardsForCodePoint(
unsigned char* msg, int len, int pos, cpUcs4* out);
#ifdef __cplusplus
}
......
/* From https://gist.github.com/javiermon/6272065#file-gateway_netlink-c */
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <sys/socket.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <linux/netlink.h>
#include <linux/rtnetlink.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <net/if.h>
#include <fstream> // std::ifstream
#include <string>
#include "common_defs.h"
#include "get_gateway_netlink.hpp"
#include "logger.hpp"
#define BUFFER_SIZE 4096
using namespace std;
//------------------------------------------------------------------------------
bool util::get_iface_l2_addr(const std::string& iface, std::string& mac) {
std::string mac_address_path =
fmt::format("/sys/class/net/{}/address", iface);
std::ifstream mac_address_in(
mac_address_path.c_str(), ios_base::in | ios_base::binary);
char wb[32];
mac_address_in.get(wb, 32);
mac.assign(wb);
Logger::pfcp_switch().error(
"Found IFace %s MAC %s", iface.c_str(), mac.c_str());
mac.erase(std::remove(mac.begin(), mac.end(), ':'), mac.end());
return true;
// ifr = {};
// strncpy ((char *) ifr.ifr_name, ifname, IFNAMSIZ);
// if (ioctl(sd, SIOCGIFFLAGS, &ifr) == 0) {
// if (! (ifr.ifr_flags & IFF_LOOPBACK)) { // don't count loopback
// if (ioctl(sd, SIOCGIFHWADDR, &ifr) == 0) {
// memcpy(pdn_mac_address, ifr.ifr_hwaddr.sa_data, 6);
// }
// }
// }
}
//------------------------------------------------------------------------------
bool util::get_gateway_and_iface(std::string& gw, std::string& iface) {
int received_bytes = 0, msg_len = 0, route_attribute_len = 0;
int sock = -1, msgseq = 0;
struct nlmsghdr *nlh, *nlmsg;
struct rtmsg* route_entry;
// This struct contain route attributes (route type)
struct rtattr* route_attribute;
char gateway_address[INET_ADDRSTRLEN], interface[IF_NAMESIZE + 1];
char msgbuf[BUFFER_SIZE], buffer[BUFFER_SIZE];
char* ptr = buffer;
struct timeval tv;
int rv = RETURNok;
if ((sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE)) < 0) {
perror("socket failed");
return false;
}
memset(msgbuf, 0, sizeof(msgbuf));
memset(gateway_address, 0, sizeof(gateway_address));
memset(interface, 0, sizeof(interface));
memset(buffer, 0, sizeof(buffer));
/* point the header and the msg structure pointers into the buffer */
nlmsg = (struct nlmsghdr*) msgbuf;
/* Fill in the nlmsg header*/
nlmsg->nlmsg_len = NLMSG_LENGTH(sizeof(struct rtmsg));
nlmsg->nlmsg_type =
RTM_GETROUTE; // Get the routes from kernel routing table .
nlmsg->nlmsg_flags =
NLM_F_DUMP | NLM_F_REQUEST; // The message is a request for dump.
nlmsg->nlmsg_seq = msgseq++; // Sequence of the message packet.
nlmsg->nlmsg_pid = getpid(); // PID of process sending the request.
/* 1 Sec Timeout to avoid stall */
tv.tv_sec = 1;
setsockopt(
sock, SOL_SOCKET, SO_RCVTIMEO, (struct timeval*) &tv,
sizeof(struct timeval));
/* send msg */
if (send(sock, nlmsg, nlmsg->nlmsg_len, 0) < 0) {
perror("send failed");
return false;
}
/* receive response */
do {
received_bytes = recv(sock, ptr, sizeof(buffer) - msg_len, 0);
if (received_bytes < 0) {
perror("Error in recv");
return false;
}
nlh = (struct nlmsghdr*) ptr;
/* Check if the header is valid */
if ((NLMSG_OK(nlmsg, received_bytes) == 0) ||
(nlmsg->nlmsg_type == NLMSG_ERROR)) {
perror("Error in received packet");
return false;
}
/* If we received all data break */
if (nlh->nlmsg_type == NLMSG_DONE)
break;
else {
ptr += received_bytes;
msg_len += received_bytes;
}
/* Break if its not a multi part message */
if ((nlmsg->nlmsg_flags & NLM_F_MULTI) == 0) break;
} while ((nlmsg->nlmsg_seq != msgseq) || (nlmsg->nlmsg_pid != getpid()));
/* parse response */
for (; NLMSG_OK(nlh, received_bytes); nlh = NLMSG_NEXT(nlh, received_bytes)) {
/* Get the route data */
route_entry = (struct rtmsg*) NLMSG_DATA(nlh);
/* We are just interested in main routing table */
if (route_entry->rtm_table != RT_TABLE_MAIN) continue;
route_attribute = (struct rtattr*) RTM_RTA(route_entry);
route_attribute_len = RTM_PAYLOAD(nlh);
/* Loop through all attributes */
for (; RTA_OK(route_attribute, route_attribute_len);
route_attribute = RTA_NEXT(route_attribute, route_attribute_len)) {
switch (route_attribute->rta_type) {
case RTA_OIF:
if_indextoname(*(int*) RTA_DATA(route_attribute), interface);
break;
case RTA_GATEWAY:
inet_ntop(
AF_INET, RTA_DATA(route_attribute), gateway_address,
sizeof(gateway_address));
break;
default:
break;
}
}
if ((*gateway_address) && (*interface)) {
gw.assign(gateway_address);
iface.assign(interface);
break;
} else {
rv = false;
}
}
close(sock);
return true;
}
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the Apache License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file get_gateway_netlink.hpp
\brief
\author Lionel Gauthier
\company Eurecom
\email: lionel.gauthier@eurecom.fr
*/
#ifndef FILE_GET_GATEWAY_NETLINK_HPP_SEEN
#define FILE_GET_GATEWAY_NETLINK_HPP_SEEN
#include <string>
namespace util {
bool get_iface_l2_addr(const std::string& iface, std::string& mac);
bool get_gateway_and_iface(std::string& gw, std::string& iface);
} // namespace util
#endif /* FILE_GET_GATEWAY_NETLINK_HPP_SEEN */
......@@ -53,7 +53,7 @@ bool mime_parser::parse(const std::string& str) {
str.substr(content_type_pos + 14, crlf_pos - (content_type_pos + 14));
Logger::smf_app().debug("Content Type: %s", p.content_type.c_str());
crlf_pos = str.find(CRLF + CRLF, content_type_pos); // beginning of content
crlf_pos = str.find(CRLF + CRLF, content_type_pos); // beginning of content
boundary_pos = str.find(boundary_full, crlf_pos);
if (boundary_pos == std::string::npos) {
boundary_pos = str.find(last_boundary, crlf_pos);
......@@ -84,7 +84,7 @@ unsigned char* mime_parser::format_string_as_hex(const std::string& str) {
conv::ascii_to_hex(data_hex, (const char*) data);
Logger::smf_app().debug(
"[Format string as Hex] Input string (%d bytes): %s ", str_len,
"Input string (%d bytes): %s ", str_len,
str.c_str());
Logger::smf_app().debug("Data (formatted):");
#if DEBUG_IS_ON
......
......@@ -94,19 +94,13 @@ void util::ipv4_to_bstring(struct in_addr ipv4_address, bstring str) {
bitstream_addr[2] = (uint8_t)(((ipv4_address.s_addr) & 0x00ff0000) >> 16);
bitstream_addr[3] = (uint8_t)(((ipv4_address.s_addr) & 0xff000000) >> 24);
str = bfromcstralloc(4, "\0");
// str = bfromcstralloc(4, "\0");
str->slen = 4;
memcpy(str->data, bitstream_addr, sizeof(bitstream_addr));
}
void util::string_to_bstring(const std::string& str, bstring bstr) {
bstr = bfromcstralloc(str.length(), "\0");
// bstr = bfromcstralloc(str.length(), "\0");
bstr->slen = str.length();
memcpy((void*) bstr->data, (void*) str.c_str(), str.length());
/*
std::string s(
(char *)bstr->data,
bstr->slen);
Logger::nrf_app().debug("Str %s", s.c_str());
*/
}
......@@ -28,7 +28,7 @@
#include "ExtendedProtocolConfigurationOptions.h"
int encode_extended_protocol_configuration_options(
ExtendedProtocolConfigurationOptions extendedprotocolconfigurationoptions,
protocol_configuration_options_nas_t extendedprotocolconfigurationoptions,
uint8_t iei, uint8_t* buffer, uint32_t len) {
uint8_t* lenPtr = NULL;
uint32_t encoded = 0;
......@@ -45,27 +45,71 @@ int encode_extended_protocol_configuration_options(
encoded++;
}
lenPtr = (buffer + encoded);
encoded++;
encoded++;
lenPtr = (buffer + encoded);
uint16_t temp = 0;
encoded += 2; // ENCODE_U16
if ((encode_result = encode_bstring(
extendedprotocolconfigurationoptions, buffer + encoded,
len - encoded)) < 0)
return encode_result;
else
encoded += encode_result;
encoded += encode_protocol_configuration_options(
extendedprotocolconfigurationoptions, buffer + encoded, len - encoded);
uint32_t res = encoded - 2 - ((iei > 0) ? 1 : 0);
*lenPtr = res / (1 << 8);
lenPtr++;
*lenPtr = res % (1 << 8);
uint32_t len_ie = encoded - 2 - ((iei > 0) ? 1 : 0);
ENCODE_U16(lenPtr, len_ie, temp);
return encoded;
}
//------------------------------------------------------------------------------
int encode_protocol_configuration_options(
const protocol_configuration_options_nas_t protocolconfigurationoptions,
uint8_t* buffer, const uint32_t len) {
uint8_t num_protocol_or_container_id = 0;
uint32_t encoded = 0;
int encode_result = 0;
*(buffer + encoded) =
0x00 | (1 << 7) |
(protocolconfigurationoptions.configuration_protocol & 0x7);
encoded++;
while (num_protocol_or_container_id <
protocolconfigurationoptions.num_protocol_or_container_id) {
ENCODE_U16(
buffer + encoded,
protocolconfigurationoptions
.protocol_or_container_ids[num_protocol_or_container_id]
.id,
encoded);
*(buffer + encoded) =
protocolconfigurationoptions
.protocol_or_container_ids[num_protocol_or_container_id]
.length;
encoded++;
if (protocolconfigurationoptions
.protocol_or_container_ids[num_protocol_or_container_id]
.length > 0) {
if ((encode_result = encode_bstring(
protocolconfigurationoptions
.protocol_or_container_ids[num_protocol_or_container_id]
.contents,
buffer + encoded,
protocolconfigurationoptions
.protocol_or_container_ids[num_protocol_or_container_id]
.length)) < 0)
return encode_result;
else
encoded += encode_result;
} else {
encoded += protocolconfigurationoptions
.protocol_or_container_ids[num_protocol_or_container_id]
.length;
}
num_protocol_or_container_id += 1;
}
return encoded;
}
int decode_extended_protocol_configuration_options(
ExtendedProtocolConfigurationOptions* extendedprotocolconfigurationoptions,
protocol_configuration_options_nas_t* extendedprotocolconfigurationoptions,
uint8_t iei, uint8_t* buffer, uint32_t len) {
int decoded = 0;
uint32_t ielen = 0;
......@@ -76,18 +120,86 @@ int decode_extended_protocol_configuration_options(
decoded++;
}
ielen = *(buffer + decoded);
decoded++;
ielen = (ielen << 8) + *(buffer + decoded);
DECODE_U16(buffer + decoded, ielen, decoded);
if (((*(buffer + decoded) >> 7) & 0x1) != 1) {
return TLV_VALUE_DOESNT_MATCH;
}
// Bits 7 to 4 of octet 3 are spare, read as 0
if (((*(buffer + decoded) & 0x78) >> 3) != 0) {
return TLV_VALUE_DOESNT_MATCH;
}
extendedprotocolconfigurationoptions->configuration_protocol =
(*(buffer + decoded) >> 1) & 0x7;
decoded++;
CHECK_LENGTH_DECODER(len - decoded, ielen);
if ((decode_result = decode_bstring(
extendedprotocolconfigurationoptions, ielen, buffer + decoded,
len - decoded)) < 0) {
decode_result = decode_protocol_configuration_options(
extendedprotocolconfigurationoptions, buffer + decoded, ielen);
if (decode_result < 0) {
return decode_result;
} else {
decoded += decode_result;
}
decoded += (uint32_t) decode_result;
return decoded;
}
//------------------------------------------------------------------------------
int decode_protocol_configuration_options(
protocol_configuration_options_nas_t* protocolconfigurationoptions,
const uint8_t* const buffer, const const uint32_t len) {
int decoded = 0;
int decode_result = 0;
protocolconfigurationoptions->num_protocol_or_container_id = 0;
while (3 <= ((int32_t) len - (int32_t) decoded)) {
DECODE_U16(
buffer + decoded,
protocolconfigurationoptions
->protocol_or_container_ids[protocolconfigurationoptions
->num_protocol_or_container_id]
.id,
decoded);
DECODE_U8(
buffer + decoded,
protocolconfigurationoptions
->protocol_or_container_ids[protocolconfigurationoptions
->num_protocol_or_container_id]
.length,
decoded);
if (0 < protocolconfigurationoptions
->protocol_or_container_ids[protocolconfigurationoptions
->num_protocol_or_container_id]
.length) {
if ((decode_result = decode_bstring(
&protocolconfigurationoptions
->protocol_or_container_ids
[protocolconfigurationoptions
->num_protocol_or_container_id]
.contents,
protocolconfigurationoptions
->protocol_or_container_ids
[protocolconfigurationoptions
->num_protocol_or_container_id]
.length,
buffer + decoded, len - decoded)) < 0) {
return decode_result;
} else {
decoded += decode_result;
}
} else {
protocolconfigurationoptions
->protocol_or_container_ids[protocolconfigurationoptions
->num_protocol_or_container_id]
.contents = NULL;
}
protocolconfigurationoptions->num_protocol_or_container_id += 1;
}
return decoded;
......
......@@ -23,7 +23,8 @@
#define _EXTENDEDPROTOCOLCONFIGURATIONOPTIONS_H_
#include <stdint.h>
#include "bstrlib.h"
#include "nas_lib.h"
#include <stdbool.h>
#define EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_MINIMUM_LENGTH 4
#define EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_MAXIMUM_LENGTH 65538
......@@ -31,13 +32,22 @@
#define EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_MINIMUM_LENGTH_TLVE 4
#define EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_MAXIMUM_LENGTH_TLVE 65538
typedef bstring ExtendedProtocolConfigurationOptions;
typedef protocol_configuration_options_nas_t
ExtendedProtocolConfigurationOptions;
int encode_extended_protocol_configuration_options(
ExtendedProtocolConfigurationOptions extendedprotocolconfigurationoptions,
protocol_configuration_options_nas_t extendedprotocolconfigurationoptions,
uint8_t iei, uint8_t* buffer, uint32_t len);
int decode_extended_protocol_configuration_options(
ExtendedProtocolConfigurationOptions* extendedprotocolconfigurationoptions,
protocol_configuration_options_nas_t* extendedprotocolconfigurationoptions,
uint8_t iei, uint8_t* buffer, uint32_t len);
int decode_protocol_configuration_options(
protocol_configuration_options_nas_t* protocolconfigurationoptions,
const uint8_t* const buffer, const uint32_t len);
int encode_protocol_configuration_options(
const protocol_configuration_options_nas_t protocolconfigurationoptions,
uint8_t* buffer, const uint32_t len);
#endif
......@@ -59,7 +59,9 @@ int encode_pdu_address(
encoded += encode_result;
// set length
*(uint8_t*) (lenPtr) = encoded - len_pos;
uint16_t temp = 0;
//*(uint8_t*) (lenPtr) = encoded - len_pos;
ENCODE_U8(lenPtr, encoded - len_pos, temp);
return encoded;
}
......
......@@ -44,7 +44,8 @@ int decode_authentication_reject(
case AUTHENTICATION_REJECT_EAP_MESSAGE_IEI:
// if((decoded_result = decode_message_type
// (&authentication_reject->messagetype,
// AUTHENTICATION_REJECT_EAP_MESSAGE_IEI, buffer+decoded,len-decoded))<0)
// AUTHENTICATION_REJECT_EAP_MESSAGE_IEI,
// buffer+decoded,len-decoded))<0)
if ((decoded_result = decode_eap_message(
&authentication_reject->eapmessage,
AUTHENTICATION_REJECT_EAP_MESSAGE_IEI, buffer + decoded,
......
......@@ -222,8 +222,8 @@ int encode_pdu_session_establishment_accept(
else
encoded += encoded_result;
// TODO: In Wireshark Version 3.2.2 (Git commit a3efece3d640), SSC Mode (4
// bit) + PDU session type (4 bit) = 1 byte, so disable encode SSC Mode for the
// moment, Should be verified later
// bit) + PDU session type (4 bit) = 1 byte, so disable encode SSC Mode for
// the moment, Should be verified later
/* if((encoded_result = encode_ssc_mode
(pdu_session_establishment_accept->sscmode, 0,
buffer+encoded,len-encoded))<0) return encoded_result; else encoded +=
......
......@@ -160,7 +160,7 @@ 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);
printf("message type %d", msg->header.message_type);
#endif
switch (msg->header.message_type) {
case PDU_SESSION_ESTABLISHMENT_REQUEST:
......
/*
* Copyright (c) 2017 Sprint
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
* Copyright (c) 2017 Sprint
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "async_shell_cmd.hpp"
#include "common_defs.h"
......@@ -33,43 +32,43 @@
#include <thread>
#include <signal.h>
#include <stdint.h>
#include <stdlib.h> // srand
#include <unistd.h> // get_pid(), pause()
#include <stdlib.h> // srand
#include <unistd.h> // get_pid(), pause()
using namespace smf;
using namespace util;
using namespace std;
using namespace oai::smf_server::api;
itti_mw *itti_inst = nullptr;
async_shell_cmd *async_shell_cmd_inst = nullptr;
smf_app *smf_app_inst = nullptr;
itti_mw* itti_inst = nullptr;
async_shell_cmd* async_shell_cmd_inst = nullptr;
smf_app* smf_app_inst = nullptr;
smf_config smf_cfg;
SMFApiServer *smf_api_server_1 = nullptr;
smf_http2_server *smf_api_server_2 = nullptr;
SMFApiServer* smf_api_server_1 = nullptr;
smf_http2_server* smf_api_server_2 = nullptr;
void send_heartbeat_to_tasks(const uint32_t sequence);
//------------------------------------------------------------------------------
void send_heartbeat_to_tasks(const uint32_t sequence)
{
itti_msg_ping *itti_msg = new itti_msg_ping(TASK_SMF_APP, TASK_ALL, sequence);
void send_heartbeat_to_tasks(const uint32_t sequence) {
itti_msg_ping* itti_msg = new itti_msg_ping(TASK_SMF_APP, TASK_ALL, sequence);
std::shared_ptr<itti_msg_ping> i = std::shared_ptr<itti_msg_ping>(itti_msg);
int ret = itti_inst->send_broadcast_msg(i);
int ret = itti_inst->send_broadcast_msg(i);
if (RETURNok != ret) {
Logger::smf_app().error( "Could not send ITTI message %s to task TASK_ALL", i->get_msg_name());
Logger::smf_app().error(
"Could not send ITTI message %s to task TASK_ALL", i->get_msg_name());
}
}
//------------------------------------------------------------------------------
void my_app_signal_handler(int s)
{
void my_app_signal_handler(int s) {
std::cout << "Caught signal " << s << std::endl;
Logger::system().startup( "exiting" );
Logger::system().startup("exiting");
itti_inst->send_terminate_msg(TASK_SMF_APP);
itti_inst->wait_tasks_end();
std::cout << "Freeing Allocated memory..." << std::endl;
if (async_shell_cmd_inst) delete async_shell_cmd_inst; async_shell_cmd_inst = nullptr;
if (async_shell_cmd_inst) delete async_shell_cmd_inst;
async_shell_cmd_inst = nullptr;
std::cout << "Async Shell CMD memory done." << std::endl;
if (smf_api_server_1) {
smf_api_server_1->shutdown();
......@@ -82,29 +81,29 @@ void my_app_signal_handler(int s)
smf_api_server_2 = nullptr;
}
std::cout << "SMF API Server memory done." << std::endl;
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;
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 << "SMF APP memory done." << std::endl;
std::cout << "Freeing Allocated memory done" << std::endl;
exit(0);
}
//------------------------------------------------------------------------------
int main(int argc, char **argv)
{
srand (time(NULL));
int main(int argc, char** argv) {
srand(time(NULL));
// Command line options
if ( !Options::parse( argc, argv ) )
{
std::cout << "Options::parse() failed" << std::endl;
return 1;
if (!Options::parse(argc, argv)) {
std::cout << "Options::parse() failed" << std::endl;
return 1;
}
// Logger
Logger::init( "smf" , Options::getlogStdout() , Options::getlogRotFilelog());
Logger::init("smf", Options::getlogStdout(), Options::getlogRotFilelog());
Logger::smf_app().startup( "Options parsed" );
Logger::smf_app().startup("Options parsed");
struct sigaction sigIntHandler;
sigIntHandler.sa_handler = my_app_signal_handler;
......@@ -121,36 +120,40 @@ int main(int argc, char **argv)
itti_inst->start(smf_cfg.itti.itti_timer_sched_params);
// system command
async_shell_cmd_inst = new async_shell_cmd(smf_cfg.itti.async_cmd_sched_params);
async_shell_cmd_inst =
new async_shell_cmd(smf_cfg.itti.async_cmd_sched_params);
// SMF application layer
smf_app_inst = new smf_app(Options::getlibconfigConfig());
// PID file
// Currently hard-coded value. TODO: add as config option.
string pid_file_name = get_exe_absolute_path("/var/run", smf_cfg.instance);
if (! is_pid_file_lock_success(pid_file_name.c_str())) {
Logger::smf_app().error( "Lock PID file %s failed\n", pid_file_name.c_str());
exit (-EDEADLK);
string pid_file_name = get_exe_absolute_path("/var/run", smf_cfg.instance);
if (!is_pid_file_lock_success(pid_file_name.c_str())) {
Logger::smf_app().error("Lock PID file %s failed\n", pid_file_name.c_str());
exit(-EDEADLK);
}
//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));
// 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));
smf_api_server_1 = new SMFApiServer(addr, smf_app_inst);
smf_api_server_1->init(2);
//smf_api_server_1->start();
// smf_api_server_1->start();
std::thread smf_http1_manager(&SMFApiServer::start, smf_api_server_1);
//SMF NGHTTP API server (HTTP2)
smf_api_server_2 = new smf_http2_server(conv::toString(smf_cfg.sbi.addr4), smf_cfg.sbi_http2_port, smf_app_inst);
//smf_api_server_2->start();
// SMF NGHTTP API server (HTTP2)
smf_api_server_2 = new smf_http2_server(
conv::toString(smf_cfg.sbi.addr4), smf_cfg.sbi_http2_port, smf_app_inst);
// smf_api_server_2->start();
std::thread smf_http2_manager(&smf_http2_server::start, smf_api_server_2);
smf_http1_manager.join();
smf_http2_manager.join();
FILE *fp = NULL;
FILE* fp = NULL;
std::string filename = fmt::format("/tmp/smf_{}.status", getpid());
fp = fopen(filename.c_str(), "w+");
fp = fopen(filename.c_str(), "w+");
fprintf(fp, "STARTED\n");
fflush(fp);
fclose(fp);
......
/*
* Copyright (c) 2017 Sprint
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
* Copyright (c) 2017 Sprint
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <iostream>
#include <stdlib.h>
......@@ -28,83 +27,104 @@ std::string Options::m_libconfigcfg;
bool Options::m_log_rot_file_log;
bool Options::m_log_stdout;
void Options::help()
{
std::cout << std::endl
<< "Usage: smf [OPTIONS]..." << std::endl
<< " -h, --help Print help and exit" << std::endl
<< " -c, --libconfigcfg filename Read the application configuration from this file." << std::endl
<< " -o, --stdoutlog Send the application logs to STDOUT fd." << std::endl
<< " -r, --rotatelog Send the application logs to local file (in current working directory)." << std::endl
;
void Options::help() {
std::cout << std::endl
<< "Usage: smf [OPTIONS]..." << std::endl
<< " -h, --help Print help and exit" << std::endl
<< " -c, --libconfigcfg filename Read the application "
"configuration from this file."
<< std::endl
<< " -o, --stdoutlog Send the application logs to "
"STDOUT fd."
<< std::endl
<< " -r, --rotatelog Send the application logs to "
"local file (in current working directory)."
<< std::endl;
}
bool Options::parse( int argc, char **argv ){
bool ret = true;
bool Options::parse(int argc, char** argv) {
bool ret = true;
ret = parseInputOptions( argc, argv );
ret &= validateOptions();
return ret;
ret = parseInputOptions(argc, argv);
ret &= validateOptions();
return ret;
}
bool Options::validateOptions(){
return (
(options & libconfigcfg)
);
bool Options::validateOptions() {
return ((options & libconfigcfg));
}
bool Options::parseInputOptions( int argc, char **argv )
{
int c;
int option_index = 0;
bool result = true;
struct option long_options[] = {
{ "help", no_argument, NULL, 'h' },
{ "libconfigcfg", required_argument, NULL, 'f' },
{ "stdoutlog", no_argument, NULL, 'o' },
{ "rotatelog", no_argument, NULL, 'r' },
{ NULL,0,NULL,0 }
};
// Loop on arguments
while (1)
{
c = getopt_long(argc, argv, "horc:", long_options, &option_index );
if (c == -1)
break; // Exit from the loop.
switch (c)
{
case 'h': { help(); exit(0); break; }
case 'c': { m_libconfigcfg = optarg; options |= libconfigcfg; break; }
case 'o': { m_log_stdout = true; options |= log_stdout; break; }
case 'r': { m_log_rot_file_log = true; options |= log_rot_file_log; break; }
bool Options::parseInputOptions(int argc, char** argv) {
int c;
int option_index = 0;
bool result = true;
struct option long_options[] = {
{"help", no_argument, NULL, 'h'},
{"libconfigcfg", required_argument, NULL, 'f'},
{"stdoutlog", no_argument, NULL, 'o'},
{"rotatelog", no_argument, NULL, 'r'},
{NULL, 0, NULL, 0}};
// Loop on arguments
while (1) {
c = getopt_long(argc, argv, "horc:", long_options, &option_index);
if (c == -1) break; // Exit from the loop.
switch (c) {
case 'h': {
help();
exit(0);
break;
}
case 'c': {
m_libconfigcfg = optarg;
options |= libconfigcfg;
break;
}
case 'o': {
m_log_stdout = true;
options |= log_stdout;
break;
}
case 'r': {
m_log_rot_file_log = true;
options |= log_rot_file_log;
break;
}
case '?':
{
switch ( optopt )
{
case 'c': { std::cout << "Option -l (libconfig config) requires an argument" << std::endl; break; }
case 'o': { std::cout << "Option -o do not requires an argument, can be also set with option -r." << std::endl; break; }
case 'r': { std::cout << "Option -r do not requires an argument, can be also set with option -o." << std::endl; break; }
default: { std::cout << "Unrecognized option [" << c << "]" << std::endl; break; }
}
result = false;
case '?': {
switch (optopt) {
case 'c': {
std::cout << "Option -l (libconfig config) requires an argument"
<< std::endl;
break;
}
case 'o': {
std::cout << "Option -o do not requires an argument, can be also "
"set with option -r."
<< std::endl;
break;
}
default:
{
}
case 'r': {
std::cout << "Option -r do not requires an argument, can be also "
"set with option -o."
<< std::endl;
break;
}
default: {
std::cout << "Unrecognized option [" << c << "]" << std::endl;
result = false;
}
break;
}
}
result = false;
break;
}
}
return result;
default: {
std::cout << "Unrecognized option [" << c << "]" << std::endl;
result = false;
}
}
}
return result;
}
/*
* Copyright (c) 2017 Sprint
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
* Copyright (c) 2017 Sprint
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __OPTIONS_H
#define __OPTIONS_H
......@@ -20,35 +20,31 @@
#include <stdint.h>
#include <string>
class Options {
public:
static bool parse(int argc, char** argv);
static bool parseInputOptions(int argc, char** argv);
static bool parseJson();
static bool validateOptions();
class Options
{
public:
static const std::string& getlibconfigConfig() { return m_libconfigcfg; }
static const bool& getlogRotFilelog() { return m_log_rot_file_log; }
static const bool& getlogStdout() { return m_log_stdout; }
static bool parse( int argc, char **argv );
static bool parseInputOptions( int argc, char **argv );
static bool parseJson();
static bool validateOptions();
private:
enum OptionsSelected {
libconfigcfg = 0x01,
log_stdout = 0x02,
log_rot_file_log = 0x04
};
static const std::string &getlibconfigConfig() { return m_libconfigcfg; }
static const bool &getlogRotFilelog() { return m_log_rot_file_log; }
static const bool &getlogStdout() { return m_log_stdout; }
static void help();
private:
static int options;
enum OptionsSelected {
libconfigcfg = 0x01,
log_stdout = 0x02,
log_rot_file_log = 0x04
};
static void help();
static int options;
static bool m_log_rot_file_log;
static bool m_log_stdout;
static std::string m_libconfigcfg;
static bool m_log_rot_file_log;
static bool m_log_stdout;
static std::string m_libconfigcfg;
};
#endif // #define __OPTIONS_H
#endif // #define __OPTIONS_H
......@@ -22,6 +22,7 @@
include_directories(${SRC_TOP_DIR}/common)
include_directories(${SRC_TOP_DIR}/common/msg)
include_directories(${SRC_TOP_DIR}/common/utils)
include_directories(${SRC_TOP_DIR}/common/bstr)
include_directories(${SRC_TOP_DIR}/common/nas)
include_directories(${SRC_TOP_DIR}/itti)
include_directories(${SRC_TOP_DIR}/pfcp)
......
This diff is collapsed.
......@@ -199,8 +199,7 @@ class smf_app {
virtual ~smf_app() {
Logger::smf_app().debug("Delete SMF_APP instance...");
// TODO: disconnect connections
// Unregister NRF
// TODO: Unregister NRF
}
void operator=(smf_app const&) = delete;
......@@ -832,7 +831,6 @@ class smf_app {
* @return void
*/
void trigger_upf_status_notification_subscribe();
};
} // namespace smf
#include "smf_config.hpp"
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -33,17 +33,17 @@
#include "smf_subscription.hpp"
using namespace smf;
extern smf::smf_app *smf_app_inst;
extern itti_mw *itti_inst;
extern smf::smf_app* smf_app_inst;
extern itti_mw* itti_inst;
//------------------------------------------------------------------------------
bs2::connection smf_event::subscribe_sm_context_status(
const sm_context_status_sig_t::slot_type &sig) {
const sm_context_status_sig_t::slot_type& sig) {
return sm_context_status.connect(sig);
}
//------------------------------------------------------------------------------
bs2::connection smf_event::subscribe_ee_pdu_session_release(
const ee_pdu_session_release_sig_t::slot_type &sig) {
const ee_pdu_session_release_sig_t::slot_type& sig) {
return ee_pdu_session_release.connect(sig);
}
......@@ -40,10 +40,10 @@ namespace smf {
class smf_event {
public:
smf_event(){};
smf_event(smf_event const &) = delete;
void operator=(smf_event const &) = delete;
smf_event(smf_event const&) = delete;
void operator=(smf_event const&) = delete;
static smf_event &get_instance() {
static smf_event& get_instance() {
static smf_event instance;
return instance;
}
......@@ -61,7 +61,7 @@ class smf_event {
* the slot
*/
bs2::connection subscribe_sm_context_status(
const sm_context_status_sig_t::slot_type &sig);
const sm_context_status_sig_t::slot_type& sig);
/*
* Subscribe to Event Exposure Event: PDU Session Release
......@@ -71,7 +71,7 @@ class smf_event {
* the slot
*/
bs2::connection subscribe_ee_pdu_session_release(
const ee_pdu_session_release_sig_t::slot_type &sig);
const ee_pdu_session_release_sig_t::slot_type& sig);
private:
sm_context_status_sig_t
......
......@@ -39,14 +39,15 @@ namespace smf {
// Signal for PDU session status
// SCID, PDU Session Status, HTTP version
typedef bs2::signal_type<void(scid_t, uint8_t, uint8_t),
bs2::keywords::mutex_type<bs2::dummy_mutex>>::type
sm_context_status_sig_t;
typedef bs2::signal_type<
void(scid_t, uint8_t, uint8_t),
bs2::keywords::mutex_type<bs2::dummy_mutex>>::type sm_context_status_sig_t;
// Signal for Event exposure
// PDU session Release, SUPI, PDU SessionID, HTTP version
typedef bs2::signal_type<void(supi64_t, pdu_session_id_t, uint8_t),
bs2::keywords::mutex_type<bs2::dummy_mutex>>::type
typedef bs2::signal_type<
void(supi64_t, pdu_session_id_t, uint8_t),
bs2::keywords::mutex_type<bs2::dummy_mutex>>::type
ee_pdu_session_release_sig_t;
// TODO: ee_ue_ip_address_change_sig_t; //UI IP Address, UE ID
......
......@@ -340,6 +340,18 @@ std::string pdu_session_create_sm_context_request::get_sm_context_status_uri()
return m_sm_context_status_uri;
}
//-----------------------------------------------------------------------------
void pdu_session_create_sm_context_request::set_epco(
const protocol_configuration_options_t& p) {
m_epco = p;
}
//-----------------------------------------------------------------------------
void pdu_session_create_sm_context_request::get_epco(
protocol_configuration_options_t& p) const {
p = m_epco;
}
/*
* class: PDU Session Create SM Context Response
*/
......@@ -388,6 +400,18 @@ std::string pdu_session_create_sm_context_response::get_smf_context_uri()
return m_smf_context_uri;
}
//-----------------------------------------------------------------------------
void pdu_session_create_sm_context_response::set_epco(
const protocol_configuration_options_t& p) {
m_epco = p;
}
//-----------------------------------------------------------------------------
void pdu_session_create_sm_context_response::get_epco(
protocol_configuration_options_t& p) const {
p = m_epco;
}
/*
* class: PDU Session Update SM Context Request
*/
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -36,5 +36,5 @@
using namespace smf;
extern smf::smf_app *smf_app_inst;
extern itti_mw *itti_inst;
extern smf::smf_app* smf_app_inst;
extern itti_mw* itti_inst;
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