Commit 953a3b93 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

update header files/polish the code

parent ec8c6d21
# REST API Server for Nsmf_PDUSession
## Overview
This API Server was generated by the [OpenAPI Generator](https://openapi-generator.tech) project.
It uses the [Pistache](https://github.com/oktal/pistache) Framework.
## Files organization
The Pistache C++ REST server generator creates three folders:
- `api`: This folder contains the handlers for each method specified in the OpenAPI definition. Every handler extracts
the path and body parameters (if any) from the requests and tries to parse and possibly validate them.
Once this step is completed, the main API class calls the corresponding abstract method that should be implemented
by the developer (a basic implementation is provided under the `impl` folder)
- `impl`: As written above, the implementation folder contains, for each API, the corresponding implementation class,
which extends the main API class and implements the abstract methods.
Every method receives the path and body parameters as constant reference variables and a reference to the response
object, that should be filled with the right response and sent at the end of the method with the command:
response.send(returnCode, responseBody, [mimeType])
- `model`: This folder contains the corresponding class for every object schema found in the OpenAPI specification.
The main folder contains also a file with a main that can be used to start the server.
Of course, is you should customize this file based on your needs
## Installation
First of all, you need to download and install the libraries listed [here](#libraries-required).
Once the libraries are installed, in order to compile and run the server please follow the steps below:
```bash
mkdir build
cd build
cmake ..
make
```
Once compiled run the server:
```bash
cd build
./api-server
```
## Libraries required
- [pistache](http://pistache.io/quickstart)
- [JSON for Modern C++](https://github.com/nlohmann/json/#integration): Please download the `json.hpp` file and
put it under the model/nlohmann folder
## Namespaces
oai.smf.api
oai.smf.model
......@@ -495,6 +495,7 @@ typedef struct imsi_s imsi_t;
// 8.4 Cause
enum cause_value_e {
/* Request / Initial message */
UNKNOWN_ERROR = -1,
LOCAL_DETACH = 2,
COMPLETE_DETACH = 3,
RAT_CHANGE_3GPP_TO_NON_3GPP = 4, ///< RAT changed from 3GPP to Non-3GPP
......
......@@ -100,29 +100,31 @@ static const std::vector<std::string> pdu_session_application_error_e2str = {
"NETWORK_FAILURE"
};
enum n2_sm_info_type_e {
PDU_RES_SETUP_REQ = 1,
PDU_RES_SETUP_RSP = 2,
PDU_RES_SETUP_FAIL = 3,
PDU_RES_REL_CMD = 4,
PDU_RES_REL_RSP = 5,
PDU_RES_MOD_REQ = 6,
PDU_RES_MOD_RSP = 7,
PDU_RES_MOD_FAIL = 8,
PDU_RES_NTY = 9,
PDU_RES_NTY_REL = 10,
PDU_RES_MOD_IND = 11,
PDU_RES_MOD_CFM = 12,
PATH_SWITCH_REQ = 13,
PATH_SWITCH_SETUP_FAIL = 14,
PATH_SWITCH_REQ_ACK = 15,
PATH_SWITCH_REQ_FAIL = 16,
HANDOVER_REQUIRED = 17,
HANDOVER_CMD = 18,
HANDOVER_PREP_FAIL = 19,
HANDOVER_REQ_ACK = 20,
HANDOVER_RES_ALLOC_FAIL = 21,
SECONDARY_RAT_USAGE = 22
//6.1.6.3.12 Enumeration: N2SmInfoType @3GPP TS 29.502 V16.0.0
enum class n2_sm_info_type_e {
PDU_RES_SETUP_REQ = 1, //PDU Session Resource Setup Request Transfer
PDU_RES_SETUP_RSP = 2, //PDU Session Resource Setup Response Transfer
PDU_RES_SETUP_FAIL = 3, //PDU Session Resource Setup Unsuccessful Transfer
PDU_RES_REL_CMD = 4, //PDU Session Resource Release Command Transfer
PDU_RES_REL_RSP = 5, //PDU Session Resource Release Response Transfer
PDU_RES_MOD_REQ = 6, //PDU Session Resource Modify Request Transfer
PDU_RES_MOD_RSP = 7, //PDU Session Resource Modify Response Transfer
PDU_RES_MOD_FAIL = 8, //PDU Session Resource Modify Unsuccessful Transfer
PDU_RES_NTY = 9, //PDU Session Resource Notify Transfer
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_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_RES_ALLOC_FAIL = 21, //Handover Resource Allocation Unsuccessful Transfer
SECONDARY_RAT_USAGE = 22 //Secondary RAT Data Usage Report Transfer
};
static const std::vector<std::string> n2_sm_info_type_e2str = {
......@@ -151,5 +153,18 @@ static const std::vector<std::string> n2_sm_info_type_e2str = {
"SECONDARY_RAT_USAGE"
};
enum class upCnx_state_e {
UPCNX_STATE_ACTIVATED = 0,
UPCNX_STATE_DEACTIVATED = 1,
UPCNX_STATE_ACTIVATING =2
};
static const std::vector<std::string> upCnx_state_e2str = {
"UPCNX_STATE_ACTIVATED",
"UPCNX_STATE_DEACTIVATED",
"UPCNX_STATE_ACTIVATING"
};
#endif
......@@ -69,13 +69,15 @@ public:
class itti_n11_create_sm_context_response : public itti_n11_msg {
public:
itti_n11_create_sm_context_response(const task_id_t orig, const task_id_t dest, Pistache::Http::ResponseWriter& response):
itti_n11_msg(N11_SESSION_CREATE_SM_CONTEXT_RESPONSE, orig, dest), http_response(response.clone()) {}
itti_n11_create_sm_context_response(const itti_n11_create_sm_context_response& i) : itti_n11_msg(i), res(i.res), http_response(i.http_response.clone()) {}
itti_n11_msg(N11_SESSION_CREATE_SM_CONTEXT_RESPONSE, orig, dest), http_response(response.clone()), scid(0) {}
itti_n11_create_sm_context_response(const itti_n11_create_sm_context_response& i) : itti_n11_msg(i), res(i.res), http_response(i.http_response.clone()), scid(i.scid) {}
itti_n11_create_sm_context_response(const itti_n11_create_sm_context_response& i, const task_id_t orig, const task_id_t dest) :
itti_n11_msg(i, orig, dest), res(i.res), http_response(i.http_response.clone()) {}
itti_n11_msg(i, orig, dest), res(i.res), http_response(i.http_response.clone()), scid(i.scid) {}
const char* get_msg_name() {return "N11_SESSION_CREATE_SM_CONTEXT_RESPONSE";};
smf::pdu_session_create_sm_context_response res;
Pistache::Http::ResponseWriter http_response;
void set_scid(scid_t id) {scid = id;};
scid_t scid; //SM Context ID
};
......@@ -109,4 +111,56 @@ public:
};
//-----------------------------------------------------------------------------
class itti_n11_modify_session_request_smf_requested : public itti_n11_msg {
public:
itti_n11_modify_session_request_smf_requested(const task_id_t orig, const task_id_t dest):
itti_n11_msg(N11_SESSION_MODIFICATION_REQUEST_SMF_REQUESTED, orig, dest) {}
itti_n11_modify_session_request_smf_requested(const itti_n11_modify_session_request_smf_requested& i) : itti_n11_msg(i), req(i.req) {}
itti_n11_modify_session_request_smf_requested(const itti_n11_modify_session_request_smf_requested& i, const task_id_t orig, const task_id_t dest) :
itti_n11_msg(i, orig, dest), req(i.req) {}
const char* get_msg_name() {return "N11_SESSION_MODIFICATION_REQUEST_SMF_REQUESTED";};
smf::pdu_session_create_sm_context_request req;
};
//-----------------------------------------------------------------------------
class itti_n11_update_pdu_session_status : public itti_n11_msg {
public:
itti_n11_update_pdu_session_status(const task_id_t orig, const task_id_t dest):
itti_n11_msg(N11_SESSION_UPDATE_PDU_SESSION_STATUS, orig, dest), scid(0), pdu_session_status(pdu_session_status_e::PDU_SESSION_INACTIVE) {}
itti_n11_update_pdu_session_status(const itti_n11_update_pdu_session_status& i) : itti_n11_msg(i), scid(i.scid), pdu_session_status(i.pdu_session_status) {}
itti_n11_update_pdu_session_status(const itti_n11_update_pdu_session_status& i, const task_id_t orig, const task_id_t dest) :
itti_n11_msg(i, orig, dest), scid(i.scid), pdu_session_status(i.pdu_session_status){}
const char* get_msg_name() {return "N11_SESSION_UPDATE_PDU_SESSION_STATUS";};
void set_scid(scid_t id) {scid = id;};
scid_t scid; //SM Context ID
pdu_session_status_e pdu_session_status;
void set_pdu_session_status(pdu_session_status_e status) {pdu_session_status = status;};
};
//-----------------------------------------------------------------------------
class itti_n11_n1n2_message_transfer_response_status : public itti_n11_msg {
public:
itti_n11_n1n2_message_transfer_response_status(const task_id_t orig, const task_id_t dest):
itti_n11_msg(N11_SESSION_N1N2_MESSAGE_TRANSFER_RESPONSE_STATUS, orig, dest), scid(0), response_code(0), msg_type(0) {}
itti_n11_n1n2_message_transfer_response_status(const itti_n11_n1n2_message_transfer_response_status& i) : itti_n11_msg(i), scid(i.scid), response_code(i.response_code), msg_type(i.msg_type) {}
itti_n11_n1n2_message_transfer_response_status(const itti_n11_n1n2_message_transfer_response_status& i, const task_id_t orig, const task_id_t dest) :
itti_n11_msg(i, orig, dest), scid(i.scid), response_code(i.response_code), msg_type(i.msg_type){}
const char* get_msg_name() {return "N11_SESSION_N1N2_MESSAGE_TRANSFER_RESPONSE_STATUS";};
void set_scid(scid_t id) {scid = id;};
void set_response_code(int16_t code) {response_code = code;};
void set_cause(std::string c) {cause = c;};
void set_msg_type(uint8_t type) {msg_type = type;};
scid_t scid; //SM Context ID
int16_t response_code;
std::string cause;
uint8_t msg_type;
};
#endif /* ITTI_MSG_N11_HPP_INCLUDED_ */
......@@ -36,7 +36,7 @@
class itti_n4_restore : public itti_msg {
public:
itti_n4_restore(const task_id_t origin, const task_id_t destination):
itti_msg(RESTORE_SX_SESSIONS, origin, destination), sessions() {}
itti_msg(RESTORE_N4_SESSIONS, origin, destination), sessions() {}
itti_n4_restore(const itti_n4_restore& i) : itti_msg(i), sessions(i.sessions) {}
itti_n4_restore(const itti_n4_restore& i, const task_id_t orig, const task_id_t dest) : itti_n4_restore(i) {
origin = orig;
......
/*
* 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
*/
/*
* itti_msg_nx.hpp
*
* Created on:
* Author:
*/
#ifndef ITTI_MSG_NX_HPP_INCLUDED_
#define ITTI_MSG_NX_HPP_INCLUDED_
#include "itti_msg.hpp"
#include "smf_msg.hpp"
#include "pistache/http.h"
class itti_nx_msg : public itti_msg {
public:
itti_nx_msg(const itti_msg_type_t msg_type, const task_id_t orig, const task_id_t dest):
itti_msg(msg_type, orig, dest) {
}
itti_nx_msg(const itti_nx_msg& i) : itti_msg(i) {}
itti_nx_msg(const itti_nx_msg& i, const task_id_t orig, const task_id_t dest) :
itti_nx_msg(i)
{
origin = orig;
destination = dest;
}
};
//-----------------------------------------------------------------------------
class itti_nx_modify_pdu_session_request_network_requested : public itti_nx_msg {
public:
itti_nx_modify_pdu_session_request_network_requested(const task_id_t orig, const task_id_t dest):
itti_nx_msg(NX_SESSION_MODIFICATION_REQUEST_NETWORK_REQUESTED, orig, dest) {}
itti_nx_modify_pdu_session_request_network_requested(const itti_nx_modify_pdu_session_request_network_requested& i) : itti_nx_msg(i) {}
itti_nx_modify_pdu_session_request_network_requested(const itti_nx_modify_pdu_session_request_network_requested& i, const task_id_t orig, const task_id_t dest) :
itti_nx_msg(i, orig, dest){}
const char* get_msg_name() {return "NX_SESSION_MODIFICATION_REQUEST_NETWORK_REQUESTED";};
// smf::pdu_session_create_sm_context_request req;
};
#endif /* ITTI_MSG_NX_HPP_INCLUDED_ */
This diff is collapsed.
/*
* 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
*/
#ifndef FILE_3GPP_38_401_SEEN
#define FILE_3GPP_38_401_SEEN
......
......@@ -38,9 +38,9 @@ typedef uint32_t sctp_assoc_id_t;
#define INVALID_RAN_UE_NGAP_ID_KEY 0xFFFFFFFFFFFFFFFF
#define RAN_UE_NGAP_ID_MASK 0x00FFFFFF
#define RAN_UE_NGAP_ID_FMT "0x%06"PRIX32
#define GNB_UE_NGAP_ID_FMT "0x%06"PRIX32
#define AMF_UE_NGAP_ID_FMT "0x%08"PRIX32
#define RAN_UE_NGAP_ID_FMT "0x%06" PRIX32
#define GNB_UE_NGAP_ID_FMT "0x%06" PRIX32
#define AMF_UE_NGAP_ID_FMT "0x%08" PRIX32
#define INVALID_AMF_UE_NGAP_ID 0x0
#define AMF_UE_NGAP_ID_MASK_ 0x0000FFFFFFFFFF
......
/*
* 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
*/
#include <stdint.h>
#include "ngap_common.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
*/
#ifndef FILE_NGAP_COMMON_SEEN
#define FILE_NGAP_COMMON_SEEN
......
......@@ -107,5 +107,55 @@ typedef struct pdu_session_type_s {
const std::string& toString() const {return pdu_session_type_e2str.at(pdu_session_type);}
} pdu_session_type_t;
//SMF + AMF + 3GPP TS 29.571 (Common data)
enum class http_response_codes_e {
HTTP_RESPONSE_CODE_OK = 200,
HTTP_RESPONSE_CODE_ACCEPTED = 202,
HTTP_RESPONSE_CODE_BAD_REQUEST = 400,
HTTP_RESPONSE_CODE_UNAUTHORIZED = 401,
HTTP_RESPONSE_CODE_FORBIDDEN = 403,
HTTP_RESPONSE_CODE_NOT_FOUND = 404,
HTTP_RESPONSE_CODE_METHOD_NOT_ALLOWED = 405,
HTTP_RESPONSE_CODE_REQUEST_TIMEOUT = 408,
HTTP_RESPONSE_CODE_406_NOT_ACCEPTED = 406,
HTTP_RESPONSE_CODE_CONFLICT = 409,
HTTP_RESPONSE_CODE_GONE = 410,
HTTP_RESPONSE_CODE_LENGTH_REQUIRED = 411,
HTTP_RESPONSE_CODE_PRECONDITION_FAILED = 412,
HTTP_RESPONSE_CODE_PAYLOAD_TOO_LARGE = 413,
HTTP_RESPONSE_CODE_URI_TOO_LONG = 414,
HTTP_RESPONSE_CODE_UNSUPPORTED_MEDIA_TYPE = 415,
HTTP_RESPONSE_CODE_TOO_MANY_REQUESTS = 429,
HTTP_RESPONSE_CODE_INTERNAL_SERVER_ERROR = 500,
HTTP_RESPONSE_CODE_NOT_IMPLEMENTED = 501,
HTTP_RESPONSE_CODE_SERVICE_UNAVAILABLE = 503,
HTTP_RESPONSE_CODE_GATEWAY_TIMEOUT = 504
};
//From 23.502
enum class session_management_procedures_type_e {
PDU_SESSION_ESTABLISHMENT_UE_REQUESTED = 0,
PDU_SESSION_MODIFICATION_UE_INITIATED = 1,
PDU_SESSION_MODIFICATION_SMF_REQUESTED = 2,
PDU_SESSION_MODIFICATION_AN_REQUESTED = 3,
PDU_SESSION_RELEASE_UE_REQUESTED = 4,
PDU_SESSION_RELEASE_NETWORK_REQUESTED = 5,
SERVICE_REQUEST_UE_TRIGGERED = 6,
SERVICE_REQUEST_NETWORK_TRIGGERED = 7
};
static const std::vector<std::string> session_management_procedures_type_e2str = {
"PDU_SESSION_ESTABLISHMENT_UE_REQUESTED",
"PDU_SESSION_MODIFICATION_UE_INITIATED",
"PDU_SESSION_MODIFICATION_SMF_REQUESTED",
"PDU_SESSION_MODIFICATION_AN_REQUESTED",
"PDU_SESSION_RELEASE_UE_REQUESTED",
"PDU_SESSION_RELEASE_NETWORK_REQUESTED",
"SERVICE_REQUEST_UE_TRIGGERED",
"SERVICE_REQUEST_NETWORK_TRIGGERED"
};
#endif
......@@ -38,7 +38,6 @@ typedef enum {
TASK_GTPV2_C,
TASK_SMF_APP,
TASK_SMF_N4,
TASK_SPGWU_SX,
TASK_SMF_N10,
TASK_SMF_N11,
TASK_MAX,
......@@ -60,7 +59,7 @@ typedef enum {
ITTI_MSG_TYPE_NONE = -1,
ITTI_MSG_TYPE_FIRST = 0,
ASYNC_SHELL_CMD = ITTI_MSG_TYPE_FIRST,
RESTORE_SX_SESSIONS,
RESTORE_N4_SESSIONS,
S11_REMOTE_PEER_NOT_RESPONDING,
S11_CREATE_SESSION_REQUEST,
S11_CREATE_SESSION_RESPONSE,
......@@ -112,6 +111,10 @@ typedef enum {
N11_SESSION_CREATE_SM_CONTEXT_RESPONSE,
N11_SESSION_UPDATE_SM_CONTEXT_REQUEST,
N11_SESSION_UPDATE_SM_CONTEXT_RESPONSE,
N11_SESSION_MODIFICATION_REQUEST_SMF_REQUESTED,
N11_SESSION_UPDATE_PDU_SESSION_STATUS,
N11_SESSION_N1N2_MESSAGE_TRANSFER_RESPONSE_STATUS,
NX_SESSION_MODIFICATION_REQUEST_NETWORK_REQUESTED,
UDP_INIT,
UDP_DATA_REQ,
UDP_DATA_IND,
......
This source diff could not be displayed because it is too large. You can view the blob instead.
#ifndef _NAS_SM_ENCODE_TO_JSON_H_
#define _NAS_SM_ENCODE_TO_JSON_H_
int sm_encode_establishment_request(void);
int sm_encode_establishment_accept(void);
int sm_encode_establishment_reject(void);
int sm_encode_authentication_command(void);
int sm_encode_authentication_complete(void);
int sm_encode_authentication_result(void);
int sm_encode_modification_request(void);
int sm_encode_modification_reject(void);
int sm_encode_modification_command(void);
int sm_encode_modification_complete(void);
int sm_encode_modification_command_reject(void);
int sm_encode_release_request(void);
int sm_encode_release_reject(void);
int sm_encode_release_command(void);
int sm_encode_release_complete(void);
int sm_encode__5gsm_status_(void);
int sm_encode_all(void);
#endif
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