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

Support PCO

parent 74e649ed
......@@ -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
......@@ -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;
//------------------------------------------------------------------------------
......
/*
* 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_NAS_LIB_SEEN
#define FILE_NAS_LIB_SEEN
#include "bstrlib.h"
typedef struct pco_protocol_or_container_id_nas_s {
uint16_t id;
uint8_t length;
bstring contents;
} pco_protocol_or_container_id_nas_t;
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
......@@ -83,3 +83,35 @@ void xgpp_conv::pdn_ip_to_pfcp_ue_ip_address(
default:;
}
}
void xgpp_conv::protocol_configuration_options_nas_to_core(
const protocol_configuration_options_nas_t& pco_nas,
protocol_configuration_options_t& pco) {
pco.ext = pco_nas.ext;
pco.spare = pco_nas.spare;
pco.configuration_protocol = pco_nas.configuration_protocol;
pco.num_protocol_or_container_id = pco_nas.num_protocol_or_container_id;
for (int i = 0; i < pco.num_protocol_or_container_id; i++) {
pco_protocol_or_container_id_t pco_item = {};
pco_item.length_of_protocol_id_contents =
pco_nas.protocol_or_container_ids[i].length;
pco_item.protocol_id = pco_nas.protocol_or_container_ids[i].id;
// pco.protocol_or_container_ids[i].length_of_protocol_id_contents =
// pco_nas.protocol_or_container_ids[i].length;
// pco.protocol_or_container_ids[i].protocol_id =
// pco_nas.protocol_or_container_ids[i].id;
unsigned char data[512] = {'\0'};
memcpy(
(void*) &data,
(void*) pco_nas.protocol_or_container_ids[i].contents->data,
pco_nas.protocol_or_container_ids[i].contents->slen);
std::string msg_bstr(
(char*) data, pco_nas.protocol_or_container_ids[i].contents->slen);
// pco.protocol_or_container_ids[i].protocol_id_contents = msg_bstr;
pco_item.protocol_id_contents = msg_bstr;
pco.protocol_or_container_ids.push_back(pco_item);
}
}
......@@ -33,6 +33,8 @@
#include "3gpp_29.281.h"
#include "3gpp_24.501.h"
#include "endpoint.hpp"
#include "3gpp_24.008.h"
#include "nas_lib.h"
namespace xgpp_conv {
......@@ -42,6 +44,11 @@ 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);
void protocol_configuration_options_nas_to_core(
const protocol_configuration_options_nas_t& pco_nas,
protocol_configuration_options_t& pco);
} // namespace xgpp_conv
#endif /* FILE_3GPP_CONVERSIONS_HPP_SEEN */
......@@ -24,6 +24,7 @@ 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}/../build/ext/spdlog/include)
......
......@@ -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;
......@@ -47,25 +47,60 @@ int encode_extended_protocol_configuration_options(
lenPtr = (buffer + encoded);
encoded++;
lenPtr = (buffer + encoded);
encoded++;
encoded += encode_protocol_configuration_options(
extendedprotocolconfigurationoptions, buffer + encoded, len - encoded);
*lenPtr = encoded - 1 - ((iei > 0) ? 1 : 0);
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 ((encode_result = encode_bstring(
extendedprotocolconfigurationoptions, buffer + encoded,
len - encoded)) < 0)
protocolconfigurationoptions
.protocol_or_container_ids[num_protocol_or_container_id]
.contents,
buffer + encoded, len - encoded)) < 0)
return encode_result;
else
encoded += encode_result;
uint32_t res = encoded - 2 - ((iei > 0) ? 1 : 0);
*lenPtr = res / (1 << 8);
lenPtr++;
*lenPtr = res % (1 << 8);
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;
......@@ -78,17 +113,84 @@ int decode_extended_protocol_configuration_options(
ielen = *(buffer + decoded);
decoded++;
ielen = (ielen << 8) + *(buffer + decoded);
decode_result = decode_protocol_configuration_options(
extendedprotocolconfigurationoptions, buffer + decoded, len - decoded);
if (decode_result < 0) {
return 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;
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;
}
protocolconfigurationoptions->configuration_protocol =
(*(buffer + decoded) >> 1) & 0x7;
decoded++;
CHECK_LENGTH_DECODER(len - decoded, ielen);
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(
extendedprotocolconfigurationoptions, ielen, buffer + decoded,
len - decoded)) < 0) {
&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
......@@ -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)
......
......@@ -39,6 +39,7 @@
#include "3gpp_24.501.h"
#include "3gpp_29.500.h"
#include "3gpp_29.502.h"
#include "3gpp_conversions.hpp"
#include "ProblemDetails.h"
#include "RefToBinaryData.h"
#include "SmContextCreateError.h"
......@@ -712,6 +713,16 @@ void smf_app::handle_pdu_session_create_sm_context_request(
// TODO: AlwaysonPDUSessionRequested
// TODO: SMPDUDNRequestContainer
// TODO: ExtendedProtocolConfigurationOptions
if (decoded_nas_msg.plain.sm.pdu_session_establishment_request
.extendedprotocolconfigurationoptions.num_protocol_or_container_id >
0) {
protocol_configuration_options_t pco = {};
xgpp_conv::protocol_configuration_options_nas_to_core(
decoded_nas_msg.plain.sm.pdu_session_establishment_request
.extendedprotocolconfigurationoptions,
pco);
smreq->req.set_pco(pco);
}
// Get necessary information
supi_t supi = smreq->req.get_supi();
......
This diff is collapsed.
......@@ -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_pco(
const protocol_configuration_options_t& p) {
epco = p;
}
//-----------------------------------------------------------------------------
void pdu_session_create_sm_context_request::get_pco(
protocol_configuration_options_t& p) const {
p = epco;
}
/*
* class: PDU Session Create SM Context Response
*/
......
......@@ -262,6 +262,8 @@ class pdu_session_create_sm_context_request
std::string get_dnn_selection_mode() const;
void set_sm_context_status_uri(const std::string& value);
std::string get_sm_context_status_uri() const;
void set_pco(const protocol_configuration_options_t& p);
void get_pco(protocol_configuration_options_t& p) const;
private:
bool m_unauthenticated_supi;
......@@ -272,6 +274,7 @@ class pdu_session_create_sm_context_request
std::string m_an_type;
std::string m_dnn_selection_mode; // SelMode
std::string m_sm_context_status_uri;
protocol_configuration_options_t epco;
};
//---------------------------------------------------------------------------------------
......
This diff is collapsed.
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