Commit 678b126f authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Merge branch 'ie_enterprise_specifc' into 'develop'

Ie enterprise specifc

See merge request oai/cn5g/oai-cn5g-smf!53
parents 0037c1bb a7c8a089
...@@ -39,6 +39,13 @@ ...@@ -39,6 +39,13 @@
#include <vector> #include <vector>
namespace pfcp { namespace pfcp {
//-------------------------------------
// 8.1.1 IE with Enterprise Info
typedef struct enterprise_specific_s {
uint16_t enterprise_id;
std::string proprietary_data;
} enterprise_specific_t;
//-------------------------------------
struct pfcp_exception : public std::exception { struct pfcp_exception : public std::exception {
pfcp_exception() throw() { pfcp_exception() throw() {
...@@ -312,6 +319,7 @@ struct pfcp_ie_value_exception : public pfcp_ie_exception { ...@@ -312,6 +319,7 @@ struct pfcp_ie_value_exception : public pfcp_ie_exception {
#define PFCP_IE_PAGING_POLICY_INDICATOR (158) #define PFCP_IE_PAGING_POLICY_INDICATOR (158)
#define PFCP_IE_APN_DNN (159) #define PFCP_IE_APN_DNN (159)
#define PFCP_IE_3GPP_INTERFACE_TYPE (160) #define PFCP_IE_3GPP_INTERFACE_TYPE (160)
#define PFCP_IE_ENTERPRISE_SPECIFIC (32770)
#define PFCP_IE_PFCPSRREQ_FLAGS_3GPP (161) #define PFCP_IE_PFCPSRREQ_FLAGS_3GPP (161)
#define PFCP_IE_PFCPAUREQ_FLAGS (162) #define PFCP_IE_PFCPAUREQ_FLAGS (162)
......
...@@ -38,6 +38,11 @@ pfcp_ie* pfcp_ie::new_pfcp_ie_from_stream(std::istream& is) { ...@@ -38,6 +38,11 @@ pfcp_ie* pfcp_ie::new_pfcp_ie_from_stream(std::istream& is) {
tlv.load_from(is); tlv.load_from(is);
if (tlv.length) { if (tlv.length) {
switch (tlv.type) { switch (tlv.type) {
case PFCP_IE_ENTERPRISE_SPECIFIC: {
pfcp_enterprise_specific_ie* ie = new pfcp_enterprise_specific_ie(tlv);
ie->load_from(is);
return ie;
} break;
case PFCP_IE_CREATE_PDR: { case PFCP_IE_CREATE_PDR: {
pfcp_create_pdr_ie* ie = new pfcp_create_pdr_ie(tlv); pfcp_create_pdr_ie* ie = new pfcp_create_pdr_ie(tlv);
ie->load_from(is); ie->load_from(is);
......
...@@ -107,7 +107,7 @@ class pfcp_ie : public stream_serializable { ...@@ -107,7 +107,7 @@ class pfcp_ie : public stream_serializable {
pfcp_ie() : tlv() {} pfcp_ie() : tlv() {}
explicit pfcp_ie(const pfcp_tlv& t) : tlv(t) {} explicit pfcp_ie(const pfcp_tlv& t) : tlv(t) {}
explicit pfcp_ie(const uint8_t tlv_type) : tlv() { tlv.type = tlv_type; } explicit pfcp_ie(const uint16_t tlv_type) : tlv() { tlv.type = tlv_type; }
virtual ~pfcp_ie(){}; virtual ~pfcp_ie(){};
...@@ -550,6 +550,70 @@ class pfcp_cause_ie : public pfcp_ie { ...@@ -550,6 +550,70 @@ class pfcp_cause_ie : public pfcp_ie {
} }
}; };
//------------------------------------- //-------------------------------------
// IE ENTERPRISE SPECIFIC
class pfcp_enterprise_specific_ie : public pfcp_ie {
public:
uint16_t enterprise_id;
std::string proprietary_data;
//--------
explicit pfcp_enterprise_specific_ie(const pfcp::enterprise_specific_t& b)
: pfcp_ie(PFCP_IE_ENTERPRISE_SPECIFIC) {
enterprise_id = b.enterprise_id;
proprietary_data = b.proprietary_data;
tlv.set_length(2 + proprietary_data.size());
}
//--------
pfcp_enterprise_specific_ie() : pfcp_ie(PFCP_IE_ENTERPRISE_SPECIFIC) {
enterprise_id = 0;
proprietary_data = {};
tlv.set_length(2);
}
// --------
explicit pfcp_enterprise_specific_ie(const pfcp_tlv& t)
: pfcp_ie(t),
enterprise_id(0),
proprietary_data(){};
//--------
void to_core_type(pfcp::enterprise_specific_t& b) {
b.enterprise_id = enterprise_id;
b.proprietary_data = proprietary_data;
}
//--------
void dump_to(std::ostream& os) {
tlv.dump_to(os);
os.write(reinterpret_cast<const char*>(&enterprise_id),
sizeof(enterprise_id));
os << enterprise_id;
}
//--------
void load_from(std::istream& is) {
// tlv.load_from(is);
if (tlv.get_length() < 2) {
throw pfcp_tlv_bad_length_exception(
tlv.type, tlv.get_length(), __FILE__, __LINE__);
}
is.read(reinterpret_cast<char*>(&enterprise_id),
sizeof(enterprise_id));
char e[tlv.get_length() - 2];
is.read(e, tlv.get_length() - 2);
proprietary_data.assign(e, tlv.get_length() - 2);
if (tlv.get_length() != (2 + proprietary_data.size())) {
throw pfcp_tlv_bad_length_exception(
tlv.type, tlv.get_length(), __FILE__, __LINE__);
}
}
//--------
void to_core_type(pfcp_ies_container& s) {
pfcp::enterprise_specific_t enterprise_specific = {};
to_core_type(enterprise_specific);
s.set(enterprise_specific);
}
};
//-------------------------------------
// IE SOURCE_INTERFACE // IE SOURCE_INTERFACE
class pfcp_source_interface_ie : public pfcp_ie { class pfcp_source_interface_ie : public pfcp_ie {
public: public:
......
...@@ -90,6 +90,16 @@ class pfcp_ies_container { ...@@ -90,6 +90,16 @@ class pfcp_ies_container {
public: public:
static const uint8_t msg_id = 0; static const uint8_t msg_id = 0;
// PFCP_IE_ENTERPRISE_SPECIFIC
virtual bool get(pfcp::enterprise_specific_t& v) const {
throw pfcp_msg_illegal_ie_exception(
0, PFCP_IE_ENTERPRISE_SPECIFIC, __FILE__, __LINE__);
}
virtual void set(const pfcp::enterprise_specific_t& v) {
throw pfcp_msg_illegal_ie_exception(
0, PFCP_IE_ENTERPRISE_SPECIFIC, __FILE__, __LINE__);
}
// PFCP_IE_CREATE_PDR // PFCP_IE_CREATE_PDR
virtual bool get(pfcp::create_pdr& v) const { virtual bool get(pfcp::create_pdr& v) const {
throw pfcp_msg_illegal_ie_exception( throw pfcp_msg_illegal_ie_exception(
...@@ -5556,13 +5566,15 @@ class pfcp_association_setup_request : public pfcp_ies_container { ...@@ -5556,13 +5566,15 @@ class pfcp_association_setup_request : public pfcp_ies_container {
std::pair<bool, pfcp::cp_function_features_t> cp_function_features; std::pair<bool, pfcp::cp_function_features_t> cp_function_features;
std::pair<bool, pfcp::user_plane_ip_resource_information_t> std::pair<bool, pfcp::user_plane_ip_resource_information_t>
user_plane_ip_resource_information; user_plane_ip_resource_information;
std::pair<bool, pfcp::enterprise_specific_t> enterprise_specific;
pfcp_association_setup_request() pfcp_association_setup_request()
: node_id(), : node_id(),
recovery_time_stamp(), recovery_time_stamp(),
up_function_features(), up_function_features(),
cp_function_features(), cp_function_features(),
user_plane_ip_resource_information() {} user_plane_ip_resource_information(),
enterprise_specific () {}
pfcp_association_setup_request(const pfcp_association_setup_request& i) { pfcp_association_setup_request(const pfcp_association_setup_request& i) {
node_id = i.node_id; node_id = i.node_id;
...@@ -5570,6 +5582,7 @@ class pfcp_association_setup_request : public pfcp_ies_container { ...@@ -5570,6 +5582,7 @@ class pfcp_association_setup_request : public pfcp_ies_container {
up_function_features = i.up_function_features; up_function_features = i.up_function_features;
cp_function_features = i.cp_function_features; cp_function_features = i.cp_function_features;
user_plane_ip_resource_information = i.user_plane_ip_resource_information; user_plane_ip_resource_information = i.user_plane_ip_resource_information;
enterprise_specific = i.enterprise_specific;
} }
const char* get_msg_name() const { return "PFCP_ASSOCIATION_SETUP_REQUEST"; }; const char* get_msg_name() const { return "PFCP_ASSOCIATION_SETUP_REQUEST"; };
...@@ -5608,6 +5621,13 @@ class pfcp_association_setup_request : public pfcp_ies_container { ...@@ -5608,6 +5621,13 @@ class pfcp_association_setup_request : public pfcp_ies_container {
} }
return false; return false;
} }
bool get(pfcp::enterprise_specific_t& v) const {
if (enterprise_specific.first) {
v = enterprise_specific.second;
return true;
}
return false;
}
void set(const pfcp::node_id_t& v) { void set(const pfcp::node_id_t& v) {
node_id.first = true; node_id.first = true;
...@@ -5629,6 +5649,10 @@ class pfcp_association_setup_request : public pfcp_ies_container { ...@@ -5629,6 +5649,10 @@ class pfcp_association_setup_request : public pfcp_ies_container {
user_plane_ip_resource_information.first = true; user_plane_ip_resource_information.first = true;
user_plane_ip_resource_information.second = v; user_plane_ip_resource_information.second = v;
} }
void set(const pfcp::enterprise_specific_t& v) {
enterprise_specific.first = true;
enterprise_specific.second = v;
}
}; };
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
...@@ -5643,6 +5667,7 @@ class pfcp_association_setup_response : public pfcp_ies_container { ...@@ -5643,6 +5667,7 @@ class pfcp_association_setup_response : public pfcp_ies_container {
std::pair<bool, pfcp::cp_function_features_t> cp_function_features; std::pair<bool, pfcp::cp_function_features_t> cp_function_features;
std::pair<bool, pfcp::user_plane_ip_resource_information_t> std::pair<bool, pfcp::user_plane_ip_resource_information_t>
user_plane_ip_resource_information; user_plane_ip_resource_information;
std::pair<bool, pfcp::enterprise_specific_t> enterprise_specific;
pfcp_association_setup_response() pfcp_association_setup_response()
: node_id(), : node_id(),
...@@ -5650,7 +5675,8 @@ class pfcp_association_setup_response : public pfcp_ies_container { ...@@ -5650,7 +5675,8 @@ class pfcp_association_setup_response : public pfcp_ies_container {
recovery_time_stamp(), recovery_time_stamp(),
up_function_features(), up_function_features(),
cp_function_features(), cp_function_features(),
user_plane_ip_resource_information() {} user_plane_ip_resource_information(),
enterprise_specific () {}
pfcp_association_setup_response(const pfcp_association_setup_response& i) { pfcp_association_setup_response(const pfcp_association_setup_response& i) {
node_id = i.node_id; node_id = i.node_id;
...@@ -5659,6 +5685,7 @@ class pfcp_association_setup_response : public pfcp_ies_container { ...@@ -5659,6 +5685,7 @@ class pfcp_association_setup_response : public pfcp_ies_container {
up_function_features = i.up_function_features; up_function_features = i.up_function_features;
cp_function_features = i.cp_function_features; cp_function_features = i.cp_function_features;
user_plane_ip_resource_information = i.user_plane_ip_resource_information; user_plane_ip_resource_information = i.user_plane_ip_resource_information;
enterprise_specific = i.enterprise_specific;
} }
const char* get_msg_name() const { const char* get_msg_name() const {
return "PFCP_ASSOCIATION_SETUP_RESPONSE"; return "PFCP_ASSOCIATION_SETUP_RESPONSE";
...@@ -5706,6 +5733,13 @@ class pfcp_association_setup_response : public pfcp_ies_container { ...@@ -5706,6 +5733,13 @@ class pfcp_association_setup_response : public pfcp_ies_container {
} }
return false; return false;
} }
bool get(pfcp::enterprise_specific_t& v) const {
if (enterprise_specific.first) {
v = enterprise_specific.second;
return true;
}
return false;
}
void set(const pfcp::node_id_t& v) { void set(const pfcp::node_id_t& v) {
node_id.first = true; node_id.first = true;
...@@ -5731,6 +5765,10 @@ class pfcp_association_setup_response : public pfcp_ies_container { ...@@ -5731,6 +5765,10 @@ class pfcp_association_setup_response : public pfcp_ies_container {
user_plane_ip_resource_information.first = true; user_plane_ip_resource_information.first = true;
user_plane_ip_resource_information.second = v; user_plane_ip_resource_information.second = v;
} }
void set(const pfcp::enterprise_specific_t& v) {
enterprise_specific.first = true;
enterprise_specific.second = v;
}
}; };
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
......
...@@ -372,6 +372,12 @@ void smf_n4::handle_receive_association_setup_request( ...@@ -372,6 +372,12 @@ void smf_n4::handle_receive_association_setup_request(
msg_ies_container.node_id.second, msg_ies_container.node_id.second,
msg_ies_container.recovery_time_stamp.second, msg_ies_container.recovery_time_stamp.second,
msg_ies_container.up_function_features.second, restore_n4_sessions); msg_ies_container.up_function_features.second, restore_n4_sessions);
} else if (msg_ies_container.enterprise_specific.first) {
pfcp_associations::get_instance().add_association(
msg_ies_container.node_id.second,
msg_ies_container.recovery_time_stamp.second,
msg_ies_container.up_function_features.second,
msg_ies_container.enterprise_specific.second, restore_n4_sessions);
} else { } else {
pfcp_associations::get_instance().add_association( pfcp_associations::get_instance().add_association(
msg_ies_container.node_id.second, msg_ies_container.node_id.second,
...@@ -446,6 +452,12 @@ void smf_n4::handle_receive_association_setup_response( ...@@ -446,6 +452,12 @@ void smf_n4::handle_receive_association_setup_response(
msg_ies_container.node_id.second, msg_ies_container.node_id.second,
msg_ies_container.recovery_time_stamp.second, msg_ies_container.recovery_time_stamp.second,
msg_ies_container.up_function_features.second, restore_n4_sessions); msg_ies_container.up_function_features.second, restore_n4_sessions);
} else if (msg_ies_container.enterprise_specific.first) {
pfcp_associations::get_instance().add_association(
msg_ies_container.node_id.second,
msg_ies_container.recovery_time_stamp.second,
msg_ies_container.up_function_features.second,
msg_ies_container.enterprise_specific.second, restore_n4_sessions);
} else { } else {
pfcp_associations::get_instance().add_association( pfcp_associations::get_instance().add_association(
msg_ies_container.node_id.second, msg_ies_container.node_id.second,
......
...@@ -215,6 +215,38 @@ bool pfcp_associations::add_association( ...@@ -215,6 +215,38 @@ bool pfcp_associations::add_association(
} }
return true; return true;
} }
//------------------------------------------------------------------------------
bool pfcp_associations::add_association(
pfcp::node_id_t& node_id, pfcp::recovery_time_stamp_t& recovery_time_stamp,
pfcp::up_function_features_s& function_features,
pfcp::enterprise_specific_s& enterprise_specific,
bool& restore_n4_sessions) {
std::shared_ptr<pfcp_association> sa =
std::shared_ptr<pfcp_association>(nullptr);
if (get_association(node_id, sa)) {
itti_inst->timer_remove(sa->timer_heartbeat);
if (sa->recovery_time_stamp == recovery_time_stamp) {
restore_n4_sessions = false;
} else {
restore_n4_sessions = true;
}
sa->recovery_time_stamp = recovery_time_stamp;
sa->function_features.first = true;
sa->function_features.second = function_features;
} else {
restore_n4_sessions = false;
pfcp_association* association =
new pfcp_association(node_id, recovery_time_stamp, function_features);
sa = std::shared_ptr<pfcp_association>(association);
sa->recovery_time_stamp = recovery_time_stamp;
sa->function_features.first = true;
sa->function_features.second = function_features;
std::size_t hash_node_id = std::hash<pfcp::node_id_t>{}(node_id);
associations.insert((int32_t) hash_node_id, sa);
trigger_heartbeat_request_procedure(sa);
}
return true;
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
bool pfcp_associations::update_association( bool pfcp_associations::update_association(
......
...@@ -190,6 +190,12 @@ class pfcp_associations { ...@@ -190,6 +190,12 @@ class pfcp_associations {
pfcp::recovery_time_stamp_t& recovery_time_stamp, pfcp::recovery_time_stamp_t& recovery_time_stamp,
pfcp::up_function_features_s& function_features, pfcp::up_function_features_s& function_features,
bool& restore_n4_sessions); bool& restore_n4_sessions);
bool add_association(
pfcp::node_id_t& node_id,
pfcp::recovery_time_stamp_t& recovery_time_stamp,
pfcp::up_function_features_s& function_features,
pfcp::enterprise_specific_s& enterprise_specific,
bool& restore_n4_sessions);
bool update_association( bool update_association(
pfcp::node_id_t& node_id, pfcp::node_id_t& node_id,
pfcp::up_function_features_s& function_features); pfcp::up_function_features_s& function_features);
......
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