X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=e2sim%2Fsrc%2Fbase%2Fe2sim.cpp;h=83535b315be4ff37b0c8c15f1a8e0942c159d315;hb=eb80dc1196968a4d34ece42dd1c2e1d31923dec8;hp=e28cbd4a985657f2e921306b741dbb9c200bf116;hpb=417a0f7a4a7e90ebfb069908e6adb612a39e233d;p=sim%2Fe2-interface.git diff --git a/e2sim/src/base/e2sim.cpp b/e2sim/src/base/e2sim.cpp index e28cbd4..83535b3 100755 --- a/e2sim/src/base/e2sim.cpp +++ b/e2sim/src/base/e2sim.cpp @@ -29,6 +29,7 @@ #include "e2sim_sctp.hpp" #include "e2ap_message_handler.hpp" #include "encode_e2apv1.hpp" +#include "RANfunctionOID.h" using namespace std; @@ -39,13 +40,13 @@ std::unordered_map E2Sim::getRegistered_ran_functions() { } void E2Sim::register_subscription_callback(long func_id, SubscriptionCallback cb) { - fprintf(stderr,"%%%%about to register callback for subscription for func_id %d\n", func_id); + LOG_I("About to register callback for subscription for func_id %d", func_id); subscription_callbacks[func_id] = cb; } SubscriptionCallback E2Sim::get_subscription_callback(long func_id) { - fprintf(stderr, "%%%%we are getting the subscription callback for func id %d\n", func_id); + LOG_I("We are getting the subscription callback for func id %d", func_id); SubscriptionCallback cb; try { @@ -61,14 +62,10 @@ void E2Sim::register_e2sm(long func_id, OCTET_STRING_t *ostr) { //Error conditions: //If we already have an entry for func_id - - printf("%%%%about to register e2sm func desc for %d\n", func_id); - + LOG_I("About to register e2sm func desc for %d", func_id); ran_functions_registered[func_id] = ostr; - } - void E2Sim::encode_and_send_sctp_data(E2AP_PDU_t* pdu) { uint8_t *buf; @@ -77,7 +74,6 @@ void E2Sim::encode_and_send_sctp_data(E2AP_PDU_t* pdu) data.len = e2ap_asn1c_encode_pdu(pdu, &buf); memcpy(data.buffer, buf, min(data.len, MAX_SCTP_BUFFER)); if (buf) free(buf); - sctp_send_data(client_fd, data); } @@ -138,6 +134,11 @@ int E2Sim::run_loop(int argc, char* argv[]){ printf("client_fd value is %d\n", client_fd); std::vector all_funcs; + RANfunctionOID_t *ranFunctionOIDe = (RANfunctionOID_t*)calloc(1,sizeof(RANfunctionOID_t)); + uint8_t *buf = (uint8_t*)"OID123"; + ranFunctionOIDe->buf = (uint8_t*)calloc(1,strlen((char*)buf)+1); + memcpy(ranFunctionOIDe->buf, buf, strlen((char*)buf)+1); + ranFunctionOIDe->size = strlen((char*)buf); //Loop through RAN function definitions that are registered @@ -148,11 +149,12 @@ int E2Sim::run_loop(int argc, char* argv[]){ next_func.ranFunctionId = elem.first; next_func.ranFunctionDesc = elem.second; next_func.ranFunctionRev = (long)2; + next_func.ranFunctionOId = ranFunctionOIDe; + all_funcs.push_back(next_func); } printf("about to call setup request encode\n"); - generate_e2apv1_setup_request_parameterized(pdu_setup, all_funcs); printf("After generating e2setup req\n"); @@ -167,7 +169,7 @@ int E2Sim::run_loop(int argc, char* argv[]){ sctp_buffer_t data; char error_buf[300] = {0, }; - size_t errlen; + size_t errlen = 0; asn_check_constraints(&asn_DEF_E2AP_PDU, pdu_setup, error_buf, &errlen); printf("error length %d\n", errlen); @@ -187,6 +189,35 @@ int E2Sim::run_loop(int argc, char* argv[]){ LOG_E("[SCTP] Unable to send E2-SETUP-REQUEST to peer"); } + buffer_size = MAX_SCTP_BUFFER; + memset(buffer, '\0', sizeof(buffer)); + E2AP_PDU_t* pdu = (E2AP_PDU_t*)calloc(1,sizeof(E2AP_PDU)); + + LOG_D("about to call E2ResetRequest encode\n"); + + encoding::generate_e2apv2_reset_request(pdu); + + LOG_D("[E2AP] Created E2ResetRequest"); + + e2ap_asn1c_print_pdu(pdu); + + sctp_buffer_t resetdata; + + error_buf[300] = {0, }; + errlen = 0; + + asn_check_constraints(&asn_DEF_E2AP_PDU, pdu, error_buf, &errlen); + printf("error length %d\n", errlen); + printf("error buf %s\n", error_buf); + er = asn_encode_to_buffer(nullptr, ATS_ALIGNED_BASIC_PER, &asn_DEF_E2AP_PDU, pdu, buffer, buffer_size); + + resetdata.len = er.encoded; + fprintf(stderr, "er encoded is %d\n", er.encoded); + + memcpy(resetdata.buffer, buffer, er.encoded); + + LOG_I("Test to delete ReSet code"); + sctp_buffer_t recv_buf; LOG_I("[SCTP] Waiting for SCTP data");