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

Merge branch 'basic_create_urr_support' into 'develop'

Basic create urr support

See merge request oai/cn5g/oai-cn5g-smf!72
parents 9b707ff3 54316604
......@@ -3550,51 +3550,61 @@ class pfcp_node_id_ie : public pfcp_ie {
// }
//};
////-------------------------------------
//// IE MEASUREMENT_METHOD
// class pfcp_measurement_method_ie : public pfcp_ie {
// public:
// uint8_t todo;
//
// //--------
// pfcp_measurement_method_ie(const pfcp::measurement_method_t& b) :
// pfcp_ie(PFCP_IE_MEASUREMENT_METHOD){
// todo = 0;
// tlv.set_length(1);
// }
// //--------
// pfcp_measurement_method_ie() : pfcp_ie(PFCP_IE_MEASUREMENT_METHOD){
// todo = 0;
// tlv.set_length(1);
// }
// //--------
// pfcp_measurement_method_ie(const pfcp_tlv& t) : pfcp_ie(t) {
// todo = 0;
// };
// //--------
// void to_core_type(pfcp::measurement_method_t& b) {
// b.todo = todo;
// }
// //--------
// void dump_to(std::ostream& os) {
// tlv.dump_to(os);
// os.write(reinterpret_cast<const char*>(&todo), sizeof(todo));
// }
// //--------
// void load_from(std::istream& is) {
// //tlv.load_from(is);
// if (tlv.get_length() != 1) {
// throw pfcp_tlv_bad_length_exception(tlv.type, tlv.get_length(),
// __FILE__, __LINE__);
// }
// is.read(reinterpret_cast<char*>(&todo), sizeof(todo));
// }
// //--------
// void to_core_type(pfcp_ies_container& s) {
// pfcp::measurement_method_t measurement_method = {};
// to_core_type(measurement_method);
// s.set(measurement_method);
// }
//};
// IE MEASUREMENT_METHOD
class pfcp_measurement_method_ie : public pfcp_ie {
public:
union {
struct {
uint8_t durat : 1;
uint8_t volum : 1;
uint8_t event : 1;
uint8_t spare : 5;
} bf;
uint8_t b;
} u1;
//--------
pfcp_measurement_method_ie(const pfcp::measurement_method_t& b)
: pfcp_ie(PFCP_IE_MEASUREMENT_METHOD) {
u1.b = 0;
u1.bf.durat = b.durat;
u1.bf.volum = b.volum;
u1.bf.event = b.event;
tlv.set_length(1);
}
//--------
pfcp_measurement_method_ie() : pfcp_ie(PFCP_IE_MEASUREMENT_METHOD) {
u1.b = 0;
tlv.set_length(1);
}
//--------
pfcp_measurement_method_ie(const pfcp_tlv& t) : pfcp_ie(t) { u1.b = 0; };
//--------
void to_core_type(pfcp::measurement_method_t& b) {
b.durat = u1.bf.durat;
b.volum = u1.bf.volum;
b.event = u1.bf.event;
}
//--------
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) {
// tlv.load_from(is);
if (tlv.get_length() != 1) {
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::measurement_method_t measurement_method = {};
to_core_type(measurement_method);
s.set(measurement_method);
}
};
////-------------------------------------
//// IE USAGE_REPORT_TRIGGER
// class pfcp_usage_report_trigger_ie : public pfcp_ie {
......@@ -4465,7 +4475,7 @@ class pfcp_urr_id_ie : public pfcp_ie {
void dump_to(std::ostream& os) {
tlv.dump_to(os);
auto be_urr_id = htobe32(urr_id);
os.write(reinterpret_cast<const char*>(&urr_id), sizeof(urr_id));
os.write(reinterpret_cast<const char*>(&be_urr_id), sizeof(be_urr_id));
}
//--------
void load_from(std::istream& is) {
......@@ -8781,10 +8791,23 @@ class pfcp_create_urr_ie : public pfcp_grouped_ie {
explicit pfcp_create_urr_ie(const pfcp::create_urr& b)
: pfcp_grouped_ie(PFCP_IE_CREATE_URR) {
tlv.set_length(0);
if (b.urr_id.first) {
std::shared_ptr<pfcp_urr_id_ie> sie(new pfcp_urr_id_ie(b.urr_id.second));
add_ie(sie);
}
if (b.urr_id.first) {
std::shared_ptr<pfcp_measurement_method_ie> sie(
new pfcp_measurement_method_ie(b.measurement_method.second));
add_ie(sie);
}
if (b.urr_id.first) {
std::shared_ptr<pfcp_reporting_triggers_ie> sie(
new pfcp_reporting_triggers_ie(b.reporting_triggers.second));
add_ie(sie);
}
// ToDo: Optional IEs
}
//--------
pfcp_create_urr_ie() : pfcp_grouped_ie(PFCP_IE_CREATE_URR) {}
//--------
explicit pfcp_create_urr_ie(const pfcp_tlv& t) : pfcp_grouped_ie(t) {}
//--------
void to_core_type(pfcp::duplicating_parameters& c) {
......
......@@ -2660,6 +2660,7 @@ class event_information : public pfcp::pfcp_ies_container {
//------------------------------------------------------------------------------
// Table 7.5.2.4-1: Create URR IE within PFCP Session Establishment Request
// Section 7.5.4.17: Create URR IE within PFCP Session Modification Request
class create_urr : public pfcp::pfcp_ies_container {
public:
std::pair<bool, pfcp::urr_id_t> urr_id;
......
......@@ -331,6 +331,18 @@ void smf_pdu_session::set_seid(const uint64_t& s) {
seid = s;
}
//------------------------------------------------------------------------------
// TODO check if urr_id should be uniq in the UPF or in the context of a pdn
// connection
void smf_pdu_session::generate_urr_id(pfcp::urr_id_t& urr_id) {
urr_id.urr_id = urr_id_generator.get_uid();
}
//------------------------------------------------------------------------------
void smf_pdu_session::release_urr_id(const pfcp::urr_id_t& urr_id) {
urr_id_generator.free_uid(urr_id.urr_id);
}
//------------------------------------------------------------------------------
// TODO check if far_id should be uniq in the UPF or in the context of a pdn
// connection
......
......@@ -296,7 +296,19 @@ class smf_pdu_session : public std::enable_shared_from_this<smf_pdu_session> {
* @return void
*/
void release_pdr_id(const pfcp::pdr_id_t& pdr_id);
/*
* Generate a URR ID
* @param [pfcp::urr_id_t &]: far_id: URR ID generated
* @return void
*/
void generate_urr_id(pfcp::urr_id_t& urr_id);
/*
* Release a URR ID
* @param [const pfcp::urr_id_t &]: far_id: URR ID to be released
* @return void
*/
void release_urr_id(const pfcp::urr_id_t& urr_id);
/*
* Generate a FAR ID
* @param [pfcp::far_id_t &]: far_id: FAR ID generated
......@@ -420,6 +432,7 @@ class smf_pdu_session : public std::enable_shared_from_this<smf_pdu_session> {
//
util::uint_generator<uint16_t> pdr_id_generator;
util::uint_generator<uint32_t> far_id_generator;
util::uint_generator<uint32_t> urr_id_generator;
uint32_t pdu_session_id;
std::string amf_id;
......
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