Update release version to 4.4.0
[ric-plt/e2mgr.git] / E2Manager / 3rdparty / asn1codec / src / configuration_update_wrapper.c
1 /*
2  * Copyright 2019 AT&T Intellectual Property
3  * Copyright 2019 Nokia
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 /*
19  * This source code is part of the near-RT RIC (RAN Intelligent Controller)
20  * platform project (RICP).
21  */
22
23
24 #include <string.h>
25 #include <errno.h>
26 #undef NDEBUG
27 #include <assert.h>
28 #include <asn_application.h>
29 #include <E2AP-PDU.h>
30 #include <ProcedureCode.h>
31 #include <SuccessfulOutcome.h>
32 #include <UnsuccessfulOutcome.h>
33 #include <ProtocolIE-ID.h>
34 #include <ProtocolIE-Field.h>
35 #include <configuration_update_wrapper.h>
36
37 /*
38  * Build and pack ENB Configuration Update Acknowledge (successful outcome response).
39  * Abort the process on allocation failure.
40  *  packed_buf_size - in: size of packed_buf; out: number of chars used.
41  */
42 bool
43 build_pack_x2enb_configuration_update_ack(
44                 size_t* packed_buf_size,
45         unsigned char* packed_buf,
46                 size_t err_buf_size,
47                 char* err_buf)
48 {
49         bool rc = true;
50         E2AP_PDU_t *pdu = calloc(1, sizeof(E2AP_PDU_t));
51         SuccessfulOutcome_t *successfulOutcome = calloc(1, sizeof(SuccessfulOutcome_t));
52         ENBConfigurationUpdateAcknowledge_t *enbConfigurationUpdateAcknowledge;
53         ENBConfigurationUpdateAcknowledge_IEs_t *enbConfigurationUpdateAcknowledge_IEs = calloc(1, sizeof(ENBConfigurationUpdateAcknowledge_IEs_t));
54
55     assert(pdu != 0);
56     assert(successfulOutcome != 0);
57     assert(enbConfigurationUpdateAcknowledge_IEs != 0);
58
59     pdu->present = E2AP_PDU_PR_successfulOutcome;
60     pdu->choice.successfulOutcome = successfulOutcome;
61
62     successfulOutcome->procedureCode = ProcedureCode_id_eNBConfigurationUpdate;
63     successfulOutcome->criticality = Criticality_reject;
64     successfulOutcome->value.present = SuccessfulOutcome__value_PR_ENBConfigurationUpdateAcknowledge;
65     enbConfigurationUpdateAcknowledge = &successfulOutcome->value.choice.ENBConfigurationUpdateAcknowledge;
66
67     enbConfigurationUpdateAcknowledge_IEs->id = ProtocolIE_ID_id_CriticalityDiagnostics;
68         enbConfigurationUpdateAcknowledge_IEs->criticality = Criticality_ignore;
69         enbConfigurationUpdateAcknowledge_IEs->value.present =  ENBConfigurationUpdateAcknowledge_IEs__value_PR_CriticalityDiagnostics;
70
71     ASN_SEQUENCE_ADD(&enbConfigurationUpdateAcknowledge->protocolIEs, enbConfigurationUpdateAcknowledge_IEs);
72
73         rc = per_pack_pdu(pdu, packed_buf_size, packed_buf,err_buf_size, err_buf);
74
75     ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pdu);
76     return rc;
77 }
78
79 /*
80  * Build and pack ENB Configuration Update Failure (unsuccessful outcome message).
81  * Abort the process on allocation failure.
82  *  packed_buf_size - in: size of packed_buf; out: number of chars used.
83  */
84 bool
85 build_pack_x2enb_configuration_update_failure(
86                 size_t* packed_buf_size,
87         unsigned char* packed_buf,
88         size_t err_buf_size,
89                 char* err_buf)
90 {
91         bool rc = true;
92         E2AP_PDU_t *pdu = calloc(1, sizeof(E2AP_PDU_t));
93         UnsuccessfulOutcome_t *unsuccessfulOutcome = calloc(1, sizeof(UnsuccessfulOutcome_t));
94         ENBConfigurationUpdateFailure_t *enbConfigurationUpdateFailure;
95         ENBConfigurationUpdateFailure_IEs_t *enbConfigurationUpdateFailure_IEs = calloc(1, sizeof(ENBConfigurationUpdateFailure_IEs_t));
96
97     assert(pdu != 0);
98     assert(unsuccessfulOutcome != 0);
99     assert(enbConfigurationUpdateFailure_IEs != 0);
100
101
102     pdu->present = E2AP_PDU_PR_unsuccessfulOutcome;
103     pdu->choice.unsuccessfulOutcome = unsuccessfulOutcome;
104
105     unsuccessfulOutcome->procedureCode = ProcedureCode_id_eNBConfigurationUpdate;
106     unsuccessfulOutcome->criticality = Criticality_reject;
107     unsuccessfulOutcome->value.present = UnsuccessfulOutcome__value_PR_ENBConfigurationUpdateFailure;
108     enbConfigurationUpdateFailure = &unsuccessfulOutcome->value.choice.ENBConfigurationUpdateFailure;
109
110     enbConfigurationUpdateFailure_IEs->id = ProtocolIE_ID_id_Cause;
111         enbConfigurationUpdateFailure_IEs->criticality = Criticality_ignore;
112         enbConfigurationUpdateFailure_IEs->value.present = ENBConfigurationUpdateFailure_IEs__value_PR_Cause;
113         enbConfigurationUpdateFailure_IEs->value.choice.Cause.present = Cause_PR_protocol;
114         enbConfigurationUpdateFailure_IEs->value.choice.Cause.choice.protocol= CauseProtocol_abstract_syntax_error_reject;
115     ASN_SEQUENCE_ADD(&enbConfigurationUpdateFailure->protocolIEs, enbConfigurationUpdateFailure_IEs);
116
117
118     rc = per_pack_pdu(pdu, packed_buf_size, packed_buf,err_buf_size, err_buf);
119
120     ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pdu);
121     return rc;
122 }
123
124 /*
125  * Build and pack ENDC Configuration Update Acknowledge (successful outcome response).
126  * Abort the process on allocation failure.
127  *  packed_buf_size - in: size of packed_buf; out: number of chars used.
128  */
129 bool
130 build_pack_endc_configuration_update_ack(
131                 size_t* packed_buf_size,
132                 unsigned char* packed_buf,
133                 size_t err_buf_size,
134                 char* err_buf)
135 {
136         bool rc = true;
137         E2AP_PDU_t *pdu = calloc(1, sizeof(E2AP_PDU_t));
138         SuccessfulOutcome_t *successfulOutcome = calloc(1, sizeof(SuccessfulOutcome_t));
139         ENDCConfigurationUpdateAcknowledge_t *endcConfigurationUpdateAcknowledge;
140         ENDCConfigurationUpdateAcknowledge_IEs_t *endcConfigurationUpdateAcknowledge_IEs = calloc(1, sizeof(ENDCConfigurationUpdateAcknowledge_IEs_t));
141
142     assert(pdu != 0);
143     assert(successfulOutcome != 0);
144     assert(endcConfigurationUpdateAcknowledge_IEs != 0);
145
146     pdu->present = E2AP_PDU_PR_successfulOutcome;
147     pdu->choice.successfulOutcome = successfulOutcome;
148
149     successfulOutcome->procedureCode = ProcedureCode_id_endcConfigurationUpdate;
150     successfulOutcome->criticality = Criticality_reject;
151     successfulOutcome->value.present = SuccessfulOutcome__value_PR_ENDCConfigurationUpdateAcknowledge;
152     endcConfigurationUpdateAcknowledge = &successfulOutcome->value.choice.ENDCConfigurationUpdateAcknowledge;
153     ASN_SEQUENCE_ADD(&endcConfigurationUpdateAcknowledge->protocolIEs, endcConfigurationUpdateAcknowledge_IEs);
154
155     endcConfigurationUpdateAcknowledge_IEs->id = ProtocolIE_ID_id_RespondingNodeType_EndcConfigUpdate;
156         endcConfigurationUpdateAcknowledge_IEs->criticality = Criticality_reject;
157         endcConfigurationUpdateAcknowledge_IEs->value.present = ENDCConfigurationUpdateAcknowledge_IEs__value_PR_RespondingNodeType_EndcConfigUpdate;
158         endcConfigurationUpdateAcknowledge_IEs->value.choice.RespondingNodeType_EndcConfigUpdate.present = RespondingNodeType_EndcConfigUpdate_PR_respond_eNB;
159
160         ProtocolIE_Container_119P95_t *enb_ENDCConfigUpdateAckIEs_Container = calloc(1, sizeof(ProtocolIE_Container_119P95_t));
161         assert(enb_ENDCConfigUpdateAckIEs_Container != 0);
162         endcConfigurationUpdateAcknowledge_IEs->value.choice.RespondingNodeType_EndcConfigUpdate.choice.respond_eNB = (struct ProtocolIE_Container*)enb_ENDCConfigUpdateAckIEs_Container;
163
164         //Leave the respond_eNB container empty (ENB_ENDCConfigUpdateAckIEs_t is an empty element).
165
166     rc = per_pack_pdu(pdu, packed_buf_size, packed_buf,err_buf_size, err_buf);
167
168     ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pdu);
169     return rc;
170 }
171
172 /*
173  * Build and pack ENDC Configuration Update Failure (unsuccessful outcome message).
174  * Abort the process on allocation failure.
175  *  packed_buf_size - in: size of packed_buf; out: number of chars used.
176  */
177 bool
178 build_pack_endc_configuration_update_failure(
179                 size_t* packed_buf_size,
180         unsigned char* packed_buf,
181         size_t err_buf_size,
182                 char* err_buf)
183 {
184         bool rc = true;
185         E2AP_PDU_t *pdu = calloc(1, sizeof(E2AP_PDU_t));
186         UnsuccessfulOutcome_t *unsuccessfulOutcome = calloc(1, sizeof(UnsuccessfulOutcome_t));
187         ENDCConfigurationUpdateFailure_t *endcConfigurationUpdateFailure;
188         ENDCConfigurationUpdateFailure_IEs_t *endcConfigurationUpdateFailure_IEs = calloc(1, sizeof(ENDCConfigurationUpdateFailure_IEs_t));
189
190     assert(pdu != 0);
191     assert(unsuccessfulOutcome != 0);
192     assert(endcConfigurationUpdateFailure_IEs != 0);
193
194
195     pdu->present = E2AP_PDU_PR_unsuccessfulOutcome;
196     pdu->choice.unsuccessfulOutcome = unsuccessfulOutcome;
197
198     unsuccessfulOutcome->procedureCode = ProcedureCode_id_endcConfigurationUpdate;
199     unsuccessfulOutcome->criticality = Criticality_reject;
200     unsuccessfulOutcome->value.present = UnsuccessfulOutcome__value_PR_ENDCConfigurationUpdateFailure;
201     endcConfigurationUpdateFailure = &unsuccessfulOutcome->value.choice.ENDCConfigurationUpdateFailure;
202
203     endcConfigurationUpdateFailure_IEs->id = ProtocolIE_ID_id_Cause;
204     endcConfigurationUpdateFailure_IEs->criticality = Criticality_ignore;
205     endcConfigurationUpdateFailure_IEs->value.present = ENDCConfigurationUpdateFailure_IEs__value_PR_Cause;
206     endcConfigurationUpdateFailure_IEs->value.choice.Cause.present = Cause_PR_protocol;
207     endcConfigurationUpdateFailure_IEs->value.choice.Cause.choice.protocol= CauseProtocol_abstract_syntax_error_reject;
208     ASN_SEQUENCE_ADD(&endcConfigurationUpdateFailure->protocolIEs, endcConfigurationUpdateFailure_IEs);
209
210     rc = per_pack_pdu(pdu, packed_buf_size, packed_buf,err_buf_size, err_buf);
211
212     ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pdu);
213     return rc;
214 }
215