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

Add 3GPP Interface Type

parent 8a13bafd
......@@ -320,6 +320,7 @@ struct pfcp_ie_value_exception : public pfcp_ie_exception {
#define PFCP_IE_FRAMED_ROUTE (153)
#define PFCP_IE_FRAMED_ROUTING (154)
#define PFCP_IE_FRAMED_IPV6_ROUTE (155)
#define PFCP_IE_3GPP_INTERFACE_TYPE (160)
#define PFCP_MESSAGE_RESERVED (0)
// PFCP_NODE_RELATED_MESSAGES
......@@ -409,8 +410,8 @@ typedef struct source_interface_s {
struct fteid_s {
uint8_t chid :1;
uint8_t ch :1;
uint8_t v4 :1;
uint8_t v6 :1;
uint8_t v4 :1;
teid_t teid;
struct in_addr ipv4_address;
struct in6_addr ipv6_address;
......@@ -1613,24 +1614,28 @@ typedef struct framed_ipv6_route_s {
//-------------------------------------
// 8.2.118. 3GPP Interface Type
enum _3gpp_interface_type_e {
S1_U = 0,
S5_S8_U = 1,
S4_U = 2,
S11_U = 3,
S12_U = 4,
GN_GP_U = 5,
S2A_U = 6,
S2B_U = 7,
ENODEB_GTP_U_DL = 8,
ENODEB_GTP_U_UL = 9,
SGW_UPF_GTP_U_DL = 10,
N3_3GPP_ACCESS = 11,
N3_TRUSTED_NON_3GPP_ACCESS = 12,
N3_UNTRUSTED_NON_3GPP_ACCESS = 13,
N3 = 14,
N9 = 15
_3GPP_INTERFACE_TYPE_S1_U = 0,
_3GPP_INTERFACE_TYPE_S5_S8_U = 1,
_3GPP_INTERFACE_TYPE_S4_U = 2,
_3GPP_INTERFACE_TYPE_S11_U = 3,
_3GPP_INTERFACE_TYPE_S12_U = 4,
_3GPP_INTERFACE_TYPE_GN_GP_U = 5,
_3GPP_INTERFACE_TYPE_S2A_U = 6,
_3GPP_INTERFACE_TYPE_S2B_U = 7,
_3GPP_INTERFACE_TYPE_ENODEB_GTP_U_DL = 8,
_3GPP_INTERFACE_TYPE_ENODEB_GTP_U_UL = 9,
_3GPP_INTERFACE_TYPE_SGW_UPF_GTP_U_DL = 10,
_3GPP_INTERFACE_TYPE_N3_3GPP_ACCESS = 11,
_3GPP_INTERFACE_TYPE_N3_TRUSTED_NON_3GPP_ACCESS = 12,
_3GPP_INTERFACE_TYPE_N3_UNTRUSTED_NON_3GPP_ACCESS = 13,
_3GPP_INTERFACE_TYPE_N3 = 14,
_3GPP_INTERFACE_TYPE_N9 = 15
};
typedef struct _3gpp_interface_type_s {
uint8_t spare :2;
uint8_t interface_type_value :6;
} _3gpp_interface_type_t;
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Specific IEs
......
......@@ -969,6 +969,13 @@ pfcp_ie * pfcp_ie::new_pfcp_ie_from_stream(std::istream& is) {
// return ie;
// }
// break;
case PFCP_IE_3GPP_INTERFACE_TYPE: {
pfcp_3gpp_interface_type_ie *ie = new pfcp_3gpp_interface_type_ie(tlv);
ie->load_from(is);
return ie;
}
break;
default:
Logger::pfcp().error("Unknown PFCP IE type %d (length %d)", tlv.get_type(), tlv.get_length());
return nullptr;
......
......@@ -7782,6 +7782,60 @@ public:
// }
//};
// IE 3gpp_interface_type
class pfcp_3gpp_interface_type_ie : public pfcp_ie {
public:
struct {
uint8_t spare :2;
uint8_t _3gpp_interface_type :6;
} interface_type;
union {
struct {
uint8_t spare :2;
uint8_t _3gpp_interface_type :6;
} bf;
uint8_t b;
} u1;
//--------
explicit pfcp_3gpp_interface_type_ie(const pfcp::_3gpp_interface_type_t& b) : pfcp_ie(PFCP_IE_3GPP_INTERFACE_TYPE){
u1.b = b.interface_type_value;
tlv.set_length(1);
}
//--------
pfcp_3gpp_interface_type_ie() : pfcp_ie(PFCP_IE_3GPP_INTERFACE_TYPE){
}
//--------
pfcp_3gpp_interface_type_ie(const pfcp_tlv& t) : pfcp_ie(t) {
};
//--------
void to_core_type(pfcp::_3gpp_interface_type_t& b) {
b.interface_type_value = u1.bf._3gpp_interface_type;
}
//--------
void dump_to(std::ostream& os) {
tlv.dump_to(os);
os.write(reinterpret_cast<const char*>(&u1.b), sizeof(u1.b));
}
//--------
void load_from(std::istream& is) {
if (tlv.get_length() != sizeof(interface_type)) {
throw pfcp_tlv_bad_length_exception(tlv.type, tlv.get_length(), __FILE__, __LINE__);
}
is.read(reinterpret_cast<char*>(&u1.b), sizeof(u1.b));
}
//--------
void to_core_type(pfcp_ies_container& s) {
pfcp::_3gpp_interface_type_t v = {};
to_core_type(v);
s.set(v);
}
};
//-------------------------------------
// IE PDI
class pfcp_pdi_ie : public pfcp_grouped_ie {
......
......@@ -558,6 +558,10 @@ namespace pfcp {
// PFCP_IE_FRAMED_IPV6_ROUTE
virtual bool get(pfcp::framed_ipv6_route_t& v) const {throw pfcp_msg_illegal_ie_exception(0, PFCP_IE_FRAMED_IPV6_ROUTE, __FILE__, __LINE__);}
virtual void set(const pfcp::framed_ipv6_route_t& v) {throw pfcp_msg_illegal_ie_exception(0, PFCP_IE_FRAMED_IPV6_ROUTE, __FILE__, __LINE__);}
// PFCP_IE_3GPP_INTERFACE_TYPE
virtual bool get(pfcp::_3gpp_interface_type_t& v) const {throw pfcp_msg_illegal_ie_exception(0, PFCP_IE_3GPP_INTERFACE_TYPE, __FILE__, __LINE__);}
virtual void set(const pfcp::_3gpp_interface_type_t& v) {throw pfcp_msg_illegal_ie_exception(0, PFCP_IE_3GPP_INTERFACE_TYPE, __FILE__, __LINE__);}
virtual ~pfcp_ies_container() {};
};
......@@ -692,6 +696,8 @@ namespace pfcp {
std::pair<bool, pfcp::framed_route_t> framed_route;
std::pair<bool, pfcp::framed_routing_t> framed_routing;
std::pair<bool, pfcp::framed_ipv6_route_t> framed_ipv6_route;
std::pair<bool, pfcp::_3gpp_interface_type_t> _3gpp_interface_type;
pdi() :
......@@ -737,6 +743,7 @@ namespace pfcp {
void set(const pfcp::framed_route_t& v) {framed_route.first = true; framed_route.second = v;}
void set(const pfcp::framed_routing_t& v) {framed_routing.first = true; framed_routing.second = v;}
void set(const pfcp::framed_ipv6_route_t& v) {framed_ipv6_route.first = true; framed_ipv6_route.second = v;}
void set(const pfcp::_3gpp_interface_type_t& v) {_3gpp_interface_type.first = true; _3gpp_interface_type.second = v;}
bool get(pfcp::source_interface_t& v) const {if (source_interface.first) {v = source_interface.second;return true;}return false;}
bool get(pfcp::fteid_t& v) const {if (local_fteid.first) {v = local_fteid.second;return true;}return false;}
......@@ -750,6 +757,7 @@ namespace pfcp {
bool get(pfcp::framed_route_t& v) const {if (framed_route.first) {v = framed_route.second;return true;}return false;}
bool get(pfcp::framed_routing_t& v) const {if (framed_routing.first) {v = framed_routing.second;return true;}return false;}
bool get(pfcp::framed_ipv6_route_t& v) const {if (framed_ipv6_route.first) {v = framed_ipv6_route.second;return true;}return false;}
bool get(pfcp::_3gpp_interface_type_t& v) const {if (_3gpp_interface_type.first) {v = _3gpp_interface_type.second;return true;}return false;}
};
//------------------------------------------------------------------------------
......
......@@ -179,9 +179,11 @@ int session_create_sm_context_procedure::run(
pfcp::sdf_filter_t sdf_filter = { };
pfcp::application_id_t application_id = { };
pfcp::qfi_t qfi = { };
pfcp::_3gpp_interface_type_t source_interface_type = { };
source_interface_type.interface_type_value = pfcp::_3GPP_INTERFACE_TYPE_N3;
source_interface.interface_value = pfcp::INTERFACE_VALUE_ACCESS;
local_fteid.ch = 1;
local_fteid.ch = 1; // SMF requests the UPF to assign a local F-TEID to the PDR
//TODO required?: local_fteid.v4 = 1;
//local_fteid.chid = 1;
......@@ -201,16 +203,22 @@ int session_create_sm_context_procedure::run(
qfi.qfi = default_qos._5qi;
Logger::smf_app().info("Default qfi %d", qfi.qfi);
//Packet detection information
//Packet detection information (see Table 7.5.2.2-2: PDI IE within PFCP Session Establishment Request, 3GPP TS 29.244 V16.0.0)
pdi.set(source_interface); //source interface
pdi.set(ue_ip_address); //UE IP address
//TODO: Network Instance (no need in this version)
pdi.set(local_fteid); // CN tunnel info
//TODO: Packet Filter Set
//TODO: Network Instance
pdi.set(ue_ip_address); //UE IP address
//TODO: Traffic Endpoint ID
//TODO: SDF Filter
//TODO: Application ID
pdi.set(qfi); //QoS Flow ID
//TODO: Ethernet PDU Session Information
//TODO: Ethernet Packet Filter
pdi.set(qfi); //QFI - QoS Flow ID
//TODO: Framed Route Information
//TODO: Framed-Routing
//TODO: Framed-IPv6-Route
//Source Interface Type - N3
pdi.set(source_interface_type);
outer_header_removal.outer_header_removal_description =
OUTER_HEADER_REMOVAL_GTPU_UDP_IPV4;
......
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