Commit 89d1be31 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen
Browse files

polish the code

parent 3a113978
/**
* Nsmf_PDUSession
* SMF PDU Session Service. © 2019, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
*
* The version of the OpenAPI document: 1.1.0.alpha-1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
* Nsmf_PDUSession
* SMF PDU Session Service. © 2019, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
*
* The version of the OpenAPI document: 1.1.0.alpha-1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
#include "SMContextsCollectionApiImpl.h"
#include "logger.hpp"
......@@ -17,8 +17,6 @@
extern "C" {
#include "nas_message.h"
#include "mmData.h"
//#include "common_types.h"
//#include "common_defs.h"
}
namespace oai {
......@@ -28,15 +26,18 @@ namespace api {
using namespace oai::smf::model;
SMContextsCollectionApiImpl::SMContextsCollectionApiImpl(std::shared_ptr<Pistache::Rest::Router> rtr, pgwc::pgw_app *smf_app_inst)
: SMContextsCollectionApi(rtr), m_smf_app(smf_app_inst)
: SMContextsCollectionApi(rtr), m_smf_app(smf_app_inst)
{ }
{ }
void SMContextsCollectionApiImpl::post_sm_contexts(const SmContextMessage &smContextMessage, Pistache::Http::ResponseWriter &response) {
Logger::smf_api_server().info("post_sm_contexts...");
//decode NAS message and assign the necessary informations to pgwc::pdu_session_create_sm_context_request and pass to SMF to handle this message
//decode NAS message and assign the necessary informations to pgwc::pdu_session_create_sm_context_request
//and pass this message to SMF to handle this message
//step 1. Decode NAS message (for instance, ... only served as an example)
nas_message_decode_status_t decode_status = {0};
nas_message_t decoded_nas_msg;
memset (&decoded_nas_msg, 0, sizeof (nas_message_t));
......@@ -46,11 +47,11 @@ void SMContextsCollectionApiImpl::post_sm_contexts(const SmContextMessage &smCon
SmContextCreateData smContextCreateData = smContextMessage.getJsonData();
std::string n1SmMessage = smContextMessage.getBinaryDataN1SmMessage();
//Decode and process nas message
//Decode and process nas message
//bsafe (disable temporarily warning for strncpy)
//std::strncpy((char *)data, n1SmMessage.c_str(), sizeof(data));
memcpy ((void *)data, (void *)n1SmMessage.c_str(),sizeof(data));
memcpy ((void *)data, (void *)n1SmMessage.c_str(),sizeof(data));
//use a temporary security mechanism
fivegmm_security_context_t * security = ( fivegmm_security_context_t *) std::calloc(1,sizeof(fivegmm_security_context_t));
......@@ -61,7 +62,7 @@ void SMContextsCollectionApiImpl::post_sm_contexts(const SmContextMessage &smCon
security->selected_algorithms.integrity = NAS_SECURITY_ALGORITHMS_NIA1;
security->knas_int[0] = 0x41;
//decode message
//decode the NAS message (using NAS lib)
decoder_rc = nas_message_decode (data, &decoded_nas_msg, sizeof(data), security, &decode_status);
Logger::smf_api_server().debug("nas header decode extended_protocol_discriminator %d, security_header_type:%d,sequence_number:%d,message_authentication_code:%d\n",
......@@ -70,15 +71,15 @@ void SMContextsCollectionApiImpl::post_sm_contexts(const SmContextMessage &smCon
decoded_nas_msg.header.sequence_number,
decoded_nas_msg.header.message_authentication_code);
//Get the value from AMF
//Step 2. Create a pdu_session_create_sm_context_request message and store the necessary information
pgwc::pdu_session_create_sm_context_request *sm_context_req = new pgwc::pdu_session_create_sm_context_request();
std::shared_ptr<pgwc::pdu_session_create_sm_context_request> sm_context_req_msg = std::shared_ptr<pgwc::pdu_session_create_sm_context_request>(sm_context_req);
//supi
//supi
supi_t supi = {.length = 0};
smf_string_to_supi(&supi, smContextCreateData.getSupi().c_str());
sm_context_req_msg->set_supi(supi);
//dnn
//dnn
sm_context_req_msg->set_dnn(smContextCreateData.getDnn());
//S-Nssai
snssai_t snssai(smContextCreateData.getSNssai().getSst(), smContextCreateData.getSNssai().getSd());
......@@ -89,7 +90,7 @@ void SMContextsCollectionApiImpl::post_sm_contexts(const SmContextMessage &smCon
sm_context_req_msg->set_serving_nf_id(smContextCreateData.getServingNfId()); //TODO: should be verified that AMF ID is stored in GUAMI or ServingNfId
//Request Type
sm_context_req_msg->set_request_type(smContextCreateData.getRequestType());
//PCF ID
//PCF ID
// Priority Access
//User Location Information
//Access Type
......@@ -101,12 +102,15 @@ void SMContextsCollectionApiImpl::post_sm_contexts(const SmContextMessage &smCon
//Subscription for PDU Session Status Notification
// Trace requirement
//From N1 Container (NAS)
//Extended protocol discriminator (Mandatory)
//Extended protocol discriminator (Mandatory)
sm_context_req_msg->set_epd(decoded_nas_msg.header.extended_protocol_discriminator);
//PDU session ID (Mandatory)
//TODO:
//PTI (Mandatory)
//TODO:
//Message type (Mandatory) (PDU SESSION ESTABLISHMENT REQUEST message identity)
sm_context_req_msg->set_message_type(decoded_nas_msg.plain.sm.pdu_session_establishment_request.messagetype);
//Integrity protection maximum data rate (Mandatory)
//PDU session type (Optional)
//SSC mode (Optional)
......@@ -117,20 +121,9 @@ void SMContextsCollectionApiImpl::post_sm_contexts(const SmContextMessage &smCon
//SM PDU DN request container (Optional)
//Extended protocol configuration options (Optional) e.g, FOR DHCP
sm_context_req_msg->set_dnn_selection_mode(smContextCreateData.getSelMode());
//handle the message from pwg_app
m_smf_app->handle_amf_msg(sm_context_req_msg, response);
/*
//move the response part to pgw_app
//step 3. send reply to AMF
nlohmann::json jsonData;
to_json(jsonData, smContextCreatedData);
std::string resBody = jsonData.dump();
response.headers().add<Pistache::Http::Header::Location>(url);
response.send(Pistache::Http::Code::Ok, resBody);
*/
//Step 3. Handle the pdu_session_create_sm_context_request message in pwg_app
m_smf_app->handle_amf_msg(sm_context_req_msg, response);
}
}
......
......@@ -25,10 +25,16 @@
typedef enum extended_protocol_discriminator_e {
/* Protocol discriminator identifier for 5G Session Management */
FIVEGS_SESSION_MANAGEMENT_MESSAGES = 0x2e,
EPD_5GS_SESSION_MANAGEMENT_MESSAGES = 0x2e,
/* Protocol discriminator identifier for 5G Mobility Management */
FIVEGS_MOBILITY_MANAGEMENT_MESSAGES = 0x7e,
EPD_5GS_MOBILITY_MANAGEMENT_MESSAGES = 0x7e,
} extended_protocol_discriminator_t;
// Integrity protection maximum data rate
typedef struct ipmdr_s {
uint8_t ul;
uint8_t dl;
} ipmdr_t;
#endif
#ifndef FILE_3GPP_24_501_H_SEEN
#define FILE_3GPP_24_501_H_SEEN
//#include <stdint.h>
//#include <stdbool.h>
// 9.3.1 Security header type
#define SECURITY_HEADER_TYPE_NOT_PROTECTED 0b0000
#define SECURITY_HEADER_TYPE_INTEGRITY_PROTECTED 0b0001
......@@ -613,6 +610,23 @@
//0b11******
//5GS Session Management Messages
typedef enum pdu_session_message_e {
PDU_SESSION_ESTABLISHMENT_REQUEST = 193,
PDU_SESSION_ESTABLISHMENT_ACCEPT = 194,
PDU_SESSION_ESTABLISHMENT_REJECT = 195,
PDU_SESSION_AUTHENTICATION_COMMAND = 197,
PDU_SESSION_AUTHENTICATION_COMPLETE = 198,
PDU_SESSION_AUTHENTICATION_RESULT = 199,
PDU_SESSION_MODIFICATION_REQUEST = 201,
PDU_SESSION_MODIFICATION_REJECT = 202,
PDU_SESSION_MODIFICATION_COMMAND = 203,
PDU_SESSION_MODIFICATION_COMPLETE = 204,
PDU_SESSION_MODIFICATION_COMMAND_REJECT = 205,
PDU_SESSION_RELEASE_REQUEST = 209,
PDU_SESSION_RELEASE_REJECT = 210,
PDU_SESSION_RELEASE_COMMAND = 211,
PDU_SESSION_RELEASE_COMPLETE = 212
};
#define PDUSessionEstablishmentRequest 0b11000001
#define PDUSessionEstablishmentAccept 0b11000010
......
This diff is collapsed.
#ifndef FILE_MM_DATA_H_SEEN
#define FILE_MM_DATA_H_SEEN
//#include "bstrlib.h"
#include "common_types.h"
#include "securityDef.h"
......@@ -44,4 +43,5 @@ typedef struct fivegmm_security_context_s {
uint8_t activated;
} fivegmm_security_context_t;
#endif
......@@ -156,7 +156,7 @@ _fivegmm_msg_encode_header (
/*
* Check the protocol discriminator
*/
if (header->extended_protocol_discriminator != FIVEGS_MOBILITY_MANAGEMENT_MESSAGES) {
if (header->extended_protocol_discriminator != EPD_5GS_MOBILITY_MANAGEMENT_MESSAGES) {
//OAILOG_ERROR (LOG_NAS_EMM, "ESM-MSG - Unexpected protocol discriminator: 0x%x\n", header->extended_protocol_discriminator);
return (TLV_PROTOCOL_NOT_SUPPORTED);
}
......@@ -290,7 +290,7 @@ _fivegmm_msg_decode_header (
/*
* Check the protocol discriminator
*/
if (header->extended_protocol_discriminator != FIVEGS_MOBILITY_MANAGEMENT_MESSAGES) {
if (header->extended_protocol_discriminator != EPD_5GS_MOBILITY_MANAGEMENT_MESSAGES) {
//OAILOG_ERROR (LOG_NAS_EMM, "ESM-MSG - Unexpected protocol discriminator: 0x%x\n", header->protocol_discriminator);
return (TLV_PROTOCOL_NOT_SUPPORTED);
}
......
......@@ -348,8 +348,8 @@ static int _nas_message_header_encode (
//printf("encoded nas security header type: %x\n",buffer[size-1]);
//printf("encoded nas security header type: %x\n",header->security_header_type);
if (header->extended_protocol_discriminator == FIVEGS_MOBILITY_MANAGEMENT_MESSAGES) {
//printf("header->extended_protocol_discriminator == FIVEGS_MOBILITY_MANAGEMENT_MESSAGES\n");
if (header->extended_protocol_discriminator == EPD_5GS_MOBILITY_MANAGEMENT_MESSAGES) {
//printf("header->extended_protocol_discriminator == EPD_5GS_MOBILITY_MANAGEMENT_MESSAGES\n");
//printf("%x\n",header->security_header_type);
if (header->security_header_type != SECURITY_HEADER_TYPE_NOT_PROTECTED) {
//printf("header->security_header_type != SECURITY_HEADER_TYPE_NOT_PROTECTED\n");
......@@ -467,7 +467,7 @@ static int _nas_message_plain_encode (
//OAILOG_FUNC_IN (LOG_NAS);
int bytes = TLV_PROTOCOL_NOT_SUPPORTED;
if (header->extended_protocol_discriminator == FIVEGS_MOBILITY_MANAGEMENT_MESSAGES) {
if (header->extended_protocol_discriminator == EPD_5GS_MOBILITY_MANAGEMENT_MESSAGES) {
/*
* Encode EPS Mobility Management L3 message
*/
......@@ -475,7 +475,7 @@ static int _nas_message_plain_encode (
bytes = fivegmm_msg_encode ((MM_msg *) (&msg->mm), (uint8_t *) buffer, length);
//printf("fivegmm_msg_encode bytes:%d\n", bytes);
//printf("Encode EPS Mobility Management L3 message 1.2.1.1.2\n");
} else if (header->extended_protocol_discriminator == FIVEGS_SESSION_MANAGEMENT_MESSAGES) {
} else if (header->extended_protocol_discriminator == EPD_5GS_SESSION_MANAGEMENT_MESSAGES) {
/*
* Encode EPS Session Management L3 message
*/
......@@ -754,7 +754,7 @@ static int _nas_message_header_decode (
DECODE_U8 (buffer + size, header->security_header_type , size);
//OAILOG_DEBUG(LOG_NAS,"security header type(%x)\n",header->security_header_type&0x0f);
*is_sr = false;
if (header->extended_protocol_discriminator == FIVEGS_MOBILITY_MANAGEMENT_MESSAGES) {
if (header->extended_protocol_discriminator == EPD_5GS_MOBILITY_MANAGEMENT_MESSAGES) {
if (header->security_header_type != SECURITY_HEADER_TYPE_NOT_PROTECTED) {
if (status) {
switch (header->security_header_type) {
......@@ -1005,14 +1005,14 @@ static int _nas_message_plain_decode (
//OAILOG_FUNC_IN (LOG_NAS);
int bytes = TLV_PROTOCOL_NOT_SUPPORTED;
//printf("_nas_message_plain_decode extended_protocol_discriminator:%0x\n", header->extended_protocol_discriminator);
if (header->extended_protocol_discriminator == FIVEGS_MOBILITY_MANAGEMENT_MESSAGES) {
if (header->extended_protocol_discriminator == EPD_5GS_MOBILITY_MANAGEMENT_MESSAGES) {
/*
* Decode 5G Mobility Management L3 message
*/
//printf("calling mm_msg_decode\n");
bytes = mm_msg_decode (&msg->mm, (uint8_t *) buffer, length);
//printf("mm_msg_decode bytes:%d\n", bytes);
} else if (header->extended_protocol_discriminator == FIVEGS_SESSION_MANAGEMENT_MESSAGES) {
} else if (header->extended_protocol_discriminator == EPD_5GS_SESSION_MANAGEMENT_MESSAGES) {
/*
* Decode 5G Session Management L3 message
*/
......
......@@ -20,7 +20,7 @@ int auth_request()
nas_message_t nas_msg;
memset (&nas_msg, 0, sizeof (nas_message_t));
nas_msg.header.extended_protocol_discriminator = FIVEGS_MOBILITY_MANAGEMENT_MESSAGES;
nas_msg.header.extended_protocol_discriminator = EPD_5GS_MOBILITY_MANAGEMENT_MESSAGES;
nas_msg.header.security_header_type = SECURITY_HEADER_TYPE_INTEGRITY_PROTECTED_CYPHERED;
uint8_t sequencenumber = 0xfe;
//uint32_t mac = 0xffffeeee;
......@@ -31,7 +31,7 @@ int auth_request()
nas_msg.security_protected.header = nas_msg.header;
MM_msg * mm_msg = &nas_msg.plain.mm;
mm_msg->header.extended_protocol_discriminator = FIVEGS_MOBILITY_MANAGEMENT_MESSAGES;
mm_msg->header.extended_protocol_discriminator = EPD_5GS_MOBILITY_MANAGEMENT_MESSAGES;
mm_msg->header.security_header_type = SECURITY_HEADER_TYPE_INTEGRITY_PROTECTED_CYPHERED;
mm_msg->header.message_type = AUTHENTICATION_REQUEST;
......@@ -167,7 +167,7 @@ int auth_response()
nas_message_t nas_msg;
memset (&nas_msg, 0, sizeof (nas_message_t));
nas_msg.header.extended_protocol_discriminator = FIVEGS_MOBILITY_MANAGEMENT_MESSAGES;
nas_msg.header.extended_protocol_discriminator = EPD_5GS_MOBILITY_MANAGEMENT_MESSAGES;
nas_msg.header.security_header_type = SECURITY_HEADER_TYPE_INTEGRITY_PROTECTED_CYPHERED;
uint8_t sequencenumber = 0xfe;
//uint32_t mac = 0xffffeeee;
......@@ -178,7 +178,7 @@ int auth_response()
nas_msg.security_protected.header = nas_msg.header;
MM_msg * mm_msg = &nas_msg.plain.mm;
mm_msg->header.extended_protocol_discriminator = FIVEGS_MOBILITY_MANAGEMENT_MESSAGES;
mm_msg->header.extended_protocol_discriminator = EPD_5GS_MOBILITY_MANAGEMENT_MESSAGES;
mm_msg->header.security_header_type = SECURITY_HEADER_TYPE_INTEGRITY_PROTECTED_CYPHERED;
mm_msg->header.message_type = AUTHENTICATION_RESPONSE;
......@@ -308,7 +308,7 @@ int auth_failure()
nas_message_t nas_msg;
memset (&nas_msg, 0, sizeof (nas_message_t));
nas_msg.header.extended_protocol_discriminator = FIVEGS_MOBILITY_MANAGEMENT_MESSAGES;
nas_msg.header.extended_protocol_discriminator = EPD_5GS_MOBILITY_MANAGEMENT_MESSAGES;
nas_msg.header.security_header_type = SECURITY_HEADER_TYPE_INTEGRITY_PROTECTED_CYPHERED;
uint8_t sequencenumber = 0xfe;
//uint32_t mac = 0xffffeeee;
......@@ -319,7 +319,7 @@ int auth_failure()
nas_msg.security_protected.header = nas_msg.header;
MM_msg * mm_msg = &nas_msg.plain.mm;
mm_msg->header.extended_protocol_discriminator = FIVEGS_MOBILITY_MANAGEMENT_MESSAGES;
mm_msg->header.extended_protocol_discriminator = EPD_5GS_MOBILITY_MANAGEMENT_MESSAGES;
mm_msg->header.security_header_type = SECURITY_HEADER_TYPE_INTEGRITY_PROTECTED_CYPHERED;
mm_msg->header.message_type = AUTHENTICATION_FAILURE;
......@@ -447,7 +447,7 @@ int auth_reject()
nas_message_t nas_msg;
memset (&nas_msg, 0, sizeof (nas_message_t));
nas_msg.header.extended_protocol_discriminator = FIVEGS_MOBILITY_MANAGEMENT_MESSAGES;
nas_msg.header.extended_protocol_discriminator = EPD_5GS_MOBILITY_MANAGEMENT_MESSAGES;
nas_msg.header.security_header_type = SECURITY_HEADER_TYPE_INTEGRITY_PROTECTED_CYPHERED;
uint8_t sequencenumber = 0xfe;
//uint32_t mac = 0xffffeeee;
......@@ -458,7 +458,7 @@ int auth_reject()
nas_msg.security_protected.header = nas_msg.header;
MM_msg * mm_msg = &nas_msg.plain.mm;
mm_msg->header.extended_protocol_discriminator = FIVEGS_MOBILITY_MANAGEMENT_MESSAGES;
mm_msg->header.extended_protocol_discriminator = EPD_5GS_MOBILITY_MANAGEMENT_MESSAGES;
mm_msg->header.security_header_type = SECURITY_HEADER_TYPE_INTEGRITY_PROTECTED_CYPHERED;
mm_msg->header.message_type = AUTHENTICATION_REJECT;
......@@ -583,7 +583,7 @@ int auth_result()
nas_message_t nas_msg;
memset (&nas_msg, 0, sizeof (nas_message_t));
nas_msg.header.extended_protocol_discriminator = FIVEGS_MOBILITY_MANAGEMENT_MESSAGES;
nas_msg.header.extended_protocol_discriminator = EPD_5GS_MOBILITY_MANAGEMENT_MESSAGES;
nas_msg.header.security_header_type = SECURITY_HEADER_TYPE_INTEGRITY_PROTECTED_CYPHERED;
uint8_t sequencenumber = 0xfe;
//uint32_t mac = 0xffffeeee;
......@@ -594,7 +594,7 @@ int auth_result()
nas_msg.security_protected.header = nas_msg.header;
MM_msg * mm_msg = &nas_msg.plain.mm;
mm_msg->header.extended_protocol_discriminator = FIVEGS_MOBILITY_MANAGEMENT_MESSAGES;
mm_msg->header.extended_protocol_discriminator = EPD_5GS_MOBILITY_MANAGEMENT_MESSAGES;
mm_msg->header.security_header_type = SECURITY_HEADER_TYPE_INTEGRITY_PROTECTED_CYPHERED;
mm_msg->header.message_type = AUTHENTICATION_RESULT;
......@@ -730,7 +730,7 @@ int reg_request()
nas_message_t nas_msg;
memset (&nas_msg, 0, sizeof (nas_message_t));
nas_msg.header.extended_protocol_discriminator = FIVEGS_MOBILITY_MANAGEMENT_MESSAGES;
nas_msg.header.extended_protocol_discriminator = EPD_5GS_MOBILITY_MANAGEMENT_MESSAGES;
nas_msg.header.security_header_type = SECURITY_HEADER_TYPE_INTEGRITY_PROTECTED_CYPHERED;
uint8_t sequencenumber = 0xfe;
//uint32_t mac = 0xffffeeee;
......@@ -741,7 +741,7 @@ int reg_request()
nas_msg.security_protected.header = nas_msg.header;
MM_msg * mm_msg = &nas_msg.plain.mm;
mm_msg->header.extended_protocol_discriminator = FIVEGS_MOBILITY_MANAGEMENT_MESSAGES;
mm_msg->header.extended_protocol_discriminator = EPD_5GS_MOBILITY_MANAGEMENT_MESSAGES;
mm_msg->header.security_header_type = SECURITY_HEADER_TYPE_INTEGRITY_PROTECTED_CYPHERED;
mm_msg->header.message_type = REGISTRATION_REQUEST;
......@@ -1062,7 +1062,7 @@ int reg_accept()
nas_message_t nas_msg;
memset (&nas_msg, 0, sizeof (nas_message_t));
nas_msg.header.extended_protocol_discriminator = FIVEGS_MOBILITY_MANAGEMENT_MESSAGES;
nas_msg.header.extended_protocol_discriminator = EPD_5GS_MOBILITY_MANAGEMENT_MESSAGES;
nas_msg.header.security_header_type = SECURITY_HEADER_TYPE_INTEGRITY_PROTECTED_CYPHERED;
uint8_t sequencenumber = 0xfe;
//uint32_t mac = 0xffffeeee;
......@@ -1073,7 +1073,7 @@ int reg_accept()
nas_msg.security_protected.header = nas_msg.header;
MM_msg * mm_msg = &nas_msg.plain.mm;
mm_msg->header.extended_protocol_discriminator = FIVEGS_MOBILITY_MANAGEMENT_MESSAGES;
mm_msg->header.extended_protocol_discriminator = EPD_5GS_MOBILITY_MANAGEMENT_MESSAGES;
mm_msg->header.security_header_type = SECURITY_HEADER_TYPE_INTEGRITY_PROTECTED_CYPHERED;
mm_msg->header.message_type = REGISTRATION_ACCEPT;
......@@ -1457,7 +1457,7 @@ int reg_accept()
}
//########## ********************* 编码长度问题导致listsize 不正确,详细请看代码;
//########## ********************* ���볤�����⵼��listsize ����ȷ,��ϸ�뿴����;
#if 0
int decode__5gs_tracking_area_identity_list ( _5GSTrackingAreaIdentityList * _5gstrackingareaidentitylist, uint8_t iei, uint8_t * buffer, uint32_t len )
{
......@@ -1590,7 +1590,7 @@ int reg_complete()
nas_message_t nas_msg;
memset (&nas_msg, 0, sizeof (nas_message_t));
nas_msg.header.extended_protocol_discriminator = FIVEGS_MOBILITY_MANAGEMENT_MESSAGES;
nas_msg.header.extended_protocol_discriminator = EPD_5GS_MOBILITY_MANAGEMENT_MESSAGES;
nas_msg.header.security_header_type = SECURITY_HEADER_TYPE_INTEGRITY_PROTECTED_CYPHERED;
uint8_t sequencenumber = 0xfe;
//uint32_t mac = 0xffffeeee;
......@@ -1601,7 +1601,7 @@ int reg_complete()
nas_msg.security_protected.header = nas_msg.header;
MM_msg * mm_msg = &nas_msg.plain.mm;
mm_msg->header.extended_protocol_discriminator = FIVEGS_MOBILITY_MANAGEMENT_MESSAGES;
mm_msg->header.extended_protocol_discriminator = EPD_5GS_MOBILITY_MANAGEMENT_MESSAGES;
mm_msg->header.security_header_type = SECURITY_HEADER_TYPE_INTEGRITY_PROTECTED_CYPHERED;
mm_msg->header.message_type = REGISTRATION_COMPLETE;
......@@ -1712,7 +1712,7 @@ int reg_reject()
nas_message_t nas_msg;
memset (&nas_msg, 0, sizeof (nas_message_t));
nas_msg.header.extended_protocol_discriminator = FIVEGS_MOBILITY_MANAGEMENT_MESSAGES;
nas_msg.header.extended_protocol_discriminator = EPD_5GS_MOBILITY_MANAGEMENT_MESSAGES;
nas_msg.header.security_header_type = SECURITY_HEADER_TYPE_INTEGRITY_PROTECTED_CYPHERED;
uint8_t sequencenumber = 0xfe;
//uint32_t mac = 0xffffeeee;
......@@ -1723,7 +1723,7 @@ int reg_reject()
nas_msg.security_protected.header = nas_msg.header;
MM_msg * mm_msg = &nas_msg.plain.mm;
mm_msg->header.extended_protocol_discriminator = FIVEGS_MOBILITY_MANAGEMENT_MESSAGES;
mm_msg->header.extended_protocol_discriminator = EPD_5GS_MOBILITY_MANAGEMENT_MESSAGES;
mm_msg->header.security_header_type = SECURITY_HEADER_TYPE_INTEGRITY_PROTECTED_CYPHERED;
mm_msg->header.message_type = REGISTRATION_REJECT;
......@@ -1848,7 +1848,7 @@ int identity_request()
nas_message_t nas_msg;
memset (&nas_msg, 0, sizeof (nas_message_t));
nas_msg.header.extended_protocol_discriminator = FIVEGS_MOBILITY_MANAGEMENT_MESSAGES;
nas_msg.header.extended_protocol_discriminator = EPD_5GS_MOBILITY_MANAGEMENT_MESSAGES;
nas_msg.header.security_header_type = SECURITY_HEADER_TYPE_INTEGRITY_PROTECTED_CYPHERED;
uint8_t sequencenumber = 0xfe;
//uint32_t mac = 0xffffeeee;
......@@ -1859,7 +1859,7 @@ int identity_request()
nas_msg.security_protected.header = nas_msg.header;
MM_msg * mm_msg = &nas_msg.plain.mm;
mm_msg->header.extended_protocol_discriminator = FIVEGS_MOBILITY_MANAGEMENT_MESSAGES;
mm_msg->header.extended_protocol_discriminator = EPD_5GS_MOBILITY_MANAGEMENT_MESSAGES;
mm_msg->header.security_header_type = SECURITY_HEADER_TYPE_INTEGRITY_PROTECTED_CYPHERED;
mm_msg->header.message_type = IDENTITY_REQUEST;
......@@ -1968,7 +1968,7 @@ int identity_response()
nas_message_t nas_msg;
memset (&nas_msg, 0, sizeof (nas_message_t));
nas_msg.header.extended_protocol_discriminator = FIVEGS_MOBILITY_MANAGEMENT_MESSAGES;
nas_msg.header.extended_protocol_discriminator = EPD_5GS_MOBILITY_MANAGEMENT_MESSAGES;
nas_msg.header.security_header_type = SECURITY_HEADER_TYPE_INTEGRITY_PROTECTED_CYPHERED;
uint8_t sequencenumber = 0xfe;
//uint32_t mac = 0xffffeeee;
......@@ -1979,7 +1979,7 @@ int identity_response()
nas_msg.security_protected.header = nas_msg.header;
MM_msg * mm_msg = &nas_msg.plain.mm;
mm_msg->header.extended_protocol_discriminator = FIVEGS_MOBILITY_MANAGEMENT_MESSAGES;
mm_msg->header.extended_protocol_discriminator = EPD_5GS_MOBILITY_MANAGEMENT_MESSAGES;
mm_msg->header.security_header_type = SECURITY_HEADER_TYPE_INTEGRITY_PROTECTED_CYPHERED;
mm_msg->header.message_type = IDENTITY_RESPONSE;
......@@ -2149,7 +2149,7 @@ int security_mode_command()
nas_message_t nas_msg;
memset (&nas_msg, 0, sizeof (nas_message_t));
nas_msg.header.extended_protocol_discriminator = FIVEGS_MOBILITY_MANAGEMENT_MESSAGES;
nas_msg.header.extended_protocol_discriminator = EPD_5GS_MOBILITY_MANAGEMENT_MESSAGES;
nas_msg.header.security_header_type = SECURITY_HEADER_TYPE_INTEGRITY_PROTECTED_CYPHERED;
uint8_t sequencenumber = 0xfe;
//uint32_t mac = 0xffffeeee;
......@@ -2160,7 +2160,7 @@ int security_mode_command()
nas_msg.security_protected.header = nas_msg.header;
MM_msg * mm_msg = &nas_msg.plain.mm;
mm_msg->header.extended_protocol_discriminator = FIVEGS_MOBILITY_MANAGEMENT_MESSAGES;
mm_msg->header.extended_protocol_discriminator = EPD_5GS_MOBILITY_MANAGEMENT_MESSAGES;
mm_msg->header.security_header_type = SECURITY_HEADER_TYPE_INTEGRITY_PROTECTED_CYPHERED;
mm_msg->header.message_type = SECURITY_MODE_COMMAND;
......@@ -2344,7 +2344,7 @@ int security_mode_complete()
nas_message_t nas_msg;
memset (&nas_msg, 0, sizeof (nas_message_t));
nas_msg.header.extended_protocol_discriminator = FIVEGS_MOBILITY_MANAGEMENT_MESSAGES;
nas_msg.header.extended_protocol_discriminator = EPD_5GS_MOBILITY_MANAGEMENT_MESSAGES;
nas_msg.header.security_header_type = SECURITY_HEADER_TYPE_INTEGRITY_PROTECTED_CYPHERED;
uint8_t sequencenumber = 0xfe;
//uint32_t mac = 0xffffeeee;
......@@ -2355,7 +2355,7 @@ int security_mode_complete()
nas_msg.security_protected.header = nas_msg.header;
MM_msg * mm_msg = &nas_msg.plain.mm;
mm_msg->header.extended_protocol_discriminator = FIVEGS_MOBILITY_MANAGEMENT_MESSAGES;
mm_msg->header.extended_protocol_discriminator = EPD_5GS_MOBILITY_MANAGEMENT_MESSAGES;
mm_msg->header.security_header_type = SECURITY_HEADER_TYPE_INTEGRITY_PROTECTED_CYPHERED;
mm_msg->header.message_type = SECURITY_MODE_COMPLETE;
......@@ -2476,7 +2476,7 @@ int security_mode_reject()
nas_message_t nas_msg;
memset (&nas_msg, 0, sizeof (nas_message_t));
nas_msg.header.extended_protocol_discriminator = FIVEGS_MOBILITY_MANAGEMENT_MESSAGES;
nas_msg.header.extended_protocol_discriminator = EPD_5GS_MOBILITY_MANAGEMENT_MESSAGES;
nas_msg.header.security_header_type = SECURITY_HEADER_TYPE_INTEGRITY_PROTECTED_CYPHERED;
uint8_t sequencenumber = 0xfe;
//uint32_t mac = 0xffffeeee;
......@@ -2487,7 +2487,7 @@ int security_mode_reject()
nas_msg.security_protected.header = nas_msg.header;
MM_msg * mm_msg = &nas_msg.plain.mm;
mm_msg->header.extended_protocol_discriminator = FIVEGS_MOBILITY_MANAGEMENT_MESSAGES;
mm_msg->header.extended_protocol_discriminator = EPD_5GS_MOBILITY_MANAGEMENT_MESSAGES;
mm_msg->header.security_header_type = SECURITY_HEADER_TYPE_INTEGRITY_PROTECTED_CYPHERED;
mm_msg->header.message_type = SECURITY_MODE_REJECT;
......
......@@ -707,10 +707,7 @@ void pgw_app::handle_amf_msg(std::shared_ptr<pdu_session_create_sm_context_reque
Logger::pgwc_app().debug("Handle AMF message, supi " SUPI_64_FMT " ", supi64);
//pdu_session_establishment_request_msg pdu_session_establishment_request = sm_context_req_msg->get_nas_msg() ;
//pdu_session_type_t pdu_session_type = {.pdu_session_type = (uint8_t)pdu_session_establishment_request._pdusessiontype};
pdu_session_type_t pdu_session_type = {.pdu_session_type = 0}; //to be removed
pdu_session_type_t pdu_session_type = {.pdu_session_type = sm_context_req_msg->get_pdu_session_type()};
Logger::pgwc_app().debug("Handle AMF message, _pdusessiontype: %d", pdu_session_type.pdu_session_type);
//Step 2. check if the DNN requested is valid
......
......@@ -985,23 +985,18 @@ void pgw_context::handle_amf_msg (std::shared_ptr<pdu_session_create_sm_context_
Logger::pgwc_app().info("Handle AMF message");
oai::smf::model::SmContextCreateError smContextCreateError;
oai::smf::model::ProblemDetails problem_details;
bool request_accepted = true;
//Step 1. get necessary information
Logger::pgwc_app().debug("Handle AMF message, supi " SUPI_64_FMT " ", sm_context_req_msg->get_supi());
std::string dnn = sm_context_req_msg->get_dnn();
//oai::smf::model::Snssai snssai_sm = smContextCreateData.getSNssai();
snssai_t snssai = sm_context_req_msg->get_snssai();
std::string requestType = sm_context_req_msg->get_request_type();
supi_t supi = sm_context_req_msg->get_supi();
supi64_t supi64 = smf_supi_to_u64(supi);
uint32_t pdu_session_id = sm_context_req_msg->get_pdu_session_id();
oai::smf::model::SmContextCreateError smContextCreateError;
oai::smf::model::ProblemDetails problem_details;
bool request_accepted = true;
//problem_details.setCause()
//Step 2. check the validity of the UE request, if valid send PDU Session Accept, otherwise send PDU Session Reject to AMF
if (!verify_sm_context_request(sm_context_req_msg)){ //TODO: Need to implement this function
// Not a valid request...
......@@ -1050,7 +1045,6 @@ void pgw_context::handle_amf_msg (std::shared_ptr<pdu_session_create_sm_context_
//create a new pdn connection
pgw_pdn_connection *p = new (pgw_pdn_connection);
p->pdn_type.pdn_type = sm_context_req_msg->get_pdu_session_type();
p->pdn_type.pdn_type = PDN_TYPE_E_IPV4; //TODO: should be removed after get the correct information from NAS_MSG
p->pdu_session_id = pdu_session_id; //should check also nas_msg.pdusessionidentity ??
//amf id
p->amf_id = sm_context_req_msg->get_serving_nf_id();
......@@ -1061,7 +1055,6 @@ void pgw_context::handle_amf_msg (std::shared_ptr<pdu_session_create_sm_context_
//TODO:
}
//pending session??
//step 4. check if supi is authenticated
......
......@@ -247,7 +247,6 @@ int session_establishment_procedure::run(std::shared_ptr<pdu_session_create_sm_c
itti_sxab_session_establishment_request *sx_ser = new itti_sxab_session_establishment_request(TASK_PGWC_APP, TASK_PGWC_SX);
sx_ser->seid = 0;
sx_ser->trxn_id = this->trxn_id;
//sx_ser->l_endpoint = boost::asio::ip::udp::endpoint(boost::asio::ip::address_v4(0xC0A8A064), 8805);
sx_ser->r_endpoint = endpoint(up_node_id.u1.ipv4_address, pfcp::default_port);
sx_triggered = std::shared_ptr<itti_sxab_session_establishment_request>(sx_ser);
......@@ -267,7 +266,6 @@ int session_establishment_procedure::run(std::shared_ptr<pdu_session_create_sm_c
sx_ser->pfcp_ies.set(cp_fseid);
// for (auto it : s5_trigger->gtp_ies.bearer_contexts_to_be_created) {
//*******************
// UPLINK
//*******************
......@@ -353,7 +351,6 @@ int session_establishment_procedure::run(std::shared_ptr<pdu_session_create_sm_c
pgw_eps_bearer b2 = b;
ppc->add_eps_bearer(b2);
// }
// for finding procedure when receiving response
pgw_app_inst->set_seid_2_pgw_context(cp_fseid.seid, pc);
......
......@@ -34,6 +34,7 @@ supi_t pdu_session_create_sm_context_request::get_supi() const
{
return m_supi;
}