X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2Fts_xapp%2Fts_xapp.cpp;h=d95bdbfedce0ed54f80bab521db498c190e9f0ed;hb=abe6b0860dfd287a4e507af074424756a58a457e;hp=02a88fef3e55be8d8eb993e0377171fec414c9e5;hpb=a1ae3a52ede2beeb84efc833f768c200727400db;p=ric-app%2Fts.git diff --git a/src/ts_xapp/ts_xapp.cpp b/src/ts_xapp/ts_xapp.cpp index 02a88fe..d95bdbf 100644 --- a/src/ts_xapp/ts_xapp.cpp +++ b/src/ts_xapp/ts_xapp.cpp @@ -42,13 +42,13 @@ #include #include #include - +#include #include #include #include #include #include - +#include #include #include #include @@ -59,6 +59,7 @@ #include #include #include +#include /* FIXME unfortunately this RMR flag has to be disabled @@ -114,6 +115,29 @@ unordered_map> cell_map; // maps each cell to its no int serving_cell_rsrp; }; */ + +//https://stackoverflow.com/a/34571089/15098882 + +static std::string base64_decode(const std::string &in) { + + std::string out; + + std::vector T(256, -1); + for (int i = 0; i < 64; i++) T["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[i]] = i; + + int val = 0, valb = -8; + for (unsigned char c : in) { + if (T[c] == -1) break; + val = (val << 6) + T[c]; + valb += 6; + if (valb >= 0) { + out.push_back(char((val >> valb) & 0xFF)); + valb -= 8; + } + } + return out; +} + struct PolicyHandler : public BaseReaderHandler, PolicyHandler> { /* Assuming we receive the following payload from A1 Mediator @@ -277,30 +301,83 @@ struct NodebListHandler : public BaseReaderHandler, NodebListHandler> { }; struct NodebHandler : public BaseReaderHandler, NodebHandler> { - string curr_key = ""; - shared_ptr nodeb = make_shared(); - - bool Key(const Ch* str, SizeType length, bool copy) { - curr_key = str; - return true; - } - - bool String(const Ch* str, SizeType length, bool copy) { - if( curr_key.compare( "ranName" ) == 0 ) { - nodeb->ran_name = str; - } else if( curr_key.compare( "plmnId" ) == 0 ) { - nodeb->global_nb_id.plmn_id = str; - } else if( curr_key.compare( "nbId" ) == 0 ) { - nodeb->global_nb_id.nb_id = str; - } else if( curr_key.compare( "cellId" ) == 0 ) { - cell_map[str] = nodeb; - } - return true; - } + string curr_key = ""; + shared_ptr nodeb = make_shared(); + std::string meid; + std::vector cells; + + bool Key(const Ch* str, SizeType length, bool copy) { + curr_key = str; + return true; + } + + bool String(const Ch* str, SizeType length, bool copy) { + + if (curr_key.compare("ranName") == 0) { + //std::cout << str << "\n"; + nodeb->ran_name = str; + meid= str; + //std::cout << "\n meid = " << meid; + + } + else if (curr_key.compare("plmnId") == 0) { + //std::cout << str << "\n"; + nodeb->global_nb_id.plmn_id = str; + } + else if (curr_key.compare("nbId") == 0) { + //std::cout <global_nb_id.nb_id = str; + } + else if (curr_key.compare("e2nodeComponentRequestPart") == 0) { + //std::cout << str<<"\n"; + auto message = base64_decode(str); + //std::cout << message<<"\n"; + int len = meid.length(); + //std::cout << "\n meid = " << meid; + int counter = 0; + for (int i = 0; i , UEDataHandler> { unordered_map cell_pred; std::string serving_cell_id; @@ -534,32 +611,48 @@ void send_grpc_control_request( string ue_id, string target_cell_id ) { shared_ptr request = make_shared(); rc::RICE2APHeader *apHeader = request->mutable_rice2apheaderdata(); - apHeader->set_ranfuncid( 300 ); - apHeader->set_ricrequestorid( 1001 ); + apHeader->set_ranfuncid(3); + apHeader->set_ricrequestorid( 1 ); rc::RICControlHeader *ctrlHeader = request->mutable_riccontrolheaderdata(); ctrlHeader->set_controlstyle( 3 ); ctrlHeader->set_controlactionid( 1 ); - ctrlHeader->set_ueid( ue_id ); + rc::UeId *ueid = ctrlHeader->mutable_ueid(); + rc::gNBUEID* gnbue= ueid->mutable_gnbueid(); + gnbue->set_amfuengapid(stoi(ue_id)); + gnbue->add_gnbcuuef1apid(stoi(ue_id)); + gnbue->add_gnbcucpuee1apid(stoi(ue_id)); + rc::Guami* gumi=gnbue->mutable_guami(); + //As of now hardcoded according to the value setted in VIAVI RSG TOOL + gumi->set_amfregionid("10100000"); + gumi->set_amfsetid("0000000000"); + gumi->set_amfpointer("000001"); + + //ctrlHeader->set_ueid( ue_id ); rc::RICControlMessage *ctrlMsg = request->mutable_riccontrolmessagedata(); - ctrlMsg->set_riccontrolcelltypeval( rc::RIC_CONTROL_CELL_UNKWON ); - ctrlMsg->set_targetcellid( target_cell_id ); + ctrlMsg->set_riccontrolcelltypeval( rc::RICControlCellTypeEnum::RIC_CONTROL_CELL_UNKWON ); + //ctrlMsg->set_riccontrolcelltypeval( api::RIC_CONTROL_CELL_UNKWON); + + ctrlMsg->set_targetcellid( target_cell_id); - auto data = cell_map.find( target_cell_id ); + auto data = cell_map.find(target_cell_id); if( data != cell_map.end() ) { request->set_e2nodeid( data->second->global_nb_id.nb_id ); request->set_plmnid( data->second->global_nb_id.plmn_id ); request->set_ranname( data->second->ran_name ); + gumi->set_plmnidentity(data->second->global_nb_id.plmn_id); } else { + cout << "[INFO] Cannot find RAN name corresponding to cell id = "<set_e2nodeid( "unknown_e2nodeid" ); request->set_plmnid( "unknown_plmnid" ); request->set_ranname( "unknown_ranname" ); + gumi->set_plmnidentity("unknown_plmnid"); } - request->set_riccontrolackreqval( rc::RIC_CONTROL_ACK_UNKWON ); // not yet used in api.proto - - cout << "[INFO] Sending gRPC control request to " << ts_control_ep << "\n" << request->DebugString(); - + request->set_riccontrolackreqval( rc::RICControlAckEnum::RIC_CONTROL_ACK_UNKWON ); + //request->set_riccontrolackreqval( api::RIC_CONTROL_ACK_UNKWON); // not yet used in api.proto + cout<<"\nin ts xapp grpc message content \n"<< request->DebugString()<<"\n"; grpc::Status status = rc_stub->SendRICControlReqServiceGrpc( &context, *request, &response ); if( status.ok() ) {