X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2Fxapp-asn%2Fe2sm%2Fe2sm_control.cc;h=7e1be7d9d2a707cb9bde1214b5bc4877d994b157;hb=28b894594573ab1e7087ed8fb50b208d7b135b07;hp=ba5f708f796e003579bbd6f68acaa3c70109cfc3;hpb=6d677813b02deda27db8039ec0de86a5332caa1f;p=ric-app%2Fhw.git diff --git a/src/xapp-asn/e2sm/e2sm_control.cc b/src/xapp-asn/e2sm/e2sm_control.cc index ba5f708..7e1be7d 100644 --- a/src/xapp-asn/e2sm/e2sm_control.cc +++ b/src/xapp-asn/e2sm/e2sm_control.cc @@ -1,93 +1,99 @@ /* - ================================================================================== +================================================================================== - Copyright (c) 2019-2020 AT&T Intellectual Property. + Copyright (c) 2019-2020 AT&T Intellectual Property. - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, softwares - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - ================================================================================== + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +================================================================================== */ /* - * e2sm_control.cc + * HWControlMessage.cc * - * Created on: Apr 30, 2020 + * Created on: Apr, 2020 * Author: Shraboni Jana */ /* Classes to handle E2 service model based on e2sm-HelloWorld-v001.asn */ #include "e2sm_control.hpp" //initialize - e2sm_control::e2sm_control(void){ + HWControlMessage::HWControlMessage(void){ - memset(&head_fmt1, 0, sizeof(E2SM_HelloWorld_ControlHeader_Format1_t)); + memset(&_message_fmt1, 0, sizeof(E2SM_HelloWorld_ControlMessage_Format1_t)); - memset(&msg_fmt1, 0, sizeof(E2SM_HelloWorld_ControlMessage_Format1_t)); + _message = 0; + _message = (E2SM_HelloWorld_ControlMessage_t*)calloc(1, sizeof(E2SM_HelloWorld_ControlMessage_t)); + assert(_message !=0); + _hw_msg_size = 0; + }; + //initialize + HWControlHeader::HWControlHeader(void){ - control_head = 0; - control_head = ( E2SM_HelloWorld_ControlHeader_t *)calloc(1, sizeof( E2SM_HelloWorld_ControlHeader_t)); - assert(control_head != 0); + memset(&_header_fmt1, 0, sizeof(E2SM_HelloWorld_ControlHeader_Format1_t)); - control_msg = 0; - control_msg = (E2SM_HelloWorld_ControlMessage_t*)calloc(1, sizeof(E2SM_HelloWorld_ControlMessage_t)); - assert(control_msg !=0); + _header = 0; + _header = ( E2SM_HelloWorld_ControlHeader_t *)calloc(1, sizeof( E2SM_HelloWorld_ControlHeader_t)); + assert(_header != 0); - errbuf_len = 128; - }; + _hw_header = 0; + }; - e2sm_control::~e2sm_control(void){ - mdclog_write(MDCLOG_DEBUG, "Freeing event trigger object memory"); + HWControlMessage::~HWControlMessage(void){ - control_head->choice.controlHeader_Format1 = 0; - - control_msg->choice.controlMessage_Format1 = 0; - - ASN_STRUCT_FREE(asn_DEF_E2SM_HelloWorld_ControlHeader, control_head); - ASN_STRUCT_FREE(asn_DEF_E2SM_HelloWorld_ControlMessage, control_msg); + mdclog_write(MDCLOG_DEBUG, "Freeing event trigger object memory"); + _message->choice.controlMessage_Format1 = 0; + ASN_STRUCT_FREE(asn_DEF_E2SM_HelloWorld_ControlMessage, _message); }; + HWControlHeader::~HWControlHeader(void){ -bool e2sm_control::encode_control_header(unsigned char *buf, size_t *size, e2sm_control_helper &helper){ + mdclog_write(MDCLOG_DEBUG, "Freeing event trigger object memory"); + _header->choice.controlHeader_Format1 = 0; + ASN_STRUCT_FREE(asn_DEF_E2SM_HelloWorld_ControlHeader, _header); + }; - ASN_STRUCT_RESET(asn_DEF_E2SM_HelloWorld_ControlHeader, control_head); +bool HWControlHeader::encode(unsigned char *buf, size_t *size){ + + ASN_STRUCT_RESET(asn_DEF_E2SM_HelloWorld_ControlHeader, _header); bool res; - res = set_fields(control_head, helper); + res = setfields(_header); if (!res){ return false; } - int ret_constr = asn_check_constraints(&asn_DEF_E2SM_HelloWorld_ControlHeader, control_head, errbuf, &errbuf_len); + int ret_constr = asn_check_constraints(&asn_DEF_E2SM_HelloWorld_ControlHeader, _header, _errbuf, &_errbuf_len); if(ret_constr){ - error_string.assign(&errbuf[0], errbuf_len); + _error_string.assign(&_errbuf[0], _errbuf_len); return false; } - xer_fprint(stdout, &asn_DEF_E2SM_HelloWorld_ControlHeader, control_head); + xer_fprint(stdout, &asn_DEF_E2SM_HelloWorld_ControlHeader, _header); - asn_enc_rval_t retval = asn_encode_to_buffer(0, ATS_ALIGNED_BASIC_PER, &asn_DEF_E2SM_HelloWorld_ControlHeader, control_head, buf, *size); + asn_enc_rval_t retval = asn_encode_to_buffer(0, ATS_ALIGNED_BASIC_PER, &asn_DEF_E2SM_HelloWorld_ControlHeader, _header, buf, *size); if(retval.encoded == -1){ - error_string.assign(strerror(errno)); + _error_string.assign(strerror(errno)); return false; } else if (retval.encoded > *size){ std::stringstream ss; ss <<"Error encoding event trigger definition. Reason = encoded pdu size " << retval.encoded << " exceeds buffer size " << *size << std::endl; - error_string = ss.str(); + _error_string = ss.str(); return false; } else{ @@ -97,33 +103,32 @@ bool e2sm_control::encode_control_header(unsigned char *buf, size_t *size, e2sm_ return true; } -bool e2sm_control::encode_control_message(unsigned char *buf, size_t *size, e2sm_control_helper &helper){ +bool HWControlMessage::encode(unsigned char *buf, size_t *size){ bool res; - res = set_fields(control_msg, helper); + res = setfields(_message); if (!res){ return false; } - - int ret_constr = asn_check_constraints(&asn_DEF_E2SM_HelloWorld_ControlMessage, control_msg, errbuf, &errbuf_len); + int ret_constr = asn_check_constraints(&asn_DEF_E2SM_HelloWorld_ControlMessage, _message, _errbuf, &_errbuf_len); if(ret_constr){ - error_string.assign(&errbuf[0], errbuf_len); + _error_string.assign(&_errbuf[0], _errbuf_len); return false; } - xer_fprint(stdout, &asn_DEF_E2SM_HelloWorld_ControlMessage, control_msg); + xer_fprint(stdout, &asn_DEF_E2SM_HelloWorld_ControlMessage, _message); - asn_enc_rval_t retval = asn_encode_to_buffer(0, ATS_ALIGNED_BASIC_PER, &asn_DEF_E2SM_HelloWorld_ControlMessage, control_msg, buf, *size); + asn_enc_rval_t retval = asn_encode_to_buffer(0, ATS_ALIGNED_BASIC_PER, &asn_DEF_E2SM_HelloWorld_ControlMessage, _message, buf, *size); if(retval.encoded == -1){ - error_string.assign(strerror(errno)); + _error_string.assign(strerror(errno)); return false; } else if (retval.encoded > *size){ std::stringstream ss; ss <<"Error encoding action definition. Reason = encoded pdu size " << retval.encoded << " exceeds buffer size " << *size << std::endl; - error_string = ss.str(); + _error_string = ss.str(); return false; } else{ @@ -133,63 +138,32 @@ bool e2sm_control::encode_control_message(unsigned char *buf, size_t *size, e2sm return true; } -bool e2sm_control::set_fields(E2SM_HelloWorld_ControlHeader_t * ref_control_head, e2sm_control_helper & helper){ +bool HWControlHeader::setfields(E2SM_HelloWorld_ControlHeader_t * _header){ - if(ref_control_head == 0){ - error_string = "Invalid reference for Event Trigger Definition set fields"; + if(_header == 0){ + _error_string = "Invalid reference for Event Trigger Definition set fields"; return false; } - ref_control_head->present = E2SM_HelloWorld_ControlHeader_PR_controlHeader_Format1; - - head_fmt1.controlHeaderParam = helper.header; - - ref_control_head->choice.controlHeader_Format1 = &head_fmt1; + _header->present = E2SM_HelloWorld_ControlHeader_PR_controlHeader_Format1; + _header_fmt1.controlHeaderParam = this->get_hw_header(); + _header->choice.controlHeader_Format1 = &_header_fmt1; return true; }; -bool e2sm_control::set_fields(E2SM_HelloWorld_ControlMessage_t * ref_control_msg, e2sm_control_helper & helper){ +bool HWControlMessage::setfields(E2SM_HelloWorld_ControlMessage_t * _message){ - if(ref_control_msg == 0){ - error_string = "Invalid reference for Event Action Definition set fields"; + if(_message == 0){ + _error_string = "Invalid reference for Event Action Definition set fields"; return false; } - ref_control_msg->present = E2SM_HelloWorld_ControlMessage_PR_controlMessage_Format1; - - msg_fmt1.controlMsgParam.buf = helper.message; - msg_fmt1.controlMsgParam.size = helper.message_len; - - - ref_control_msg->choice.controlMessage_Format1 = &msg_fmt1; + _message->present = E2SM_HelloWorld_ControlMessage_PR_controlMessage_Format1; + _message_fmt1.controlMsgParam.buf = this->get_hw_message(); + _message_fmt1.controlMsgParam.size = this->get_hw_message_size(); + _message->choice.controlMessage_Format1 = &_message_fmt1; return true; }; -bool e2sm_control::get_fields(E2SM_HelloWorld_ControlHeader_t * ref_indictaion_header, e2sm_control_helper & helper){ - - if (ref_indictaion_header == 0){ - error_string = "Invalid reference for Control Header get fields"; - return false; - } - - helper.header = ref_indictaion_header->choice.controlHeader_Format1->controlHeaderParam; - return true; -} - -bool e2sm_control::get_fields(E2SM_HelloWorld_ControlMessage_t * ref_control_message, e2sm_control_helper & helper){ - - if (ref_control_message == 0){ - error_string = "Invalid reference for Control Message get fields"; - return false; - } - helper.message = ref_control_message->choice.controlMessage_Format1->controlMsgParam.buf; - helper.message_len = ref_control_message->choice.controlMessage_Format1->controlMsgParam.size; - - return true; - } - - - -