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 <asn_application.h>
26 #include <ProcedureCode.h>
27 #include <SuccessfulOutcome.h>
28 #include <ProtocolIE-ID.h>
29 #include <ProtocolIE-Field.h>
30 #include <x2reset_response_wrapper.h>
33 * Build and pack a reset response.
34 * Abort the process on allocation failure.
35 * packed_buf_size - in: size of packed_buf; out: number of chars used.
39 build_pack_x2reset_response(size_t* packed_buf_size, unsigned char* packed_buf,size_t err_buf_size, char* err_buf)
42 E2AP_PDU_t *pdu = calloc(1, sizeof(E2AP_PDU_t));
44 ResetResponse_t *resetResponse;
45 SuccessfulOutcome_t *successfulOutcome = calloc(1, sizeof(SuccessfulOutcome_t));
46 ResetResponse_IEs_t *resetResponse_ie = calloc(1, sizeof(ResetResponse_IEs_t));
49 assert(successfulOutcome != 0);
50 assert(resetResponse_ie != 0);
52 pdu->present = E2AP_PDU_PR_successfulOutcome;
53 pdu->choice.successfulOutcome = successfulOutcome;
55 successfulOutcome->procedureCode = ProcedureCode_id_reset;
56 successfulOutcome->criticality = Criticality_reject;
57 successfulOutcome->value.present = SuccessfulOutcome__value_PR_ResetResponse;
58 resetResponse = &successfulOutcome->value.choice.ResetResponse;
60 resetResponse_ie->id = ProtocolIE_ID_id_CriticalityDiagnostics;
61 resetResponse_ie->criticality = Criticality_ignore;
62 resetResponse_ie->value.present = ResetResponse_IEs__value_PR_CriticalityDiagnostics;
64 ASN_SEQUENCE_ADD(&resetResponse->protocolIEs, resetResponse_ie);
66 CriticalityDiagnostics_IE_List_t *critList = calloc(1, sizeof(CriticalityDiagnostics_IE_List_t));
67 assert(critList != 0);
69 CriticalityDiagnostics_IE_List__Member *member= calloc(1, sizeof(CriticalityDiagnostics_IE_List__Member));
72 ASN_SEQUENCE_ADD(critList ,member);
73 ASN_SEQUENCE_ADD(resetResponse_ie->value.choice.CriticalityDiagnostics.iEsCriticalityDiagnostics, critList);
75 rc = per_pack_pdu(pdu, packed_buf_size, packed_buf,err_buf_size, err_buf);
76 ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pdu);