From 085267b6f8aaa197dc6971f5634362c77f11778a Mon Sep 17 00:00:00 2001 From: Ron Shacham Date: Wed, 20 May 2020 22:09:23 -0400 Subject: [PATCH] Added support for A1 Policy Create message parsing Signed-off-by: Ron Shacham Change-Id: I002d447b0c908b94deda50e92ace58115bbe05aa --- container-tag.yaml | 2 +- docs/rel-notes.rst | 4 +++ src/ts_xapp/ts_xapp.cpp | 84 +++++++++++++++++++++++++++++++++++++++++++-- xapp-descriptor/config.json | 2 +- 4 files changed, 87 insertions(+), 5 deletions(-) diff --git a/container-tag.yaml b/container-tag.yaml index 65ce26e..5da5941 100644 --- a/container-tag.yaml +++ b/container-tag.yaml @@ -1,3 +1,3 @@ # this is used by CI jobs to apply a tag when it builds the image --- -tag: '1.0.4' +tag: '1.0.5' diff --git a/docs/rel-notes.rst b/docs/rel-notes.rst index c866179..3f25bbd 100644 --- a/docs/rel-notes.rst +++ b/docs/rel-notes.rst @@ -9,6 +9,10 @@ Traffic Steering xAPP ===================== +2020 May 20 Version 1.0.5 +---------------------------- + Support parsing of A1 Policy Create message + 2020 May 20 Version 1.0.4 ---------------------------- Ensure that the SDL libraries are included in the image. diff --git a/src/ts_xapp/ts_xapp.cpp b/src/ts_xapp/ts_xapp.cpp index 4cb3ebc..5a760e6 100644 --- a/src/ts_xapp/ts_xapp.cpp +++ b/src/ts_xapp/ts_xapp.cpp @@ -85,6 +85,74 @@ struct UEData { }; +struct PolicyHandler : public BaseReaderHandler, PolicyHandler> { + unordered_map cell_pred; + std::string ue_id; + bool ue_id_found = false; + string curr_key = ""; + string curr_value = ""; + int policy_type_id; + int policy_instance_id; + int threshold; + std::string operation; + bool found_threshold = false; + + + bool Null() { cout << "Null()" << endl; return true; } + bool Bool(bool b) { cout << "Bool(" << boolalpha << b << ")" << endl; return true; } + bool Int(int i) { + cout << "Int(" << i << ")" << endl; + if (curr_key.compare("policy_type_id") == 0) { + policy_type_id = i; + } else if (curr_key.compare("policy_instance_id") == 0) { + policy_instance_id = i; + } else if (curr_key.compare("threshold") == 0) { + found_threshold = true; + threshold = i; + } + + return true; + } + bool Uint(unsigned u) { + cout << "Int(" << u << ")" << endl; + if (curr_key.compare("policy_type_id") == 0) { + policy_type_id = u; + } else if (curr_key.compare("policy_instance_id") == 0) { + policy_instance_id = u; + } else if (curr_key.compare("threshold") == 0) { + found_threshold = true; + threshold = u; + } + + return true; + } + bool Int64(int64_t i) { cout << "Int64(" << i << ")" << endl; return true; } + bool Uint64(uint64_t u) { cout << "Uint64(" << u << ")" << endl; return true; } + bool Double(double d) { cout << "Double(" << d << ")" << endl; return true; } + bool String(const char* str, SizeType length, bool copy) { + cout << "String(" << str << ", " << length << ", " << boolalpha << copy << ")" << endl; + if (curr_key.compare("operation") != 0) { + operation = str; + } + + return true; + } + bool StartObject() { + cout << "StartObject()" << endl; + return true; + } + bool Key(const char* str, SizeType length, bool copy) { + cout << "Key(" << str << ", " << length << ", " << boolalpha << copy << ")" << endl; + curr_key = str; + + return true; + } + bool EndObject(SizeType memberCount) { cout << "EndObject(" << memberCount << ")" << endl; return true; } + bool StartArray() { cout << "StartArray()" << endl; return true; } + bool EndArray(SizeType elementCount) { cout << "EndArray(" << elementCount << ")" << endl; return true; } + +}; + struct PredictionHandler : public BaseReaderHandler, PredictionHandler> { unordered_map cell_pred; std::string ue_id; @@ -266,8 +334,18 @@ void policy_callback( Message& mbuf, int mtype, int subid, int len, Msg_componen mbuf.Send_response( 101, -1, 5, (unsigned char *) "OK1\n" ); // validate that we can use the same buffer for 2 rts calls mbuf.Send_response( 101, -1, 5, (unsigned char *) "OK2\n" ); + const char *arg = (const char*)payload.get(); + + PolicyHandler handler; + Reader reader; + StringStream ss(arg); + reader.Parse(ss,handler); + //Set the threshold value + if (handler.found_threshold) { + rsrp_threshold = handler.threshold; + } } @@ -363,11 +441,11 @@ void prediction_callback( Message& mbuf, int mtype, int subid, int len, Msg_comp fprintf(stderr, "cb 1\n"); - char *incoming_msg = "{\"12345\": {\"222\": \"20000\", \"333\" : \"50000\"} }"; + const char* arg = (const char*)payload.get(); PredictionHandler handler; Reader reader; - StringStream ss(incoming_msg); + StringStream ss(arg); reader.Parse(ss,handler); std::string pred_ue_id = handler.ue_id; @@ -482,7 +560,7 @@ extern int main( int argc, char** argv ) { nsu = Namespace(sdl_namespace_u); nsc = Namespace(sdl_namespace_c); - + fprintf( stderr, " listening on port: %s\n", port ); xfw = std::unique_ptr( new Xapp( port, true ) ); // new xAPP thing; wait for a route table diff --git a/xapp-descriptor/config.json b/xapp-descriptor/config.json index 6c4e52a..d492f95 100644 --- a/xapp-descriptor/config.json +++ b/xapp-descriptor/config.json @@ -7,7 +7,7 @@ "image": { "registry": "nexus3.o-ran-sc.org:10002", "name": "o-ran-sc/ric-app-ts", - "tag": "1.0.4" + "tag": "1.0.5" } } ], -- 2.16.6