blob: 69f1dcb5d8d44fca225f4e25e313fa8e091eb269 [file] [log] [blame]
Juha Hyttinenff8dccd2019-12-10 14:34:07 +02001/*
2==================================================================================
3 Copyright (c) 2019 AT&T Intellectual Property.
4 Copyright (c) 2019 Nokia
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#include <stdio.h>
21#include <stdlib.h>
22
23#include "E2AP-PDU.h"
24#include "ProtocolIE-Field.h"
25#include "RICsubsequentAction.h"
26#include "E2SM-gNB-X2-eventTriggerDefinition.h"
27#include "E2SM-gNB-X2-indicationHeader.h"
28#include "E2SM-gNB-X2-indicationMessage.h"
29#include "asn_constant.h"
30#include "E2AP_if.h"
31
32#ifdef DEBUG
33 static const bool debug = true;
34#else
35 static const bool debug = false;
36#endif
37
38
39const int64_t cMaxNrOfErrors = 256;
40
41const uint64_t cMaxSizeOfOctetString = 1024;
42
43const size_t cMacroENBIDP_20Bits = 20;
44const size_t cHomeENBID_28Bits = 28;
45const size_t cShortMacroENBID_18Bits = 18;
46const size_t clongMacroENBIDP_21Bits = 21;
47
48const int cRICCauseRadioNetwork = 1; // this is content of type RICCause_t
49const int cRICCauseTransport = 2; // this is content of type RICCause_t
50const int cRICCauseProtocol = 3; // this is content of type RICCause_t
51const int cRICCauseMisc = 4; // this is content of type RICCause_t
52const int cRICCauseRic = 5; // this is content of type RICCause_t
53
54//////////////////////////////////////////////////////////////////////
55// Message definitons
56
57// Below constant values are same as in E2AP, E2SM and X2AP specs
58const uint64_t cE2InitiatingMessage = 1;
59const uint64_t cE2SuccessfulOutcome = 2;
60const uint64_t cE2UnsuccessfulOutcome = 3;
61
62// E2AP messages
63// Initiating message
64const uint64_t cRICSubscriptionRequest = 1;
65const uint64_t cRICSubscriptionDeleteRequest = 2;
66const uint64_t cRICIndication = 11;
67
68// Successful outcome
69const uint64_t cRICSubscriptionResponse = 1;
70const uint64_t cRICsubscriptionDeleteResponse = 2;
71
72// Unsuccessful outcome
73const uint64_t cRICSubscriptionFailure = 1;
74const uint64_t cRICsubscriptionDeleteFailure = 2;
75
76typedef union {
77 uint32_t nodeID;
78 uint8_t octets[4];
79} IdOctects_t;
80
81//////////////////////////////////////////////////////////////////////
82const char* getE2ErrorString(uint64_t errorCode) {
83
84 return E2ErrorStrings[errorCode];
85}
86
87/////////////////////////////////////////////////////////////////////
88bool E2encode(E2AP_PDU_t* pE2AP_PDU, size_t* dataBufferSize, byte* dataBuffer, char* pLogBuffer) {
89
90 // Debug print
91 if (debug)
92 asn_fprint(stdout, &asn_DEF_E2AP_PDU, pE2AP_PDU);
93
94 asn_enc_rval_t rval;
95 rval = asn_encode_to_buffer(0, ATS_ALIGNED_BASIC_PER, &asn_DEF_E2AP_PDU, pE2AP_PDU, dataBuffer, *dataBufferSize);
96 if (rval.encoded == -1) {
Anssi Mannila4721d4e2020-01-16 09:14:47 +020097 sprintf(pLogBuffer,"Serialization of %s failed.", asn_DEF_E2AP_PDU.name);
Juha Hyttinenff8dccd2019-12-10 14:34:07 +020098 ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pE2AP_PDU);
99 return false;
100 }
101 else if (rval.encoded > *dataBufferSize) {
Anssi Mannila4721d4e2020-01-16 09:14:47 +0200102 sprintf(pLogBuffer,"Buffer of size %zu is too small for %s, need %zu",*dataBufferSize, asn_DEF_E2AP_PDU.name, rval.encoded);
Juha Hyttinenff8dccd2019-12-10 14:34:07 +0200103 ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pE2AP_PDU);
104 return false;
105 }
106 else {
107 if (debug)
Anssi Mannila4721d4e2020-01-16 09:14:47 +0200108 sprintf(pLogBuffer,"Successfully encoded %s. Buffer size %zu, encoded size %zu",asn_DEF_E2AP_PDU.name, *dataBufferSize, rval.encoded);
Juha Hyttinenff8dccd2019-12-10 14:34:07 +0200109
110 ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pE2AP_PDU);
111 *dataBufferSize = rval.encoded;
112 return true;
113 }
114}
115
116//////////////////////////////////////////////////////////////////////
117uint64_t packRICSubscriptionRequest(size_t* pdataBufferSize, byte* pDataBuffer, char* pLogBuffer, RICSubscriptionRequest_t* pRICSubscriptionRequest) {
118
119 E2AP_PDU_t* pE2AP_PDU = calloc(1, sizeof(E2AP_PDU_t));
120 if(pE2AP_PDU)
121 {
122 pE2AP_PDU->present = E2AP_PDU_PR_initiatingMessage;
123 pE2AP_PDU->choice.initiatingMessage.procedureCode = ProcedureCode_id_ricSubscription;
124 pE2AP_PDU->choice.initiatingMessage.criticality = Criticality_ignore;
125 pE2AP_PDU->choice.initiatingMessage.value.present = RICInitiatingMessage__value_PR_RICsubscriptionRequest;
126
127 // RICrequestID
128 RICsubscriptionRequest_IEs_t* pRICsubscriptionRequest_IEs = calloc(1, sizeof(RICsubscriptionRequest_IEs_t));
129 if (pRICsubscriptionRequest_IEs) {
130 pRICsubscriptionRequest_IEs->id = ProtocolIE_ID_id_RICrequestID;
131 pRICsubscriptionRequest_IEs->criticality = Criticality_reject;
132 pRICsubscriptionRequest_IEs->value.present = RICsubscriptionRequest_IEs__value_PR_RICrequestID;
133 pRICsubscriptionRequest_IEs->value.choice.RICrequestID.ricRequestorID = pRICSubscriptionRequest->ricRequestID.ricRequestorID;
134 pRICsubscriptionRequest_IEs->value.choice.RICrequestID.ricRequestSequenceNumber = pRICSubscriptionRequest->ricRequestID.ricRequestSequenceNumber;
135 ASN_SEQUENCE_ADD(&pE2AP_PDU->choice.initiatingMessage.value.choice.RICsubscriptionRequest.protocolIEs.list, pRICsubscriptionRequest_IEs);
136 }
137 else
138 return e2err_RICSubscriptionRequestAllocRICrequestIDFail;
139
140 // RANfunctionID
141 pRICsubscriptionRequest_IEs = calloc(1, sizeof(RICsubscriptionRequest_IEs_t));
142 if (pRICsubscriptionRequest_IEs) {
143 pRICsubscriptionRequest_IEs->id = ProtocolIE_ID_id_RANfunctionID;
144 pRICsubscriptionRequest_IEs->criticality = Criticality_reject;
145 pRICsubscriptionRequest_IEs->value.present = RICsubscriptionRequest_IEs__value_PR_RANfunctionID;
146 pRICsubscriptionRequest_IEs->value.choice.RANfunctionID = pRICSubscriptionRequest->ranFunctionID;
147 ASN_SEQUENCE_ADD(&pE2AP_PDU->choice.initiatingMessage.value.choice.RICsubscriptionRequest.protocolIEs.list, pRICsubscriptionRequest_IEs);
148 }
149 else
150 return e2err_RICSubscriptionRequestAllocRANfunctionIDFail;
151
152 // RICsubscription
153 pRICsubscriptionRequest_IEs = calloc(1, sizeof(RICsubscriptionRequest_IEs_t));
154 if (pRICsubscriptionRequest_IEs) {
155 pRICsubscriptionRequest_IEs->id = ProtocolIE_ID_id_RICsubscription;
156 pRICsubscriptionRequest_IEs->criticality = Criticality_reject;
157 pRICsubscriptionRequest_IEs->value.present = RICsubscriptionRequest_IEs__value_PR_RICsubscription;
158
159 // RICeventTriggerDefinition
160 uint64_t returnCode;
161 if ((returnCode = packRICEventTriggerDefinition(pLogBuffer, &pRICSubscriptionRequest->ricSubscription.ricEventTriggerDefinition) != e2err_OK))
162 return returnCode;
163
164 pRICsubscriptionRequest_IEs->value.choice.RICsubscription.ricEventTriggerDefinition.buf =
165 calloc(1, pRICSubscriptionRequest->ricSubscription.ricEventTriggerDefinition.octetString.contentLength);
166 if (pRICsubscriptionRequest_IEs->value.choice.RICsubscription.ricEventTriggerDefinition.buf) {
167 pRICsubscriptionRequest_IEs->value.choice.RICsubscription.ricEventTriggerDefinition.size =
168 pRICSubscriptionRequest->ricSubscription.ricEventTriggerDefinition.octetString.contentLength;
169 memcpy(pRICsubscriptionRequest_IEs->value.choice.RICsubscription.ricEventTriggerDefinition.buf,
170 pRICSubscriptionRequest->ricSubscription.ricEventTriggerDefinition.octetString.data,
171 pRICSubscriptionRequest->ricSubscription.ricEventTriggerDefinition.octetString.contentLength);
172 }
173 else
174 return e2err_RICSubscriptionRequestAllocRICeventTriggerDefinitionBufFail;
175
176 // RICactions-ToBeSetup-List
177 uint64_t index = 0;
178 while (index < pRICSubscriptionRequest->ricSubscription.ricActionToBeSetupItemIEs.contentLength && index < maxofRICactionID) {
179
180 RICaction_ToBeSetup_ItemIEs_t* pRICaction_ToBeSetup_ItemIEs = calloc(1, sizeof(RICaction_ToBeSetup_ItemIEs_t));
181 if (pRICaction_ToBeSetup_ItemIEs) {
182 pRICaction_ToBeSetup_ItemIEs->id = ProtocolIE_ID_id_RICaction_ToBeSetup_Item;
183 pRICaction_ToBeSetup_ItemIEs->criticality = Criticality_reject;
184 pRICaction_ToBeSetup_ItemIEs->value.present = RICaction_ToBeSetup_ItemIEs__value_PR_RICaction_ToBeSetup_Item;
185 // RICActionID
186 pRICaction_ToBeSetup_ItemIEs->value.choice.RICaction_ToBeSetup_Item.ricActionID =
187 pRICSubscriptionRequest->ricSubscription.ricActionToBeSetupItemIEs.ricActionToBeSetupItem[index].ricActionID;
188 // RICActionType
189 pRICaction_ToBeSetup_ItemIEs->value.choice.RICaction_ToBeSetup_Item.ricActionType =
190 pRICSubscriptionRequest->ricSubscription.ricActionToBeSetupItemIEs.ricActionToBeSetupItem[index].ricActionType;
191 }
192 else
193 return e2err_RICSubscriptionRequestAllocRICaction_ToBeSetup_ItemIEsFail;
194
195 // RICactionDefinition, OPTIONAL
196 // This is not used in RIC
197
198 // RICsubsequentAction, OPTIONAL
199 RICsubsequentAction_t* pRICsubsequentAction = calloc(1, sizeof(RICsubsequentAction_t));
200 if (pRICsubsequentAction) {
201 pRICsubsequentAction->ricSubsequentActionType =
202 pRICSubscriptionRequest->ricSubscription.ricActionToBeSetupItemIEs.ricActionToBeSetupItem[index].ricSubsequentAction.ricSubsequentActionType;
203 pRICsubsequentAction->ricTimeToWait =
204 pRICSubscriptionRequest->ricSubscription.ricActionToBeSetupItemIEs.ricActionToBeSetupItem[index].ricSubsequentAction.ricTimeToWait;
205 pRICaction_ToBeSetup_ItemIEs->value.choice.RICaction_ToBeSetup_Item.ricSubsequentAction = pRICsubsequentAction;
206 }
207 else
208 return e2err_RICSubscriptionRequestAllocRICsubsequentActionFail;
209
210 ASN_SEQUENCE_ADD(&pRICsubscriptionRequest_IEs->value.choice.RICsubscription.ricAction_ToBeSetup_List.list, pRICaction_ToBeSetup_ItemIEs);
211 index++;
212 }
213 ASN_SEQUENCE_ADD(&pE2AP_PDU->choice.initiatingMessage.value.choice.RICsubscriptionRequest.protocolIEs.list, pRICsubscriptionRequest_IEs);
214 }
215 else
216 return e2err_RICSubscriptionRequestAllocRICsubscriptionRequest_IEsFail;
217
218 if (E2encode(pE2AP_PDU, pdataBufferSize, pDataBuffer, pLogBuffer))
219 return e2err_OK;
220 else
221 return e2err_RICSubscriptionRequestEncodeFail;
222 }
223 return e2err_RICSubscriptionRequestAllocE2AP_PDUFail;
224}
225
226//////////////////////////////////////////////////////////////////////
227uint64_t packRICEventTriggerDefinition(char* pLogBuffer, RICEventTriggerDefinition_t* pRICEventTriggerDefinition) {
228
229 E2SM_gNB_X2_eventTriggerDefinition_t* pE2SM_gNB_X2_eventTriggerDefinition = calloc(1, sizeof(E2SM_gNB_X2_eventTriggerDefinition_t));
230 if(pE2SM_gNB_X2_eventTriggerDefinition)
231 {
232 // RICeventTriggerDefinition
233 // InterfaceID
234 if ((pRICEventTriggerDefinition->interfaceID.globalENBIDPresent == true && pRICEventTriggerDefinition->interfaceID.globalGNBIDPresent == true) ||
235 (pRICEventTriggerDefinition->interfaceID.globalENBIDPresent == false && pRICEventTriggerDefinition->interfaceID.globalGNBIDPresent == false))
236 return e2err_RICEventTriggerDefinitionIEValueFail_1;
237
238 // GlobalENB-ID or GlobalGNB-ID
239 if (pRICEventTriggerDefinition->interfaceID.globalENBIDPresent)
240 {
241 pE2SM_gNB_X2_eventTriggerDefinition->interface_ID.present = Interface_ID_PR_global_eNB_ID;
242
243 // GlobalENB-ID
244 // PLMN-Identity
245 pE2SM_gNB_X2_eventTriggerDefinition->interface_ID.choice.global_eNB_ID.pLMN_Identity.size =
246 pRICEventTriggerDefinition->interfaceID.globalENBID.pLMNIdentity.contentLength;
247 pE2SM_gNB_X2_eventTriggerDefinition->interface_ID.choice.global_eNB_ID.pLMN_Identity.buf = calloc(1,3);
248 if (pE2SM_gNB_X2_eventTriggerDefinition->interface_ID.choice.global_eNB_ID.pLMN_Identity.buf) {
249 memcpy(pE2SM_gNB_X2_eventTriggerDefinition->interface_ID.choice.global_eNB_ID.pLMN_Identity.buf,
250 pRICEventTriggerDefinition->interfaceID.globalENBID.pLMNIdentity.pLMNIdentityVal,
251 pRICEventTriggerDefinition->interfaceID.globalENBID.pLMNIdentity.contentLength);
252 }
253 else
254 return e2err_RICIndicationAllocRICEventTriggerDefinitionglobal_eNB_IDpLMN_IdentityBufFail;
255
256 // Add ENB-ID
257 if (pRICEventTriggerDefinition->interfaceID.globalENBID.nodeID.bits == cMacroENBIDP_20Bits){
258 // BIT STRING (SIZE (20)
259 pE2SM_gNB_X2_eventTriggerDefinition->interface_ID.choice.global_eNB_ID.eNB_ID.present = ENB_ID_PR_macro_eNB_ID;
260 pE2SM_gNB_X2_eventTriggerDefinition->interface_ID.choice.global_eNB_ID.eNB_ID.choice.macro_eNB_ID.buf = calloc(1,3);
261 if (pE2SM_gNB_X2_eventTriggerDefinition->interface_ID.choice.global_eNB_ID.eNB_ID.choice.macro_eNB_ID.buf) {
262 pE2SM_gNB_X2_eventTriggerDefinition->interface_ID.choice.global_eNB_ID.eNB_ID.choice.macro_eNB_ID.size = 3; // bytes
263 pE2SM_gNB_X2_eventTriggerDefinition->interface_ID.choice.global_eNB_ID.eNB_ID.choice.macro_eNB_ID.bits_unused = 4; // trailing unused bits
264 memcpy(pE2SM_gNB_X2_eventTriggerDefinition->interface_ID.choice.global_eNB_ID.eNB_ID.choice.macro_eNB_ID.buf,
265 (void*)&pRICEventTriggerDefinition->interfaceID.globalENBID.nodeID.nodeID,3);
266 }
267 else
268 return e2err_RICIndicationAllocRICEventTriggerDefinitionglobal_eNB_IDeNB_IDmacro_eNB_IDBufFail;
269 }
270 else if (pRICEventTriggerDefinition->interfaceID.globalENBID.nodeID.bits == cHomeENBID_28Bits) {
271 // BIT STRING (SIZE (28)
272 pE2SM_gNB_X2_eventTriggerDefinition->interface_ID.choice.global_eNB_ID.eNB_ID.present = ENB_ID_PR_home_eNB_ID;
273 pE2SM_gNB_X2_eventTriggerDefinition->interface_ID.choice.global_eNB_ID.eNB_ID.choice.home_eNB_ID.buf = calloc(1,4);
274 if (pE2SM_gNB_X2_eventTriggerDefinition->interface_ID.choice.global_eNB_ID.eNB_ID.choice.home_eNB_ID.buf) {
275 pE2SM_gNB_X2_eventTriggerDefinition->interface_ID.choice.global_eNB_ID.eNB_ID.choice.home_eNB_ID.size = 4; // bytes
276 pE2SM_gNB_X2_eventTriggerDefinition->interface_ID.choice.global_eNB_ID.eNB_ID.choice.home_eNB_ID.bits_unused = 4; // trailing unused bits
277 memcpy(pE2SM_gNB_X2_eventTriggerDefinition->interface_ID.choice.global_eNB_ID.eNB_ID.choice.home_eNB_ID.buf,
278 (void*)&pRICEventTriggerDefinition->interfaceID.globalENBID.nodeID.nodeID,4);
279 }
280 else
281 return e2err_RICIndicationAllocRICEventTriggerDefinitionglobal_eNB_IDeNB_IDhome_eNB_IDBufFail;
282 }
283 else if (pRICEventTriggerDefinition->interfaceID.globalENBID.nodeID.bits == cShortMacroENBID_18Bits) {
284 // BIT STRING (SIZE(18)
285 pE2SM_gNB_X2_eventTriggerDefinition->interface_ID.choice.global_eNB_ID.eNB_ID.present = ENB_ID_PR_short_Macro_eNB_ID;
286 pE2SM_gNB_X2_eventTriggerDefinition->interface_ID.choice.global_eNB_ID.eNB_ID.choice.short_Macro_eNB_ID.buf = calloc(1,3);
287 if (pE2SM_gNB_X2_eventTriggerDefinition->interface_ID.choice.global_eNB_ID.eNB_ID.choice.short_Macro_eNB_ID.buf) {
288 pE2SM_gNB_X2_eventTriggerDefinition->interface_ID.choice.global_eNB_ID.eNB_ID.choice.short_Macro_eNB_ID.size = 3;
289 pE2SM_gNB_X2_eventTriggerDefinition->interface_ID.choice.global_eNB_ID.eNB_ID.choice.short_Macro_eNB_ID.bits_unused = 6; // trailing unused bits
290 memcpy(pE2SM_gNB_X2_eventTriggerDefinition->interface_ID.choice.global_eNB_ID.eNB_ID.choice.short_Macro_eNB_ID.buf,
291 (void*)&pRICEventTriggerDefinition->interfaceID.globalENBID.nodeID.nodeID,3);
292 }
293 else
294 return e2err_RICIndicationAllocRICEventTriggerDefinitionglobal_eNB_IDeNB_IDshort_Macro_eNB_IDBufFail;
295 }
296 else if (pRICEventTriggerDefinition->interfaceID.globalENBID.nodeID.bits == clongMacroENBIDP_21Bits) {
297 // BIT STRING (SIZE(21)
298 pE2SM_gNB_X2_eventTriggerDefinition->interface_ID.choice.global_eNB_ID.eNB_ID.present = ENB_ID_PR_long_Macro_eNB_ID;
299 pE2SM_gNB_X2_eventTriggerDefinition->interface_ID.choice.global_eNB_ID.eNB_ID.choice.long_Macro_eNB_ID.buf = calloc(1,3);
300 if (pE2SM_gNB_X2_eventTriggerDefinition->interface_ID.choice.global_eNB_ID.eNB_ID.choice.long_Macro_eNB_ID.buf) {
301 pE2SM_gNB_X2_eventTriggerDefinition->interface_ID.choice.global_eNB_ID.eNB_ID.choice.long_Macro_eNB_ID.size = 3; // bytes
302 pE2SM_gNB_X2_eventTriggerDefinition->interface_ID.choice.global_eNB_ID.eNB_ID.choice.long_Macro_eNB_ID.bits_unused = 3; // trailing unused bits
303 memcpy(pE2SM_gNB_X2_eventTriggerDefinition->interface_ID.choice.global_eNB_ID.eNB_ID.choice.long_Macro_eNB_ID.buf,
304 (void*)&pRICEventTriggerDefinition->interfaceID.globalENBID.nodeID.nodeID,3);
305 }
306 else
307 return e2err_RICIndicationAllocRICEventTriggerDefinitionglobal_eNB_IDeNB_IDlong_Macro_eNB_IDBufFail;
308 }
309 else
310 return e2err_RICEventTriggerDefinitionIEValueFail_2;
311
312 }
313 else if (pRICEventTriggerDefinition->interfaceID.globalGNBIDPresent) {
314 // GlobalGNB-ID
315 pE2SM_gNB_X2_eventTriggerDefinition->interface_ID.present = Interface_ID_PR_global_gNB_ID;
316
317 // PLMN-Identity
318 pE2SM_gNB_X2_eventTriggerDefinition->interface_ID.choice.global_gNB_ID.pLMN_Identity.size =
319 pRICEventTriggerDefinition->interfaceID.globalGNBID.pLMNIdentity.contentLength;
320 pE2SM_gNB_X2_eventTriggerDefinition->interface_ID.choice.global_gNB_ID.pLMN_Identity.buf =
321 calloc(1,pRICEventTriggerDefinition->interfaceID.globalGNBID.pLMNIdentity.contentLength);
322 if (pE2SM_gNB_X2_eventTriggerDefinition->interface_ID.choice.global_gNB_ID.pLMN_Identity.buf) {
323 memcpy(pE2SM_gNB_X2_eventTriggerDefinition->interface_ID.choice.global_gNB_ID.pLMN_Identity.buf,
324 (void*)&pRICEventTriggerDefinition->interfaceID.globalGNBID.pLMNIdentity.pLMNIdentityVal,
325 pRICEventTriggerDefinition->interfaceID.globalGNBID.pLMNIdentity.contentLength);
326 }
327 else
328 return e2err_RICIndicationAllocRICEventTriggerDefinitionglobal_gNB_IDpLMN_IdentityBufFail;
329
330 // GNB-ID, BIT STRING (SIZE (22..32)
331 pE2SM_gNB_X2_eventTriggerDefinition->interface_ID.choice.global_gNB_ID.gNB_ID.choice.gNB_ID.size = 4; //32bits
332 pE2SM_gNB_X2_eventTriggerDefinition->interface_ID.choice.global_gNB_ID.gNB_ID.choice.gNB_ID.buf = calloc(1, 4);
333 if (pE2SM_gNB_X2_eventTriggerDefinition->interface_ID.choice.global_gNB_ID.gNB_ID.choice.gNB_ID.buf) {
334 memcpy(pE2SM_gNB_X2_eventTriggerDefinition->interface_ID.choice.global_gNB_ID.gNB_ID.choice.gNB_ID.buf,
335 (void*)&pRICEventTriggerDefinition->interfaceID.globalGNBID,4); //32bits
336 }
337 else
338 return e2err_RICIndicationAllocRICEventTriggerDefinitionglobal_gNB_IDgNB_IDBufFail;
339 }
340 else
341 return e2err_RICEventTriggerDefinitionIEValueFail_3;
342
343 // InterfaceDirection
344 pE2SM_gNB_X2_eventTriggerDefinition->interfaceDirection = pRICEventTriggerDefinition->interfaceDirection;
345
346 // InterfaceMessageType
347 // ProcedureCode
348 pE2SM_gNB_X2_eventTriggerDefinition->interfaceMessageType.procedureCode = pRICEventTriggerDefinition->interfaceMessageType.procedureCode;
349
350 // TypeOfMessage
351 if(pRICEventTriggerDefinition->interfaceMessageType.typeOfMessage == cE2InitiatingMessage)
352 pE2SM_gNB_X2_eventTriggerDefinition->interfaceMessageType.typeOfMessage = TypeOfMessage_initiating_message;
353 else if(pRICEventTriggerDefinition->interfaceMessageType.typeOfMessage == cE2SuccessfulOutcome)
354 pE2SM_gNB_X2_eventTriggerDefinition->interfaceMessageType.typeOfMessage = TypeOfMessage_successful_outcome;
355 else if(pRICEventTriggerDefinition->interfaceMessageType.typeOfMessage == cE2UnsuccessfulOutcome)
356 pE2SM_gNB_X2_eventTriggerDefinition->interfaceMessageType.typeOfMessage = TypeOfMessage_unsuccessful_outcome;
357 else
358 return e2err_RICEventTriggerDefinitionIEValueFail_4;
359
360 // InterfaceProtocolIE-List, OPTIONAL
361
362 // Debug print
363 if (debug)
364 asn_fprint(stdout, &asn_DEF_E2SM_gNB_X2_eventTriggerDefinition, pE2SM_gNB_X2_eventTriggerDefinition);
365
366 // Encode
367 size_t bufferSize = sizeof(pRICEventTriggerDefinition->octetString.data);
368 asn_enc_rval_t rval;
369 rval = asn_encode_to_buffer(0, ATS_ALIGNED_BASIC_PER, &asn_DEF_E2SM_gNB_X2_eventTriggerDefinition, pE2SM_gNB_X2_eventTriggerDefinition,
370 pRICEventTriggerDefinition->octetString.data, bufferSize);
371 if(rval.encoded == -1)
372 {
Anssi Mannila4721d4e2020-01-16 09:14:47 +0200373 sprintf(pLogBuffer,"Serialization of %s failed.", asn_DEF_E2SM_gNB_X2_eventTriggerDefinition.name);
Juha Hyttinenff8dccd2019-12-10 14:34:07 +0200374 return e2err_RICEventTriggerDefinitionPackFail_1;
375 }
376 else if(rval.encoded > bufferSize)
377 {
Anssi Mannila4721d4e2020-01-16 09:14:47 +0200378 sprintf(pLogBuffer,"Buffer of size %zu is too small for %s, need %zu",bufferSize, asn_DEF_E2SM_gNB_X2_eventTriggerDefinition.name, rval.encoded);
Juha Hyttinenff8dccd2019-12-10 14:34:07 +0200379 return e2err_RICEventTriggerDefinitionPackFail_2;
380 }
381 else
382 if (debug)
Anssi Mannila4721d4e2020-01-16 09:14:47 +0200383 sprintf(pLogBuffer,"Successfully encoded %s. Buffer size %zu, encoded size %zu",asn_DEF_E2SM_gNB_X2_eventTriggerDefinition.name, bufferSize, rval.encoded);
Juha Hyttinenff8dccd2019-12-10 14:34:07 +0200384
385 ASN_STRUCT_FREE(asn_DEF_E2SM_gNB_X2_eventTriggerDefinition, pE2SM_gNB_X2_eventTriggerDefinition);
386
387 pRICEventTriggerDefinition->octetString.contentLength = rval.encoded;
388 return e2err_OK;
389 }
390 return e2err_RICEventTriggerDefinitionAllocE2SM_gNB_X2_eventTriggerDefinitionFail;
391}
392
393//////////////////////////////////////////////////////////////////////
394uint64_t packRICSubscriptionResponse(size_t* pDataBufferSize, byte* pDataBuffer, char* pLogBuffer, RICSubscriptionResponse_t* pRICSubscriptionResponse) {
395
396 E2AP_PDU_t* pE2AP_PDU = calloc(1, sizeof(E2AP_PDU_t));
397 if(pE2AP_PDU)
398 {
399 pE2AP_PDU->present = E2AP_PDU_PR_successfulOutcome;
400 pE2AP_PDU->choice.initiatingMessage.procedureCode = ProcedureCode_id_ricSubscription;
401 pE2AP_PDU->choice.initiatingMessage.criticality = Criticality_ignore;
402 pE2AP_PDU->choice.initiatingMessage.value.present = RICSuccessfulOutcome__value_PR_RICsubscriptionResponse;
403
404 // RICrequestID
405 RICsubscriptionResponse_IEs_t* pRICsubscriptionResponse_IEs = calloc(1, sizeof(RICsubscriptionResponse_IEs_t));
406 if (pRICsubscriptionResponse_IEs) {
407 pRICsubscriptionResponse_IEs->id = ProtocolIE_ID_id_RICrequestID;
408 pRICsubscriptionResponse_IEs->criticality = Criticality_reject;
409 pRICsubscriptionResponse_IEs->value.present = RICsubscriptionResponse_IEs__value_PR_RICrequestID;
410 pRICsubscriptionResponse_IEs->value.choice.RICrequestID.ricRequestorID = pRICSubscriptionResponse->ricRequestID.ricRequestorID;
411 pRICsubscriptionResponse_IEs->value.choice.RICrequestID.ricRequestSequenceNumber = pRICSubscriptionResponse->ricRequestID.ricRequestSequenceNumber;
412 ASN_SEQUENCE_ADD(&pE2AP_PDU->choice.successfulOutcome.value.choice.RICsubscriptionResponse.protocolIEs.list, pRICsubscriptionResponse_IEs);
413 }
414 else
415 return e2err_RICSubscriptionResponseAllocRICrequestIDFail;
416
417 // RANfunctionID
418 pRICsubscriptionResponse_IEs = calloc(1, sizeof(RICsubscriptionResponse_IEs_t));
419 if (pRICsubscriptionResponse_IEs) {
420 pRICsubscriptionResponse_IEs->id = ProtocolIE_ID_id_RANfunctionID;
421 pRICsubscriptionResponse_IEs->criticality = Criticality_reject;
422 pRICsubscriptionResponse_IEs->value.present = RICsubscriptionResponse_IEs__value_PR_RANfunctionID;
423 pRICsubscriptionResponse_IEs->value.choice.RANfunctionID = pRICSubscriptionResponse->ranFunctionID;
424 ASN_SEQUENCE_ADD(&pE2AP_PDU->choice.successfulOutcome.value.choice.RICsubscriptionResponse.protocolIEs.list, pRICsubscriptionResponse_IEs);
425 }
426 else
427 return e2err_RICSubscriptionResponseAllocRANfunctionIDFail;
428
429 // RICaction-Admitted list
430 pRICsubscriptionResponse_IEs = calloc(1, sizeof(RICsubscriptionResponse_IEs_t));
431 if (pRICsubscriptionResponse_IEs) {
432 pRICsubscriptionResponse_IEs->id = ProtocolIE_ID_id_RICactions_Admitted;
433 pRICsubscriptionResponse_IEs->criticality = Criticality_reject;
434 pRICsubscriptionResponse_IEs->value.present = RICsubscriptionResponse_IEs__value_PR_RICaction_Admitted_List;
435
436 uint64_t index = 0;
437 while (index < pRICSubscriptionResponse->ricActionAdmittedList.contentLength && index < maxofRICactionID) {
438
439 RICaction_Admitted_ItemIEs_t* pRICaction_Admitted_ItemIEs = calloc(1, sizeof (RICaction_Admitted_ItemIEs_t));
440 if (pRICaction_Admitted_ItemIEs)
441 {
442 pRICaction_Admitted_ItemIEs->id = ProtocolIE_ID_id_RICaction_Admitted_Item;
443 pRICaction_Admitted_ItemIEs->criticality = Criticality_reject;
444 pRICaction_Admitted_ItemIEs->value.present = RICaction_Admitted_ItemIEs__value_PR_RICaction_Admitted_Item;
445
446 // RICActionID
447 pRICaction_Admitted_ItemIEs->value.choice.RICaction_Admitted_Item.ricActionID = pRICSubscriptionResponse->ricActionAdmittedList.ricActionID[index];
448 ASN_SEQUENCE_ADD(&pRICsubscriptionResponse_IEs->value.choice.RICaction_Admitted_List.list, pRICaction_Admitted_ItemIEs);
449 }
450 else
451 return e2err_RICSubscriptionResponseAllocRICaction_Admitted_ItemIEsFail;
452 index++;
453 }
454 }
455 else
456 return e2err_RICSubscriptionResponseAllocRICActionAdmittedListFail;
457
458 ASN_SEQUENCE_ADD(&pE2AP_PDU->choice.successfulOutcome.value.choice.RICsubscriptionResponse.protocolIEs.list, pRICsubscriptionResponse_IEs);
459
460 // RICaction-NotAdmitted list
461 if (pRICSubscriptionResponse->ricActionNotAdmittedListPresent) {
462 pRICsubscriptionResponse_IEs = calloc(1, sizeof(RICsubscriptionResponse_IEs_t));
463 if (pRICsubscriptionResponse_IEs) {
464 pRICsubscriptionResponse_IEs->id = ProtocolIE_ID_id_RICactions_NotAdmitted;
465 pRICsubscriptionResponse_IEs->criticality = Criticality_reject;
466 pRICsubscriptionResponse_IEs->value.present = RICsubscriptionResponse_IEs__value_PR_RICaction_NotAdmitted_List;
467
468 uint64_t index = 0;
469 while (index < pRICSubscriptionResponse->ricActionNotAdmittedList.contentLength && index < maxofRICactionID) {
470
471 RICaction_NotAdmitted_ItemIEs_t* pRICaction_NotAdmitted_ItemIEs = calloc(1, sizeof (RICaction_NotAdmitted_ItemIEs_t));
472 if (pRICaction_NotAdmitted_ItemIEs)
473 {
474 pRICaction_NotAdmitted_ItemIEs->id = ProtocolIE_ID_id_RICaction_NotAdmitted_Item;
475 pRICaction_NotAdmitted_ItemIEs->criticality = Criticality_reject;
476 pRICaction_NotAdmitted_ItemIEs->value.present = RICaction_NotAdmitted_ItemIEs__value_PR_RICaction_NotAdmitted_Item;
477
478 // RICActionID
479 pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.ricActionID =
480 pRICSubscriptionResponse->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].ricActionID;
481
482 // RICCause
483 if (pRICSubscriptionResponse->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].ricCause.content == RICcause_PR_radioNetwork) {
484 pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.ricCause.present = RICcause_PR_radioNetwork;
485 pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.ricCause.choice.radioNetwork =
486 pRICSubscriptionResponse->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].ricCause.cause;
487 }
488 else if (pRICSubscriptionResponse->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].ricCause.content == RICcause_PR_transport) {
489 pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.ricCause.present = RICcause_PR_transport;
490 pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.ricCause.choice.transport =
491 pRICSubscriptionResponse->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].ricCause.cause;
492 }
493 else if (pRICSubscriptionResponse->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].ricCause.content == RICcause_PR_protocol) {
494 pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.ricCause.present = RICcause_PR_protocol;
495 pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.ricCause.choice.protocol =
496 pRICSubscriptionResponse->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].ricCause.cause;
497 }
498 else if (pRICSubscriptionResponse->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].ricCause.content == RICcause_PR_misc) {
499 pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.ricCause.present = RICcause_PR_misc;
500 pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.ricCause.choice.misc =
501 pRICSubscriptionResponse->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].ricCause.cause;
502 }
503 else if (pRICSubscriptionResponse->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].ricCause.content == RICcause_PR_ric) {
504 pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.ricCause.present = RICcause_PR_ric;
505 pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.ricCause.choice.ric =
506 pRICSubscriptionResponse->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].ricCause.cause;
507 }
508 ASN_SEQUENCE_ADD(&pRICsubscriptionResponse_IEs->value.choice.RICaction_NotAdmitted_List.list, pRICaction_NotAdmitted_ItemIEs);
509 }
510 else
511 return e2err_RICSubscriptionResponseAllocRICaction_NotAdmitted_ItemIEsFail;
512 index++;
513 }
514 }
515 ASN_SEQUENCE_ADD(&pE2AP_PDU->choice.successfulOutcome.value.choice.RICsubscriptionResponse.protocolIEs.list, pRICsubscriptionResponse_IEs);
516 }
517 else
518 return e2err_RICSubscriptionResponseAllocRICActionNotAdmittedListFail;
519
520 if (E2encode(pE2AP_PDU, pDataBufferSize, pDataBuffer, pLogBuffer))
521 return e2err_OK;
522 else
523 return e2err_RICSubscriptionResponseEncodeFail;
524 }
525 return e2err_RICSubscriptionResponseAllocE2AP_PDUFail;
526}
527
528//////////////////////////////////////////////////////////////////////
529uint64_t packRICSubscriptionFailure(size_t* pDataBufferSize, byte* pDataBuffer, char* pLogBuffer, RICSubscriptionFailure_t* pRICSubscriptionFailure) {
530
531 E2AP_PDU_t* pE2AP_PDU = calloc(1, sizeof(E2AP_PDU_t));
532 if(pE2AP_PDU)
533 {
534 pE2AP_PDU->present = E2AP_PDU_PR_unsuccessfulOutcome;
535 pE2AP_PDU->choice.unsuccessfulOutcome.procedureCode = ProcedureCode_id_ricSubscription;
536 pE2AP_PDU->choice.unsuccessfulOutcome.criticality = Criticality_ignore;
537 pE2AP_PDU->choice.unsuccessfulOutcome.value.present = RICUnsuccessfulOutcome__value_PR_RICsubscriptionFailure;
538
539 // RICrequestID
540 RICsubscriptionFailure_IEs_t* pRICsubscriptionFailure_IEs = calloc(1, sizeof(RICsubscriptionFailure_IEs_t));
541 if (pRICsubscriptionFailure_IEs) {
542 pRICsubscriptionFailure_IEs->id = ProtocolIE_ID_id_RICrequestID;
543 pRICsubscriptionFailure_IEs->criticality = Criticality_reject;
544 pRICsubscriptionFailure_IEs->value.present = RICsubscriptionFailure_IEs__value_PR_RICrequestID;
545 pRICsubscriptionFailure_IEs->value.choice.RICrequestID.ricRequestorID = pRICSubscriptionFailure->ricRequestID.ricRequestorID;
546 pRICsubscriptionFailure_IEs->value.choice.RICrequestID.ricRequestSequenceNumber = pRICSubscriptionFailure->ricRequestID.ricRequestSequenceNumber;
547 ASN_SEQUENCE_ADD(&pE2AP_PDU->choice.unsuccessfulOutcome.value.choice.RICsubscriptionFailure.protocolIEs.list, pRICsubscriptionFailure_IEs);
548 }
549 else
550 return e2err_RICSubscriptionFailureAllocRICrequestIDFail;
551
552 // RANfunctionID
553 pRICsubscriptionFailure_IEs = calloc(1, sizeof(RICsubscriptionFailure_IEs_t));
554 if (pRICsubscriptionFailure_IEs) {
555 pRICsubscriptionFailure_IEs->id = ProtocolIE_ID_id_RANfunctionID;
556 pRICsubscriptionFailure_IEs->criticality = Criticality_reject;
557 pRICsubscriptionFailure_IEs->value.present = RICsubscriptionFailure_IEs__value_PR_RANfunctionID;
558 pRICsubscriptionFailure_IEs->value.choice.RANfunctionID = pRICSubscriptionFailure->ranFunctionID;
559 ASN_SEQUENCE_ADD(&pE2AP_PDU->choice.unsuccessfulOutcome.value.choice.RICsubscriptionFailure.protocolIEs.list, pRICsubscriptionFailure_IEs);
560 }
561 else
562 return e2err_RICSubscriptionFailureAllocRANfunctionIDFail;
563
564 // RICaction-NotAdmitted list
565 pRICsubscriptionFailure_IEs = calloc(1, sizeof(RICsubscriptionFailure_IEs_t));
566 if (pRICsubscriptionFailure_IEs) {
567 pRICsubscriptionFailure_IEs->id = ProtocolIE_ID_id_RICactions_NotAdmitted;
568 pRICsubscriptionFailure_IEs->criticality = Criticality_reject;
569 pRICsubscriptionFailure_IEs->value.present = RICsubscriptionFailure_IEs__value_PR_RICaction_NotAdmitted_List;
570
571 uint64_t index = 0;
572 while (index < pRICSubscriptionFailure->ricActionNotAdmittedList.contentLength && index < maxofRICactionID) {
573
574 RICaction_NotAdmitted_ItemIEs_t* pRICaction_NotAdmitted_ItemIEs = calloc(1, sizeof (RICaction_NotAdmitted_ItemIEs_t));
575 if (pRICaction_NotAdmitted_ItemIEs)
576 {
577 pRICaction_NotAdmitted_ItemIEs->id = ProtocolIE_ID_id_RICaction_NotAdmitted_Item;
578 pRICaction_NotAdmitted_ItemIEs->criticality = Criticality_reject;
579 pRICaction_NotAdmitted_ItemIEs->value.present = RICaction_NotAdmitted_ItemIEs__value_PR_RICaction_NotAdmitted_Item;
580
581 // RICActionID
582 pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.ricActionID =
583 pRICSubscriptionFailure->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].ricActionID;
584
585 // RICCause
586 if (pRICSubscriptionFailure->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].ricCause.content == RICcause_PR_radioNetwork) {
587 pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.ricCause.present = RICcause_PR_radioNetwork;
588 pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.ricCause.choice.radioNetwork =
589 pRICSubscriptionFailure->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].ricCause.cause;
590 }
591 else if (pRICSubscriptionFailure->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].ricCause.content == RICcause_PR_transport) {
592 pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.ricCause.present = RICcause_PR_transport;
593 pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.ricCause.choice.transport =
594 pRICSubscriptionFailure->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].ricCause.cause;
595 }
596 else if (pRICSubscriptionFailure->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].ricCause.content == RICcause_PR_protocol) {
597 pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.ricCause.present = RICcause_PR_protocol;
598 pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.ricCause.choice.protocol =
599 pRICSubscriptionFailure->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].ricCause.cause;
600 }
601 else if (pRICSubscriptionFailure->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].ricCause.content == RICcause_PR_misc) {
602 pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.ricCause.present = RICcause_PR_misc;
603 pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.ricCause.choice.misc =
604 pRICSubscriptionFailure->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].ricCause.cause;
605 }
606 else if (pRICSubscriptionFailure->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].ricCause.content == RICcause_PR_ric) {
607 pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.ricCause.present = RICcause_PR_ric;
608 pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.ricCause.choice.ric =
609 pRICSubscriptionFailure->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].ricCause.cause;
610 }
611 ASN_SEQUENCE_ADD(&pRICsubscriptionFailure_IEs->value.choice.RICaction_NotAdmitted_List.list, pRICaction_NotAdmitted_ItemIEs);
612 }
613 else
614 return e2err_RICSubscriptionFailureAllocRICaction_NotAdmitted_ItemIEsFail;
615 index++;
616 }
617 ASN_SEQUENCE_ADD(&pE2AP_PDU->choice.unsuccessfulOutcome.value.choice.RICsubscriptionFailure.protocolIEs.list, pRICsubscriptionFailure_IEs);
618 }
619 else
620 return e2err_RICSubscriptionFailureAllocRICActionAdmittedListFail;
621
622 // CriticalityDiagnostics, OPTIONAL. Not used in RIC
623
624 if (E2encode(pE2AP_PDU, pDataBufferSize, pDataBuffer, pLogBuffer))
625 return e2err_OK;
626 else
627 return e2err_RICSubscriptionFailureEncodeFail;
628 }
629 else
630 return e2err_RICSubscriptionFailureAllocE2AP_PDUFail;
631}
632
633//////////////////////////////////////////////////////////////////////
634uint64_t packRICIndication(size_t* pDataBufferSize, byte* pDataBuffer, char* pLogBuffer, RICIndication_t* pRICIndication) {
635
636 E2AP_PDU_t* pE2AP_PDU = calloc(1, sizeof(E2AP_PDU_t));
637 if(pE2AP_PDU)
638 {
639 pE2AP_PDU->present = E2AP_PDU_PR_initiatingMessage;
640 pE2AP_PDU->choice.initiatingMessage.procedureCode = ProcedureCode_id_ricIndication;
641 pE2AP_PDU->choice.initiatingMessage.criticality = Criticality_ignore;
642 pE2AP_PDU->choice.initiatingMessage.value.present = RICInitiatingMessage__value_PR_RICindication;
643
644 // RICrequestID
645 RICindication_IEs_t* pRICindication_IEs = calloc(1, sizeof(RICindication_IEs_t));
646 if (pRICindication_IEs) {
647 pRICindication_IEs->id = ProtocolIE_ID_id_RICrequestID;
648 pRICindication_IEs->criticality = Criticality_reject;
649 pRICindication_IEs->value.present = RICindication_IEs__value_PR_RICrequestID;
650 pRICindication_IEs->value.choice.RICrequestID.ricRequestorID = pRICIndication->ricRequestID.ricRequestorID;
651 pRICindication_IEs->value.choice.RICrequestID.ricRequestSequenceNumber = pRICIndication->ricRequestID.ricRequestSequenceNumber;
652 ASN_SEQUENCE_ADD(&pE2AP_PDU->choice.initiatingMessage.value.choice.RICindication.protocolIEs.list, pRICindication_IEs);
653 }
654 else
655 return e2err_RICIndicationRICrequestIDFail;
656
657 // RANfunctionID
658 pRICindication_IEs = calloc(1, sizeof(RICindication_IEs_t));
659 if (pRICindication_IEs) {
660 pRICindication_IEs->id = ProtocolIE_ID_id_RANfunctionID;
661 pRICindication_IEs->criticality = Criticality_reject;
662 pRICindication_IEs->value.present = RICindication_IEs__value_PR_RANfunctionID;
663 pRICindication_IEs->value.choice.RANfunctionID = pRICIndication->ranFunctionID;
664 ASN_SEQUENCE_ADD(&pE2AP_PDU->choice.initiatingMessage.value.choice.RICindication.protocolIEs.list, pRICindication_IEs);
665 }
666 else
667 return e2err_RICIndicationAllocRANfunctionIDFail;
668
669 // RICactionID
670 pRICindication_IEs = calloc(1, sizeof(RICindication_IEs_t));
671 if (pRICindication_IEs) {
672 pRICindication_IEs->id = ProtocolIE_ID_id_RICactionID;
673 pRICindication_IEs->criticality = Criticality_reject;
674 pRICindication_IEs->value.present = RICindication_IEs__value_PR_RICactionID;
675 pRICindication_IEs->value.choice.RICactionID = pRICIndication->ricActionID;
676 ASN_SEQUENCE_ADD(&pE2AP_PDU->choice.initiatingMessage.value.choice.RICindication.protocolIEs.list, pRICindication_IEs);
677 }
678 else
679 return e2err_RICIndicationAllocRICactionIDFail;
680
681 // RICindicationSN
682 pRICindication_IEs = calloc(1, sizeof(RICindication_IEs_t));
683 if (pRICindication_IEs) {
684 pRICindication_IEs->id = ProtocolIE_ID_id_RICindicationSN;
685 pRICindication_IEs->criticality = Criticality_reject;
686 pRICindication_IEs->value.present = RICindication_IEs__value_PR_RICindicationSN;
687 pRICindication_IEs->value.choice.RICindicationSN = pRICIndication->ricIndicationSN;
688 ASN_SEQUENCE_ADD(&pE2AP_PDU->choice.initiatingMessage.value.choice.RICindication.protocolIEs.list, pRICindication_IEs);
689 }
690 else
691 return e2err_RICIndicationAllocRICindicationSNFail;
692
693 // RICindicationType
694 pRICindication_IEs = calloc(1, sizeof(RICindication_IEs_t));
695 if (pRICindication_IEs) {
696 pRICindication_IEs->id = ProtocolIE_ID_id_RICindicationType;
697 pRICindication_IEs->criticality = Criticality_reject;
698 pRICindication_IEs->value.present = RICindication_IEs__value_PR_RICindicationType;
699 pRICindication_IEs->value.choice.RICindicationType = pRICIndication->ricIndicationType;
700 ASN_SEQUENCE_ADD(&pE2AP_PDU->choice.initiatingMessage.value.choice.RICindication.protocolIEs.list, pRICindication_IEs);
701 }
702 else
703 return e2err_RICIndicationAllocRICindicationTypeFail;
704
705 // RICindicationHeader
706 uint64_t returnCode;
707 uint64_t logBufferSize = 512;
708 char logBuffer[logBufferSize];
709 if ((returnCode = packRICIndicationHeader(logBuffer, &pRICIndication->ricIndicationHeader)) != e2err_OK) {
710 return returnCode;
711 }
712
713 pRICindication_IEs = calloc(1, sizeof(RICindication_IEs_t));
714 if (pRICindication_IEs) {
715 pRICindication_IEs->id = ProtocolIE_ID_id_RICindicationHeader;
716 pRICindication_IEs->criticality = Criticality_reject;
717 pRICindication_IEs->value.present = RICindication_IEs__value_PR_RICindicationHeader;
718 pRICindication_IEs->value.choice.RICindicationHeader.buf = calloc(1,pRICIndication->ricIndicationHeader.octetString.contentLength);
719 if (pRICindication_IEs->value.choice.RICindicationHeader.buf) {
720 pRICindication_IEs->value.choice.RICindicationHeader.size = pRICIndication->ricIndicationHeader.octetString.contentLength;
721 memcpy(pRICindication_IEs->value.choice.RICindicationHeader.buf,pRICIndication->ricIndicationHeader.octetString.data,
722 pRICIndication->ricIndicationHeader.octetString.contentLength);
723 ASN_SEQUENCE_ADD(&pE2AP_PDU->choice.initiatingMessage.value.choice.RICindication.protocolIEs.list, pRICindication_IEs);
724 }
725 else
726 return e2err_RICIndicationAllocRRICindicationHeaderBufFail;
727 }
728 else
729 return e2err_RICIndicationAllocRICindicationHeaderFail;
730
731 // RICindicationMessage
732 if ((returnCode = packRICIndicationMessage(logBuffer, &pRICIndication->ricIndicationMessage)) != e2err_OK) {
733 return returnCode;
734 }
735
736 pRICindication_IEs = calloc(1, sizeof(RICindication_IEs_t));
737 if (pRICindication_IEs) {
738 pRICindication_IEs->id = ProtocolIE_ID_id_RICindicationMessage;
739 pRICindication_IEs->criticality = Criticality_reject;
740 pRICindication_IEs->value.present = RICindication_IEs__value_PR_RICindicationMessage;
741 pRICindication_IEs->value.choice.RICindicationMessage.buf = calloc(1,pRICIndication->ricIndicationMessage.octetString.contentLength);
742 if (pRICindication_IEs->value.choice.RICindicationMessage.buf) {
743 pRICindication_IEs->value.choice.RICindicationMessage.size = pRICIndication->ricIndicationMessage.octetString.contentLength;
744 memcpy(pRICindication_IEs->value.choice.RICindicationHeader.buf,pRICIndication->ricIndicationMessage.octetString.data,
745 pRICIndication->ricIndicationMessage.octetString.contentLength);
746 ASN_SEQUENCE_ADD(&pE2AP_PDU->choice.initiatingMessage.value.choice.RICindication.protocolIEs.list, pRICindication_IEs);
747 }
748 else
749 return e2err_RICIndicationAllocRICindicationMessageBufFail;
750 }
751 else
752 return e2err_RICIndicationAllocRICindicationMessageFail;
753
754 // RICcallProcessID, OPTIONAL. Not used in RIC.
755
756 if (E2encode(pE2AP_PDU, pDataBufferSize, pDataBuffer, pLogBuffer))
757 return e2err_OK;
758 else
759 return e2err_RICIndicationEncodeFail;
760 }
761 else
762 return e2err_RICIndicationAllocE2AP_PDUFail;
763}
764
765//////////////////////////////////////////////////////////////////////
766uint64_t packRICIndicationHeader(char* pLogBuffer, RICIndicationHeader_t* pRICIndicationHeader) {
767
768 E2SM_gNB_X2_indicationHeader_t* pE2SM_gNB_X2_indicationHeader = calloc(1, sizeof(E2SM_gNB_X2_indicationHeader_t));
769 if(pE2SM_gNB_X2_indicationHeader)
770 {
771 // InterfaceID
772 if ((pRICIndicationHeader->interfaceID.globalENBIDPresent == true && pRICIndicationHeader->interfaceID.globalGNBIDPresent == true) ||
773 (pRICIndicationHeader->interfaceID.globalENBIDPresent == false && pRICIndicationHeader->interfaceID.globalGNBIDPresent == false))
774 return e2err_RICindicationHeaderIEValueFail_1;
775
776 // GlobalENB-ID or GlobalGNB-ID
777 if (pRICIndicationHeader->interfaceID.globalENBIDPresent)
778 {
779 pE2SM_gNB_X2_indicationHeader->interface_ID.present = Interface_ID_PR_global_eNB_ID;
780
781 // GlobalENB-ID
782 // PLMN-Identity
783 pE2SM_gNB_X2_indicationHeader->interface_ID.choice.global_eNB_ID.pLMN_Identity.size =
784 pRICIndicationHeader->interfaceID.globalENBID.pLMNIdentity.contentLength;
785 pE2SM_gNB_X2_indicationHeader->interface_ID.choice.global_eNB_ID.pLMN_Identity.buf = calloc(1,3);
786 if (pE2SM_gNB_X2_indicationHeader->interface_ID.choice.global_eNB_ID.pLMN_Identity.buf) {
787 memcpy(pE2SM_gNB_X2_indicationHeader->interface_ID.choice.global_eNB_ID.pLMN_Identity.buf,
788 pRICIndicationHeader->interfaceID.globalENBID.pLMNIdentity.pLMNIdentityVal,
789 pRICIndicationHeader->interfaceID.globalENBID.pLMNIdentity.contentLength);
790 }
791 else
792 return e2err_RICIndicationAllocRICIndicationHeaderglobal_eNB_IDpLMN_IdentityBufFail;
793
794 // Add ENB-ID
795 if (pRICIndicationHeader->interfaceID.globalENBID.nodeID.bits == cMacroENBIDP_20Bits){
796 // BIT STRING (SIZE (20)
797 pE2SM_gNB_X2_indicationHeader->interface_ID.choice.global_eNB_ID.eNB_ID.present = ENB_ID_PR_macro_eNB_ID;
798
799 pE2SM_gNB_X2_indicationHeader->interface_ID.choice.global_eNB_ID.eNB_ID.choice.macro_eNB_ID.buf = calloc(1,3);
800 if (pE2SM_gNB_X2_indicationHeader->interface_ID.choice.global_eNB_ID.eNB_ID.choice.macro_eNB_ID.buf) {
801 pE2SM_gNB_X2_indicationHeader->interface_ID.choice.global_eNB_ID.eNB_ID.choice.macro_eNB_ID.size = 3; // bytes
802 pE2SM_gNB_X2_indicationHeader->interface_ID.choice.global_eNB_ID.eNB_ID.choice.macro_eNB_ID.bits_unused = 4; // trailing unused bits
803 memcpy(pE2SM_gNB_X2_indicationHeader->interface_ID.choice.global_eNB_ID.eNB_ID.choice.macro_eNB_ID.buf,
804 (void*)&pRICIndicationHeader->interfaceID.globalENBID.nodeID.nodeID,3);
805 }
806 else
807 return e2err_RICIndicationAllocRICIndicationHeaderglobal_eNB_IDeNB_IDmacro_eNB_IDBufFail;
808 }
809 else if (pRICIndicationHeader->interfaceID.globalENBID.nodeID.bits == cHomeENBID_28Bits) {
810 // BIT STRING (SIZE (28)
811 pE2SM_gNB_X2_indicationHeader->interface_ID.choice.global_eNB_ID.eNB_ID.present = ENB_ID_PR_home_eNB_ID;
812
813 pE2SM_gNB_X2_indicationHeader->interface_ID.choice.global_eNB_ID.eNB_ID.choice.home_eNB_ID.buf = calloc(1,4);
814 if (pE2SM_gNB_X2_indicationHeader->interface_ID.choice.global_eNB_ID.eNB_ID.choice.home_eNB_ID.buf) {
815 pE2SM_gNB_X2_indicationHeader->interface_ID.choice.global_eNB_ID.eNB_ID.choice.home_eNB_ID.size = 4; // bytes
816 pE2SM_gNB_X2_indicationHeader->interface_ID.choice.global_eNB_ID.eNB_ID.choice.home_eNB_ID.bits_unused = 4; // trailing unused bits
817 memcpy(pE2SM_gNB_X2_indicationHeader->interface_ID.choice.global_eNB_ID.eNB_ID.choice.home_eNB_ID.buf,
818 (void*)&pRICIndicationHeader->interfaceID.globalENBID.nodeID.nodeID,4);
819 }
820 else
821 return e2err_RICIndicationAllocRICIndicationHeaderglobal_eNB_IDeNB_IDhome_eNB_IDBufFail;
822 }
823 else if (pRICIndicationHeader->interfaceID.globalENBID.nodeID.bits == cShortMacroENBID_18Bits) {
824 // BIT STRING (SIZE(18)
825 pE2SM_gNB_X2_indicationHeader->interface_ID.choice.global_eNB_ID.eNB_ID.present = ENB_ID_PR_short_Macro_eNB_ID;
826
827 pE2SM_gNB_X2_indicationHeader->interface_ID.choice.global_eNB_ID.eNB_ID.choice.short_Macro_eNB_ID.buf = calloc(1,3);
828 if (pE2SM_gNB_X2_indicationHeader->interface_ID.choice.global_eNB_ID.eNB_ID.choice.short_Macro_eNB_ID.buf) {
829 pE2SM_gNB_X2_indicationHeader->interface_ID.choice.global_eNB_ID.eNB_ID.choice.short_Macro_eNB_ID.size = 3;
830 pE2SM_gNB_X2_indicationHeader->interface_ID.choice.global_eNB_ID.eNB_ID.choice.short_Macro_eNB_ID.bits_unused = 6; // trailing unused bits
831 memcpy(pE2SM_gNB_X2_indicationHeader->interface_ID.choice.global_eNB_ID.eNB_ID.choice.short_Macro_eNB_ID.buf,
832 (void*)&pRICIndicationHeader->interfaceID.globalENBID.nodeID.nodeID,3);
833 }
834 else
835 return e2err_RICIndicationAllocRICIndicationHeaderglobal_eNB_IDeNB_IDshort_Macro_eNB_IDBufFail;
836 }
837 else if (pRICIndicationHeader->interfaceID.globalENBID.nodeID.bits == clongMacroENBIDP_21Bits) {
838 // BIT STRING (SIZE(21)
839 pE2SM_gNB_X2_indicationHeader->interface_ID.choice.global_eNB_ID.eNB_ID.present = ENB_ID_PR_long_Macro_eNB_ID;
840
841 pE2SM_gNB_X2_indicationHeader->interface_ID.choice.global_eNB_ID.eNB_ID.choice.long_Macro_eNB_ID.buf = calloc(1,3);
842 if (pE2SM_gNB_X2_indicationHeader->interface_ID.choice.global_eNB_ID.eNB_ID.choice.long_Macro_eNB_ID.buf) {
843 pE2SM_gNB_X2_indicationHeader->interface_ID.choice.global_eNB_ID.eNB_ID.choice.long_Macro_eNB_ID.size = 3; // bytes
844 pE2SM_gNB_X2_indicationHeader->interface_ID.choice.global_eNB_ID.eNB_ID.choice.long_Macro_eNB_ID.bits_unused = 3; // trailing unused bits
845 memcpy(pE2SM_gNB_X2_indicationHeader->interface_ID.choice.global_eNB_ID.eNB_ID.choice.long_Macro_eNB_ID.buf,
846 (void*)&pRICIndicationHeader->interfaceID.globalENBID.nodeID.nodeID,3);
847 }
848 else
849 return e2err_RICIndicationAllocRICIndicationHeaderglobal_eNB_IDeNB_IDlong_Macro_eNB_IDBufFail;
850 }
851 else
852 return e2err_RICindicationHeaderIEValueFail_2;
853
854 }
855 else if (pRICIndicationHeader->interfaceID.globalGNBIDPresent) {
856 // GlobalGNB-ID
857 pE2SM_gNB_X2_indicationHeader->interface_ID.present = Interface_ID_PR_global_gNB_ID;
858
859 // PLMN-Identity
860 pE2SM_gNB_X2_indicationHeader->interface_ID.choice.global_gNB_ID.pLMN_Identity.size =
861 pRICIndicationHeader->interfaceID.globalGNBID.pLMNIdentity.contentLength;
862 pE2SM_gNB_X2_indicationHeader->interface_ID.choice.global_gNB_ID.pLMN_Identity.buf =
863 calloc(1,pRICIndicationHeader->interfaceID.globalGNBID.pLMNIdentity.contentLength);
864 if (pE2SM_gNB_X2_indicationHeader->interface_ID.choice.global_gNB_ID.pLMN_Identity.buf) {
865 memcpy(pE2SM_gNB_X2_indicationHeader->interface_ID.choice.global_gNB_ID.pLMN_Identity.buf,
866 (void*)&pRICIndicationHeader->interfaceID.globalGNBID.pLMNIdentity.pLMNIdentityVal,
867 pRICIndicationHeader->interfaceID.globalGNBID.pLMNIdentity.contentLength);
868 }
869 else
870 return e2err_RICIndicationAllocRICIndicationHeaderglobal_gNB_IDpLMN_IdentityBufFail;
871
872 // GNB-ID, BIT STRING (SIZE (22..32)
873 pE2SM_gNB_X2_indicationHeader->interface_ID.choice.global_gNB_ID.gNB_ID.choice.gNB_ID.size = 4; //32bits
874 pE2SM_gNB_X2_indicationHeader->interface_ID.choice.global_gNB_ID.gNB_ID.choice.gNB_ID.buf = calloc(1,4);
875 if (pE2SM_gNB_X2_indicationHeader->interface_ID.choice.global_gNB_ID.gNB_ID.choice.gNB_ID.buf) {
876 memcpy(pE2SM_gNB_X2_indicationHeader->interface_ID.choice.global_gNB_ID.gNB_ID.choice.gNB_ID.buf,
877 (void*)&pRICIndicationHeader->interfaceID.globalGNBID,4); //32bits
878 }
879 else
880 return e2err_RICIndicationAllocRICIndicationHeaderglobal_gNB_IDgNB_IDgNB_IDBufFail;
881 }
882 else
883 return e2err_RICindicationHeaderIEValueFail_3;
884
885 // InterfaceDirection
886 pE2SM_gNB_X2_indicationHeader->interfaceDirection = pRICIndicationHeader->interfaceDirection;
887
888 // TimeStamp OPTIONAL. Not used in RIC.
889
890 // Debug print
891 if (debug)
892 asn_fprint(stdout, &asn_DEF_E2SM_gNB_X2_indicationHeader, pE2SM_gNB_X2_indicationHeader);
893
894 // Encode
895 size_t bufferSize = sizeof(pRICIndicationHeader->octetString.data);
896 asn_enc_rval_t rval;
897 rval = asn_encode_to_buffer(0, ATS_ALIGNED_BASIC_PER, &asn_DEF_E2SM_gNB_X2_indicationHeader, pE2SM_gNB_X2_indicationHeader,
898 pRICIndicationHeader->octetString.data, bufferSize);
899 if(rval.encoded == -1)
900 {
Anssi Mannila4721d4e2020-01-16 09:14:47 +0200901 sprintf(pLogBuffer,"Serialization of %s failed.", asn_DEF_E2SM_gNB_X2_indicationHeader.name);
Juha Hyttinenff8dccd2019-12-10 14:34:07 +0200902 return e2err_RICindicationHeaderPackFail_1;
903 }
904 else if(rval.encoded > bufferSize)
905 {
Anssi Mannila4721d4e2020-01-16 09:14:47 +0200906 sprintf(pLogBuffer,"Buffer of size %zu is too small for %s, need %zu",bufferSize, asn_DEF_E2SM_gNB_X2_indicationHeader.name, rval.encoded);
Juha Hyttinenff8dccd2019-12-10 14:34:07 +0200907 return e2err_RICindicationHeaderPackFail_2;
908 }
909 else
910 if (debug)
Anssi Mannila4721d4e2020-01-16 09:14:47 +0200911 sprintf(pLogBuffer,"Successfully encoded %s. Buffer size %zu, encoded size %zu",asn_DEF_E2SM_gNB_X2_indicationHeader.name, bufferSize, rval.encoded);
Juha Hyttinenff8dccd2019-12-10 14:34:07 +0200912
913 ASN_STRUCT_FREE(asn_DEF_E2SM_gNB_X2_indicationHeader, pE2SM_gNB_X2_indicationHeader);
914
915 pRICIndicationHeader->octetString.contentLength = rval.encoded;
916 return e2err_OK;
917 }
918 else
919 return e2err_RICIndicationHeaderAllocE2AP_PDUFail;
920}
921
922//////////////////////////////////////////////////////////////////////
923uint64_t packRICIndicationMessage(char* pLogBuffer, RICIndicationMessage_t* pRICIndicationMessage) {
924
925 E2SM_gNB_X2_indicationMessage_t* pE2SM_gNB_X2_indicationMessage = calloc(1, sizeof(E2SM_gNB_X2_indicationMessage_t));
926 if(pE2SM_gNB_X2_indicationMessage)
927 {
928 pE2SM_gNB_X2_indicationMessage->interfaceMessage.buf = calloc(1, pRICIndicationMessage->interfaceMessage.contentLength);
929 if(pE2SM_gNB_X2_indicationMessage->interfaceMessage.buf)
930 {
931 pE2SM_gNB_X2_indicationMessage->interfaceMessage.size = pRICIndicationMessage->interfaceMessage.contentLength;
932 memcpy(pE2SM_gNB_X2_indicationMessage->interfaceMessage.buf,pRICIndicationMessage->interfaceMessage.data,pRICIndicationMessage->interfaceMessage.contentLength);
933 }
934 else
935 return e2err_RICIndicationMessageAllocinterfaceMessageFail;
936
937 // Debug print
938 if (debug)
939 asn_fprint(stdout, &asn_DEF_E2SM_gNB_X2_indicationMessage, pE2SM_gNB_X2_indicationMessage);
940
941 // Encode
942 size_t bufferSize = sizeof(pRICIndicationMessage->octetString.data);
943 asn_enc_rval_t rval;
944 rval = asn_encode_to_buffer(0, ATS_ALIGNED_BASIC_PER, &asn_DEF_E2SM_gNB_X2_indicationMessage, pE2SM_gNB_X2_indicationMessage,
945 pRICIndicationMessage->octetString.data, bufferSize);
946 if(rval.encoded == -1)
947 {
Anssi Mannila4721d4e2020-01-16 09:14:47 +0200948 sprintf(pLogBuffer,"Serialization of %s failed.", asn_DEF_E2SM_gNB_X2_indicationMessage.name);
Juha Hyttinenff8dccd2019-12-10 14:34:07 +0200949 return e2err_RICindicationMessagePackFail_1;
950 }
951 else if(rval.encoded > bufferSize)
952 {
Anssi Mannila4721d4e2020-01-16 09:14:47 +0200953 sprintf(pLogBuffer,"Buffer of size %zu is too small for %s, need %zu",bufferSize, asn_DEF_E2SM_gNB_X2_indicationMessage.name, rval.encoded);
Juha Hyttinenff8dccd2019-12-10 14:34:07 +0200954 return e2err_RICindicationMessagePackFail_2;
955 }
956 else
957 if (debug)
Anssi Mannila4721d4e2020-01-16 09:14:47 +0200958 sprintf(pLogBuffer,"Successfully encoded %s. Buffer size %zu, encoded size %zu",asn_DEF_E2SM_gNB_X2_indicationMessage.name, bufferSize, rval.encoded);
Juha Hyttinenff8dccd2019-12-10 14:34:07 +0200959
960 ASN_STRUCT_FREE(asn_DEF_E2SM_gNB_X2_indicationMessage, pE2SM_gNB_X2_indicationMessage);
961
962 pRICIndicationMessage->octetString.contentLength = rval.encoded;
963 return e2err_OK;
964 }
965 else
966 return e2err_E2SM_gNB_X2_indicationMessageAllocE2AP_PDUFail;
967}
968
969//////////////////////////////////////////////////////////////////////
970uint64_t packRICSubscriptionDeleteRequest(size_t* pDataBufferSize, byte* pDataBuffer, char* pLogBuffer, RICSubscriptionDeleteRequest_t* pRICSubscriptionDeleteRequest) {
971
972 E2AP_PDU_t* pE2AP_PDU = calloc(1, sizeof(E2AP_PDU_t));
973 if(pE2AP_PDU)
974 {
975 pE2AP_PDU->present = E2AP_PDU_PR_initiatingMessage;
976 pE2AP_PDU->choice.initiatingMessage.procedureCode = ProcedureCode_id_ricSubscriptionDelete;
977 pE2AP_PDU->choice.initiatingMessage.criticality = Criticality_ignore;
978 pE2AP_PDU->choice.initiatingMessage.value.present = RICInitiatingMessage__value_PR_RICsubscriptionDeleteRequest;
979
980 // RICrequestID
981 RICsubscriptionDeleteRequest_IEs_t* pRICsubscriptionDeleteRequest_IEs = calloc(1, sizeof(RICsubscriptionDeleteRequest_IEs_t));
982 if (pRICsubscriptionDeleteRequest_IEs) {
983 pRICsubscriptionDeleteRequest_IEs->id = ProtocolIE_ID_id_RICrequestID;
984 pRICsubscriptionDeleteRequest_IEs->criticality = Criticality_reject;
985 pRICsubscriptionDeleteRequest_IEs->value.present = RICsubscriptionDeleteRequest_IEs__value_PR_RICrequestID;
986 pRICsubscriptionDeleteRequest_IEs->value.choice.RICrequestID.ricRequestorID = pRICSubscriptionDeleteRequest->ricRequestID.ricRequestorID;
987 pRICsubscriptionDeleteRequest_IEs->value.choice.RICrequestID.ricRequestSequenceNumber = pRICSubscriptionDeleteRequest->ricRequestID.ricRequestSequenceNumber;
988 ASN_SEQUENCE_ADD(&pE2AP_PDU->choice.initiatingMessage.value.choice.RICsubscriptionDeleteRequest.protocolIEs.list, pRICsubscriptionDeleteRequest_IEs);
989 }
990 else
991 return e2err_RICSubscriptionDeleteRequestAllocRICrequestIDFail;
992
993 // RANfunctionID
994 pRICsubscriptionDeleteRequest_IEs = calloc(1, sizeof(RICsubscriptionDeleteRequest_IEs_t));
995 if (pRICsubscriptionDeleteRequest_IEs) {
996 pRICsubscriptionDeleteRequest_IEs->id = ProtocolIE_ID_id_RANfunctionID;
997 pRICsubscriptionDeleteRequest_IEs->criticality = Criticality_reject;
998 pRICsubscriptionDeleteRequest_IEs->value.present = RICsubscriptionDeleteRequest_IEs__value_PR_RANfunctionID;
999 pRICsubscriptionDeleteRequest_IEs->value.choice.RANfunctionID = pRICSubscriptionDeleteRequest->ranFunctionID;
1000 ASN_SEQUENCE_ADD(&pE2AP_PDU->choice.initiatingMessage.value.choice.RICsubscriptionDeleteRequest.protocolIEs.list, pRICsubscriptionDeleteRequest_IEs);
1001 }
1002 else
1003 return e2err_RICSubscriptionDeleteRequestAllocRANfunctionIDFail;
1004
1005 if (E2encode(pE2AP_PDU, pDataBufferSize, pDataBuffer, pLogBuffer))
1006 return e2err_OK;
1007 else
1008 return e2err_RICSubscriptionDeleteRequestEncodeFail;
1009 }
1010 else
1011 return e2err_RICSubscriptionDeleteRequestAllocE2AP_PDUFail;
1012}
1013
1014//////////////////////////////////////////////////////////////////////
1015uint64_t packRICSubscriptionDeleteResponse(size_t* pDataBufferSize, byte* pDataBuffer, char* pLogBuffer, RICSubscriptionDeleteResponse_t* pRICSubscriptionDeleteResponse) {
1016
1017 E2AP_PDU_t* pE2AP_PDU = calloc(1, sizeof(E2AP_PDU_t));
1018 if(pE2AP_PDU)
1019 {
1020 pE2AP_PDU->present = E2AP_PDU_PR_successfulOutcome;
1021 pE2AP_PDU->choice.successfulOutcome.procedureCode = ProcedureCode_id_ricSubscriptionDelete;
1022 pE2AP_PDU->choice.successfulOutcome.criticality = Criticality_ignore;
1023 pE2AP_PDU->choice.successfulOutcome.value.present = RICSuccessfulOutcome__value_PR_RICsubscriptionDeleteResponse;
1024
1025 // RICrequestID
1026 RICsubscriptionDeleteResponse_IEs_t* pRICsubscriptionDeleteResponse_IEs = calloc(1, sizeof(RICsubscriptionDeleteResponse_IEs_t));
1027 if (pRICsubscriptionDeleteResponse_IEs) {
1028 pRICsubscriptionDeleteResponse_IEs->id = ProtocolIE_ID_id_RICrequestID;
1029 pRICsubscriptionDeleteResponse_IEs->criticality = Criticality_reject;
1030 pRICsubscriptionDeleteResponse_IEs->value.present = RICsubscriptionDeleteResponse_IEs__value_PR_RICrequestID;
1031 pRICsubscriptionDeleteResponse_IEs->value.choice.RICrequestID.ricRequestorID = pRICSubscriptionDeleteResponse->ricRequestID.ricRequestorID;
1032 pRICsubscriptionDeleteResponse_IEs->value.choice.RICrequestID.ricRequestSequenceNumber = pRICSubscriptionDeleteResponse->ricRequestID.ricRequestSequenceNumber;
1033 ASN_SEQUENCE_ADD(&pE2AP_PDU->choice.successfulOutcome.value.choice.RICsubscriptionDeleteResponse.protocolIEs.list, pRICsubscriptionDeleteResponse_IEs);
1034 }
1035 else
1036 return e2err_RICSubscriptionDeleteResponseAllocRICrequestIDFail;
1037
1038 // RANfunctionID
1039 pRICsubscriptionDeleteResponse_IEs = calloc(1, sizeof(RICsubscriptionDeleteResponse_IEs_t));
1040 if (pRICsubscriptionDeleteResponse_IEs) {
1041 pRICsubscriptionDeleteResponse_IEs->id = ProtocolIE_ID_id_RANfunctionID;
1042 pRICsubscriptionDeleteResponse_IEs->criticality = Criticality_reject;
1043 pRICsubscriptionDeleteResponse_IEs->value.present = RICsubscriptionDeleteResponse_IEs__value_PR_RANfunctionID;
1044 pRICsubscriptionDeleteResponse_IEs->value.choice.RANfunctionID = pRICSubscriptionDeleteResponse->ranFunctionID;
1045 ASN_SEQUENCE_ADD(&pE2AP_PDU->choice.successfulOutcome.value.choice.RICsubscriptionDeleteResponse.protocolIEs.list, pRICsubscriptionDeleteResponse_IEs);
1046 }
1047 else
1048 return e2err_RICSubscriptionDeleteResponseAllocRANfunctionIDFail;
1049
1050 if (E2encode(pE2AP_PDU, pDataBufferSize, pDataBuffer, pLogBuffer))
1051 return e2err_OK;
1052 else
1053 return e2err_RICSubscriptionDeleteResponseEncodeFail;
1054 }
1055 else
1056 return e2err_RICSubscriptionDeleteResponseAllocE2AP_PDUFail;
1057}
1058
1059uint64_t packRICSubscriptionDeleteFailure(size_t* pDataBufferSize, byte* pDataBuffer, char* pLogBuffer, RICSubscriptionDeleteFailure_t* pRICSubscriptionDeleteFailure) {
1060
1061 E2AP_PDU_t* pE2AP_PDU = calloc(1, sizeof(E2AP_PDU_t));
1062 if(pE2AP_PDU)
1063 {
1064 pE2AP_PDU->present = E2AP_PDU_PR_unsuccessfulOutcome;
1065 pE2AP_PDU->choice.unsuccessfulOutcome.procedureCode = ProcedureCode_id_ricSubscriptionDelete;
1066 pE2AP_PDU->choice.unsuccessfulOutcome.criticality = Criticality_ignore;
1067 pE2AP_PDU->choice.unsuccessfulOutcome.value.present = RICUnsuccessfulOutcome__value_PR_RICsubscriptionDeleteFailure;
1068
1069 // RICrequestID
1070 RICsubscriptionDeleteFailure_IEs_t* pRICsubscriptionDeleteFailure_IEs = calloc(1, sizeof(RICsubscriptionDeleteFailure_IEs_t));
1071 if (pRICsubscriptionDeleteFailure_IEs) {
1072 pRICsubscriptionDeleteFailure_IEs->id = ProtocolIE_ID_id_RICrequestID;
1073 pRICsubscriptionDeleteFailure_IEs->criticality = Criticality_reject;
1074 pRICsubscriptionDeleteFailure_IEs->value.present = RICsubscriptionDeleteFailure_IEs__value_PR_RICrequestID;
1075 pRICsubscriptionDeleteFailure_IEs->value.choice.RICrequestID.ricRequestorID = pRICSubscriptionDeleteFailure->ricRequestID.ricRequestorID;
1076 pRICsubscriptionDeleteFailure_IEs->value.choice.RICrequestID.ricRequestSequenceNumber = pRICSubscriptionDeleteFailure->ricRequestID.ricRequestSequenceNumber;
1077 ASN_SEQUENCE_ADD(&pE2AP_PDU->choice.unsuccessfulOutcome.value.choice.RICsubscriptionDeleteFailure.protocolIEs.list, pRICsubscriptionDeleteFailure_IEs);
1078 }
1079 else
1080 return e2err_RICSubscriptionDeleteFailureAllocRICrequestIDFail;
1081
1082 // RANfunctionID
1083 pRICsubscriptionDeleteFailure_IEs = calloc(1, sizeof(RICsubscriptionDeleteFailure_IEs_t));
1084 if (pRICsubscriptionDeleteFailure_IEs) {
1085 pRICsubscriptionDeleteFailure_IEs->id = ProtocolIE_ID_id_RANfunctionID;
1086 pRICsubscriptionDeleteFailure_IEs->criticality = Criticality_reject;
1087 pRICsubscriptionDeleteFailure_IEs->value.present = RICsubscriptionDeleteFailure_IEs__value_PR_RANfunctionID;
1088 pRICsubscriptionDeleteFailure_IEs->value.choice.RANfunctionID = pRICSubscriptionDeleteFailure->ranFunctionID;
1089 ASN_SEQUENCE_ADD(&pE2AP_PDU->choice.unsuccessfulOutcome.value.choice.RICsubscriptionDeleteFailure.protocolIEs.list, pRICsubscriptionDeleteFailure_IEs);
1090 }
1091 else
1092 return e2err_RICSubscriptionDeleteFailureAllocRANfunctionIDFail;
1093
1094 // RICcause
1095 pRICsubscriptionDeleteFailure_IEs = calloc(1, sizeof(RICsubscriptionDeleteFailure_IEs_t));
1096 if (pRICsubscriptionDeleteFailure_IEs) {
1097 pRICsubscriptionDeleteFailure_IEs->id = ProtocolIE_ID_id_RICcause;
1098 pRICsubscriptionDeleteFailure_IEs->criticality = Criticality_reject;
1099 pRICsubscriptionDeleteFailure_IEs->value.present = RICsubscriptionDeleteFailure_IEs__value_PR_RICcause;
1100 if (pRICSubscriptionDeleteFailure->ricCause.content == RICcause_PR_radioNetwork) {
1101 pRICsubscriptionDeleteFailure_IEs->value.choice.RICcause.present = RICcause_PR_radioNetwork;
1102 pRICsubscriptionDeleteFailure_IEs->value.choice.RICcause.choice.radioNetwork =
1103 pRICSubscriptionDeleteFailure->ricCause.cause;
1104 }
1105 else if (pRICSubscriptionDeleteFailure->ricCause.content == RICcause_PR_transport) {
1106 pRICsubscriptionDeleteFailure_IEs->value.choice.RICcause.present = RICcause_PR_transport;
1107 pRICsubscriptionDeleteFailure_IEs->value.choice.RICcause.choice.transport =
1108 pRICSubscriptionDeleteFailure->ricCause.cause;
1109 }
1110 else if (pRICSubscriptionDeleteFailure->ricCause.content == RICcause_PR_protocol) {
1111 pRICsubscriptionDeleteFailure_IEs->value.choice.RICcause.present = RICcause_PR_protocol;
1112 pRICsubscriptionDeleteFailure_IEs->value.choice.RICcause.choice.protocol =
1113 pRICSubscriptionDeleteFailure->ricCause.cause;
1114 }
1115 else if (pRICSubscriptionDeleteFailure->ricCause.content == RICcause_PR_misc) {
1116 pRICsubscriptionDeleteFailure_IEs->value.choice.RICcause.present = RICcause_PR_misc;
1117 pRICsubscriptionDeleteFailure_IEs->value.choice.RICcause.choice.misc =
1118 pRICSubscriptionDeleteFailure->ricCause.cause;
1119 }
1120 else if (pRICSubscriptionDeleteFailure->ricCause.content == RICcause_PR_ric) {
1121 pRICsubscriptionDeleteFailure_IEs->value.choice.RICcause.present = RICcause_PR_ric;
1122 pRICsubscriptionDeleteFailure_IEs->value.choice.RICcause.choice.ric =
1123 pRICSubscriptionDeleteFailure->ricCause.cause;
1124 }
1125 ASN_SEQUENCE_ADD(&pE2AP_PDU->choice.unsuccessfulOutcome.value.choice.RICsubscriptionDeleteFailure.protocolIEs.list, pRICsubscriptionDeleteFailure_IEs);
1126 }
1127 else
1128 return e2err_RICSubscriptionDeleteFailureAllocRICcauseFail;
1129
1130 // CriticalityDiagnostics, OPTIONAL
1131
1132 if (E2encode(pE2AP_PDU, pDataBufferSize, pDataBuffer, pLogBuffer))
1133 return e2err_OK;
1134 else
1135 return e2err_RICSubscriptionDeleteFailureEncodeFail;
1136 }
1137 else
1138 return e2err_RICSubscriptionDeleteFailureAllocE2AP_PDUFail;
1139}
1140
1141//////////////////////////////////////////////////////////////////////
1142e2ap_pdu_ptr_t* unpackE2AP_pdu(const size_t dataBufferSize, const byte* dataBuffer, char* pLogBuffer, E2MessageInfo_t* pMessageInfo) {
1143
1144 E2AP_PDU_t* pE2AP_PDU = 0;
1145 asn_dec_rval_t rval;
1146 rval = asn_decode(0, ATS_ALIGNED_BASIC_PER, &asn_DEF_E2AP_PDU, (void **)&pE2AP_PDU, dataBuffer, dataBufferSize);
1147 switch (rval.code) {
1148 case RC_OK:
1149 // Debug print
1150 if (debug) {
Anssi Mannila4721d4e2020-01-16 09:14:47 +02001151 sprintf(pLogBuffer,"Successfully decoded E2AP-PDU");
Juha Hyttinenff8dccd2019-12-10 14:34:07 +02001152 asn_fprint(stdout, &asn_DEF_E2AP_PDU, pE2AP_PDU);
1153 }
1154
1155 if (pE2AP_PDU->present == E2AP_PDU_PR_initiatingMessage) {
1156 if (pE2AP_PDU->choice.initiatingMessage.procedureCode == ProcedureCode_id_ricSubscription) {
1157 if (pE2AP_PDU->choice.initiatingMessage.value.present == RICInitiatingMessage__value_PR_RICsubscriptionRequest) {
1158 pMessageInfo->messageType = cE2InitiatingMessage;
1159 pMessageInfo->messageId = cRICSubscriptionRequest;
1160 return (e2ap_pdu_ptr_t*)pE2AP_PDU;
1161 }
1162 else {
Anssi Mannila4721d4e2020-01-16 09:14:47 +02001163 sprintf(pLogBuffer,"Error. Not supported initiatingMessage MessageId = %u",pE2AP_PDU->choice.initiatingMessage.value.present);
Juha Hyttinenff8dccd2019-12-10 14:34:07 +02001164 return 0;
1165 }
1166 }
1167 else if (pE2AP_PDU->choice.initiatingMessage.procedureCode == ProcedureCode_id_ricIndication) {
1168 if (pE2AP_PDU->choice.initiatingMessage.value.present == RICInitiatingMessage__value_PR_RICindication) {
1169 pMessageInfo->messageType = cE2InitiatingMessage;
1170 pMessageInfo->messageId = cRICIndication;
1171 return (e2ap_pdu_ptr_t*)pE2AP_PDU;
1172 }
1173 else {
Anssi Mannila4721d4e2020-01-16 09:14:47 +02001174 sprintf(pLogBuffer,"Error. Not supported initiatingMessage MessageId = %u",pE2AP_PDU->choice.initiatingMessage.value.present);
Juha Hyttinenff8dccd2019-12-10 14:34:07 +02001175 return 0;
1176 }
1177 }
1178 else if (pE2AP_PDU->choice.initiatingMessage.procedureCode == ProcedureCode_id_ricSubscriptionDelete) {
1179 if (pE2AP_PDU->choice.initiatingMessage.value.present == RICInitiatingMessage__value_PR_RICsubscriptionDeleteRequest) {
1180 pMessageInfo->messageType = cE2InitiatingMessage;
1181 pMessageInfo->messageId = cRICSubscriptionDeleteRequest;
1182 return (e2ap_pdu_ptr_t*)pE2AP_PDU;
1183 }
1184 else {
Anssi Mannila4721d4e2020-01-16 09:14:47 +02001185 sprintf(pLogBuffer,"Error. Not supported initiatingMessage MessageId = %u",pE2AP_PDU->choice.initiatingMessage.value.present);
Juha Hyttinenff8dccd2019-12-10 14:34:07 +02001186 return 0;
1187 }
1188 }
1189 else {
Anssi Mannila4721d4e2020-01-16 09:14:47 +02001190 sprintf(pLogBuffer,"Error. Procedure not supported. ProcedureCode = %li",pE2AP_PDU->choice.initiatingMessage.procedureCode);
Juha Hyttinenff8dccd2019-12-10 14:34:07 +02001191 return 0;
1192 }
1193 }
1194 else if (pE2AP_PDU->present == E2AP_PDU_PR_successfulOutcome) {
1195 if (pE2AP_PDU->choice.successfulOutcome.procedureCode == ProcedureCode_id_ricSubscription) {
1196 if (pE2AP_PDU->choice.successfulOutcome.value.present == RICSuccessfulOutcome__value_PR_RICsubscriptionResponse) {
1197 pMessageInfo->messageType = cE2SuccessfulOutcome;
1198 pMessageInfo->messageId = cRICSubscriptionResponse;
1199 return (e2ap_pdu_ptr_t*)pE2AP_PDU;
1200 }
1201 else {
Anssi Mannila4721d4e2020-01-16 09:14:47 +02001202 sprintf(pLogBuffer,"Error. Not supported successfulOutcome MessageId = %u",pE2AP_PDU->choice.successfulOutcome.value.present);
Juha Hyttinenff8dccd2019-12-10 14:34:07 +02001203 return 0;
1204 }
1205 }
1206 else if (pE2AP_PDU->choice.successfulOutcome.procedureCode == ProcedureCode_id_ricSubscriptionDelete) {
1207 if (pE2AP_PDU->choice.successfulOutcome.value.present == RICSuccessfulOutcome__value_PR_RICsubscriptionDeleteResponse) {
1208 pMessageInfo->messageType = cE2SuccessfulOutcome;
1209 pMessageInfo->messageId = cRICsubscriptionDeleteResponse;
1210 return (e2ap_pdu_ptr_t*)pE2AP_PDU;
1211 }
1212 else {
Anssi Mannila4721d4e2020-01-16 09:14:47 +02001213 sprintf(pLogBuffer,"Error. Not supported successfulOutcome MessageId = %u",pE2AP_PDU->choice.successfulOutcome.value.present);
Juha Hyttinenff8dccd2019-12-10 14:34:07 +02001214 return 0;
1215 }
1216 }
1217 else {
Anssi Mannila4721d4e2020-01-16 09:14:47 +02001218 sprintf(pLogBuffer,"Error. Procedure not supported. ProcedureCode = %li",pE2AP_PDU->choice.successfulOutcome.procedureCode);
Juha Hyttinenff8dccd2019-12-10 14:34:07 +02001219 return 0;
1220 }
1221 }
1222 else if (pE2AP_PDU->present == E2AP_PDU_PR_unsuccessfulOutcome) {
1223 if (pE2AP_PDU->choice.unsuccessfulOutcome.procedureCode == ProcedureCode_id_ricSubscription) {
1224 if (pE2AP_PDU->choice.unsuccessfulOutcome.value.present == RICUnsuccessfulOutcome__value_PR_RICsubscriptionFailure) {
1225 pMessageInfo->messageType = cE2UnsuccessfulOutcome;
1226 pMessageInfo->messageId = cRICSubscriptionFailure;
1227 return (e2ap_pdu_ptr_t*)pE2AP_PDU;
1228 }
1229 else {
Anssi Mannila4721d4e2020-01-16 09:14:47 +02001230 sprintf(pLogBuffer,"Error. Not supported unsuccessfulOutcome MessageId = %u",pE2AP_PDU->choice.unsuccessfulOutcome.value.present);
Juha Hyttinenff8dccd2019-12-10 14:34:07 +02001231 return 0;
1232 }
1233 }
1234 else if (pE2AP_PDU->choice.unsuccessfulOutcome.procedureCode == ProcedureCode_id_ricSubscriptionDelete) {
1235 if (pE2AP_PDU->choice.unsuccessfulOutcome.value.present == RICUnsuccessfulOutcome__value_PR_RICsubscriptionDeleteFailure) {
1236 pMessageInfo->messageType = cE2UnsuccessfulOutcome;
1237 pMessageInfo->messageId = cRICsubscriptionDeleteFailure;
1238 return (e2ap_pdu_ptr_t*)pE2AP_PDU;
1239 }
1240 else {
Anssi Mannila4721d4e2020-01-16 09:14:47 +02001241 sprintf(pLogBuffer,"Error. Not supported unsuccessfulOutcome MessageId = %u",pE2AP_PDU->choice.unsuccessfulOutcome.value.present);
Juha Hyttinenff8dccd2019-12-10 14:34:07 +02001242 return 0;
1243 }
1244 }
1245 }
1246 else
Anssi Mannila4721d4e2020-01-16 09:14:47 +02001247 sprintf(pLogBuffer,"Decode failed. Invalid message type %u",pE2AP_PDU->present);
Juha Hyttinenff8dccd2019-12-10 14:34:07 +02001248 ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pE2AP_PDU);
1249 return 0;
1250 case RC_WMORE:
Anssi Mannila4721d4e2020-01-16 09:14:47 +02001251 sprintf(pLogBuffer,"Decode failed. More data needed. Buffer size %zu, %s, consumed %zu",dataBufferSize, asn_DEF_E2AP_PDU.name, rval.consumed);
Juha Hyttinenff8dccd2019-12-10 14:34:07 +02001252 return 0;
1253 case RC_FAIL:
Anssi Mannila4721d4e2020-01-16 09:14:47 +02001254 sprintf(pLogBuffer,"Decode failed. Buffer size %zu, %s, consumed %zu",dataBufferSize, asn_DEF_E2AP_PDU.name, rval.consumed);
Juha Hyttinenff8dccd2019-12-10 14:34:07 +02001255 return 0;
1256 default:
1257 return 0;
1258 }
1259}
1260
1261//////////////////////////////////////////////////////////////////////
1262uint64_t getRICSubscriptionRequestData(e2ap_pdu_ptr_t* pE2AP_PDU_pointer, RICSubscriptionRequest_t* pRICSubscriptionRequest) {
1263
1264 E2AP_PDU_t* pE2AP_PDU = (E2AP_PDU_t*)pE2AP_PDU_pointer;
1265 RICsubscriptionRequest_IEs_t* pRICsubscriptionRequest_IEs;
1266 // RICrequestID
1267 if (pE2AP_PDU->choice.initiatingMessage.value.choice.RICsubscriptionRequest.protocolIEs.list.count > 0) {
1268 pRICsubscriptionRequest_IEs = pE2AP_PDU->choice.initiatingMessage.value.choice.RICsubscriptionRequest.protocolIEs.list.array[0];
1269 pRICSubscriptionRequest->ricRequestID.ricRequestorID = pRICsubscriptionRequest_IEs->value.choice.RICrequestID.ricRequestorID;
1270 pRICSubscriptionRequest->ricRequestID.ricRequestSequenceNumber = pRICsubscriptionRequest_IEs->value.choice.RICrequestID.ricRequestSequenceNumber;
1271 }
1272 else {
1273 ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pE2AP_PDU);
1274 return e2err_RICsubscriptionRequestRICrequestIDMissing;
1275 }
1276
1277 // RANfunctionID
1278 if (pE2AP_PDU->choice.initiatingMessage.value.choice.RICsubscriptionRequest.protocolIEs.list.count > 1) {
1279 pRICsubscriptionRequest_IEs = pE2AP_PDU->choice.initiatingMessage.value.choice.RICsubscriptionRequest.protocolIEs.list.array[1];
1280 pRICSubscriptionRequest->ranFunctionID = pRICsubscriptionRequest_IEs->value.choice.RANfunctionID;
1281 }
1282 else {
1283 ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pE2AP_PDU);
1284 return e2err_RICsubscriptionRequestRANfunctionIDMissing;
1285 }
1286
1287 // RICsubscription
1288 if (pE2AP_PDU->choice.initiatingMessage.value.choice.RICsubscriptionRequest.protocolIEs.list.count > 2) {
1289 pRICsubscriptionRequest_IEs = pE2AP_PDU->choice.initiatingMessage.value.choice.RICsubscriptionRequest.protocolIEs.list.array[2];
1290
1291 // Unpack EventTriggerDefinition
1292 RICeventTriggerDefinition_t* pRICeventTriggerDefinition =
1293 (RICeventTriggerDefinition_t*)&pRICsubscriptionRequest_IEs->value.choice.RICsubscription.ricEventTriggerDefinition;
1294 pRICSubscriptionRequest->ricSubscription.ricEventTriggerDefinition.octetString.contentLength = pRICeventTriggerDefinition->size;
1295 memcpy(pRICSubscriptionRequest->ricSubscription.ricEventTriggerDefinition.octetString.data, pRICeventTriggerDefinition->buf, pRICeventTriggerDefinition->size); //octetstring
1296
1297 uint64_t returnCode;
1298 if ((returnCode = getRICEventTriggerDefinitionData(&pRICSubscriptionRequest->ricSubscription.ricEventTriggerDefinition) != e2err_OK)) {
1299 ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pE2AP_PDU);
1300 return returnCode;
1301 }
1302
1303 // RICactions-ToBeSetup-List
1304 RICaction_ToBeSetup_ItemIEs_t* pRICaction_ToBeSetup_ItemIEs;
1305 uint64_t index = 0;
1306 while (index < pRICsubscriptionRequest_IEs->value.choice.RICsubscription.ricAction_ToBeSetup_List.list.count)
1307 {
1308 pRICaction_ToBeSetup_ItemIEs = (RICaction_ToBeSetup_ItemIEs_t*)pRICsubscriptionRequest_IEs->value.choice.RICsubscription.ricAction_ToBeSetup_List.list.array[index];
1309
1310 // RICActionID
1311 pRICSubscriptionRequest->ricSubscription.ricActionToBeSetupItemIEs.ricActionToBeSetupItem[index].ricActionID =
1312 pRICaction_ToBeSetup_ItemIEs->value.choice.RICaction_ToBeSetup_Item.ricActionID;
1313
1314 // RICActionType
1315 pRICSubscriptionRequest->ricSubscription.ricActionToBeSetupItemIEs.ricActionToBeSetupItem[index].ricActionType =
1316 pRICaction_ToBeSetup_ItemIEs->value.choice.RICaction_ToBeSetup_Item.ricActionType;
1317
1318 // RICactionDefinition, OPTIONAL
1319 if (pRICaction_ToBeSetup_ItemIEs->value.choice.RICaction_ToBeSetup_Item.ricActionDefinition)
1320 {
1321 pRICSubscriptionRequest->ricSubscription.ricActionToBeSetupItemIEs.ricActionToBeSetupItem[index].ricActionDefinitionPresent = false;
1322 // not used in RIC
1323 }
1324 else
1325 pRICSubscriptionRequest->ricSubscription.ricActionToBeSetupItemIEs.ricActionToBeSetupItem[index].ricActionDefinitionPresent = false;
1326
1327 // RICsubsequentAction, OPTIONAL
1328 RICsubsequentAction_t* pRICsubsequentAction;
1329 if (pRICaction_ToBeSetup_ItemIEs->value.choice.RICaction_ToBeSetup_Item.ricSubsequentAction)
1330 {
1331 pRICsubsequentAction = pRICaction_ToBeSetup_ItemIEs->value.choice.RICaction_ToBeSetup_Item.ricSubsequentAction;
1332 pRICSubscriptionRequest->ricSubscription.ricActionToBeSetupItemIEs.ricActionToBeSetupItem[index].ricSubsequentActionPresent = true;
1333 pRICSubscriptionRequest->ricSubscription.ricActionToBeSetupItemIEs.ricActionToBeSetupItem[index].ricSubsequentAction.ricSubsequentActionType =
1334 pRICsubsequentAction->ricSubsequentActionType;
1335 pRICSubscriptionRequest->ricSubscription.ricActionToBeSetupItemIEs.ricActionToBeSetupItem[index].ricSubsequentAction.ricTimeToWait =
1336 pRICsubsequentAction->ricTimeToWait;
1337 }
1338 else
1339 pRICSubscriptionRequest->ricSubscription.ricActionToBeSetupItemIEs.ricActionToBeSetupItem[index].ricSubsequentActionPresent = false;
1340 index++;
1341 }
1342 pRICSubscriptionRequest->ricSubscription.ricActionToBeSetupItemIEs.contentLength = index;
1343 }
1344 else {
1345 ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pE2AP_PDU);
1346 return e2err_RICsubscriptionRequestICsubscriptionMissing;
1347 }
1348
1349 ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pE2AP_PDU);
1350 return e2err_OK;
1351}
1352
1353//////////////////////////////////////////////////////////////////////
1354uint64_t getRICEventTriggerDefinitionData(RICEventTriggerDefinition_t* pRICEventTriggerDefinition) {
1355
1356 E2SM_gNB_X2_eventTriggerDefinition_t* pE2SM_gNB_X2_eventTriggerDefinition = 0;
1357 asn_dec_rval_t rval;
1358 rval = asn_decode(0, ATS_ALIGNED_BASIC_PER, &asn_DEF_E2SM_gNB_X2_eventTriggerDefinition, (void **)&pE2SM_gNB_X2_eventTriggerDefinition,
1359 pRICEventTriggerDefinition->octetString.data, pRICEventTriggerDefinition->octetString.contentLength);
1360 switch(rval.code) {
1361 case RC_OK:
1362 // Debug print
1363 if (debug) {
Anssi Mannila4721d4e2020-01-16 09:14:47 +02001364 printf("Successfully decoded E2SM_gNB_X2_eventTriggerDefinition");
Juha Hyttinenff8dccd2019-12-10 14:34:07 +02001365 asn_fprint(stdout, &asn_DEF_E2SM_gNB_X2_eventTriggerDefinition, pE2SM_gNB_X2_eventTriggerDefinition);
1366 }
1367
1368 // InterfaceID, GlobalENB-ID or GlobalGNB-ID
1369 if (pE2SM_gNB_X2_eventTriggerDefinition->interface_ID.present == Interface_ID_PR_global_eNB_ID) {
1370
1371 // GlobalENB-ID
1372 pRICEventTriggerDefinition->interfaceID.globalENBIDPresent = true;
1373
1374 // PLMN-Identity
1375 pRICEventTriggerDefinition->interfaceID.globalENBID.pLMNIdentity.contentLength =
1376 pE2SM_gNB_X2_eventTriggerDefinition->interface_ID.choice.global_eNB_ID.pLMN_Identity.size;
1377 memcpy(pRICEventTriggerDefinition->interfaceID.globalENBID.pLMNIdentity.pLMNIdentityVal,
1378 pE2SM_gNB_X2_eventTriggerDefinition->interface_ID.choice.global_eNB_ID.pLMN_Identity.buf,
1379 pRICEventTriggerDefinition->interfaceID.globalENBID.pLMNIdentity.contentLength);
1380
1381 // ENB-ID
1382 IdOctects_t eNBOctects;
1383 memset(eNBOctects.octets, 0, sizeof(eNBOctects));
1384 if (pE2SM_gNB_X2_eventTriggerDefinition->interface_ID.choice.global_eNB_ID.eNB_ID.present == ENB_ID_PR_macro_eNB_ID) {
1385 // BIT STRING (SIZE (20)
1386 pRICEventTriggerDefinition->interfaceID.globalENBID.nodeID.bits = cMacroENBIDP_20Bits;
1387 memcpy(eNBOctects.octets,pE2SM_gNB_X2_eventTriggerDefinition->interface_ID.choice.global_eNB_ID.eNB_ID.choice.macro_eNB_ID.buf,
1388 pE2SM_gNB_X2_eventTriggerDefinition->interface_ID.choice.global_eNB_ID.eNB_ID.choice.macro_eNB_ID.size);
1389 pRICEventTriggerDefinition->interfaceID.globalENBID.nodeID.nodeID = eNBOctects.nodeID;
1390 }
1391 else if (pE2SM_gNB_X2_eventTriggerDefinition->interface_ID.choice.global_eNB_ID.eNB_ID.present == ENB_ID_PR_home_eNB_ID) {
1392 // BIT STRING (SIZE (28)
1393 pRICEventTriggerDefinition->interfaceID.globalENBID.nodeID.bits = cHomeENBID_28Bits;
1394 memcpy(eNBOctects.octets,pE2SM_gNB_X2_eventTriggerDefinition->interface_ID.choice.global_eNB_ID.eNB_ID.choice.home_eNB_ID.buf,
1395 pE2SM_gNB_X2_eventTriggerDefinition->interface_ID.choice.global_eNB_ID.eNB_ID.choice.home_eNB_ID.size);
1396 pRICEventTriggerDefinition->interfaceID.globalENBID.nodeID.nodeID = eNBOctects.nodeID;
1397 }
1398 else if (pE2SM_gNB_X2_eventTriggerDefinition->interface_ID.choice.global_eNB_ID.eNB_ID.present == ENB_ID_PR_short_Macro_eNB_ID) {
1399 // BIT STRING (SIZE(18)
1400 pRICEventTriggerDefinition->interfaceID.globalENBID.nodeID.bits = cShortMacroENBID_18Bits;
1401 memcpy(eNBOctects.octets,pE2SM_gNB_X2_eventTriggerDefinition->interface_ID.choice.global_eNB_ID.eNB_ID.choice.short_Macro_eNB_ID.buf,
1402 pE2SM_gNB_X2_eventTriggerDefinition->interface_ID.choice.global_eNB_ID.eNB_ID.choice.short_Macro_eNB_ID.size);
1403 pRICEventTriggerDefinition->interfaceID.globalENBID.nodeID.nodeID = eNBOctects.nodeID;
1404 }
1405 else if (pE2SM_gNB_X2_eventTriggerDefinition->interface_ID.choice.global_eNB_ID.eNB_ID.present == ENB_ID_PR_long_Macro_eNB_ID) {
1406 // BIT STRING (SIZE(21)
1407 pRICEventTriggerDefinition->interfaceID.globalENBID.nodeID.bits = clongMacroENBIDP_21Bits;
1408 memcpy(eNBOctects.octets,pE2SM_gNB_X2_eventTriggerDefinition->interface_ID.choice.global_eNB_ID.eNB_ID.choice.long_Macro_eNB_ID.buf,
1409 pE2SM_gNB_X2_eventTriggerDefinition->interface_ID.choice.global_eNB_ID.eNB_ID.choice.long_Macro_eNB_ID.size);
1410 pRICEventTriggerDefinition->interfaceID.globalENBID.nodeID.nodeID = eNBOctects.nodeID;
1411 }
1412 else {
1413 pRICEventTriggerDefinition->interfaceID.globalENBIDPresent = false;
1414 pRICEventTriggerDefinition->interfaceID.globalGNBIDPresent = false;
1415 ASN_STRUCT_FREE(asn_DEF_E2SM_gNB_X2_eventTriggerDefinition, pE2SM_gNB_X2_eventTriggerDefinition);
1416 return e2err_RICEventTriggerDefinitionIEValueFail_5;
1417 }
1418 }
1419 else if (pE2SM_gNB_X2_eventTriggerDefinition->interface_ID.present == Interface_ID_PR_global_gNB_ID) {
1420 // GlobalGNB-ID
1421 pRICEventTriggerDefinition->interfaceID.globalGNBIDPresent = true;
1422
1423 // PLMN-Identity
1424 pRICEventTriggerDefinition->interfaceID.globalGNBID.pLMNIdentity.contentLength =
1425 pE2SM_gNB_X2_eventTriggerDefinition->interface_ID.choice.global_eNB_ID.pLMN_Identity.size;
1426 memcpy(pRICEventTriggerDefinition->interfaceID.globalGNBID.pLMNIdentity.pLMNIdentityVal,
1427 pE2SM_gNB_X2_eventTriggerDefinition->interface_ID.choice.global_eNB_ID.pLMN_Identity.buf,
1428 pRICEventTriggerDefinition->interfaceID.globalGNBID.pLMNIdentity.contentLength);
1429
1430 // GNB-ID
1431 IdOctects_t gNBOctects;
1432 memset(gNBOctects.octets, 0, sizeof(gNBOctects));
1433 if (pE2SM_gNB_X2_eventTriggerDefinition->interface_ID.choice.global_gNB_ID.gNB_ID.present == GNB_ID_PR_gNB_ID) {
1434 pRICEventTriggerDefinition->interfaceID.globalGNBID.nodeID.bits = pE2SM_gNB_X2_eventTriggerDefinition->interface_ID.choice.global_gNB_ID.gNB_ID.choice.gNB_ID.size;
1435 memcpy(gNBOctects.octets, pE2SM_gNB_X2_eventTriggerDefinition->interface_ID.choice.global_gNB_ID.gNB_ID.choice.gNB_ID.buf,
1436 pRICEventTriggerDefinition->interfaceID.globalGNBID.nodeID.bits);
1437 pRICEventTriggerDefinition->interfaceID.globalGNBID.nodeID.nodeID = gNBOctects.nodeID;
1438 }
1439 else {
1440 pRICEventTriggerDefinition->interfaceID.globalENBIDPresent = false;
1441 pRICEventTriggerDefinition->interfaceID.globalGNBIDPresent = false;
1442 ASN_STRUCT_FREE(asn_DEF_E2SM_gNB_X2_eventTriggerDefinition, pE2SM_gNB_X2_eventTriggerDefinition);
1443 return e2err_RICEventTriggerDefinitionIEValueFail_6;
1444 }
1445 }
1446 else {
1447 pRICEventTriggerDefinition->interfaceID.globalENBIDPresent = false;
1448 pRICEventTriggerDefinition->interfaceID.globalGNBIDPresent = false;
1449 ASN_STRUCT_FREE(asn_DEF_E2SM_gNB_X2_eventTriggerDefinition, pE2SM_gNB_X2_eventTriggerDefinition);
1450 return e2err_RICEventTriggerDefinitionIEValueFail_7;
1451 }
1452
1453 // InterfaceDirection
1454 pRICEventTriggerDefinition->interfaceDirection = pE2SM_gNB_X2_eventTriggerDefinition->interfaceDirection;
1455
1456 // InterfaceMessageType
1457 pRICEventTriggerDefinition->interfaceMessageType.procedureCode = pE2SM_gNB_X2_eventTriggerDefinition->interfaceMessageType.procedureCode;
1458
1459 if (pE2SM_gNB_X2_eventTriggerDefinition->interfaceMessageType.typeOfMessage == TypeOfMessage_initiating_message)
1460 pRICEventTriggerDefinition->interfaceMessageType.typeOfMessage = cE2InitiatingMessage;
1461 else if (pE2SM_gNB_X2_eventTriggerDefinition->interfaceMessageType.typeOfMessage == TypeOfMessage_successful_outcome)
1462 pRICEventTriggerDefinition->interfaceMessageType.typeOfMessage = cE2SuccessfulOutcome;
1463 else if (pE2SM_gNB_X2_eventTriggerDefinition->interfaceMessageType.typeOfMessage == TypeOfMessage_unsuccessful_outcome)
1464 pRICEventTriggerDefinition->interfaceMessageType.typeOfMessage = cE2UnsuccessfulOutcome;
1465 else {
1466 ASN_STRUCT_FREE(asn_DEF_E2SM_gNB_X2_eventTriggerDefinition, pE2SM_gNB_X2_eventTriggerDefinition);
1467 return e2err_RICEventTriggerDefinitionIEValueFail_8;
1468 }
1469
1470 ASN_STRUCT_FREE(asn_DEF_E2SM_gNB_X2_eventTriggerDefinition, pE2SM_gNB_X2_eventTriggerDefinition);
1471 return e2err_OK;
1472 case RC_WMORE:
1473 if (debug)
Anssi Mannila4721d4e2020-01-16 09:14:47 +02001474 printf("Decode failed. More data needed. Buffer size %zu, %s, consumed %zu",pRICEventTriggerDefinition->octetString.contentLength,
Juha Hyttinenff8dccd2019-12-10 14:34:07 +02001475 asn_DEF_E2SM_gNB_X2_eventTriggerDefinition.name, rval.consumed);
1476
1477 return e2err_RICEventTriggerDefinitionDecodeWMOREFail;
1478 case RC_FAIL:
1479 if (debug)
Anssi Mannila4721d4e2020-01-16 09:14:47 +02001480 printf("Decode failed. Buffer size %zu, %s, consumed %zu",pRICEventTriggerDefinition->octetString.contentLength,
Juha Hyttinenff8dccd2019-12-10 14:34:07 +02001481 asn_DEF_E2SM_gNB_X2_eventTriggerDefinition.name, rval.consumed);
1482
1483 return e2err_RICEventTriggerDefinitionDecodeFAIL;
1484 default:
1485 return e2err_RICEventTriggerDefinitionDecodeDefaultFail;
1486 }
1487}
1488
1489//////////////////////////////////////////////////////////////////////
1490uint64_t getRICSubscriptionResponseData(e2ap_pdu_ptr_t* pE2AP_PDU_pointer, RICSubscriptionResponse_t* pRICSubscriptionResponse) {
1491
1492 E2AP_PDU_t* pE2AP_PDU = (E2AP_PDU_t*)pE2AP_PDU_pointer;
1493
1494 // RICrequestID
1495 RICsubscriptionResponse_IEs_t* pRICsubscriptionResponse_IEs;
1496 if (pE2AP_PDU->choice.successfulOutcome.value.choice.RICsubscriptionResponse.protocolIEs.list.count > 0) {
1497 pRICsubscriptionResponse_IEs = pE2AP_PDU->choice.successfulOutcome.value.choice.RICsubscriptionResponse.protocolIEs.list.array[0];
1498 pRICSubscriptionResponse->ricRequestID.ricRequestorID = pRICsubscriptionResponse_IEs->value.choice.RICrequestID.ricRequestorID;
1499 pRICSubscriptionResponse->ricRequestID.ricRequestSequenceNumber = pRICsubscriptionResponse_IEs->value.choice.RICrequestID.ricRequestSequenceNumber;
1500 }
1501 else {
1502 ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pE2AP_PDU);
1503 return e2err_RICsubscriptionResponseRICrequestIDMissing;
1504 }
1505
1506 // RANfunctionID
1507 if (pE2AP_PDU->choice.successfulOutcome.value.choice.RICsubscriptionResponse.protocolIEs.list.count > 1) {
1508 pRICsubscriptionResponse_IEs = pE2AP_PDU->choice.successfulOutcome.value.choice.RICsubscriptionResponse.protocolIEs.list.array[1];
1509 pRICSubscriptionResponse->ranFunctionID = pRICsubscriptionResponse_IEs->value.choice.RANfunctionID;
1510 }
1511 else {
1512 ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pE2AP_PDU);
1513 return e2err_RICsubscriptionResponseRANfunctionIDMissing;
1514 }
1515
1516 // RICaction-Admitted-List
1517 if (pE2AP_PDU->choice.successfulOutcome.value.choice.RICsubscriptionResponse.protocolIEs.list.count > 2) {
1518 pRICsubscriptionResponse_IEs = pE2AP_PDU->choice.successfulOutcome.value.choice.RICsubscriptionResponse.protocolIEs.list.array[2];
1519 pRICSubscriptionResponse->ricActionAdmittedList.contentLength = 0;
1520 uint64_t index = 0;
1521 while ((index < maxofRICactionID) && (index < pRICsubscriptionResponse_IEs->value.choice.RICaction_Admitted_List.list.count)) {
1522 RICaction_Admitted_ItemIEs_t* pRICaction_Admitted_ItemIEs =
1523 (RICaction_Admitted_ItemIEs_t*)pRICsubscriptionResponse_IEs->value.choice.RICaction_Admitted_List.list.array[index];
1524
1525 // RICActionID
1526 pRICSubscriptionResponse->ricActionAdmittedList.ricActionID[index] =
1527 pRICaction_Admitted_ItemIEs->value.choice.RICaction_Admitted_Item.ricActionID;
1528 index++;
1529 }
1530 pRICSubscriptionResponse->ricActionAdmittedList.contentLength = index;
1531 }
1532 else {
1533 ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pE2AP_PDU);
1534 return e2err_RICsubscriptionResponseRICaction_Admitted_ListMissing;
1535 }
1536
1537 // RICaction-NotAdmitted-List, OPTIONAL
1538 if (pE2AP_PDU->choice.successfulOutcome.value.choice.RICsubscriptionResponse.protocolIEs.list.count > 3) {
1539 pRICsubscriptionResponse_IEs = pE2AP_PDU->choice.successfulOutcome.value.choice.RICsubscriptionResponse.protocolIEs.list.array[3];
1540 if (pRICsubscriptionResponse_IEs->value.present == RICsubscriptionResponse_IEs__value_PR_RICaction_NotAdmitted_List) {
1541 pRICSubscriptionResponse->ricActionNotAdmittedListPresent = true;
1542 pRICSubscriptionResponse->ricActionNotAdmittedList.contentLength = 0;
1543 uint64_t index = 0;
1544 while ((index < maxofRICactionID) && (index < pRICsubscriptionResponse_IEs->value.choice.RICaction_NotAdmitted_List.list.count)) {
1545 RICaction_NotAdmitted_ItemIEs_t* pRICaction_NotAdmitted_ItemIEs =
1546 (RICaction_NotAdmitted_ItemIEs_t*)pRICsubscriptionResponse_IEs->value.choice.RICaction_NotAdmitted_List.list.array[index];
1547
1548 // RICActionID
1549 pRICSubscriptionResponse->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].ricActionID =
1550 pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.ricActionID;
1551
1552 // RICcause
1553 if (pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.ricCause.present == RICcause_PR_radioNetwork) {
1554 pRICSubscriptionResponse->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].ricCause.content = RICcause_PR_radioNetwork;
1555 pRICSubscriptionResponse->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].ricCause.cause =
1556 pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.ricCause.choice.radioNetwork;
1557 }
1558 else if (pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.ricCause.present == RICcause_PR_transport) {
1559 pRICSubscriptionResponse->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].ricCause.content = RICcause_PR_transport;
1560 pRICSubscriptionResponse->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].ricCause.cause =
1561 pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.ricCause.choice.transport;
1562 }
1563 else if (pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.ricCause.present == RICcause_PR_protocol) {
1564 pRICSubscriptionResponse->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].ricCause.content = RICcause_PR_protocol;
1565 pRICSubscriptionResponse->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].ricCause.cause =
1566 pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.ricCause.choice.protocol;
1567 }
1568 else if(pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.ricCause.present == RICcause_PR_misc) {
1569 pRICSubscriptionResponse->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].ricCause.content = RICcause_PR_misc;
1570 pRICSubscriptionResponse->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].ricCause.cause =
1571 pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.ricCause.choice.misc;
1572 }
1573 else if (pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.ricCause.present == RICcause_PR_ric) {
1574 pRICSubscriptionResponse->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].ricCause.content = RICcause_PR_ric;
1575 pRICSubscriptionResponse->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].ricCause.cause =
1576 pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.ricCause.choice.ric;
1577 }
1578 index++;
1579 }
1580 pRICSubscriptionResponse->ricActionNotAdmittedList.contentLength = index;
1581 }
1582 }
Juha Hyttinenff8dccd2019-12-10 14:34:07 +02001583
1584 ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pE2AP_PDU);
1585 return e2err_OK;
1586}
1587
1588//////////////////////////////////////////////////////////////////////
1589uint64_t getRICSubscriptionFailureData(e2ap_pdu_ptr_t* pE2AP_PDU_pointer, RICSubscriptionFailure_t* pRICSubscriptionFailure) {
1590
1591 E2AP_PDU_t* pE2AP_PDU = (E2AP_PDU_t*)pE2AP_PDU_pointer;
1592
1593 // RICrequestID
1594 RICsubscriptionFailure_IEs_t* pRICsubscriptionFailure_IEs;
1595 if (pE2AP_PDU->choice.unsuccessfulOutcome.value.choice.RICsubscriptionFailure.protocolIEs.list.count > 0) {
1596 pRICsubscriptionFailure_IEs = pE2AP_PDU->choice.unsuccessfulOutcome.value.choice.RICsubscriptionFailure.protocolIEs.list.array[0];
1597 pRICSubscriptionFailure->ricRequestID.ricRequestorID = pRICsubscriptionFailure_IEs->value.choice.RICrequestID.ricRequestorID;
1598 pRICSubscriptionFailure->ricRequestID.ricRequestSequenceNumber = pRICsubscriptionFailure_IEs->value.choice.RICrequestID.ricRequestSequenceNumber;
1599 }
1600 else {
1601 ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pE2AP_PDU);
1602 return e2err_RICsubscriptionFailureRICrequestIDMissing;
1603 }
1604
1605 // RANfunctionID
1606 if (pE2AP_PDU->choice.unsuccessfulOutcome.value.choice.RICsubscriptionFailure.protocolIEs.list.count > 1) {
1607 pRICsubscriptionFailure_IEs = pE2AP_PDU->choice.unsuccessfulOutcome.value.choice.RICsubscriptionFailure.protocolIEs.list.array[1];
1608 pRICSubscriptionFailure->ranFunctionID = pRICsubscriptionFailure_IEs->value.choice.RANfunctionID;
1609 }
1610 else {
1611 ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pE2AP_PDU);
1612 return e2err_RICsubscriptionFailureRANfunctionIDMissing;
1613 }
1614
1615 // RICaction-NotAdmitted-List
1616 if (pE2AP_PDU->choice.unsuccessfulOutcome.value.choice.RICsubscriptionFailure.protocolIEs.list.count > 2) {
1617 pRICsubscriptionFailure_IEs = pE2AP_PDU->choice.unsuccessfulOutcome.value.choice.RICsubscriptionFailure.protocolIEs.list.array[2];
1618 uint64_t index = 0;
1619 while ((index < maxofRICactionID) && (index < pRICsubscriptionFailure_IEs->value.choice.RICaction_NotAdmitted_List.list.count)) {
1620 RICaction_NotAdmitted_ItemIEs_t* pRICaction_NotAdmitted_ItemIEs =
1621 (RICaction_NotAdmitted_ItemIEs_t*)pRICsubscriptionFailure_IEs->value.choice.RICaction_NotAdmitted_List.list.array[index];
1622
1623 // RICActionID
1624 pRICSubscriptionFailure->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].ricActionID =
1625 pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.ricActionID;
1626
1627 // RICcause
1628 if (pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.ricCause.present == RICcause_PR_radioNetwork) {
1629 pRICSubscriptionFailure->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].ricCause.content = RICcause_PR_radioNetwork;
1630 pRICSubscriptionFailure->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].ricCause.cause =
1631 pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.ricCause.choice.radioNetwork;
1632 }
1633 else if (pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.ricCause.present == RICcause_PR_transport) {
1634 pRICSubscriptionFailure->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].ricCause.content = RICcause_PR_transport;
1635 pRICSubscriptionFailure->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].ricCause.cause =
1636 pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.ricCause.choice.transport;
1637 }
1638 else if (pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.ricCause.present == RICcause_PR_protocol) {
1639 pRICSubscriptionFailure->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].ricCause.content = RICcause_PR_protocol;
1640 pRICSubscriptionFailure->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].ricCause.cause =
1641 pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.ricCause.choice.protocol;
1642 }
1643 else if(pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.ricCause.present == RICcause_PR_misc) {
1644 pRICSubscriptionFailure->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].ricCause.content = RICcause_PR_misc;
1645 pRICSubscriptionFailure->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].ricCause.cause =
1646 pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.ricCause.choice.misc;
1647 }
1648 else if (pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.ricCause.present == RICcause_PR_ric) {
1649 pRICSubscriptionFailure->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].ricCause.content = RICcause_PR_ric;
1650 pRICSubscriptionFailure->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].ricCause.cause =
1651 pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.ricCause.choice.ric;
1652 }
1653 index++;
1654 }
1655 pRICSubscriptionFailure->ricActionNotAdmittedList.contentLength = index;
1656
1657 // CriticalityDiagnostics. OPTIONAL
1658
1659 }
1660 else {
1661 ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pE2AP_PDU);
1662 return e2err_RICsubscriptionFailureRICaction_NotAdmitted_ListMissing;
1663 }
1664
1665 ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pE2AP_PDU);
1666 return e2err_OK;
1667}
1668
1669//////////////////////////////////////////////////////////////////////
1670uint64_t getRICIndicationData(e2ap_pdu_ptr_t* pE2AP_PDU_pointer, RICIndication_t* pRICIndication) {
1671
1672 E2AP_PDU_t* pE2AP_PDU = (E2AP_PDU_t*)pE2AP_PDU_pointer;
1673
1674 // RICrequestID
1675 RICindication_IEs_t* pRICindication_IEs;
1676 if (pE2AP_PDU->choice.initiatingMessage.value.choice.RICindication.protocolIEs.list.count > 0) {
1677 pRICindication_IEs = pE2AP_PDU->choice.initiatingMessage.value.choice.RICindication.protocolIEs.list.array[0];
1678 pRICIndication->ricRequestID.ricRequestorID = pRICindication_IEs->value.choice.RICrequestID.ricRequestorID;
1679 pRICIndication->ricRequestID.ricRequestSequenceNumber = pRICindication_IEs->value.choice.RICrequestID.ricRequestSequenceNumber;
1680 }
1681 else {
1682 ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pE2AP_PDU);
1683 return e2err_RICindicationRICrequestIDMissing;
1684 }
1685
1686 // RANfunctionID
1687 if (pE2AP_PDU->choice.initiatingMessage.value.choice.RICindication.protocolIEs.list.count > 1) {
1688 pRICindication_IEs = pE2AP_PDU->choice.initiatingMessage.value.choice.RICindication.protocolIEs.list.array[1];
1689 pRICIndication->ranFunctionID = pRICindication_IEs->value.choice.RANfunctionID;
1690 }
1691 else {
1692 ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pE2AP_PDU);
1693 return e2err_RICindicationRANfunctionIDMissing;
1694 }
1695
1696 // RICactionID
1697 if (pE2AP_PDU->choice.initiatingMessage.value.choice.RICindication.protocolIEs.list.count > 2) {
1698 pRICindication_IEs = pE2AP_PDU->choice.initiatingMessage.value.choice.RICindication.protocolIEs.list.array[2];
1699 pRICIndication->ricActionID = pRICindication_IEs->value.choice.RICactionID;
1700 }
1701 else {
1702 ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pE2AP_PDU);
1703 return e2err_RICindicationRICactionIDMissing;
1704 }
1705
1706 // RICindicationSN
1707 if (pE2AP_PDU->choice.initiatingMessage.value.choice.RICindication.protocolIEs.list.count > 3) {
1708 pRICindication_IEs = pE2AP_PDU->choice.initiatingMessage.value.choice.RICindication.protocolIEs.list.array[3];
1709 pRICIndication->ricIndicationSN = pRICindication_IEs->value.choice.RICindicationSN;
1710 }
1711 else {
1712 ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pE2AP_PDU);
1713 return e2err_RICindicationRICindicationSNMissing;
1714 }
1715
1716 // RICindicationType
1717 if (pE2AP_PDU->choice.initiatingMessage.value.choice.RICindication.protocolIEs.list.count > 4) {
1718 pRICindication_IEs = pE2AP_PDU->choice.initiatingMessage.value.choice.RICindication.protocolIEs.list.array[4];
1719 pRICIndication->ricIndicationType = pRICindication_IEs->value.choice.RICindicationType;
1720 }
1721 else {
1722 ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pE2AP_PDU);
1723 return e2err_RICindicationRICindicationTypeMissing;
1724 }
1725
1726 // RICindicationHeader
1727 if (pE2AP_PDU->choice.initiatingMessage.value.choice.RICindication.protocolIEs.list.count > 5) {
1728 pRICindication_IEs = pE2AP_PDU->choice.initiatingMessage.value.choice.RICindication.protocolIEs.list.array[5];
1729
1730 pRICIndication->ricIndicationHeader.octetString.contentLength = pRICindication_IEs->value.choice.RICindicationHeader.size;
1731 if (pRICIndication->ricIndicationHeader.octetString.contentLength < cMaxSizeOfOctetString) {
1732 memcpy(pRICIndication->ricIndicationHeader.octetString.data, pRICindication_IEs->value.choice.RICindicationHeader.buf,
1733 pRICIndication->ricIndicationHeader.octetString.contentLength);
1734
1735 uint64_t returnCode;
1736 if ((returnCode = getRICIndicationHeaderData(&pRICIndication->ricIndicationHeader) != e2err_OK)) {
1737 ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pE2AP_PDU);
1738 return returnCode;
1739 }
1740 }
1741 else {
1742 ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pE2AP_PDU);
1743 return e2err_RICIndicationHeaderContentLengthFail;
1744 }
1745 }
1746 else {
1747 ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pE2AP_PDU);
1748 return e2err_RICindicationRICindicationHeaderMissing;
1749 }
1750
1751 // RICindicationMessage
1752 if (pE2AP_PDU->choice.initiatingMessage.value.choice.RICindication.protocolIEs.list.count > 6) {
1753 pRICindication_IEs = pE2AP_PDU->choice.initiatingMessage.value.choice.RICindication.protocolIEs.list.array[6];
1754
1755 pRICIndication->ricIndicationMessage.octetString.contentLength = pRICindication_IEs->value.choice.RICindicationMessage.size;
1756 if (pRICIndication->ricIndicationMessage.octetString.contentLength < cMaxSizeOfOctetString) {
1757 memcpy(pRICIndication->ricIndicationMessage.octetString.data, pRICindication_IEs->value.choice.RICindicationMessage.buf,
1758 pRICIndication->ricIndicationMessage.octetString.contentLength);
1759
1760 uint64_t returnCode;
1761 if ((returnCode = getRICIndicationMessageData(&pRICIndication->ricIndicationMessage) != e2err_OK)) {
1762 ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pE2AP_PDU);
1763 return returnCode;
1764 }
1765 }
1766 else {
1767 ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pE2AP_PDU);
1768 return e2err_RICIndicationMessageContentLengthFail;
1769 }
1770 }
1771 else {
1772 ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pE2AP_PDU);
1773 return e2err_RICindicationRICindicationMessageMissing;
1774 }
1775
1776 // RICcallProcessID, OPTIONAL. Not used in RIC.
1777
1778 ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pE2AP_PDU);
1779 return e2err_OK;
1780}
1781
1782//////////////////////////////////////////////////////////////////////
1783uint64_t getRICIndicationHeaderData(RICIndicationHeader_t* pRICIndicationHeader) {
1784
1785 E2SM_gNB_X2_indicationHeader_t* pE2SM_gNB_X2_indicationHeader = 0;
1786 asn_dec_rval_t rval;
1787 rval = asn_decode(0, ATS_ALIGNED_BASIC_PER, &asn_DEF_E2SM_gNB_X2_indicationHeader, (void **)&pE2SM_gNB_X2_indicationHeader,
1788 pRICIndicationHeader->octetString.data, pRICIndicationHeader->octetString.contentLength);
1789 switch(rval.code) {
1790 case RC_OK:
1791 // Debug print
1792 if (debug) {
Anssi Mannila4721d4e2020-01-16 09:14:47 +02001793 printf("Successfully decoded E2SM_gNB_X2_indicationHeader");
Juha Hyttinenff8dccd2019-12-10 14:34:07 +02001794 asn_fprint(stdout, &asn_DEF_E2SM_gNB_X2_indicationHeader, pE2SM_gNB_X2_indicationHeader);
1795 }
1796
1797 // InterfaceID, GlobalENB-ID or GlobalGNB-ID
1798 if (pE2SM_gNB_X2_indicationHeader->interface_ID.present == Interface_ID_PR_global_eNB_ID) {
1799
1800 // GlobalENB-ID
1801 pRICIndicationHeader->interfaceID.globalENBIDPresent = true;
1802
1803 // PLMN-Identity
1804 pRICIndicationHeader->interfaceID.globalENBID.pLMNIdentity.contentLength =
1805 pE2SM_gNB_X2_indicationHeader->interface_ID.choice.global_eNB_ID.pLMN_Identity.size;
1806 memcpy(pRICIndicationHeader->interfaceID.globalENBID.pLMNIdentity.pLMNIdentityVal,
1807 pE2SM_gNB_X2_indicationHeader->interface_ID.choice.global_eNB_ID.pLMN_Identity.buf,
1808 pRICIndicationHeader->interfaceID.globalENBID.pLMNIdentity.contentLength);
1809
1810 // ENB-ID
1811 IdOctects_t eNBOctects;
1812 memset(eNBOctects.octets, 0, sizeof(eNBOctects));
1813 if (pE2SM_gNB_X2_indicationHeader->interface_ID.choice.global_eNB_ID.eNB_ID.present == ENB_ID_PR_macro_eNB_ID) {
1814 // BIT STRING (SIZE (20)
1815 pRICIndicationHeader->interfaceID.globalENBID.nodeID.bits = cMacroENBIDP_20Bits;
1816 memcpy(eNBOctects.octets,pE2SM_gNB_X2_indicationHeader->interface_ID.choice.global_eNB_ID.eNB_ID.choice.macro_eNB_ID.buf,
1817 pE2SM_gNB_X2_indicationHeader->interface_ID.choice.global_eNB_ID.eNB_ID.choice.macro_eNB_ID.size);
1818 pRICIndicationHeader->interfaceID.globalENBID.nodeID.nodeID = eNBOctects.nodeID;
1819 }
1820 else if (pE2SM_gNB_X2_indicationHeader->interface_ID.choice.global_eNB_ID.eNB_ID.present == ENB_ID_PR_home_eNB_ID) {
1821 // BIT STRING (SIZE (28)
1822 pRICIndicationHeader->interfaceID.globalENBID.nodeID.bits = cHomeENBID_28Bits;
1823 memcpy(eNBOctects.octets,pE2SM_gNB_X2_indicationHeader->interface_ID.choice.global_eNB_ID.eNB_ID.choice.home_eNB_ID.buf,
1824 pE2SM_gNB_X2_indicationHeader->interface_ID.choice.global_eNB_ID.eNB_ID.choice.home_eNB_ID.size);
1825 pRICIndicationHeader->interfaceID.globalENBID.nodeID.nodeID = eNBOctects.nodeID;
1826 }
1827 else if (pE2SM_gNB_X2_indicationHeader->interface_ID.choice.global_eNB_ID.eNB_ID.present == ENB_ID_PR_short_Macro_eNB_ID) {
1828 // BIT STRING (SIZE(18)
1829 pRICIndicationHeader->interfaceID.globalENBID.nodeID.bits = cShortMacroENBID_18Bits;
1830 memcpy(eNBOctects.octets,pE2SM_gNB_X2_indicationHeader->interface_ID.choice.global_eNB_ID.eNB_ID.choice.short_Macro_eNB_ID.buf,
1831 pE2SM_gNB_X2_indicationHeader->interface_ID.choice.global_eNB_ID.eNB_ID.choice.short_Macro_eNB_ID.size);
1832 pRICIndicationHeader->interfaceID.globalENBID.nodeID.nodeID = eNBOctects.nodeID;
1833 }
1834 else if (pE2SM_gNB_X2_indicationHeader->interface_ID.choice.global_eNB_ID.eNB_ID.present == ENB_ID_PR_long_Macro_eNB_ID) {
1835 // BIT STRING (SIZE(21)
1836 pRICIndicationHeader->interfaceID.globalENBID.nodeID.bits = clongMacroENBIDP_21Bits;
1837 memcpy(eNBOctects.octets,pE2SM_gNB_X2_indicationHeader->interface_ID.choice.global_eNB_ID.eNB_ID.choice.long_Macro_eNB_ID.buf,
1838 pE2SM_gNB_X2_indicationHeader->interface_ID.choice.global_eNB_ID.eNB_ID.choice.long_Macro_eNB_ID.size);
1839 pRICIndicationHeader->interfaceID.globalENBID.nodeID.nodeID = eNBOctects.nodeID;
1840 }
1841 else {
1842 pRICIndicationHeader->interfaceID.globalENBIDPresent = false;
1843 pRICIndicationHeader->interfaceID.globalGNBIDPresent = false;
1844 ASN_STRUCT_FREE(asn_DEF_E2SM_gNB_X2_indicationHeader, pE2SM_gNB_X2_indicationHeader);
1845 return e2err_RICEventTriggerDefinitionIEValueFail_9;
1846 }
1847 }
1848 else if (pE2SM_gNB_X2_indicationHeader->interface_ID.present == Interface_ID_PR_global_gNB_ID) {
1849 // GlobalGNB-ID
1850 pRICIndicationHeader->interfaceID.globalGNBIDPresent = true;
1851
1852 // PLMN-Identity
1853 pRICIndicationHeader->interfaceID.globalGNBID.pLMNIdentity.contentLength =
1854 pE2SM_gNB_X2_indicationHeader->interface_ID.choice.global_eNB_ID.pLMN_Identity.size;
1855 memcpy(pRICIndicationHeader->interfaceID.globalGNBID.pLMNIdentity.pLMNIdentityVal,
1856 pE2SM_gNB_X2_indicationHeader->interface_ID.choice.global_eNB_ID.pLMN_Identity.buf,
1857 pRICIndicationHeader->interfaceID.globalGNBID.pLMNIdentity.contentLength);
1858
1859 // GNB-ID
1860 IdOctects_t gNBOctects;
1861 memset(gNBOctects.octets, 0, sizeof(gNBOctects));
1862 if (pE2SM_gNB_X2_indicationHeader->interface_ID.choice.global_gNB_ID.gNB_ID.present == GNB_ID_PR_gNB_ID) {
1863 pRICIndicationHeader->interfaceID.globalGNBID.nodeID.bits = pE2SM_gNB_X2_indicationHeader->interface_ID.choice.global_gNB_ID.gNB_ID.choice.gNB_ID.size;
1864 memcpy(gNBOctects.octets, pE2SM_gNB_X2_indicationHeader->interface_ID.choice.global_gNB_ID.gNB_ID.choice.gNB_ID.buf,
1865 pRICIndicationHeader->interfaceID.globalGNBID.nodeID.bits);
1866 pRICIndicationHeader->interfaceID.globalGNBID.nodeID.nodeID = gNBOctects.nodeID;
1867 }
1868 else {
1869 pRICIndicationHeader->interfaceID.globalENBIDPresent = false;
1870 pRICIndicationHeader->interfaceID.globalGNBIDPresent = false;
1871 ASN_STRUCT_FREE(asn_DEF_E2SM_gNB_X2_indicationHeader, pE2SM_gNB_X2_indicationHeader);
1872 return e2err_RICEventTriggerDefinitionIEValueFail_10;
1873 }
1874 }
1875 else {
1876 pRICIndicationHeader->interfaceID.globalENBIDPresent = false;
1877 pRICIndicationHeader->interfaceID.globalGNBIDPresent = false;
1878 ASN_STRUCT_FREE(asn_DEF_E2SM_gNB_X2_indicationHeader, pE2SM_gNB_X2_indicationHeader);
1879 return e2err_RICEventTriggerDefinitionIEValueFail_11;
1880 }
1881
1882 // InterfaceDirection
1883 pRICIndicationHeader->interfaceDirection = pE2SM_gNB_X2_indicationHeader->interfaceDirection;
1884
1885 // TimeStamp OPTIONAL. Not used in RIC.
1886
1887 ASN_STRUCT_FREE(asn_DEF_E2SM_gNB_X2_indicationHeader, pE2SM_gNB_X2_indicationHeader);
1888 return e2err_OK;
1889 case RC_WMORE:
1890 if (debug)
Anssi Mannila4721d4e2020-01-16 09:14:47 +02001891 printf("Decode failed. More data needed. Buffer size %zu, %s, consumed %zu",pRICIndicationHeader->octetString.contentLength,
Juha Hyttinenff8dccd2019-12-10 14:34:07 +02001892 asn_DEF_E2SM_gNB_X2_indicationHeader.name, rval.consumed);
1893 return e2err_RICIndicationHeaderDecodeWMOREFail;
1894 case RC_FAIL:
1895 if (debug)
Anssi Mannila4721d4e2020-01-16 09:14:47 +02001896 printf("Decode failed. Buffer size %zu, %s, consumed %zu",pRICIndicationHeader->octetString.contentLength,
Juha Hyttinenff8dccd2019-12-10 14:34:07 +02001897 asn_DEF_E2SM_gNB_X2_indicationHeader.name, rval.consumed);
1898
1899 return e2err_RICIndicationHeaderDecodeFAIL;
1900 default:
1901 return e2err_RICIndicationHeaderDecodeDefaultFail;
1902 }
1903}
1904
1905//////////////////////////////////////////////////////////////////////
1906uint64_t getRICIndicationMessageData(RICIndicationMessage_t* pRICIndicationMessage) {
1907
1908 E2SM_gNB_X2_indicationMessage_t* pE2SM_gNB_X2_indicationMessage = 0;
1909 asn_dec_rval_t rval;
1910 rval = asn_decode(0, ATS_ALIGNED_BASIC_PER, &asn_DEF_E2SM_gNB_X2_indicationMessage, (void **)&pE2SM_gNB_X2_indicationMessage,
1911 pRICIndicationMessage->octetString.data, pRICIndicationMessage->octetString.contentLength);
1912 switch(rval.code) {
1913 case RC_OK:
1914 // Debug print
1915 if (debug) {
Anssi Mannila4721d4e2020-01-16 09:14:47 +02001916 printf("Successfully decoded E2SM_gNB_X2_indicationMessage");
Juha Hyttinenff8dccd2019-12-10 14:34:07 +02001917 asn_fprint(stdout, &asn_DEF_E2SM_gNB_X2_indicationMessage, pE2SM_gNB_X2_indicationMessage);
1918 }
1919
1920 // InterfaceMessage
1921 pRICIndicationMessage->interfaceMessage.contentLength = pE2SM_gNB_X2_indicationMessage->interfaceMessage.size;
1922 if(pRICIndicationMessage->octetString.contentLength < cMaxSizeOfOctetString) {
1923 memcpy(pRICIndicationMessage->interfaceMessage.data,pE2SM_gNB_X2_indicationMessage->interfaceMessage.buf,
1924 pRICIndicationMessage->interfaceMessage.contentLength);
1925 ASN_STRUCT_FREE(asn_DEF_E2SM_gNB_X2_indicationMessage, pE2SM_gNB_X2_indicationMessage);
1926 return e2err_OK;
1927 }
1928 else {
1929 ASN_STRUCT_FREE(asn_DEF_E2SM_gNB_X2_indicationMessage, pE2SM_gNB_X2_indicationMessage);
1930 return e2err_RICIndicationMessageIEContentLengthFail;
1931 }
1932 case RC_WMORE:
1933 if (debug)
Anssi Mannila4721d4e2020-01-16 09:14:47 +02001934 printf("Decode failed. More data needed. Buffer size %zu, %s, consumed %zu",pRICIndicationMessage->octetString.contentLength,
Juha Hyttinenff8dccd2019-12-10 14:34:07 +02001935 asn_DEF_E2SM_gNB_X2_indicationMessage.name, rval.consumed);
1936
1937 return e2err_RICIndicationMessageDecodeWMOREFail;
1938 case RC_FAIL:
1939 if (debug)
Anssi Mannila4721d4e2020-01-16 09:14:47 +02001940 printf("Decode failed. Buffer size %zu, %s, consumed %zu",pRICIndicationMessage->octetString.contentLength,
Juha Hyttinenff8dccd2019-12-10 14:34:07 +02001941 asn_DEF_E2SM_gNB_X2_indicationMessage.name, rval.consumed);
1942
1943 return e2err_RICIndicationMessageDecodeFAIL;
1944 default:
1945 return e2err_RICIndicationMessageDecodeDefaultFail;
1946 }
1947}
1948
1949//////////////////////////////////////////////////////////////////////
1950uint64_t getRICSubscriptionDeleteRequestData(e2ap_pdu_ptr_t* pE2AP_PDU_pointer, RICSubscriptionDeleteRequest_t* pRICSubscriptionDeleteRequest) {
1951
1952 E2AP_PDU_t* pE2AP_PDU = (E2AP_PDU_t*)pE2AP_PDU_pointer;
1953
1954 // RICrequestID
1955 RICsubscriptionDeleteRequest_IEs_t* pRICsubscriptionDeleteRequest_IEs;
1956 if (pE2AP_PDU->choice.initiatingMessage.value.choice.RICsubscriptionDeleteRequest.protocolIEs.list.count > 0) {
1957 pRICsubscriptionDeleteRequest_IEs = pE2AP_PDU->choice.initiatingMessage.value.choice.RICsubscriptionDeleteRequest.protocolIEs.list.array[0];
1958 pRICSubscriptionDeleteRequest->ricRequestID.ricRequestorID = pRICsubscriptionDeleteRequest_IEs->value.choice.RICrequestID.ricRequestorID;
1959 pRICSubscriptionDeleteRequest->ricRequestID.ricRequestSequenceNumber = pRICsubscriptionDeleteRequest_IEs->value.choice.RICrequestID.ricRequestSequenceNumber;
1960 }
1961 else {
1962 ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pE2AP_PDU);
1963 return e2err_RICsubscriptionDeleteRequestRICrequestIDMissing;
1964 }
1965
1966 // RANfunctionID
1967 if (pE2AP_PDU->choice.initiatingMessage.value.choice.RICsubscriptionDeleteRequest.protocolIEs.list.count > 1) {
1968 pRICsubscriptionDeleteRequest_IEs = pE2AP_PDU->choice.initiatingMessage.value.choice.RICsubscriptionDeleteRequest.protocolIEs.list.array[1];
1969 pRICSubscriptionDeleteRequest->ranFunctionID = pRICsubscriptionDeleteRequest_IEs->value.choice.RANfunctionID;
1970 }
1971 else {
1972 ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pE2AP_PDU);
1973 return e2err_RICsubscriptionDeleteRequestRANfunctionIDMissing;
1974 }
1975
1976 ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pE2AP_PDU);
1977 return e2err_OK;
1978}
1979
1980//////////////////////////////////////////////////////////////////////
1981uint64_t getRICSubscriptionDeleteResponseData(e2ap_pdu_ptr_t* pE2AP_PDU_pointer, RICSubscriptionDeleteResponse_t* pRICSubscriptionDeleteResponse) {
1982
1983 E2AP_PDU_t* pE2AP_PDU = (E2AP_PDU_t*)pE2AP_PDU_pointer;
1984
1985 // RICrequestID
1986 RICsubscriptionDeleteResponse_IEs_t* pRICsubscriptionDeleteResponse_IEs;
1987 if (pE2AP_PDU->choice.successfulOutcome.value.choice.RICsubscriptionDeleteResponse.protocolIEs.list.count > 0) {
1988 pRICsubscriptionDeleteResponse_IEs = pE2AP_PDU->choice.successfulOutcome.value.choice.RICsubscriptionDeleteResponse.protocolIEs.list.array[0];
1989 pRICSubscriptionDeleteResponse->ricRequestID.ricRequestorID = pRICsubscriptionDeleteResponse_IEs->value.choice.RICrequestID.ricRequestorID;
1990 pRICSubscriptionDeleteResponse->ricRequestID.ricRequestSequenceNumber = pRICsubscriptionDeleteResponse_IEs->value.choice.RICrequestID.ricRequestSequenceNumber;
1991 }
1992 else {
1993 ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pE2AP_PDU);
1994 return e2err_RICsubscriptionDeleteResponseRICrequestIDMissing;
1995 }
1996
1997 // RANfunctionID
1998 if (pE2AP_PDU->choice.successfulOutcome.value.choice.RICsubscriptionDeleteResponse.protocolIEs.list.count > 1) {
1999 pRICsubscriptionDeleteResponse_IEs = pE2AP_PDU->choice.successfulOutcome.value.choice.RICsubscriptionDeleteResponse.protocolIEs.list.array[1];
2000 pRICSubscriptionDeleteResponse->ranFunctionID = pRICsubscriptionDeleteResponse_IEs->value.choice.RANfunctionID;
2001 }
2002 else {
2003 ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pE2AP_PDU);
2004 return e2err_RICsubscriptionDeleteResponseRANfunctionIDMissing;
2005 }
2006
2007 ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pE2AP_PDU);
2008 return e2err_OK;
2009}
2010
2011//////////////////////////////////////////////////////////////////////
2012uint64_t getRICSubscriptionDeleteFailureData(e2ap_pdu_ptr_t* pE2AP_PDU_pointer, RICSubscriptionDeleteFailure_t* pRICSubscriptionDeleteFailure) {
2013
2014 E2AP_PDU_t* pE2AP_PDU = (E2AP_PDU_t*)pE2AP_PDU_pointer;
2015
2016 // RICrequestID
2017 RICsubscriptionDeleteFailure_IEs_t* pRICsubscriptionDeleteFailure_IEs;
2018 if (pE2AP_PDU->choice.unsuccessfulOutcome.value.choice.RICsubscriptionDeleteFailure.protocolIEs.list.count > 0) {
2019 pRICsubscriptionDeleteFailure_IEs = pE2AP_PDU->choice.unsuccessfulOutcome.value.choice.RICsubscriptionDeleteFailure.protocolIEs.list.array[0];
2020 pRICSubscriptionDeleteFailure->ricRequestID.ricRequestorID = pRICsubscriptionDeleteFailure_IEs->value.choice.RICrequestID.ricRequestorID;
2021 pRICSubscriptionDeleteFailure->ricRequestID.ricRequestSequenceNumber = pRICsubscriptionDeleteFailure_IEs->value.choice.RICrequestID.ricRequestSequenceNumber;
2022 }
2023 else {
2024 ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pE2AP_PDU);
2025 return e2err_RICsubscriptionDeleteFailureRICrequestIDMissing;
2026 }
2027
2028 // RANfunctionID
2029 if (pE2AP_PDU->choice.unsuccessfulOutcome.value.choice.RICsubscriptionDeleteFailure.protocolIEs.list.count > 1) {
2030 pRICsubscriptionDeleteFailure_IEs = pE2AP_PDU->choice.unsuccessfulOutcome.value.choice.RICsubscriptionDeleteFailure.protocolIEs.list.array[1];
2031 pRICSubscriptionDeleteFailure->ranFunctionID = pRICsubscriptionDeleteFailure_IEs->value.choice.RANfunctionID;
2032 }
2033 else {
2034 ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pE2AP_PDU);
2035 return e2err_RICsubscriptionDeleteFailureRANfunctionIDMissing;
2036 }
2037
2038 // RICcause
2039 if (pE2AP_PDU->choice.unsuccessfulOutcome.value.choice.RICsubscriptionDeleteFailure.protocolIEs.list.count > 2) {
2040 pRICsubscriptionDeleteFailure_IEs = pE2AP_PDU->choice.unsuccessfulOutcome.value.choice.RICsubscriptionDeleteFailure.protocolIEs.list.array[2];
2041 if (pRICsubscriptionDeleteFailure_IEs->value.choice.RICcause.present == RICcause_PR_radioNetwork) {
2042 pRICSubscriptionDeleteFailure->ricCause.content = RICcause_PR_radioNetwork;
2043 pRICSubscriptionDeleteFailure->ricCause.cause =
2044 pRICsubscriptionDeleteFailure_IEs->value.choice.RICcause.choice.radioNetwork;
2045 }
2046 else if (pRICsubscriptionDeleteFailure_IEs->value.choice.RICcause.present == RICcause_PR_transport) {
2047 pRICSubscriptionDeleteFailure->ricCause.content = RICcause_PR_transport;
2048 pRICSubscriptionDeleteFailure->ricCause.cause =
2049 pRICsubscriptionDeleteFailure_IEs->value.choice.RICcause.choice.transport;
2050 }
2051 else if (pRICsubscriptionDeleteFailure_IEs->value.choice.RICcause.present == RICcause_PR_protocol) {
2052 pRICSubscriptionDeleteFailure->ricCause.content = RICcause_PR_protocol;
2053 pRICSubscriptionDeleteFailure->ricCause.cause =
2054 pRICsubscriptionDeleteFailure_IEs->value.choice.RICcause.choice.protocol;
2055 }
2056 else if(pRICsubscriptionDeleteFailure_IEs->value.choice.RICcause.present == RICcause_PR_misc) {
2057 pRICSubscriptionDeleteFailure->ricCause.content = RICcause_PR_misc;
2058 pRICSubscriptionDeleteFailure->ricCause.cause =
2059 pRICsubscriptionDeleteFailure_IEs->value.choice.RICcause.choice.misc;
2060 }
2061 else if (pRICsubscriptionDeleteFailure_IEs->value.choice.RICcause.present == RICcause_PR_ric) {
2062 pRICSubscriptionDeleteFailure->ricCause.content = RICcause_PR_ric;
2063 pRICSubscriptionDeleteFailure->ricCause.cause =
2064 pRICsubscriptionDeleteFailure_IEs->value.choice.RICcause.choice.ric;
2065 }
2066 }
2067 else {
2068 ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pE2AP_PDU);
2069 return e2err_RICsubscriptionDeleteFailureRICcauseMissing;
2070 }
2071 // CriticalityDiagnostics, OPTIONAL
2072
2073 ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pE2AP_PDU);
2074 return e2err_OK;
2075}