Commit ba332d2a authored by Rohan's avatar Rohan Committed by Rohan

IE Enterprise Specific - decoding function added

parent 2308605a
......@@ -39,6 +39,13 @@
#include <vector>
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 {
pfcp_exception() throw() {
......@@ -312,6 +319,7 @@ struct pfcp_ie_value_exception : public pfcp_ie_exception {
#define PFCP_IE_PAGING_POLICY_INDICATOR (158)
#define PFCP_IE_APN_DNN (159)
#define PFCP_IE_3GPP_INTERFACE_TYPE (160)
#define PFCP_IE_ENTERPRISE_SPECIFIC (32770)
#define PFCP_IE_PFCPSRREQ_FLAGS_3GPP (161)
#define PFCP_IE_PFCPAUREQ_FLAGS (162)
......
......@@ -38,6 +38,11 @@ pfcp_ie* pfcp_ie::new_pfcp_ie_from_stream(std::istream& is) {
tlv.load_from(is);
if (tlv.length) {
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: {
pfcp_create_pdr_ie* ie = new pfcp_create_pdr_ie(tlv);
ie->load_from(is);
......
......@@ -107,7 +107,7 @@ class pfcp_ie : public stream_serializable {
pfcp_ie() : tlv() {}
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(){};
......@@ -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
class pfcp_source_interface_ie : public pfcp_ie {
public:
......
......@@ -90,6 +90,16 @@ class pfcp_ies_container {
public:
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
virtual bool get(pfcp::create_pdr& v) const {
throw pfcp_msg_illegal_ie_exception(
......
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