2aee074637c752ee51f0c67632ccfeecf95c94d4
[ric-plt/resource-status-manager.git] / RSM / 3rdparty / asn1codec / src / tests / resource_status_request_wrapper_test.c
1     /*
2      *
3      * Copyright 2019 AT&T Intellectual Property
4      * Copyright 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
21     #include <stdbool.h>
22     #include <stdio.h>
23     #include <stdlib.h>
24     #include <resource_status_request_wrapper.h>
25
26     void test_build_pack_resource_status_request();
27     void test_unpack(void);
28
29     int
30     main(int argc, char* argv[])
31     {
32         test_build_pack_resource_status_request();
33         exit(0);
34     }
35
36     /*reportCharacteristics:
37 1)    First Bit = PRB Periodic,
38 2)    Second Bit = TNL load Ind Periodic,
39 3)    Third Bit = HW Load Ind Periodic,
40 4)    Fourth Bit = Composite Available Capacity Periodic, this bit should be set to 1 if at least one of the First, Second
41 or Third bits is set to 1,
42 5)    Fifth Bit = ABS Status Periodic,
43 6)    Sixth Bit = RSRP Measurement Report Periodic,
44 7)    Seventh Bit = CSI Report Periodic
45      */
46     void test_build_pack_resource_status_request(){
47         size_t error_buf_size = 8192;
48         size_t packed_buf_size = 4096;
49         unsigned char outBuf[packed_buf_size];
50         char errorBuf[error_buf_size];
51         uint8_t pLMN_Identity[] = {0xa,0xb,0xc};
52         uint8_t eUTRANCellIdentifier[] = {0xab, 0xcd, 0x70, 0};
53         E2AP_PDU_t *pdu;
54
55         bool result = build_pack_resource_status_request(
56                         pLMN_Identity, eUTRANCellIdentifier,
57                         15 /*measurement_ID*/, 0  /*measurement_ID2*/,
58                                 Registration_Request_start /*Registration_Request_start,Registration_Request_stop,Registration_Request_partial_stop, Registration_Request_add*/,
59                         0xf0,
60                                 ReportingPeriodicity_one_thousand_ms /*ReportingPeriodicity_one_thousand_ms, ReportingPeriodicity_two_thousand_ms, ReportingPeriodicity_five_thousand_ms,ReportingPeriodicity_ten_thousand_ms*/,
61                                 PartialSuccessIndicator_partial_success_allowed /*PartialSuccessIndicator_partial_success_allowed*/,
62                                 ReportingPeriodicityRSRPMR_one_hundred_20_ms /*ReportingPeriodicityRSRPMR_one_hundred_20_ms, ReportingPeriodicityRSRPMR_two_hundred_40_ms, ReportingPeriodicityRSRPMR_four_hundred_80_ms,ReportingPeriodicityRSRPMR_six_hundred_40_ms*/,
63                                 ReportingPeriodicityCSIR_ms5 /* ReportingPeriodicityCSIR_ms5, ReportingPeriodicityCSIR_ms10,ReportingPeriodicityCSIR_ms20,ReportingPeriodicityCSIR_ms40,ReportingPeriodicityCSIR_ms80*/,
64                         &packed_buf_size, outBuf, error_buf_size, errorBuf);
65
66         if (!result) {
67             printf("#%s failed. Packing error %s\n", __func__,errorBuf);
68             return;
69         }
70         printf("packed size:%lu\nPayload:\n", packed_buf_size);
71         for (size_t i = 0; i < packed_buf_size; ++i)
72             printf("%02x",outBuf[i]);
73         printf("\n");
74
75         pdu = calloc(1, sizeof(E2AP_PDU_t));
76         if (!unpack_pdu_aux(pdu, packed_buf_size, outBuf,error_buf_size, errorBuf,ATS_ALIGNED_BASIC_PER)){
77                 printf("#%s failed. Unpacking error %s\n", __func__, errorBuf);
78         }
79         errorBuf[0] = 0;
80         asn1_pdu_printer(pdu, sizeof(errorBuf), errorBuf);
81         printf("#%s: %s\n", __func__, errorBuf);
82
83     }
84