Commit bfb3a8e4 authored by Rohan's avatar Rohan Committed by Tien-Thinh Nguyen

Fix for encode/decode of create QER IE

parent af74363a
...@@ -1417,8 +1417,8 @@ typedef struct dl_flow_level_marking_s { ...@@ -1417,8 +1417,8 @@ typedef struct dl_flow_level_marking_s {
uint8_t spare : 6; uint8_t spare : 6;
uint8_t sci : 1; uint8_t sci : 1;
uint8_t ttc : 1; uint8_t ttc : 1;
uint16_t tos_traffic_class; std::string tos_traffic_class;
uint16_t service_class_indicator; std::string service_class_indicator;
} dl_flow_level_marking_t; } dl_flow_level_marking_t;
//------------------------------------- //-------------------------------------
......
...@@ -5529,52 +5529,138 @@ class pfcp_ue_ip_address_ie : public pfcp_ie { ...@@ -5529,52 +5529,138 @@ class pfcp_ue_ip_address_ie : public pfcp_ie {
s.set(v); s.set(v);
} }
}; };
////------------------------------------- //-------------------------------------
//// IE PACKET_RATE // IE PACKET_RATE
// class pfcp_packet_rate_ie : public pfcp_ie { class pfcp_packet_rate_ie : public pfcp_ie {
// public: public:
// uint8_t todo; union {
// struct {
// //-------- uint8_t ulpr : 1;
// pfcp_packet_rate_ie(const pfcp::packet_rate_t& b) : uint8_t dlpr : 1;
// pfcp_ie(PFCP_IE_PACKET_RATE){ uint8_t spare1 : 6;
// todo = 0; } bf;
// tlv.set_length(1); uint8_t b;
// } } u1;
// //-------- union {
// pfcp_packet_rate_ie() : pfcp_ie(PFCP_IE_PACKET_RATE){ struct {
// todo = 0; uint8_t uplink_time_unit : 3;
// tlv.set_length(1); uint8_t spare2 : 5;
// } } bf;
// //-------- uint8_t b;
// pfcp_packet_rate_ie(const pfcp_tlv& t) : pfcp_ie(t) { } u2;
// todo = 0; uint16_t maximum_uplink_packet_rate;
// }; union {
// //-------- struct {
// void to_core_type(pfcp::packet_rate_t& b) { uint8_t downlink_time_unit : 3;
// b.todo = todo; uint8_t spare3 : 5;
// } } bf;
// //-------- uint8_t b;
// void dump_to(std::ostream& os) { } u3;
// tlv.dump_to(os); uint16_t maximum_downlink_packet_rate;
// os.write(reinterpret_cast<const char*>(&todo), sizeof(todo));
// } //--------
// //-------- explicit pfcp_packet_rate_ie(const pfcp::packet_rate_t& b)
// void load_from(std::istream& is) { : pfcp_ie(PFCP_IE_PACKET_RATE) {
// //tlv.load_from(is); u1.b = 0;
// if (tlv.get_length() != 1) { u2.b = 0;
// throw pfcp_tlv_bad_length_exception(tlv.type, tlv.get_length(), maximum_uplink_packet_rate = 0;
// __FILE__, __LINE__); u3.b = 0;
// } maximum_downlink_packet_rate = 0;
// is.read(reinterpret_cast<char*>(&todo), sizeof(todo)); tlv.set_length(3);
// }
// //-------- u1.bf.dlpr = b.dlpr;
// void to_core_type(pfcp_ies_container& s) { u1.bf.ulpr = b.ulpr;
// pfcp::packet_rate_t packet_rate = {}; u2.bf.uplink_time_unit = b.uplink_time_unit;
// to_core_type(packet_rate); if (u1.bf.ulpr) {
// s.set(packet_rate); maximum_uplink_packet_rate = b.maximum_uplink_packet_rate;
// } tlv.add_length(2);
//}; }
u3.bf.downlink_time_unit = b.downlink_time_unit;
if (u1.bf.dlpr) {
maximum_downlink_packet_rate = b.maximum_downlink_packet_rate;
tlv.add_length(2);
}
}
//--------
pfcp_packet_rate_ie() : pfcp_ie(PFCP_IE_PACKET_RATE) {
u1.b = 0;
u2.b = 0;
maximum_uplink_packet_rate = 0;
u3.b = 0;
maximum_downlink_packet_rate = 0;
tlv.set_length(3);
}
//--------
explicit pfcp_packet_rate_ie(const pfcp_tlv& t) : pfcp_ie(t) {
u1.b = 0;
u2.b = 0;
maximum_uplink_packet_rate = 0;
u3.b = 0;
maximum_downlink_packet_rate = 0;
};
//--------
void to_core_type(pfcp::packet_rate_t& b) {
b = {};
b.dlpr = u1.bf.dlpr;
b.ulpr = u1.bf.ulpr;
b.uplink_time_unit = u2.bf.uplink_time_unit;
if (u1.bf.ulpr) {
b.maximum_uplink_packet_rate = maximum_uplink_packet_rate;
}
b.downlink_time_unit = u3.bf.downlink_time_unit;
if (u1.bf.dlpr) {
b.maximum_downlink_packet_rate = maximum_downlink_packet_rate;
}
}
//--------
void dump_to(std::ostream& os) {
tlv.dump_to(os);
os.write(reinterpret_cast<const char*>(&u1.b), sizeof(u1.b));
os.write(reinterpret_cast<const char*>(&u2.b), sizeof(u2.b));
if (u1.bf.ulpr) {
auto be_maximum_uplink_packet_rate = htobe16(maximum_uplink_packet_rate);
os.write(
reinterpret_cast<const char*>(&be_maximum_uplink_packet_rate),
sizeof(be_maximum_uplink_packet_rate));
}
os.write(reinterpret_cast<const char*>(&u3.b), sizeof(u3.b));
if (u1.bf.dlpr) {
auto be_maximum_downlink_packet_rate =
htobe16(maximum_downlink_packet_rate);
os.write(
reinterpret_cast<const char*>(&be_maximum_downlink_packet_rate),
sizeof(be_maximum_downlink_packet_rate));
}
}
//--------
void load_from(std::istream& is) {
if (tlv.get_length() < 3) {
throw pfcp_tlv_bad_length_exception(
tlv.type, tlv.get_length(), __FILE__, __LINE__);
}
is.read(reinterpret_cast<char*>(&u1.b), sizeof(u1.b));
is.read(reinterpret_cast<char*>(&u2.b), sizeof(u2.b));
if (u1.bf.ulpr) {
is.read(
reinterpret_cast<char*>(&maximum_uplink_packet_rate),
sizeof(maximum_uplink_packet_rate));
maximum_uplink_packet_rate = be16toh(maximum_uplink_packet_rate);
}
is.read(reinterpret_cast<char*>(&u3.b), sizeof(u3.b));
if (u1.bf.dlpr) {
is.read(
reinterpret_cast<char*>(&maximum_downlink_packet_rate),
sizeof(maximum_downlink_packet_rate));
maximum_downlink_packet_rate = be16toh(maximum_downlink_packet_rate);
}
}
//--------
void to_core_type(pfcp_ies_container& s) {
pfcp::packet_rate_t packet_rate = {};
to_core_type(packet_rate);
s.set(packet_rate);
}
};
//------------------------------------- //-------------------------------------
// IE OUTER_HEADER_REMOVAL // IE OUTER_HEADER_REMOVAL
class pfcp_outer_header_removal_ie : public pfcp_ie { class pfcp_outer_header_removal_ie : public pfcp_ie {
...@@ -5678,52 +5764,104 @@ class pfcp_recovery_time_stamp_ie : public pfcp_ie { ...@@ -5678,52 +5764,104 @@ class pfcp_recovery_time_stamp_ie : public pfcp_ie {
s.set(v); s.set(v);
} }
}; };
////------------------------------------- //-------------------------------------
//// IE DL_FLOW_LEVEL_MARKING // IE DL_FLOW_LEVEL_MARKING
// class pfcp_dl_flow_level_marking_ie : public pfcp_ie { class pfcp_dl_flow_level_marking_ie : public pfcp_ie {
// public: public:
// uint8_t todo; union {
// struct {
// //-------- uint8_t ttc : 1;
// pfcp_dl_flow_level_marking_ie(const pfcp::dl_flow_level_marking_t& b) : uint8_t sci : 1;
// pfcp_ie(PFCP_IE_DL_FLOW_LEVEL_MARKING){ uint8_t spare1 : 6;
// todo = 0; } bf;
// tlv.set_length(1); uint8_t b;
// } } u1;
// //-------- std::string tos_traffic_class; // 2 octets
// pfcp_dl_flow_level_marking_ie() : pfcp_ie(PFCP_IE_DL_FLOW_LEVEL_MARKING){ std::string service_class_indicator; // 2 octets
// todo = 0;
// tlv.set_length(1); //--------
// } explicit pfcp_dl_flow_level_marking_ie(const pfcp::dl_flow_level_marking_t& b)
// //-------- : pfcp_ie(PFCP_IE_DL_FLOW_LEVEL_MARKING) {
// pfcp_dl_flow_level_marking_ie(const pfcp_tlv& t) : pfcp_ie(t) { tlv.set_length(1);
// todo = 0; u1.b = 0;
// }; tos_traffic_class = {};
// //-------- service_class_indicator = {};
// void to_core_type(pfcp::dl_flow_level_marking_t& b) { u1.bf.ttc = b.ttc;
// b.todo = todo; u1.bf.sci = b.sci;
// } if (u1.bf.ttc) {
// //-------- if (b.tos_traffic_class.size() != 2) {
// void dump_to(std::ostream& os) { throw pfcp_ie_value_exception(tlv.type, "tos_traffic_class");
// tlv.dump_to(os); }
// os.write(reinterpret_cast<const char*>(&todo), sizeof(todo)); tos_traffic_class = b.tos_traffic_class;
// } tlv.add_length(2);
// //-------- }
// void load_from(std::istream& is) { if (u1.bf.sci) {
// //tlv.load_from(is); if (b.service_class_indicator.size() != 2) {
// if (tlv.get_length() != 1) { throw pfcp_ie_value_exception(tlv.type, "service_class_indicator");
// throw pfcp_tlv_bad_length_exception(tlv.type, tlv.get_length(), }
// __FILE__, __LINE__); service_class_indicator = b.service_class_indicator;
// } tlv.add_length(2);
// is.read(reinterpret_cast<char*>(&todo), sizeof(todo)); }
// } }
// //-------- //--------
// void to_core_type(pfcp_ies_container& s) { pfcp_dl_flow_level_marking_ie() : pfcp_ie(PFCP_IE_DL_FLOW_LEVEL_MARKING) {
// pfcp::dl_flow_level_marking_t dl_flow_level_marking = {}; u1.b = 0;
// to_core_type(dl_flow_level_marking); tos_traffic_class = {};
// s.set(dl_flow_level_marking); service_class_indicator = {};
// } tlv.set_length(1);
//}; }
//--------
explicit pfcp_dl_flow_level_marking_ie(const pfcp_tlv& t) : pfcp_ie(t){};
//--------
void to_core_type(pfcp::dl_flow_level_marking_t& b) {
b = {};
b.ttc = u1.bf.ttc;
b.sci = u1.bf.sci;
if (u1.bf.ttc) {
b.tos_traffic_class = tos_traffic_class;
}
if (u1.bf.sci) {
b.service_class_indicator = service_class_indicator;
}
}
//--------
void dump_to(std::ostream& os) {
tlv.dump_to(os);
os.write(reinterpret_cast<const char*>(&u1.b), sizeof(u1.b));
char spare = 0;
os.write(reinterpret_cast<const char*>(&spare), sizeof(spare));
if (u1.bf.ttc) {
os << tos_traffic_class;
}
if (u1.bf.sci) {
os << service_class_indicator;
}
}
//--------
void load_from(std::istream& is) {
// tlv.load_from(is);
is.read(reinterpret_cast<char*>(&u1.b), sizeof(u1.b));
char spare = 0;
is.read(reinterpret_cast<char*>(&spare), sizeof(spare));
if (u1.bf.ttc) {
char e[2];
is.read(e, 2);
tos_traffic_class.assign(e, 2);
}
if (u1.bf.sci) {
char e[2];
is.read(e, 2);
service_class_indicator.assign(e, 2);
}
}
//--------
void to_core_type(pfcp_ies_container& s) {
pfcp::dl_flow_level_marking_t v = {};
to_core_type(v);
s.set(v);
}
};
////------------------------------------- ////-------------------------------------
//// IE HEADER_ENRICHMENT //// IE HEADER_ENRICHMENT
// class pfcp_header_enrichment_ie : public pfcp_ie { // class pfcp_header_enrichment_ie : public pfcp_ie {
...@@ -7208,51 +7346,54 @@ class pfcp_user_plane_inactivity_timer_ie : public pfcp_ie { ...@@ -7208,51 +7346,54 @@ class pfcp_user_plane_inactivity_timer_ie : public pfcp_ie {
// s.set(subsequent_time_quota); // s.set(subsequent_time_quota);
// } // }
//}; //};
////------------------------------------- //-------------------------------------
//// IE RQI // IE RQI
// class pfcp_rqi_ie : public pfcp_ie { class pfcp_rqi_ie : public pfcp_ie {
// public: public:
// uint8_t todo; union {
// struct {
// //-------- uint8_t rqi : 1;
// pfcp_rqi_ie(const pfcp::rqi_t& b) : pfcp_ie(PFCP_IE_RQI){ uint8_t spare : 7;
// todo = 0; } bf;
// tlv.set_length(1); uint8_t b;
// } } u1;
// //--------
// pfcp_rqi_ie() : pfcp_ie(PFCP_IE_RQI){ //--------
// todo = 0; pfcp_rqi_ie(const pfcp::rqi_t& b) : pfcp_ie(PFCP_IE_RQI) {
// tlv.set_length(1); u1.b = 0;
// } u1.bf.rqi = b.rqi;
// //-------- tlv.set_length(1);
// pfcp_rqi_ie(const pfcp_tlv& t) : pfcp_ie(t) { }
// todo = 0; //--------
// }; pfcp_rqi_ie() : pfcp_ie(PFCP_IE_RQI) {
// //-------- u1.b = 0;
// void to_core_type(pfcp::rqi_t& b) { tlv.set_length(1);
// b.todo = todo; }
// } //--------
// //-------- explicit pfcp_rqi_ie(const pfcp_tlv& t) : pfcp_ie(t){};
// void dump_to(std::ostream& os) { //--------
// tlv.dump_to(os); void to_core_type(pfcp::rqi_t& b) { b.rqi = u1.bf.rqi; }
// os.write(reinterpret_cast<const char*>(&todo), sizeof(todo)); //--------
// } void dump_to(std::ostream& os) {
// //-------- tlv.dump_to(os);
// void load_from(std::istream& is) { os.write(reinterpret_cast<const char*>(&u1.b), sizeof(u1.b));
// //tlv.load_from(is); }
// if (tlv.get_length() != 1) { //--------
// throw pfcp_tlv_bad_length_exception(tlv.type, tlv.get_length(), void load_from(std::istream& is) {
// __FILE__, __LINE__); // tlv.load_from(is);
// } if (tlv.get_length() != 1) {
// is.read(reinterpret_cast<char*>(&todo), sizeof(todo)); throw pfcp_tlv_bad_length_exception(
// } tlv.type, tlv.get_length(), __FILE__, __LINE__);
// //-------- }
// void to_core_type(pfcp_ies_container& s) { is.read(reinterpret_cast<char*>(&u1.b), sizeof(u1.b));
// pfcp::rqi_t rqi = {}; }
// to_core_type(rqi); //--------
// s.set(rqi); void to_core_type(pfcp_ies_container& s) {
// } pfcp::rqi_t v = {};
//}; to_core_type(v);
s.set(v);
}
};
//------------------------------------- //-------------------------------------
// IE QFI // IE QFI
class pfcp_qfi_ie : public pfcp_ie { class pfcp_qfi_ie : public pfcp_ie {
...@@ -9302,6 +9443,53 @@ class pfcp_create_qer_ie : public pfcp_grouped_ie { ...@@ -9302,6 +9443,53 @@ class pfcp_create_qer_ie : public pfcp_grouped_ie {
explicit pfcp_create_qer_ie(const pfcp::create_qer& b) explicit pfcp_create_qer_ie(const pfcp::create_qer& b)
: pfcp_grouped_ie(PFCP_IE_CREATE_QER) { : pfcp_grouped_ie(PFCP_IE_CREATE_QER) {
tlv.set_length(0); tlv.set_length(0);
if (b.qer_id.first) {
std::shared_ptr<pfcp_qer_id_ie> sie =
std::make_shared<pfcp_qer_id_ie>(b.qer_id.second);
add_ie(sie);
}
if (b.qer_correlation_id.first) {
std::shared_ptr<pfcp_qer_correlation_id_ie> sie =
std::make_shared<pfcp_qer_correlation_id_ie>(
b.qer_correlation_id.second);
add_ie(sie);
}
if (b.gate_status.first) {
std::shared_ptr<pfcp_gate_status_ie> sie =
std::make_shared<pfcp_gate_status_ie>(b.gate_status.second);
add_ie(sie);
}
if (b.maximum_bitrate.first) {
std::shared_ptr<pfcp_mbr_ie> sie =
std::make_shared<pfcp_mbr_ie>(b.maximum_bitrate.second);
add_ie(sie);
}
if (b.guaranteed_bitrate.first) {
std::shared_ptr<pfcp_gbr_ie> sie =
std::make_shared<pfcp_gbr_ie>(b.guaranteed_bitrate.second);
add_ie(sie);
}
if (b.packet_rate.first) {
std::shared_ptr<pfcp_packet_rate_ie> sie =
std::make_shared<pfcp_packet_rate_ie>(b.packet_rate.second);
add_ie(sie);
}
if (b.dl_flow_level_marking.first) {
std::shared_ptr<pfcp_dl_flow_level_marking_ie> sie =
std::make_shared<pfcp_dl_flow_level_marking_ie>(
b.dl_flow_level_marking.second);
add_ie(sie);
}
if (b.qos_flow_identifier.first) {
std::shared_ptr<pfcp_qfi_ie> sie =
std::make_shared<pfcp_qfi_ie>(b.qos_flow_identifier.second);
add_ie(sie);
}
if (b.reflective_qos.first) {
std::shared_ptr<pfcp_rqi_ie> sie =
std::make_shared<pfcp_rqi_ie>(b.reflective_qos.second);
add_ie(sie);
}
} }
//-------- //--------
pfcp_create_qer_ie() : pfcp_grouped_ie(PFCP_IE_CREATE_QER) {} pfcp_create_qer_ie() : pfcp_grouped_ie(PFCP_IE_CREATE_QER) {}
......
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