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