3 * Copyright 2019 AT&T Intellectual Property
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
10 * http://www.apache.org/licenses/LICENSE-2.0
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.
24 #include <ProcedureCode.h>
25 #include <InitiatingMessage.h>
26 #include <ProtocolIE-ID.h>
27 #include <x2reset_request_wrapper.h>
30 * Build and pack a reset request.
31 * Abort the process on allocation failure.
32 * packed_buf_size - in: size of packed_buf; out: number of chars used.
36 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)
38 return build_pack_x2reset_request_aux(cause_group, cause_value, packed_buf_size, packed_buf,err_buf_size,err_buf,ATS_ALIGNED_BASIC_PER);
43 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)
46 E2AP_PDU_t *pdu = calloc(1, sizeof(E2AP_PDU_t));
47 InitiatingMessage_t *initiatingMessage = calloc(1, sizeof(InitiatingMessage_t));
48 ResetRequest_t *resetRequest;
51 assert(initiatingMessage != 0);
54 pdu->present = E2AP_PDU_PR_initiatingMessage;
55 pdu->choice.initiatingMessage = initiatingMessage;
57 initiatingMessage->procedureCode = ProcedureCode_id_reset;
58 initiatingMessage->criticality = Criticality_reject;
59 initiatingMessage->value.present = InitiatingMessage__value_PR_ResetRequest;
60 resetRequest = &initiatingMessage->value.choice.ResetRequest;
62 ResetRequest_IEs_t *cause_ie = calloc(1, sizeof(ResetRequest_IEs_t));
63 assert(cause_ie != 0);
64 ASN_SEQUENCE_ADD(&resetRequest->protocolIEs, cause_ie);
66 cause_ie->id = ProtocolIE_ID_id_Cause;
67 cause_ie->criticality = Criticality_ignore;
68 cause_ie->value.present = ResetRequest_IEs__value_PR_Cause;
69 Cause_t *cause = &cause_ie->value.choice.Cause;
70 cause->present = cause_group;
71 switch (cause->present) {
72 case Cause_PR_radioNetwork:
73 cause->choice.radioNetwork = cause_value;
75 case Cause_PR_transport:
76 cause->choice.transport = cause_value;
78 case Cause_PR_protocol:
79 cause->choice.protocol = cause_value;
82 cause->choice.misc = cause_value;
85 cause->choice.misc = CauseMisc_om_intervention;
89 rc = pack_pdu_aux(pdu, packed_buf_size, packed_buf,err_buf_size, err_buf,syntax);
91 ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pdu);