Control Message Encode/Decode
[ric-app/hw.git] / src / xapp-asn / e2ap / e2ap_control_ack.hpp
1 /*
2 ==================================================================================
3
4         Copyright (c) 2019-2020 AT&T Intellectual Property.
5
6    Licensed under the Apache License, Version 2.0 (the "License");
7    you may not use this file except in compliance with the License.
8    You may obtain a copy of the License at
9
10        http://www.apache.org/licenses/LICENSE-2.0
11
12    Unless required by applicable law or agreed to in writing, software
13    distributed under the License is distributed on an "AS IS" BASIS,
14    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15    See the License for the specific language governing permissions and
16    limitations under the License.
17 ==================================================================================
18 */
19 /*
20  * e2ap_control_ack.hpp
21  *
22  * Author: Shraboni Jana
23  */
24
25 /*-- **************************************************************
26 --
27 -- RIC CONTROL ACKNOWLEDGE
28 --
29 -- **************************************************************
30 RICcontrolAcknowledge ::= SEQUENCE {
31         protocolIEs                                     ProtocolIE-Container    {{RICcontrolAcknowledge-IEs}},
32         ...
33 }
34
35 RICcontrolAcknowledge-IEs E2AP-PROTOCOL-IES ::= {
36         { ID id-RICrequestID                            CRITICALITY reject      TYPE RICrequestID                                       PRESENCE mandatory      }|
37         { ID id-RANfunctionID                           CRITICALITY reject      TYPE RANfunctionID                                      PRESENCE mandatory      }|
38         { ID id-RICcallProcessID                        CRITICALITY reject      TYPE RICcallProcessID                           PRESENCE optional       }|
39         { ID id-RICcontrolStatus                        CRITICALITY reject      TYPE RICcontrolStatus                           PRESENCE mandatory      } |
40         { ID id-RICcontrolOutcome                       CRITICALITY reject      TYPE RICcontrolOutcome                          PRESENCE optional       },
41         ...
42 }*/
43
44 #ifndef SRC_XAPP_ASN_E2AP_E2AP_CONTROL_ACK_HPP_
45 #define SRC_XAPP_ASN_E2AP_E2AP_CONTROL_ACK_HPP_
46 #include <iostream>
47 #include <errno.h>
48 #include <mdclog/mdclog.h>
49 #include <sstream>
50 #include <memory>
51 #include <E2AP-PDU.h>
52 #include <SuccessfulOutcome.h>
53 #include <RICcontrolAcknowledge.h>
54 #include <ProtocolIE-Field.h>
55 #include "e2ap_consts.hpp"
56
57 class E2APControlAcknowledge{
58
59 public:
60   class ControlAcknowledgeIEs{
61   private:
62             long int ricRequestorID , ricInstanceID, ranFunctionID, ricCallProcessID,  ricControlStatus;
63
64             unsigned char ricCallProcessId[IE_SIZE];
65             size_t ricCallProcessId_size = IE_SIZE;
66             bool is_ricCallProcessId;
67             unsigned char ricControlOutcome[IE_SIZE];
68             size_t ricControlOutcome_size = IE_SIZE;
69             bool is_ricControlOutcome;
70
71           public:
72             ControlAcknowledgeIEs(void):ricRequestorID(1), ricInstanceID(1),ranFunctionID(1), ricCallProcessID(0),ricControlStatus(1),is_ricControlOutcome(false),is_ricCallProcessId(false){};
73             void* get_ricCallProcessId(){return this->ricCallProcessId;};
74             size_t get_ricCallProcessId_size(){return this->ricCallProcessId_size;};
75
76             void* get_ricControlOutcome(){return this->ricControlOutcome;};
77             size_t get_ricControlOutcome_size(){return this->ricControlOutcome_size;};
78
79             long int get_ricRequestorID(){return this->ricRequestorID;};
80             long int get_ricInstanceID(){return this->ricInstanceID;};
81             long int get_ranFunctionID(){return this->ranFunctionID;};
82             long int get_ricControlStatus(){return this->ricControlStatus;};
83
84             bool get_is_ricCallProcessId(){return is_ricCallProcessId;};
85             bool get_is_ricControlOutcome(){return is_ricControlOutcome;};
86
87
88             ControlAcknowledgeIEs& set_ricCallProcessID(std::string strCallProcID){
89                 is_ricCallProcessId = true; ricCallProcessId_size = strlen(strCallProcID.c_str());
90                 memcpy((char*)ricCallProcessId, strCallProcID.c_str(), ricCallProcessId_size);
91                 return *this;
92             }
93             ControlAcknowledgeIEs& set_ricCallProcessID(unsigned char* callproc, size_t callproc_size){
94                         is_ricCallProcessId = true;
95                         memcpy(ricCallProcessId, callproc, callproc_size); ricCallProcessId_size = callproc_size;
96                         return *this;
97                     }
98
99
100             ControlAcknowledgeIEs& set_ricControlOutcome(std::string strOutcome){
101                 is_ricControlOutcome = true; ricControlOutcome_size = strlen(strOutcome.c_str());
102                     memcpy((char*)ricControlOutcome, strOutcome.c_str(), ricControlOutcome_size);
103                     return *this;
104                 }
105             ControlAcknowledgeIEs& set_ricControlOutcome(unsigned char* callproc, size_t callproc_size){
106                 is_ricControlOutcome = true;
107                         memcpy(ricControlOutcome, callproc, callproc_size); ricControlOutcome_size = callproc_size;
108                         return *this;
109                 }
110
111
112             ControlAcknowledgeIEs& set_ricRequestorID(long int reqID){this->ricRequestorID = reqID; return *this;}
113             ControlAcknowledgeIEs& set_ricControlStatus(long int stat){this->ricControlStatus = stat; return *this;}
114             ControlAcknowledgeIEs& set_ricInstanceID(long int reqID){this->ricInstanceID = reqID; return *this;}
115             ControlAcknowledgeIEs& set_ranFunctionID(long int funcID){this->ranFunctionID = funcID; return *this;}
116
117   };
118   E2APControlAcknowledge(ControlAcknowledgeIEs &);
119   E2APControlAcknowledge(unsigned char *, size_t *);
120  ~E2APControlAcknowledge(void);
121   bool encode(unsigned char *, size_t *);
122   bool decode(unsigned char *, size_t *);
123   ControlAcknowledgeIEs& getIEs(){ return *_cntrlIEs.get();};
124   std::string get_error(void) const {return _error_string ; };
125 private:
126
127   E2AP_PDU_t * _e2ap_pdu_obj;
128   SuccessfulOutcome_t * _successMsg;
129   RICcontrolAcknowledge_IEs_t *IE_array;
130   std::string _error_string;
131   bool setfields(SuccessfulOutcome_t *);
132   bool getfields(SuccessfulOutcome_t *);
133   std::unique_ptr<ControlAcknowledgeIEs> _cntrlIEs;
134   char _errbuf[128];
135   size_t _errbuf_len = IE_SIZE;
136 };
137
138
139
140
141 #endif /* SRC_XAPP_ASN_E2AP_E2AP_CONTROL_ACK_HPP_ */