2 * Copyright 2019 AT&T Intellectual Property
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
19 * This source code is part of the near-RT RIC (RAN Intelligent Controller)
20 * platform project (RICP).
28 #include <ProcedureCode.h>
29 #include <InitiatingMessage.h>
30 #include <ProtocolIE-ID.h>
31 #include <x2reset_request_wrapper.h>
34 * Build and pack a reset request.
35 * Abort the process on allocation failure.
36 * packed_buf_size - in: size of packed_buf; out: number of chars used.
40 build_pack_x2reset_request(enum Cause_PR cause_group, int cause_value, size_t* packed_buf_size, unsigned char* packed_buf,size_t err_buf_size, char* err_buf)
42 return build_pack_x2reset_request_aux(cause_group, cause_value, packed_buf_size, packed_buf,err_buf_size,err_buf,ATS_ALIGNED_BASIC_PER);
47 build_pack_x2reset_request_aux(enum Cause_PR cause_group, int cause_value, size_t* packed_buf_size, unsigned char* packed_buf,size_t err_buf_size, char* err_buf,enum asn_transfer_syntax syntax)
50 E2AP_PDU_t *pdu = calloc(1, sizeof(E2AP_PDU_t));
51 InitiatingMessage_t *initiatingMessage = calloc(1, sizeof(InitiatingMessage_t));
52 ResetRequest_t *resetRequest;
55 assert(initiatingMessage != 0);
58 pdu->present = E2AP_PDU_PR_initiatingMessage;
59 pdu->choice.initiatingMessage = initiatingMessage;
61 initiatingMessage->procedureCode = ProcedureCode_id_reset;
62 initiatingMessage->criticality = Criticality_reject;
63 initiatingMessage->value.present = InitiatingMessage__value_PR_ResetRequest;
64 resetRequest = &initiatingMessage->value.choice.ResetRequest;
66 ResetRequest_IEs_t *cause_ie = calloc(1, sizeof(ResetRequest_IEs_t));
67 assert(cause_ie != 0);
68 ASN_SEQUENCE_ADD(&resetRequest->protocolIEs, cause_ie);
70 cause_ie->id = ProtocolIE_ID_id_Cause;
71 cause_ie->criticality = Criticality_ignore;
72 cause_ie->value.present = ResetRequest_IEs__value_PR_Cause;
73 Cause_t *cause = &cause_ie->value.choice.Cause;
74 cause->present = cause_group;
75 switch (cause->present) {
76 case Cause_PR_radioNetwork:
77 cause->choice.radioNetwork = cause_value;
79 case Cause_PR_transport:
80 cause->choice.transport = cause_value;
82 case Cause_PR_protocol:
83 cause->choice.protocol = cause_value;
86 cause->choice.misc = cause_value;
89 cause->choice.misc = CauseMisc_om_intervention;
93 rc = pack_pdu_aux(pdu, packed_buf_size, packed_buf,err_buf_size, err_buf,syntax);
95 ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pdu);