blob: 73655ab073f014f628f79ce12f61453e23700983 [file] [log] [blame]
dhirajverma31768a92021-05-06 12:38:49 +05301#include <gtest/gtest.h>
2#include <gmock/gmock.h>
3#include "sctpThread.h"
4#include <sys/epoll.h>
dhirajverma6cf28612021-06-23 04:53:34 -04005#include "E2AP-PDU.h"
dhirajverma31768a92021-05-06 12:38:49 +05306
7using namespace testing;
8
dhirajverma6cf28612021-06-23 04:53:34 -04009typedef struct {
10 int32_t mtype; // message type ("long" network integer)
11 int32_t plen; // payload length (sender data length in payload)
12 int32_t rmr_ver; // our internal message version number
13 unsigned char xid[RMR_MAX_XID]; // space for user transaction id or somesuch
14 unsigned char sid[RMR_MAX_SID]; // sender ID for return to sender needs
15 unsigned char src[RMR_MAX_SRC]; // name:port of the sender (source)
16 unsigned char meid[RMR_MAX_MEID]; // managed element id.
17 struct timespec ts; // timestamp ???
18 int32_t flags; // HFL_* constants
19 int32_t len0; // length of the RMr header data
20 int32_t len1; // length of the tracing data
21 int32_t len2; // length of data 1 (d1)
22 int32_t len3; // length of data 2 (d2)
23 int32_t sub_id; // subscription id (-1 invalid)
24
25 unsigned char srcip[RMR_MAX_SRC]; // ip address and port of the source
26} uta_mhdr_t;
27
dhirajverma99990292021-07-05 10:03:59 -040028void init_memories(ReportingMessages_t &message, RmrMessagesBuffer_t &rmrMessageBuffer, sctp_params_t &sctp_ut_params);
29
dhirajverma31768a92021-05-06 12:38:49 +053030TEST(sctp, TEST1) {
dhirajverma6cf28612021-06-23 04:53:34 -040031 mdclog_level_set(MDCLOG_DEBUG);
dhirajverma31768a92021-05-06 12:38:49 +053032 string s;
33 s = translateRmrErrorMessages(0);
34 EXPECT_THAT(s, HasSubstr("RMR_OK"));
35 s = translateRmrErrorMessages(1);
36 EXPECT_THAT(s, HasSubstr("RMR_ERR_BADARG"));
37 s = translateRmrErrorMessages(2);
38 EXPECT_THAT(s, HasSubstr("RMR_ERR_NOENDPT"));
39 s = translateRmrErrorMessages(3);
40 EXPECT_THAT(s, HasSubstr("RMR_ERR_EMPTY"));
41 s = translateRmrErrorMessages(4);
42 EXPECT_THAT(s, HasSubstr("RMR_ERR_NOHDR"));
43 s = translateRmrErrorMessages(5);
44 EXPECT_THAT(s, HasSubstr("RMR_ERR_SENDFAILED"));
45 s = translateRmrErrorMessages(6);
46 EXPECT_THAT(s, HasSubstr("RMR_ERR_CALLFAILED"));
47 s = translateRmrErrorMessages(7);
48 EXPECT_THAT(s, HasSubstr("RMR_ERR_NOWHOPEN"));
49 s = translateRmrErrorMessages(8);
50 EXPECT_THAT(s, HasSubstr("RMR_ERR_WHID"));
51 s = translateRmrErrorMessages(9);
52 EXPECT_THAT(s, HasSubstr("RMR_ERR_OVERFLOW"));
53 s = translateRmrErrorMessages(10);
54 EXPECT_THAT(s, HasSubstr("RMR_ERR_RETRY"));
55 s = translateRmrErrorMessages(11);
56 EXPECT_THAT(s, HasSubstr("RMR_ERR_RCVFAILED"));
57 s = translateRmrErrorMessages(12);
58 EXPECT_THAT(s, HasSubstr("RMR_ERR_TIMEOUT"));
59 s = translateRmrErrorMessages(13);
60 EXPECT_THAT(s, HasSubstr("RMR_ERR_UNSET"));
61 s = translateRmrErrorMessages(14);
62 EXPECT_THAT(s, HasSubstr("RMR_ERR_TRUNC"));
63 s = translateRmrErrorMessages(15);
64 EXPECT_THAT(s, HasSubstr("RMR_ERR_INITFAILED"));
65 s = translateRmrErrorMessages(16);
66 EXPECT_THAT(s, HasSubstr("RMR_ERR_NOTSUPP"));
67 s = translateRmrErrorMessages(17);
68 EXPECT_THAT(s, HasSubstr("UNDOCUMENTED RMR_ERR"));
69}
70
71auto *peerInfo = (ConnectedCU_t *)calloc(1, sizeof(ConnectedCU_t));
72
73TEST(sctp, TEST2) {
dhirajverma6cf28612021-06-23 04:53:34 -040074 struct epoll_event event;
dhirajverma31768a92021-05-06 12:38:49 +053075 event.events = EPOLLIN;
76 event.data.fd = 0;
77 ConnectedCU_t data1;
78 ConnectedCU_t *data = &data1;
79 event.data.ptr = (void *)data;
80 sctp_params_t sctp_ut_params;
81 sctp_params_t* sctp = &sctp_ut_params;
82 ReportingMessages_t reporting_msg;
83 RmrMessagesBuffer_t rmrmessagesbuffer;
84 handleEinprogressMessages(event,reporting_msg,rmrmessagesbuffer,sctp);
85}
86
87TEST(sctp, TEST3) {
dhirajverma6cf28612021-06-23 04:53:34 -040088 struct epoll_event event;
dhirajverma31768a92021-05-06 12:38:49 +053089 event.events = EPOLLIN;
90 event.data.fd = 0;
91 ConnectedCU_t data1;
92 ConnectedCU_t *data = &data1;
93 event.data.ptr = (void *)data;
94 sctp_params_t sctp_ut_params;
95 sctp_params_t* sctp = &sctp_ut_params;
96 Sctp_Map_t m1;
97 sctp ->sctpMap = &m1;
98 ReportingMessages_t reporting_msg;
99 RmrMessagesBuffer_t rmrmessagesbuffer;
100 handlepoll_error(event,reporting_msg,rmrmessagesbuffer,sctp);
101}
102
dhirajverma31768a92021-05-06 12:38:49 +0530103TEST(sctp, TEST4) {
dhirajverma6cf28612021-06-23 04:53:34 -0400104 ConnectedCU_t cu;
105 ConnectedCU_t* connected_cu = &cu;
106 Sctp_Map_t m1;
107 Sctp_Map_t *m = &m1;
108 cleanHashEntry(connected_cu,m);
dhirajverma31768a92021-05-06 12:38:49 +0530109}
110
111TEST(sctp, TEST5) {
dhirajverma6cf28612021-06-23 04:53:34 -0400112 sctp_params_t sctp_ut_params;
113 sctp_params_t* sctp = &sctp_ut_params;
dhirajverma99990292021-07-05 10:03:59 -0400114 sctp->configFilePath.assign("/opt/e2/RIC-E2-TERMINATION/config");
dhirajverma6cf28612021-06-23 04:53:34 -0400115 sctp->configFileName.assign("config.conf");
116 handleConfigChange(sctp);
dhirajverma31768a92021-05-06 12:38:49 +0530117}
118
dhirajverma31768a92021-05-06 12:38:49 +0530119TEST(sctp, TEST6) {
dhirajverma6cf28612021-06-23 04:53:34 -0400120 int epoll_fd = epoll_create1(0);
121 ConnectedCU_t cu;
122 ConnectedCU_t* peerinfo = &cu;
123 Sctp_Map_t m1;
124 Sctp_Map_t *m = &m1;
125 modifyToEpoll(epoll_fd,peerinfo,2,m, (char*)"enodeb1",2);
dhirajverma31768a92021-05-06 12:38:49 +0530126}
127
dhirajverma60f8bef2021-06-29 07:22:58 -0400128
dhirajverma6cf28612021-06-23 04:53:34 -0400129/* TEST7 Begin: */
dhirajverma60f8bef2021-06-29 07:22:58 -0400130void init_memories(ReportingMessages_t &message, RmrMessagesBuffer_t &rmrMessageBuffer, sctp_params_t &sctp_ut_params) {
131 message.peerInfo = peerInfo;
132 message.peerInfo->sctpParams = &sctp_ut_params;
133 snprintf(message.message.enodbName, strlen("Nokia_enb "), "%s", (char*)"Nokia_enb");
dhirajverma6cf28612021-06-23 04:53:34 -0400134
dhirajverma60f8bef2021-06-29 07:22:58 -0400135 sctp_ut_params.myIP = "1.2.3.4";
136 sctp_ut_params.rmrPort = 38000;
137 snprintf(sctp_ut_params.rmrAddress, sizeof(sctp_ut_params.rmrAddress), "%d", (int) (sctp_ut_params.rmrPort));
138
139 rmrMessageBuffer.sendMessage = (rmr_mbuf_t*) malloc(sizeof(rmr_mbuf_t));
140 rmrMessageBuffer.sendMessage->header = (uta_mhdr_t*) malloc(sizeof(uta_mhdr_t));
141 rmrMessageBuffer.sendMessage->len = strlen("Saying Hello from NOKIA ");
142 rmrMessageBuffer.sendMessage->payload = (unsigned char*)strdup("Saying Hello from NOKIA");
143}
144
145void delete_memories_initiatingMessage(E2AP_PDU_t *pdu, RmrMessagesBuffer_t &rmrMessageBuffer) {
146
147 if( (pdu->choice.initiatingMessage->value.choice.RICindication.protocolIEs.list.array) &&
148 (pdu->choice.initiatingMessage->value.choice.RICindication.protocolIEs.list.array[0]) ) {
149 free(pdu->choice.initiatingMessage->value.choice.RICindication.protocolIEs.list.array[0]);
150 pdu->choice.initiatingMessage->value.choice.RICindication.protocolIEs.list.array[0] = NULL;
151 }
152 if(pdu->choice.initiatingMessage->value.choice.RICindication.protocolIEs.list.array) {
153 free(pdu->choice.initiatingMessage->value.choice.RICindication.protocolIEs.list.array);
154 pdu->choice.initiatingMessage->value.choice.RICindication.protocolIEs.list.array = NULL;
155 }
156 pdu->choice.initiatingMessage->value.choice.RICindication.protocolIEs.list.count = 0;
157 pdu->choice.initiatingMessage->value.choice.RICindication.protocolIEs.list.size = 0;
158
159 if(rmrMessageBuffer.sendMessage && rmrMessageBuffer.sendMessage->header) {
160 free(rmrMessageBuffer.sendMessage->header);
161 rmrMessageBuffer.sendMessage->header = NULL;
162 }
163 if(rmrMessageBuffer.sendMessage->payload) {
164 free(rmrMessageBuffer.sendMessage->payload);
165 rmrMessageBuffer.sendMessage->payload = NULL;
166 }
167 if(rmrMessageBuffer.sendMessage) {
168 free(rmrMessageBuffer.sendMessage);
169 rmrMessageBuffer.sendMessage = NULL;
170 }
171 if(rmrMessageBuffer.rmrCtx) {
172 rmr_close(rmrMessageBuffer.rmrCtx);
173 rmrMessageBuffer.rmrCtx = NULL;
174 }
175}
176
177void create_asnInitiatingReq_Procedure_RICserviceUpdate(E2AP_PDU_t *pdu,
178 Sctp_Map_t *sctpMap,
179 ReportingMessages_t &message,
180 RmrMessagesBuffer_t &rmrMessageBuffer,
181 sctp_params_t &sctp_ut_params) {
182
183 init_memories(message, rmrMessageBuffer, sctp_ut_params);
dhirajverma6cf28612021-06-23 04:53:34 -0400184 /* Sending E2AP_PDU_PR_initiatingMessage and procedure code as: ProcedureCode_id_RICserviceUpdate */
185 pdu->choice.initiatingMessage->procedureCode = ProcedureCode_id_RICserviceUpdate;
186 pdu->choice.initiatingMessage->value.present = InitiatingMessage__value_PR_RICserviceUpdate;
czichy2175dd32022-05-17 15:24:51 +0300187
188 int streamId = 0;
189 asnInitiatingRequest(pdu, sctpMap, message, rmrMessageBuffer,streamId);
dhirajverma60f8bef2021-06-29 07:22:58 -0400190 delete_memories_initiatingMessage(pdu, rmrMessageBuffer);
dhirajverma6cf28612021-06-23 04:53:34 -0400191}
dhirajverma31768a92021-05-06 12:38:49 +0530192
dhirajverma60f8bef2021-06-29 07:22:58 -0400193void create_asnInitiatingReq_Procedure_RICindication(E2AP_PDU_t *pdu,
194 Sctp_Map_t *sctpMap,
195 ReportingMessages_t &message,
196 RmrMessagesBuffer_t &rmrMessageBuffer,
197 sctp_params_t &sctp_ut_params) {
dhirajverma6cf28612021-06-23 04:53:34 -0400198
dhirajverma60f8bef2021-06-29 07:22:58 -0400199 init_memories(message, rmrMessageBuffer, sctp_ut_params);
dhirajverma6cf28612021-06-23 04:53:34 -0400200 /* Sending E2AP_PDU_PR_initiatingMessage and procedure code as: ProcedureCode_id_RICindication */
201 pdu->choice.initiatingMessage->procedureCode = ProcedureCode_id_RICindication;
202 pdu->choice.initiatingMessage->value.present = InitiatingMessage__value_PR_RICindication;
203 pdu->choice.initiatingMessage->value.choice.RICindication.protocolIEs.list.array = (RICindication_IEs**) malloc(1 * sizeof(RICindication_IEs*));
204 pdu->choice.initiatingMessage->value.choice.RICindication.protocolIEs.list.count = 1;
205 pdu->choice.initiatingMessage->value.choice.RICindication.protocolIEs.list.size = sizeof(RICindication_IEs);
206 pdu->choice.initiatingMessage->value.choice.RICindication.protocolIEs.list.array[0] = (RICindication_IEs*) malloc(sizeof(RICindication_IEs));
207 RICindication_IEs_t *ie = pdu->choice.initiatingMessage->value.choice.RICindication.protocolIEs.list.array[0];
208 ie->id = ProtocolIE_ID_id_RICrequestID;
209 ie->value.present = RICindication_IEs__value_PR_RICrequestID;
210 ie->value.choice.RICrequestID.ricRequestorID = 12345;
211 ie->value.choice.RICrequestID.ricInstanceID = 1;
czichy2175dd32022-05-17 15:24:51 +0300212 int streamId = 0;
213 asnInitiatingRequest(pdu, sctpMap, message, rmrMessageBuffer,streamId);
dhirajverma60f8bef2021-06-29 07:22:58 -0400214 delete_memories_initiatingMessage(pdu, rmrMessageBuffer);
dhirajverma6cf28612021-06-23 04:53:34 -0400215}
216
dhirajverma60f8bef2021-06-29 07:22:58 -0400217void create_asnInitiatingReq_Procedure_ErrorIndication(E2AP_PDU_t *pdu,
218 Sctp_Map_t *sctpMap,
219 ReportingMessages_t &message,
220 RmrMessagesBuffer_t &rmrMessageBuffer,
221 sctp_params_t &sctp_ut_params) {
dhirajverma6cf28612021-06-23 04:53:34 -0400222
dhirajverma60f8bef2021-06-29 07:22:58 -0400223 init_memories(message, rmrMessageBuffer, sctp_ut_params);
dhirajverma6cf28612021-06-23 04:53:34 -0400224 /* Sending E2AP_PDU_PR_initiatingMessage and procedure code as: ProcedureCode_id_ErrorIndication */
225 pdu->choice.initiatingMessage->procedureCode = ProcedureCode_id_ErrorIndication;
226 pdu->choice.initiatingMessage->value.present = InitiatingMessage__value_PR_ErrorIndication;
czichy2175dd32022-05-17 15:24:51 +0300227 int streamId = 0;
228 asnInitiatingRequest(pdu, sctpMap, message, rmrMessageBuffer, streamId);
dhirajverma60f8bef2021-06-29 07:22:58 -0400229 delete_memories_initiatingMessage(pdu, rmrMessageBuffer);
dhirajverma6cf28612021-06-23 04:53:34 -0400230}
231
dhirajverma60f8bef2021-06-29 07:22:58 -0400232void create_asnInitiatingReq_Procedure_Reset(E2AP_PDU_t *pdu,
233 Sctp_Map_t *sctpMap,
234 ReportingMessages_t &message,
235 RmrMessagesBuffer_t &rmrMessageBuffer,
236 sctp_params_t &sctp_ut_params) {
237
238 init_memories(message, rmrMessageBuffer, sctp_ut_params);
dhirajverma6cf28612021-06-23 04:53:34 -0400239 /* Sending E2AP_PDU_PR_initiatingMessage and procedure code as: ProcedureCode_id_Reset */
240 pdu->choice.initiatingMessage->procedureCode = ProcedureCode_id_Reset;
241 pdu->choice.initiatingMessage->value.present = InitiatingMessage__value_PR_ResetRequest;
czichy2175dd32022-05-17 15:24:51 +0300242 int streamId =0;
243 asnInitiatingRequest(pdu, sctpMap, message, rmrMessageBuffer,streamId);
dhirajverma60f8bef2021-06-29 07:22:58 -0400244 delete_memories_initiatingMessage(pdu, rmrMessageBuffer);
dhirajverma6cf28612021-06-23 04:53:34 -0400245}
246
247TEST(sctp, TEST7) {
248 E2AP_PDU_t pdu;
249 Sctp_Map_t *sctpMap = new Sctp_Map_t();
250 ReportingMessages_t message;
251 RmrMessagesBuffer_t rmrMessageBuffer;
252 sctp_params_t sctp_ut_params;
dhirajverma60f8bef2021-06-29 07:22:58 -0400253
dhirajverma6cf28612021-06-23 04:53:34 -0400254 pdu.present = E2AP_PDU_PR_initiatingMessage;
255 pdu.choice.initiatingMessage = (InitiatingMessage*) malloc(sizeof(InitiatingMessage));
256 memset( (void*)pdu.choice.initiatingMessage, 0, sizeof(pdu.choice.initiatingMessage));
257 memset( (void*)&message, 0, sizeof(message));
258 memset( (void*)&rmrMessageBuffer, 0, sizeof(rmrMessageBuffer));
dhirajverma60f8bef2021-06-29 07:22:58 -0400259
260 snprintf(sctp_ut_params.rmrAddress, strlen("tcp:4560 "), "%s", (char*)"tcp:4560");
261 rmrMessageBuffer.rmrCtx = rmr_init(sctp_ut_params.rmrAddress, RECEIVE_XAPP_BUFFER_SIZE, 0x01);
dhirajverma6cf28612021-06-23 04:53:34 -0400262
263 /* Sending E2AP_PDU_PR_initiatingMessage and procedure code as: ProcedureCode_id_RICserviceUpdate */
dhirajverma60f8bef2021-06-29 07:22:58 -0400264 create_asnInitiatingReq_Procedure_RICserviceUpdate(&pdu, sctpMap, message, rmrMessageBuffer, sctp_ut_params);
dhirajverma6cf28612021-06-23 04:53:34 -0400265 /* Sending E2AP_PDU_PR_initiatingMessage and procedure code as: ProcedureCode_id_RICindication */
dhirajverma60f8bef2021-06-29 07:22:58 -0400266 create_asnInitiatingReq_Procedure_RICindication(&pdu, sctpMap, message, rmrMessageBuffer, sctp_ut_params);
dhirajverma6cf28612021-06-23 04:53:34 -0400267 /* Sending E2AP_PDU_PR_initiatingMessage and procedure code as: ProcedureCode_id_ErrorIndication */
dhirajverma60f8bef2021-06-29 07:22:58 -0400268 create_asnInitiatingReq_Procedure_ErrorIndication(&pdu, sctpMap, message, rmrMessageBuffer, sctp_ut_params);
dhirajverma6cf28612021-06-23 04:53:34 -0400269 /* Sending E2AP_PDU_PR_initiatingMessage and procedure code as: ProcedureCode_id_Reset */
dhirajverma60f8bef2021-06-29 07:22:58 -0400270 create_asnInitiatingReq_Procedure_Reset(&pdu, sctpMap, message, rmrMessageBuffer, sctp_ut_params);
dhirajverma6cf28612021-06-23 04:53:34 -0400271 /* For Procedure's Default case. */
272 pdu.choice.initiatingMessage->procedureCode = ((ProcedureCode_t)100);
czichy2175dd32022-05-17 15:24:51 +0300273 int streamId =0;
274 asnInitiatingRequest(&pdu, sctpMap, message, rmrMessageBuffer,streamId);
dhirajverma6cf28612021-06-23 04:53:34 -0400275
dhirajverma60f8bef2021-06-29 07:22:58 -0400276 if(pdu.choice.initiatingMessage) {
dhirajverma6cf28612021-06-23 04:53:34 -0400277 free(pdu.choice.initiatingMessage);
dhirajverma60f8bef2021-06-29 07:22:58 -0400278 pdu.choice.initiatingMessage = NULL;
279 }
280 if(sctpMap) {
281 delete sctpMap;
282 sctpMap = NULL;
283 }
dhirajverma6cf28612021-06-23 04:53:34 -0400284}
285
dhirajverma60f8bef2021-06-29 07:22:58 -0400286/* TEST8 Begin: */
287void delete_memories_successfulOutcome(E2AP_PDU_t *pdu, RmrMessagesBuffer_t &rmrMessageBuffer) {
288
289 if( (pdu->choice.successfulOutcome->value.choice.RICcontrolAcknowledge.protocolIEs.list.array) &&
290 (pdu->choice.successfulOutcome->value.choice.RICcontrolAcknowledge.protocolIEs.list.array[0]) ) {
291 free(pdu->choice.successfulOutcome->value.choice.RICcontrolAcknowledge.protocolIEs.list.array[0]);
292 pdu->choice.successfulOutcome->value.choice.RICcontrolAcknowledge.protocolIEs.list.array[0] = NULL;
293 }
294 if(pdu->choice.successfulOutcome->value.choice.RICcontrolAcknowledge.protocolIEs.list.array) {
295 free(pdu->choice.successfulOutcome->value.choice.RICcontrolAcknowledge.protocolIEs.list.array);
296 pdu->choice.successfulOutcome->value.choice.RICcontrolAcknowledge.protocolIEs.list.array = NULL;
297 }
298 pdu->choice.successfulOutcome->value.choice.RICcontrolAcknowledge.protocolIEs.list.count = 0;
299 pdu->choice.successfulOutcome->value.choice.RICcontrolAcknowledge.protocolIEs.list.size = 0;
300
301 if(rmrMessageBuffer.sendMessage && rmrMessageBuffer.sendMessage->header) {
302 free(rmrMessageBuffer.sendMessage->header);
303 rmrMessageBuffer.sendMessage->header = NULL;
304 }
305 if(rmrMessageBuffer.sendMessage->payload) {
306 free(rmrMessageBuffer.sendMessage->payload);
307 rmrMessageBuffer.sendMessage->payload = NULL;
308 }
dhirajverma60f8bef2021-06-29 07:22:58 -0400309 if(rmrMessageBuffer.sendMessage) {
310 free(rmrMessageBuffer.sendMessage);
311 rmrMessageBuffer.sendMessage = NULL;
312 }
313}
314
315
316void create_asnSuccessfulMsg_Procedure_Reset(E2AP_PDU_t *pdu,
317 Sctp_Map_t *sctpMap,
318 ReportingMessages_t &message,
319 RmrMessagesBuffer_t &rmrMessageBuffer,
320 sctp_params_t &sctp_ut_params) {
dhirajverma6cf28612021-06-23 04:53:34 -0400321
dhirajverma60f8bef2021-06-29 07:22:58 -0400322 init_memories(message, rmrMessageBuffer, sctp_ut_params);
dhirajverma6cf28612021-06-23 04:53:34 -0400323 /* Sending E2AP_PDU_PR_successfulOutcome and procedure code as: ProcedureCode_id_Reset */
324 pdu->choice.successfulOutcome->procedureCode = ProcedureCode_id_Reset;
325 asnSuccessfulMsg(pdu, sctpMap, message, rmrMessageBuffer);
dhirajverma60f8bef2021-06-29 07:22:58 -0400326 delete_memories_successfulOutcome(pdu, rmrMessageBuffer);
dhirajverma6cf28612021-06-23 04:53:34 -0400327}
328
dhirajverma60f8bef2021-06-29 07:22:58 -0400329void create_asnSuccessfulMsg_Procedure_RICcontrol(E2AP_PDU_t *pdu,
330 Sctp_Map_t *sctpMap,
331 ReportingMessages_t &message,
332 RmrMessagesBuffer_t &rmrMessageBuffer,
333 sctp_params_t &sctp_ut_params) {
dhirajverma6cf28612021-06-23 04:53:34 -0400334
dhirajverma60f8bef2021-06-29 07:22:58 -0400335 init_memories(message, rmrMessageBuffer, sctp_ut_params);
336
dhirajverma6cf28612021-06-23 04:53:34 -0400337 pdu->choice.successfulOutcome->value.choice.RICcontrolAcknowledge.protocolIEs.list.array = (RICcontrolAcknowledge_IEs_t**) malloc(1 * sizeof(RICcontrolAcknowledge_IEs_t*));
338 pdu->choice.successfulOutcome->value.choice.RICcontrolAcknowledge.protocolIEs.list.count = 1;
339 pdu->choice.successfulOutcome->value.choice.RICcontrolAcknowledge.protocolIEs.list.size = sizeof(RICcontrolAcknowledge_IEs_t);
340 pdu->choice.successfulOutcome->value.choice.RICcontrolAcknowledge.protocolIEs.list.array[0] = (RICcontrolAcknowledge_IEs_t*) malloc(sizeof(RICcontrolAcknowledge_IEs_t));
341 RICcontrolAcknowledge_IEs_t *ie = pdu->choice.successfulOutcome->value.choice.RICcontrolAcknowledge.protocolIEs.list.array[0];
342
343 ie->id = ProtocolIE_ID_id_RICrequestID;
344 ie->value.present = RICcontrolAcknowledge_IEs__value_PR_RICrequestID;
345 /* Sending E2AP_PDU_PR_successfulOutcome and procedure code as: ProcedureCode_id_RICcontrol */
346 pdu->choice.successfulOutcome->procedureCode = ProcedureCode_id_RICcontrol;
347 asnSuccessfulMsg(pdu, sctpMap, message, rmrMessageBuffer);
dhirajverma60f8bef2021-06-29 07:22:58 -0400348 delete_memories_successfulOutcome(pdu, rmrMessageBuffer);
dhirajverma6cf28612021-06-23 04:53:34 -0400349}
350
dhirajverma60f8bef2021-06-29 07:22:58 -0400351void create_asnSuccessfulMsg_Procedure_RICsubscription(E2AP_PDU_t *pdu,
352 Sctp_Map_t *sctpMap,
353 ReportingMessages_t &message,
354 RmrMessagesBuffer_t &rmrMessageBuffer,
355 sctp_params_t &sctp_ut_params) {
356
357 init_memories(message, rmrMessageBuffer, sctp_ut_params);
dhirajverma6cf28612021-06-23 04:53:34 -0400358 /* Sending E2AP_PDU_PR_successfulOutcome and procedure code as: ProcedureCode_id_RICsubscription */
359 pdu->choice.successfulOutcome->procedureCode = ProcedureCode_id_RICsubscription;
360 asnSuccessfulMsg(pdu, sctpMap, message, rmrMessageBuffer);
dhirajverma60f8bef2021-06-29 07:22:58 -0400361 delete_memories_successfulOutcome(pdu, rmrMessageBuffer);
dhirajverma6cf28612021-06-23 04:53:34 -0400362}
363
dhirajverma60f8bef2021-06-29 07:22:58 -0400364void create_asnSuccessfulMsg_Procedure_RICsubscriptionDelete(E2AP_PDU_t *pdu,
365 Sctp_Map_t *sctpMap,
366 ReportingMessages_t &message,
367 RmrMessagesBuffer_t &rmrMessageBuffer,
368 sctp_params_t &sctp_ut_params) {
369
370 init_memories(message, rmrMessageBuffer, sctp_ut_params);
dhirajverma6cf28612021-06-23 04:53:34 -0400371 /* Sending E2AP_PDU_PR_successfulOutcome and procedure code as: ProcedureCode_id_RICsubscriptionDelete */
372 pdu->choice.successfulOutcome->procedureCode = ProcedureCode_id_RICsubscriptionDelete;
373 asnSuccessfulMsg(pdu, sctpMap, message, rmrMessageBuffer);
dhirajverma60f8bef2021-06-29 07:22:58 -0400374 delete_memories_successfulOutcome(pdu, rmrMessageBuffer);
dhirajverma6cf28612021-06-23 04:53:34 -0400375}
376
377TEST(sctp, TEST8) {
378 E2AP_PDU_t pdu;
379 Sctp_Map_t *sctpMap = new Sctp_Map_t();
380 ReportingMessages_t message;
381 RmrMessagesBuffer_t rmrMessageBuffer;
382 sctp_params_t sctp_ut_params;
dhirajverma60f8bef2021-06-29 07:22:58 -0400383
dhirajverma6cf28612021-06-23 04:53:34 -0400384 pdu.present = E2AP_PDU_PR_successfulOutcome;
385 pdu.choice.successfulOutcome = (SuccessfulOutcome*) malloc(sizeof(SuccessfulOutcome));
386 memset( (void*)pdu.choice.successfulOutcome, 0, sizeof(pdu.choice.successfulOutcome));
387 memset( (void*)&message, 0, sizeof(message));
388 memset( (void*)&rmrMessageBuffer, 0, sizeof(rmrMessageBuffer));
dhirajverma60f8bef2021-06-29 07:22:58 -0400389
390 snprintf(sctp_ut_params.rmrAddress, strlen("127.0.0.1 "), "%s", (char*)"127.0.0.1");
391
dhirajverma6cf28612021-06-23 04:53:34 -0400392 /* Sending E2AP_PDU_PR_successfulOutcome and procedure code as: ProcedureCode_id_Reset */
dhirajverma60f8bef2021-06-29 07:22:58 -0400393 create_asnSuccessfulMsg_Procedure_Reset(&pdu, sctpMap, message, rmrMessageBuffer, sctp_ut_params);
dhirajverma6cf28612021-06-23 04:53:34 -0400394 /* Sending E2AP_PDU_PR_successfulOutcome and procedure code as: ProcedureCode_id_RICcontrol */
dhirajverma60f8bef2021-06-29 07:22:58 -0400395 create_asnSuccessfulMsg_Procedure_RICcontrol(&pdu, sctpMap, message, rmrMessageBuffer, sctp_ut_params);
dhirajverma6cf28612021-06-23 04:53:34 -0400396 /* Sending E2AP_PDU_PR_successfulOutcome and procedure code as: ProcedureCode_id_RICsubscription */
dhirajverma60f8bef2021-06-29 07:22:58 -0400397 create_asnSuccessfulMsg_Procedure_RICsubscription(&pdu, sctpMap, message, rmrMessageBuffer, sctp_ut_params);
dhirajverma6cf28612021-06-23 04:53:34 -0400398 /* Sending E2AP_PDU_PR_successfulOutcome and procedure code as: ProcedureCode_id_RICsubscriptionDelete */
dhirajverma60f8bef2021-06-29 07:22:58 -0400399 create_asnSuccessfulMsg_Procedure_RICsubscriptionDelete(&pdu, sctpMap, message, rmrMessageBuffer, sctp_ut_params);
dhirajverma6cf28612021-06-23 04:53:34 -0400400 /* For Procedure's Default case. */
401 pdu.choice.successfulOutcome->procedureCode = ((ProcedureCode_t)100);
402 asnSuccessfulMsg(&pdu, sctpMap, message, rmrMessageBuffer);
dhirajverma60f8bef2021-06-29 07:22:58 -0400403
404 if(pdu.choice.successfulOutcome) {
dhirajverma6cf28612021-06-23 04:53:34 -0400405 free(pdu.choice.successfulOutcome);
dhirajverma60f8bef2021-06-29 07:22:58 -0400406 pdu.choice.successfulOutcome = NULL;
407 }
408 if(sctpMap) {
409 delete sctpMap;
410 sctpMap = NULL;
411 }
dhirajverma6cf28612021-06-23 04:53:34 -0400412}
413
414/* TEST9 Begin: */
dhirajverma60f8bef2021-06-29 07:22:58 -0400415void delete_memories_unsuccessfulOutcome(E2AP_PDU_t *pdu, RmrMessagesBuffer_t &rmrMessageBuffer) {
dhirajverma6cf28612021-06-23 04:53:34 -0400416
dhirajverma60f8bef2021-06-29 07:22:58 -0400417 if( (pdu->choice.unsuccessfulOutcome->value.choice.RICcontrolFailure.protocolIEs.list.array) &&
418 (pdu->choice.unsuccessfulOutcome->value.choice.RICcontrolFailure.protocolIEs.list.array[0]) ) {
419 free(pdu->choice.unsuccessfulOutcome->value.choice.RICcontrolFailure.protocolIEs.list.array[0]);
420 pdu->choice.unsuccessfulOutcome->value.choice.RICcontrolFailure.protocolIEs.list.array[0] = NULL;
421 }
422 if(pdu->choice.unsuccessfulOutcome->value.choice.RICcontrolFailure.protocolIEs.list.array) {
423 free(pdu->choice.unsuccessfulOutcome->value.choice.RICcontrolFailure.protocolIEs.list.array);
424 pdu->choice.unsuccessfulOutcome->value.choice.RICcontrolFailure.protocolIEs.list.array = NULL;
425 }
426 pdu->choice.unsuccessfulOutcome->value.choice.RICcontrolFailure.protocolIEs.list.count = 0;
427 pdu->choice.unsuccessfulOutcome->value.choice.RICcontrolFailure.protocolIEs.list.size = 0;
428
429 if(rmrMessageBuffer.sendMessage && rmrMessageBuffer.sendMessage->header) {
430 free(rmrMessageBuffer.sendMessage->header);
431 rmrMessageBuffer.sendMessage->header = NULL;
432 }
433 if(rmrMessageBuffer.sendMessage->payload) {
434 free(rmrMessageBuffer.sendMessage->payload);
435 rmrMessageBuffer.sendMessage->payload = NULL;
436 }
dhirajverma60f8bef2021-06-29 07:22:58 -0400437 if(rmrMessageBuffer.sendMessage) {
438 free(rmrMessageBuffer.sendMessage);
439 rmrMessageBuffer.sendMessage = NULL;
440 }
441}
442
443void create_asnUnSuccsesfulMsg_Procedure_RICcontrol(E2AP_PDU_t *pdu,
444 Sctp_Map_t *sctpMap,
445 ReportingMessages_t &message,
446 RmrMessagesBuffer_t &rmrMessageBuffer,
447 sctp_params_t &sctp_ut_params) {
448
449 init_memories(message, rmrMessageBuffer, sctp_ut_params);
450
dhirajverma6cf28612021-06-23 04:53:34 -0400451 pdu->choice.unsuccessfulOutcome->value.choice.RICcontrolFailure.protocolIEs.list.array = (RICcontrolFailure_IEs_t**) malloc(1*sizeof(RICcontrolFailure_IEs_t*));
452 pdu->choice.unsuccessfulOutcome->value.choice.RICcontrolFailure.protocolIEs.list.count = 1;
453 pdu->choice.unsuccessfulOutcome->value.choice.RICcontrolFailure.protocolIEs.list.size = sizeof(RICcontrolFailure_IEs_t);
454 pdu->choice.unsuccessfulOutcome->value.choice.RICcontrolFailure.protocolIEs.list.array[0] = (RICcontrolFailure_IEs_t*) malloc(sizeof(RICcontrolFailure_IEs_t));
455 RICcontrolFailure_IEs_t *ie = pdu->choice.unsuccessfulOutcome->value.choice.RICcontrolFailure.protocolIEs.list.array[0];
456
457 ie->id = ProtocolIE_ID_id_RICrequestID;
458 ie->value.present = RICcontrolFailure_IEs__value_PR_RICrequestID;
459 /* Sending E2AP_PDU_PR_unsuccessfulOutcome and procedure code as: ProcedureCode_id_RICcontrol */
460 pdu->choice.unsuccessfulOutcome->procedureCode = ProcedureCode_id_RICcontrol;
461 asnUnSuccsesfulMsg(pdu, sctpMap, message, rmrMessageBuffer);
dhirajverma60f8bef2021-06-29 07:22:58 -0400462 delete_memories_unsuccessfulOutcome(pdu, rmrMessageBuffer);
dhirajverma6cf28612021-06-23 04:53:34 -0400463}
464
dhirajverma60f8bef2021-06-29 07:22:58 -0400465void create_asnUnSuccsesfulMsg_Procedure_RICsubscription(E2AP_PDU_t *pdu,
466 Sctp_Map_t *sctpMap,
467 ReportingMessages_t &message,
468 RmrMessagesBuffer_t &rmrMessageBuffer,
469 sctp_params_t &sctp_ut_params) {
470
471 init_memories(message, rmrMessageBuffer, sctp_ut_params);
dhirajverma6cf28612021-06-23 04:53:34 -0400472 /* Sending E2AP_PDU_PR_unsuccessfulOutcome and procedure code as: ProcedureCode_id_RICsubscription */
473 pdu->choice.unsuccessfulOutcome->procedureCode = ProcedureCode_id_RICsubscription;
474 asnUnSuccsesfulMsg(pdu, sctpMap, message, rmrMessageBuffer);
dhirajverma60f8bef2021-06-29 07:22:58 -0400475 delete_memories_unsuccessfulOutcome(pdu, rmrMessageBuffer);
dhirajverma6cf28612021-06-23 04:53:34 -0400476}
477
dhirajverma60f8bef2021-06-29 07:22:58 -0400478void create_asnUnSuccsesfulMsg_Procedure_RICsubscriptionDelete(E2AP_PDU_t *pdu,
479 Sctp_Map_t *sctpMap,
480 ReportingMessages_t &message,
481 RmrMessagesBuffer_t &rmrMessageBuffer,
482 sctp_params_t &sctp_ut_params) {
dhirajverma6cf28612021-06-23 04:53:34 -0400483
dhirajverma60f8bef2021-06-29 07:22:58 -0400484 init_memories(message, rmrMessageBuffer, sctp_ut_params);
dhirajverma6cf28612021-06-23 04:53:34 -0400485 /* Sending E2AP_PDU_PR_unsuccessfulOutcome and procedure code as: ProcedureCode_id_RICsubscriptionDelete */
486 pdu->choice.unsuccessfulOutcome->procedureCode = ProcedureCode_id_RICsubscriptionDelete;
487 asnUnSuccsesfulMsg(pdu, sctpMap, message, rmrMessageBuffer);
dhirajverma60f8bef2021-06-29 07:22:58 -0400488 delete_memories_unsuccessfulOutcome(pdu, rmrMessageBuffer);
dhirajverma6cf28612021-06-23 04:53:34 -0400489}
490
491TEST(sctp, TEST9) {
492 E2AP_PDU_t pdu;
493 Sctp_Map_t *sctpMap = new Sctp_Map_t();
494 ReportingMessages_t message;
495 RmrMessagesBuffer_t rmrMessageBuffer;
496 sctp_params_t sctp_ut_params;
dhirajverma60f8bef2021-06-29 07:22:58 -0400497
dhirajverma6cf28612021-06-23 04:53:34 -0400498 pdu.present = E2AP_PDU_PR_unsuccessfulOutcome;
499 pdu.choice.unsuccessfulOutcome = (UnsuccessfulOutcome*) malloc(sizeof(UnsuccessfulOutcome));
500 memset( (void*)pdu.choice.unsuccessfulOutcome, 0, sizeof(pdu.choice.unsuccessfulOutcome));
501 memset( (void*)&message, 0, sizeof(message));
502 memset( (void*)&rmrMessageBuffer, 0, sizeof(rmrMessageBuffer));
dhirajverma6cf28612021-06-23 04:53:34 -0400503
dhirajverma60f8bef2021-06-29 07:22:58 -0400504 snprintf(sctp_ut_params.rmrAddress, strlen("127.0.0.1 "), "%s", (char*)"127.0.0.1");
dhirajverma6cf28612021-06-23 04:53:34 -0400505
506 /* Sending E2AP_PDU_PR_unsuccessfulOutcome and procedure code as: ProcedureCode_id_RICcontrol */
dhirajverma60f8bef2021-06-29 07:22:58 -0400507 create_asnUnSuccsesfulMsg_Procedure_RICcontrol(&pdu, sctpMap, message, rmrMessageBuffer, sctp_ut_params);
dhirajverma6cf28612021-06-23 04:53:34 -0400508 /* Sending E2AP_PDU_PR_unsuccessfulOutcome and procedure code as: ProcedureCode_id_RICsubscription */
dhirajverma60f8bef2021-06-29 07:22:58 -0400509 create_asnUnSuccsesfulMsg_Procedure_RICsubscription(&pdu, sctpMap, message, rmrMessageBuffer, sctp_ut_params);
dhirajverma6cf28612021-06-23 04:53:34 -0400510 /* Sending E2AP_PDU_PR_unsuccessfulOutcome and procedure code as: ProcedureCode_id_RICsubscriptionDelete */
dhirajverma60f8bef2021-06-29 07:22:58 -0400511 create_asnUnSuccsesfulMsg_Procedure_RICsubscriptionDelete(&pdu, sctpMap, message, rmrMessageBuffer, sctp_ut_params);
dhirajverma6cf28612021-06-23 04:53:34 -0400512 /* For Procedure's Default case. */
513 pdu.choice.unsuccessfulOutcome->procedureCode = ((ProcedureCode_t)100);
514 asnUnSuccsesfulMsg(&pdu, sctpMap, message, rmrMessageBuffer);
dhirajverma60f8bef2021-06-29 07:22:58 -0400515
516 if(pdu.choice.unsuccessfulOutcome) {
dhirajverma6cf28612021-06-23 04:53:34 -0400517 free(pdu.choice.unsuccessfulOutcome);
dhirajverma60f8bef2021-06-29 07:22:58 -0400518 pdu.choice.unsuccessfulOutcome = NULL;
519 }
520 if(sctpMap) {
521 delete sctpMap;
522 sctpMap = NULL;
523 }
dhirajverma6cf28612021-06-23 04:53:34 -0400524}
525
dhirajverma60f8bef2021-06-29 07:22:58 -0400526
dhirajverma6cf28612021-06-23 04:53:34 -0400527TEST(sctp, TEST10) {
528 int epoll_fd = epoll_create1(0);
529 ConnectedCU_t cu;
530 ConnectedCU_t* peerinfo = &cu;
531 Sctp_Map_t m1;
532 Sctp_Map_t *m = &m1;
533 addToEpoll(epoll_fd, peerinfo, 2, m, (char*)"enodeb1", 0);
534}
535
536TEST(sctp, TEST11) {
537 sctp_params_t sctpParams;
538 int argc = 5;
dhirajverma60f8bef2021-06-29 07:22:58 -0400539 char **argv = (char**) calloc(argc, sizeof(char*));
540 argv[0] = (char*) malloc(40 * sizeof(char));
541 argv[1] = (char*) malloc(40 * sizeof(char));
542 argv[2] = (char*) malloc(40 * sizeof(char));
543 argv[3] = (char*) malloc(40 * sizeof(char));
544 argv[4] = (char*) malloc(40 * sizeof(char));
545 snprintf(argv[0], strlen("./e2 "), "%s", (char*)"./e2");
546 snprintf(argv[1], strlen("-p "), "%s", (char*)"-p");
547 snprintf(argv[2], strlen("/opt/e2/RIC-E2-TERMINATION/config "), "%s", (char*)"/opt/e2/RIC-E2-TERMINATION/config");
548 snprintf(argv[3], strlen("-f "), "%s", (char*)"-f");
549 snprintf(argv[4], strlen("config.conf "), "%s", (char*)"config.conf");
dhirajverma6cf28612021-06-23 04:53:34 -0400550
551 auto result = parse(argc, argv, sctpParams);
552 sctpParams.podName.assign("E2TermAlpha_pod");
dhirajverma60f8bef2021-06-29 07:22:58 -0400553 sctpParams.sctpMap = new mapWrapper();
dhirajverma6cf28612021-06-23 04:53:34 -0400554 sctpParams.epoll_fd = epoll_create1(0);
dhirajverma60f8bef2021-06-29 07:22:58 -0400555 buildConfiguration(sctpParams);
dhirajverma6cf28612021-06-23 04:53:34 -0400556 // getRmrContext(sctpParams);
557 buildInotify(sctpParams);
558 buildListeningPort(sctpParams);
dhirajverma6cf28612021-06-23 04:53:34 -0400559 listener(&sctpParams);
dhirajverma60f8bef2021-06-29 07:22:58 -0400560
561 if(sctpParams.sctpMap) {
562 delete sctpParams.sctpMap;
563 sctpParams.sctpMap = NULL;
564 }
565 if(argv) {
566 free(argv[0]);
567 argv[0] = NULL;
568 free(argv[1]);
569 argv[1] = NULL;
570 free(argv[2]);
571 argv[2] = NULL;
572 free(argv[3]);
573 argv[3] = NULL;
574 free(argv[4]);
575 argv[4] = NULL;
576 free(argv);
577 argv=NULL;
578 }
dhirajverma6cf28612021-06-23 04:53:34 -0400579}
580
581TEST(sctp, TEST12) {
582 ReportingMessages_t reporting_msg;
583 Sctp_Map_t *sctpMap = new Sctp_Map_t();
584 sendSctpMsg(peerInfo, reporting_msg, sctpMap);
dhirajverma60f8bef2021-06-29 07:22:58 -0400585
586 if(sctpMap) {
587 delete sctpMap;
588 sctpMap = NULL;
589 }
dhirajverma6cf28612021-06-23 04:53:34 -0400590}
591
dhirajverma60f8bef2021-06-29 07:22:58 -0400592/*TEST13 Begin*/
dhirajverma6cf28612021-06-23 04:53:34 -0400593
dhirajverma60f8bef2021-06-29 07:22:58 -0400594void inti_buffers_rcv(ReportingMessages_t &message, RmrMessagesBuffer_t &rmrMessageBuffer) {
595 message.peerInfo = peerInfo;
596 snprintf(message.message.enodbName, strlen("Nokia_enb "), "%s", (char*)"Nokia_enb");
597
598 rmrMessageBuffer.rcvMessage = (rmr_mbuf_t*) malloc(sizeof(rmr_mbuf_t));
599 rmrMessageBuffer.rcvMessage->header = (uta_mhdr_t*) malloc(sizeof(uta_mhdr_t));
600 rmrMessageBuffer.rcvMessage->len = strlen("Saying Hello from Ramji ");
601 rmrMessageBuffer.rcvMessage->payload = (unsigned char*)strdup("Saying Hello from Ramji");
602
603 rmrMessageBuffer.sendMessage = (rmr_mbuf_t*) malloc(sizeof(rmr_mbuf_t));
604 rmrMessageBuffer.sendMessage->header = (uta_mhdr_t*) malloc(sizeof(uta_mhdr_t));
605 rmrMessageBuffer.sendMessage->len = strlen("Saying Hello from Ramji ");
606 rmrMessageBuffer.sendMessage->payload = (unsigned char*)strdup("Saying Hello from Ramji");
607
608}
609
610void delete_memories_rcv(RmrMessagesBuffer_t &rmrMessageBuffer) {
611
612 if(rmrMessageBuffer.rcvMessage && rmrMessageBuffer.rcvMessage->header) {
613 free(rmrMessageBuffer.rcvMessage->header);
614 rmrMessageBuffer.rcvMessage->header = NULL;
615 }
616 if(rmrMessageBuffer.rcvMessage) {
617 free(rmrMessageBuffer.rcvMessage);
618 rmrMessageBuffer.rcvMessage = NULL;
619 }
620 if(rmrMessageBuffer.sendMessage && rmrMessageBuffer.sendMessage->header) {
621 free(rmrMessageBuffer.sendMessage->header);
622 rmrMessageBuffer.sendMessage->header = NULL;
623 }
624 if(rmrMessageBuffer.sendMessage) {
625 free(rmrMessageBuffer.sendMessage);
626 rmrMessageBuffer.sendMessage = NULL;
627 }
628
629}
630
631void create_receiveXappMessages_RIC_ERROR_INDICATION(Sctp_Map_t *sctpMap, ReportingMessages_t &message,
632 RmrMessagesBuffer_t &rmrMessageBuffer) {
633 inti_buffers_rcv(message, rmrMessageBuffer);
634 rmrMessageBuffer.rcvMessage->mtype = RIC_ERROR_INDICATION;
635 receiveXappMessages(sctpMap, rmrMessageBuffer, message.message.time);
636 delete_memories_rcv(rmrMessageBuffer);
637
638}
639void create_receiveXappMessages_RIC_E2_SETUP_FAILURE(Sctp_Map_t *sctpMap, ReportingMessages_t &message,
640 RmrMessagesBuffer_t &rmrMessageBuffer) {
641 inti_buffers_rcv(message, rmrMessageBuffer);
642 rmrMessageBuffer.rcvMessage->mtype = RIC_E2_SETUP_FAILURE;
643 receiveXappMessages(sctpMap, rmrMessageBuffer, message.message.time);
644 delete_memories_rcv(rmrMessageBuffer);
645}
646
647void create_receiveXappMessages_RIC_SUB_REQ(Sctp_Map_t *sctpMap, ReportingMessages_t &message,
648 RmrMessagesBuffer_t &rmrMessageBuffer) {
649 inti_buffers_rcv(message, rmrMessageBuffer);
650 rmrMessageBuffer.rcvMessage->mtype = RIC_SUB_REQ;
651 receiveXappMessages(sctpMap, rmrMessageBuffer, message.message.time);
652 delete_memories_rcv(rmrMessageBuffer);
653}
654
655void create_receiveXappMessages_RIC_CONTROL_REQ(Sctp_Map_t *sctpMap, ReportingMessages_t &message,
656 RmrMessagesBuffer_t &rmrMessageBuffer) {
657 inti_buffers_rcv(message, rmrMessageBuffer);
658 rmrMessageBuffer.rcvMessage->mtype = RIC_CONTROL_REQ;
659 receiveXappMessages(sctpMap, rmrMessageBuffer, message.message.time);
660 delete_memories_rcv(rmrMessageBuffer);
661}
662
663void create_receiveXappMessages_RIC_SERVICE_QUERY(Sctp_Map_t *sctpMap, ReportingMessages_t &message,
664 RmrMessagesBuffer_t &rmrMessageBuffer) {
665 inti_buffers_rcv(message, rmrMessageBuffer);
666 rmrMessageBuffer.rcvMessage->mtype = RIC_SERVICE_QUERY;
667 receiveXappMessages(sctpMap, rmrMessageBuffer, message.message.time);
668 delete_memories_rcv(rmrMessageBuffer);
669}
670
671void create_receiveXappMessages_RIC_SERVICE_UPDATE_ACK(Sctp_Map_t *sctpMap, ReportingMessages_t &message,
672 RmrMessagesBuffer_t &rmrMessageBuffer) {
673 inti_buffers_rcv(message, rmrMessageBuffer);
674 rmrMessageBuffer.rcvMessage->mtype = RIC_SERVICE_UPDATE_ACK;
675 receiveXappMessages(sctpMap, rmrMessageBuffer, message.message.time);
676 delete_memories_rcv(rmrMessageBuffer);
677}
678
679void create_receiveXappMessages_RIC_SERVICE_UPDATE_FAILURE(Sctp_Map_t *sctpMap, ReportingMessages_t &message,
680 RmrMessagesBuffer_t &rmrMessageBuffer) {
681 inti_buffers_rcv(message, rmrMessageBuffer);
682 rmrMessageBuffer.rcvMessage->mtype = RIC_SERVICE_UPDATE_FAILURE;
683 receiveXappMessages(sctpMap, rmrMessageBuffer, message.message.time);
684 delete_memories_rcv(rmrMessageBuffer);
685}
686
687
688void create_receiveXappMessages_RIC_E2_RESET_REQ(Sctp_Map_t *sctpMap, ReportingMessages_t &message,
689 RmrMessagesBuffer_t &rmrMessageBuffer) {
690 inti_buffers_rcv(message, rmrMessageBuffer);
691 rmrMessageBuffer.rcvMessage->mtype = RIC_E2_RESET_REQ;
692 receiveXappMessages(sctpMap, rmrMessageBuffer, message.message.time);
693 delete_memories_rcv(rmrMessageBuffer);
694}
695
696void create_receiveXappMessages_RIC_E2_RESET_RESP(Sctp_Map_t *sctpMap, ReportingMessages_t &message,
697 RmrMessagesBuffer_t &rmrMessageBuffer) {
698 inti_buffers_rcv(message, rmrMessageBuffer);
699 rmrMessageBuffer.rcvMessage->mtype = RIC_E2_RESET_RESP;
700 receiveXappMessages(sctpMap, rmrMessageBuffer, message.message.time);
701 delete_memories_rcv(rmrMessageBuffer);
702}
703
704void create_receiveXappMessages_RIC_SCTP_CLEAR_ALL(Sctp_Map_t *sctpMap, ReportingMessages_t &message,
705 RmrMessagesBuffer_t &rmrMessageBuffer) {
706 inti_buffers_rcv(message, rmrMessageBuffer);
707 rmrMessageBuffer.rcvMessage->mtype = RIC_SCTP_CLEAR_ALL;
708 receiveXappMessages(sctpMap, rmrMessageBuffer, message.message.time);
709 delete_memories_rcv(rmrMessageBuffer);
710}
711
712void create_receiveXappMessages_RIC_HEALTH_CHECK_REQ(Sctp_Map_t *sctpMap, ReportingMessages_t &message,
713 RmrMessagesBuffer_t &rmrMessageBuffer) {
714 inti_buffers_rcv(message, rmrMessageBuffer);
715 rmrMessageBuffer.rcvMessage->mtype = RIC_HEALTH_CHECK_REQ;
716 receiveXappMessages(sctpMap, rmrMessageBuffer, message.message.time);
717 delete_memories_rcv(rmrMessageBuffer);
718}
719
720void create_receiveXappMessages_E2_TERM_KEEP_ALIVE_REQ(Sctp_Map_t *sctpMap, ReportingMessages_t &message,
721 RmrMessagesBuffer_t &rmrMessageBuffer) {
722 inti_buffers_rcv(message, rmrMessageBuffer);
723 rmrMessageBuffer.rcvMessage->mtype = E2_TERM_KEEP_ALIVE_REQ;
724 receiveXappMessages(sctpMap, rmrMessageBuffer, message.message.time);
725 delete_memories_rcv(rmrMessageBuffer);
726}
727
dhirajverma99990292021-07-05 10:03:59 -0400728void create_receiveXappMessages_RIC_SUB_DEL_REQ(Sctp_Map_t *sctpMap, ReportingMessages_t &message,
729 RmrMessagesBuffer_t &rmrMessageBuffer) {
730 inti_buffers_rcv(message, rmrMessageBuffer);
dhirajverma93b6d9c2021-07-10 00:49:13 -0400731 rmrMessageBuffer.rcvMessage->mtype = RIC_SUB_DEL_REQ;
dhirajverma99990292021-07-05 10:03:59 -0400732 receiveXappMessages(sctpMap, rmrMessageBuffer, message.message.time);
733 delete_memories_rcv(rmrMessageBuffer);
734}
dhirajverma60f8bef2021-06-29 07:22:58 -0400735
dhirajverma93b6d9c2021-07-10 00:49:13 -0400736void create_receiveXappMessages_RIC_E2_SETUP_RESP(Sctp_Map_t *sctpMap, ReportingMessages_t &message,
737 RmrMessagesBuffer_t &rmrMessageBuffer) {
738 inti_buffers_rcv(message, rmrMessageBuffer);
739 rmrMessageBuffer.rcvMessage->mtype = RIC_E2_SETUP_RESP;
740 receiveXappMessages(sctpMap, rmrMessageBuffer, message.message.time);
741 delete_memories_rcv(rmrMessageBuffer);
742}
743
dhirajverma60f8bef2021-06-29 07:22:58 -0400744TEST(sctp, TEST13) {
745 Sctp_Map_t *sctpMap = new Sctp_Map_t();
746 ReportingMessages_t message;
747 RmrMessagesBuffer_t rmrMessageBuffer;
748
dhirajverma6cf28612021-06-23 04:53:34 -0400749 memset( (void*)&message, 0, sizeof(message));
750 memset( (void*)&rmrMessageBuffer, 0, sizeof(rmrMessageBuffer));
751
dhirajverma60f8bef2021-06-29 07:22:58 -0400752 // Sending E2AP_PDU_PR_successfulOutcome and procedure code as: ProcedureCode_id_Reset
753 create_receiveXappMessages_RIC_E2_SETUP_FAILURE(sctpMap, message, rmrMessageBuffer);
754 create_receiveXappMessages_RIC_ERROR_INDICATION(sctpMap, message, rmrMessageBuffer);
755 create_receiveXappMessages_RIC_SUB_REQ(sctpMap, message, rmrMessageBuffer);
756 create_receiveXappMessages_RIC_CONTROL_REQ(sctpMap, message, rmrMessageBuffer);
757 create_receiveXappMessages_RIC_HEALTH_CHECK_REQ(sctpMap, message, rmrMessageBuffer);
758 create_receiveXappMessages_E2_TERM_KEEP_ALIVE_REQ(sctpMap, message, rmrMessageBuffer);
759 create_receiveXappMessages_RIC_SCTP_CLEAR_ALL(sctpMap, message, rmrMessageBuffer);
dhirajverma60f8bef2021-06-29 07:22:58 -0400760 create_receiveXappMessages_RIC_E2_RESET_RESP(sctpMap, message, rmrMessageBuffer);
761 create_receiveXappMessages_RIC_E2_RESET_REQ(sctpMap, message, rmrMessageBuffer);
762 create_receiveXappMessages_RIC_SERVICE_UPDATE_FAILURE(sctpMap, message, rmrMessageBuffer);
763 create_receiveXappMessages_RIC_SERVICE_UPDATE_ACK(sctpMap, message, rmrMessageBuffer);
764 create_receiveXappMessages_RIC_SERVICE_QUERY(sctpMap, message, rmrMessageBuffer);
dhirajverma99990292021-07-05 10:03:59 -0400765 create_receiveXappMessages_RIC_SUB_DEL_REQ(sctpMap, message, rmrMessageBuffer);
dhirajverma93b6d9c2021-07-10 00:49:13 -0400766 create_receiveXappMessages_RIC_E2_SETUP_RESP(sctpMap, message, rmrMessageBuffer);
dhirajverma6cf28612021-06-23 04:53:34 -0400767
dhirajverma60f8bef2021-06-29 07:22:58 -0400768 inti_buffers_rcv(message, rmrMessageBuffer);
dhirajverma99990292021-07-05 10:03:59 -0400769 rmrMessageBuffer.rcvMessage->mtype = 52345; /*Dummy Integer Value for default case*/
dhirajverma60f8bef2021-06-29 07:22:58 -0400770 receiveXappMessages(sctpMap, rmrMessageBuffer, message.message.time);
771 delete_memories_rcv(rmrMessageBuffer);
772
773 if(sctpMap) {
774 delete sctpMap;
775 sctpMap = NULL;
776 }
777}
dhirajverma99990292021-07-05 10:03:59 -0400778/* TEST 14 Begin: */
779void receiveDataFromSctp_asnSuccessfulMsg_Procedure_Default( E2AP_PDU_t *pdu,
780 RmrMessagesBuffer_t &rmrMessageBuffer) {
781 pdu->present = E2AP_PDU_PR_successfulOutcome;
782 pdu->choice.successfulOutcome = (SuccessfulOutcome*) malloc(sizeof(SuccessfulOutcome));
783 memset( (void*)pdu->choice.successfulOutcome, 0, sizeof(pdu->choice.successfulOutcome));
784 pdu->choice.successfulOutcome->procedureCode = ((ProcedureCode_t)100);
785
786 rmrMessageBuffer.sendMessage->tp_buf = pdu;
787}
788
789void delete_pdu_memories(E2AP_PDU_t *pdu) {
790 if(pdu->choice.successfulOutcome) {
791 free(pdu->choice.successfulOutcome);
792 pdu->choice.successfulOutcome = NULL;
793 }
794 if(pdu->choice.unsuccessfulOutcome) {
795 free(pdu->choice.unsuccessfulOutcome);
796 pdu->choice.unsuccessfulOutcome = NULL;
797 }
798}
799
dhirajvermac40ea1f2021-07-08 12:52:30 -0400800/*void receiveDataFromSctp_asnUnSuccsesfulMsg_Procedure_Default(E2AP_PDU_t *pdu,
dhirajverma99990292021-07-05 10:03:59 -0400801 RmrMessagesBuffer_t &rmrMessageBuffer) {
802 pdu->present = E2AP_PDU_PR_unsuccessfulOutcome;
803 pdu->choice.unsuccessfulOutcome = (UnsuccessfulOutcome*) malloc(sizeof(UnsuccessfulOutcome));
804 memset( (void*)pdu->choice.unsuccessfulOutcome, 0, sizeof(pdu->choice.unsuccessfulOutcome));
805 pdu->choice.unsuccessfulOutcome->procedureCode = ((ProcedureCode_t)100);
806
807 rmrMessageBuffer.sendMessage->tp_buf = pdu;
dhirajvermac40ea1f2021-07-08 12:52:30 -0400808}*/
dhirajverma99990292021-07-05 10:03:59 -0400809
810TEST(sctp, TEST14) {
811 E2AP_PDU_t pdu;
812 struct epoll_event events;
813 Sctp_Map_t *sctpMap = new Sctp_Map_t();
814 int numOfMessages=0;
815 RmrMessagesBuffer_t rmrMessageBuffer;
816 struct timespec ts;
817 ConnectedCU_t *peerInfo = (ConnectedCU_t *) calloc(1, sizeof(ConnectedCU_t));
818 events.data.ptr = peerInfo;
819 snprintf(peerInfo->enodbName, strlen("Nokia_enb "), "%s", (char*)"Nokia_enb");
820
821 rmrMessageBuffer.sendMessage = (rmr_mbuf_t*) malloc(sizeof(rmr_mbuf_t));
822 rmrMessageBuffer.sendMessage->header = (uta_mhdr_t*) malloc(sizeof(uta_mhdr_t));
823 rmrMessageBuffer.sendMessage->len = strlen("Saying Hello from NOKIA ");
824 rmrMessageBuffer.sendMessage->payload = (unsigned char*)strdup("Saying Hello from NOKIA");
825
826 clock_gettime(CLOCK_MONOTONIC, &ts);
827
828 receiveDataFromSctp_asnSuccessfulMsg_Procedure_Default(&pdu, rmrMessageBuffer);
829 receiveDataFromSctp(&events, sctpMap, numOfMessages, rmrMessageBuffer, ts);
830 delete_pdu_memories(&pdu);
831
832 if(rmrMessageBuffer.sendMessage->payload) {
833 free(rmrMessageBuffer.sendMessage->payload);
834 rmrMessageBuffer.sendMessage->payload = NULL;
835 }
836
dhirajvermac40ea1f2021-07-08 12:52:30 -0400837 /*rmrMessageBuffer.sendMessage->payload = (unsigned char*)strdup("Saying Hello from NOKIA");
dhirajverma99990292021-07-05 10:03:59 -0400838 receiveDataFromSctp_asnUnSuccsesfulMsg_Procedure_Default(&pdu, rmrMessageBuffer);
839 receiveDataFromSctp(&events, sctpMap, numOfMessages, rmrMessageBuffer, ts);
840 delete_pdu_memories(&pdu);
841
842 if(rmrMessageBuffer.sendMessage->payload) {
843 free(rmrMessageBuffer.sendMessage->payload);
844 rmrMessageBuffer.sendMessage->payload = NULL;
dhirajvermac40ea1f2021-07-08 12:52:30 -0400845 }*/
dhirajverma99990292021-07-05 10:03:59 -0400846 if(rmrMessageBuffer.sendMessage->header) {
847 free(rmrMessageBuffer.sendMessage->header);
848 rmrMessageBuffer.sendMessage->header = NULL;
849 }
850 if(rmrMessageBuffer.sendMessage) {
851 free(rmrMessageBuffer.sendMessage);
852 }
853 if(peerInfo) {
854 free(peerInfo);
855 peerInfo = NULL;
856 }
857 if(sctpMap) {
858 delete sctpMap;
859 sctpMap = NULL;
860 }
861}
dhirajverma60f8bef2021-06-29 07:22:58 -0400862
dhirajverma31768a92021-05-06 12:38:49 +0530863int main(int argc, char **argv) {
864
865 testing::InitGoogleTest(&argc, argv);
866 return RUN_ALL_TESTS();
867
868}