blob: 226d59eccdba37cf11e7ab99f07650f1c64e3a45 [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;
187
188 asnInitiatingRequest(pdu, sctpMap, message, rmrMessageBuffer);
dhirajverma60f8bef2021-06-29 07:22:58 -0400189 delete_memories_initiatingMessage(pdu, rmrMessageBuffer);
dhirajverma6cf28612021-06-23 04:53:34 -0400190}
dhirajverma31768a92021-05-06 12:38:49 +0530191
dhirajverma60f8bef2021-06-29 07:22:58 -0400192void create_asnInitiatingReq_Procedure_RICindication(E2AP_PDU_t *pdu,
193 Sctp_Map_t *sctpMap,
194 ReportingMessages_t &message,
195 RmrMessagesBuffer_t &rmrMessageBuffer,
196 sctp_params_t &sctp_ut_params) {
dhirajverma6cf28612021-06-23 04:53:34 -0400197
dhirajverma60f8bef2021-06-29 07:22:58 -0400198 init_memories(message, rmrMessageBuffer, sctp_ut_params);
dhirajverma6cf28612021-06-23 04:53:34 -0400199 /* Sending E2AP_PDU_PR_initiatingMessage and procedure code as: ProcedureCode_id_RICindication */
200 pdu->choice.initiatingMessage->procedureCode = ProcedureCode_id_RICindication;
201 pdu->choice.initiatingMessage->value.present = InitiatingMessage__value_PR_RICindication;
202 pdu->choice.initiatingMessage->value.choice.RICindication.protocolIEs.list.array = (RICindication_IEs**) malloc(1 * sizeof(RICindication_IEs*));
203 pdu->choice.initiatingMessage->value.choice.RICindication.protocolIEs.list.count = 1;
204 pdu->choice.initiatingMessage->value.choice.RICindication.protocolIEs.list.size = sizeof(RICindication_IEs);
205 pdu->choice.initiatingMessage->value.choice.RICindication.protocolIEs.list.array[0] = (RICindication_IEs*) malloc(sizeof(RICindication_IEs));
206 RICindication_IEs_t *ie = pdu->choice.initiatingMessage->value.choice.RICindication.protocolIEs.list.array[0];
207 ie->id = ProtocolIE_ID_id_RICrequestID;
208 ie->value.present = RICindication_IEs__value_PR_RICrequestID;
209 ie->value.choice.RICrequestID.ricRequestorID = 12345;
210 ie->value.choice.RICrequestID.ricInstanceID = 1;
211
212 asnInitiatingRequest(pdu, sctpMap, message, rmrMessageBuffer);
dhirajverma60f8bef2021-06-29 07:22:58 -0400213 delete_memories_initiatingMessage(pdu, rmrMessageBuffer);
dhirajverma6cf28612021-06-23 04:53:34 -0400214}
215
dhirajverma60f8bef2021-06-29 07:22:58 -0400216void create_asnInitiatingReq_Procedure_ErrorIndication(E2AP_PDU_t *pdu,
217 Sctp_Map_t *sctpMap,
218 ReportingMessages_t &message,
219 RmrMessagesBuffer_t &rmrMessageBuffer,
220 sctp_params_t &sctp_ut_params) {
dhirajverma6cf28612021-06-23 04:53:34 -0400221
dhirajverma60f8bef2021-06-29 07:22:58 -0400222 init_memories(message, rmrMessageBuffer, sctp_ut_params);
dhirajverma6cf28612021-06-23 04:53:34 -0400223 /* Sending E2AP_PDU_PR_initiatingMessage and procedure code as: ProcedureCode_id_ErrorIndication */
224 pdu->choice.initiatingMessage->procedureCode = ProcedureCode_id_ErrorIndication;
225 pdu->choice.initiatingMessage->value.present = InitiatingMessage__value_PR_ErrorIndication;
226 asnInitiatingRequest(pdu, sctpMap, message, rmrMessageBuffer);
dhirajverma60f8bef2021-06-29 07:22:58 -0400227 delete_memories_initiatingMessage(pdu, rmrMessageBuffer);
dhirajverma6cf28612021-06-23 04:53:34 -0400228}
229
dhirajverma60f8bef2021-06-29 07:22:58 -0400230void create_asnInitiatingReq_Procedure_Reset(E2AP_PDU_t *pdu,
231 Sctp_Map_t *sctpMap,
232 ReportingMessages_t &message,
233 RmrMessagesBuffer_t &rmrMessageBuffer,
234 sctp_params_t &sctp_ut_params) {
235
236 init_memories(message, rmrMessageBuffer, sctp_ut_params);
dhirajverma6cf28612021-06-23 04:53:34 -0400237 /* Sending E2AP_PDU_PR_initiatingMessage and procedure code as: ProcedureCode_id_Reset */
238 pdu->choice.initiatingMessage->procedureCode = ProcedureCode_id_Reset;
239 pdu->choice.initiatingMessage->value.present = InitiatingMessage__value_PR_ResetRequest;
240 asnInitiatingRequest(pdu, sctpMap, message, rmrMessageBuffer);
dhirajverma60f8bef2021-06-29 07:22:58 -0400241 delete_memories_initiatingMessage(pdu, rmrMessageBuffer);
dhirajverma6cf28612021-06-23 04:53:34 -0400242}
243
244TEST(sctp, TEST7) {
245 E2AP_PDU_t pdu;
246 Sctp_Map_t *sctpMap = new Sctp_Map_t();
247 ReportingMessages_t message;
248 RmrMessagesBuffer_t rmrMessageBuffer;
249 sctp_params_t sctp_ut_params;
dhirajverma60f8bef2021-06-29 07:22:58 -0400250
dhirajverma6cf28612021-06-23 04:53:34 -0400251 pdu.present = E2AP_PDU_PR_initiatingMessage;
252 pdu.choice.initiatingMessage = (InitiatingMessage*) malloc(sizeof(InitiatingMessage));
253 memset( (void*)pdu.choice.initiatingMessage, 0, sizeof(pdu.choice.initiatingMessage));
254 memset( (void*)&message, 0, sizeof(message));
255 memset( (void*)&rmrMessageBuffer, 0, sizeof(rmrMessageBuffer));
dhirajverma60f8bef2021-06-29 07:22:58 -0400256
257 snprintf(sctp_ut_params.rmrAddress, strlen("tcp:4560 "), "%s", (char*)"tcp:4560");
258 rmrMessageBuffer.rmrCtx = rmr_init(sctp_ut_params.rmrAddress, RECEIVE_XAPP_BUFFER_SIZE, 0x01);
dhirajverma6cf28612021-06-23 04:53:34 -0400259
260 /* Sending E2AP_PDU_PR_initiatingMessage and procedure code as: ProcedureCode_id_RICserviceUpdate */
dhirajverma60f8bef2021-06-29 07:22:58 -0400261 create_asnInitiatingReq_Procedure_RICserviceUpdate(&pdu, sctpMap, message, rmrMessageBuffer, sctp_ut_params);
dhirajverma6cf28612021-06-23 04:53:34 -0400262 /* Sending E2AP_PDU_PR_initiatingMessage and procedure code as: ProcedureCode_id_RICindication */
dhirajverma60f8bef2021-06-29 07:22:58 -0400263 create_asnInitiatingReq_Procedure_RICindication(&pdu, sctpMap, message, rmrMessageBuffer, sctp_ut_params);
dhirajverma6cf28612021-06-23 04:53:34 -0400264 /* Sending E2AP_PDU_PR_initiatingMessage and procedure code as: ProcedureCode_id_ErrorIndication */
dhirajverma60f8bef2021-06-29 07:22:58 -0400265 create_asnInitiatingReq_Procedure_ErrorIndication(&pdu, sctpMap, message, rmrMessageBuffer, sctp_ut_params);
dhirajverma6cf28612021-06-23 04:53:34 -0400266 /* Sending E2AP_PDU_PR_initiatingMessage and procedure code as: ProcedureCode_id_Reset */
dhirajverma60f8bef2021-06-29 07:22:58 -0400267 create_asnInitiatingReq_Procedure_Reset(&pdu, sctpMap, message, rmrMessageBuffer, sctp_ut_params);
dhirajverma6cf28612021-06-23 04:53:34 -0400268 /* For Procedure's Default case. */
269 pdu.choice.initiatingMessage->procedureCode = ((ProcedureCode_t)100);
270 asnInitiatingRequest(&pdu, sctpMap, message, rmrMessageBuffer);
271
dhirajverma60f8bef2021-06-29 07:22:58 -0400272 if(pdu.choice.initiatingMessage) {
dhirajverma6cf28612021-06-23 04:53:34 -0400273 free(pdu.choice.initiatingMessage);
dhirajverma60f8bef2021-06-29 07:22:58 -0400274 pdu.choice.initiatingMessage = NULL;
275 }
276 if(sctpMap) {
277 delete sctpMap;
278 sctpMap = NULL;
279 }
dhirajverma6cf28612021-06-23 04:53:34 -0400280}
281
dhirajverma60f8bef2021-06-29 07:22:58 -0400282/* TEST8 Begin: */
283void delete_memories_successfulOutcome(E2AP_PDU_t *pdu, RmrMessagesBuffer_t &rmrMessageBuffer) {
284
285 if( (pdu->choice.successfulOutcome->value.choice.RICcontrolAcknowledge.protocolIEs.list.array) &&
286 (pdu->choice.successfulOutcome->value.choice.RICcontrolAcknowledge.protocolIEs.list.array[0]) ) {
287 free(pdu->choice.successfulOutcome->value.choice.RICcontrolAcknowledge.protocolIEs.list.array[0]);
288 pdu->choice.successfulOutcome->value.choice.RICcontrolAcknowledge.protocolIEs.list.array[0] = NULL;
289 }
290 if(pdu->choice.successfulOutcome->value.choice.RICcontrolAcknowledge.protocolIEs.list.array) {
291 free(pdu->choice.successfulOutcome->value.choice.RICcontrolAcknowledge.protocolIEs.list.array);
292 pdu->choice.successfulOutcome->value.choice.RICcontrolAcknowledge.protocolIEs.list.array = NULL;
293 }
294 pdu->choice.successfulOutcome->value.choice.RICcontrolAcknowledge.protocolIEs.list.count = 0;
295 pdu->choice.successfulOutcome->value.choice.RICcontrolAcknowledge.protocolIEs.list.size = 0;
296
297 if(rmrMessageBuffer.sendMessage && rmrMessageBuffer.sendMessage->header) {
298 free(rmrMessageBuffer.sendMessage->header);
299 rmrMessageBuffer.sendMessage->header = NULL;
300 }
301 if(rmrMessageBuffer.sendMessage->payload) {
302 free(rmrMessageBuffer.sendMessage->payload);
303 rmrMessageBuffer.sendMessage->payload = NULL;
304 }
dhirajverma60f8bef2021-06-29 07:22:58 -0400305 if(rmrMessageBuffer.sendMessage) {
306 free(rmrMessageBuffer.sendMessage);
307 rmrMessageBuffer.sendMessage = NULL;
308 }
309}
310
311
312void create_asnSuccessfulMsg_Procedure_Reset(E2AP_PDU_t *pdu,
313 Sctp_Map_t *sctpMap,
314 ReportingMessages_t &message,
315 RmrMessagesBuffer_t &rmrMessageBuffer,
316 sctp_params_t &sctp_ut_params) {
dhirajverma6cf28612021-06-23 04:53:34 -0400317
dhirajverma60f8bef2021-06-29 07:22:58 -0400318 init_memories(message, rmrMessageBuffer, sctp_ut_params);
dhirajverma6cf28612021-06-23 04:53:34 -0400319 /* Sending E2AP_PDU_PR_successfulOutcome and procedure code as: ProcedureCode_id_Reset */
320 pdu->choice.successfulOutcome->procedureCode = ProcedureCode_id_Reset;
321 asnSuccessfulMsg(pdu, sctpMap, message, rmrMessageBuffer);
dhirajverma60f8bef2021-06-29 07:22:58 -0400322 delete_memories_successfulOutcome(pdu, rmrMessageBuffer);
dhirajverma6cf28612021-06-23 04:53:34 -0400323}
324
dhirajverma60f8bef2021-06-29 07:22:58 -0400325void create_asnSuccessfulMsg_Procedure_RICcontrol(E2AP_PDU_t *pdu,
326 Sctp_Map_t *sctpMap,
327 ReportingMessages_t &message,
328 RmrMessagesBuffer_t &rmrMessageBuffer,
329 sctp_params_t &sctp_ut_params) {
dhirajverma6cf28612021-06-23 04:53:34 -0400330
dhirajverma60f8bef2021-06-29 07:22:58 -0400331 init_memories(message, rmrMessageBuffer, sctp_ut_params);
332
dhirajverma6cf28612021-06-23 04:53:34 -0400333 pdu->choice.successfulOutcome->value.choice.RICcontrolAcknowledge.protocolIEs.list.array = (RICcontrolAcknowledge_IEs_t**) malloc(1 * sizeof(RICcontrolAcknowledge_IEs_t*));
334 pdu->choice.successfulOutcome->value.choice.RICcontrolAcknowledge.protocolIEs.list.count = 1;
335 pdu->choice.successfulOutcome->value.choice.RICcontrolAcknowledge.protocolIEs.list.size = sizeof(RICcontrolAcknowledge_IEs_t);
336 pdu->choice.successfulOutcome->value.choice.RICcontrolAcknowledge.protocolIEs.list.array[0] = (RICcontrolAcknowledge_IEs_t*) malloc(sizeof(RICcontrolAcknowledge_IEs_t));
337 RICcontrolAcknowledge_IEs_t *ie = pdu->choice.successfulOutcome->value.choice.RICcontrolAcknowledge.protocolIEs.list.array[0];
338
339 ie->id = ProtocolIE_ID_id_RICrequestID;
340 ie->value.present = RICcontrolAcknowledge_IEs__value_PR_RICrequestID;
341 /* Sending E2AP_PDU_PR_successfulOutcome and procedure code as: ProcedureCode_id_RICcontrol */
342 pdu->choice.successfulOutcome->procedureCode = ProcedureCode_id_RICcontrol;
343 asnSuccessfulMsg(pdu, sctpMap, message, rmrMessageBuffer);
dhirajverma60f8bef2021-06-29 07:22:58 -0400344 delete_memories_successfulOutcome(pdu, rmrMessageBuffer);
dhirajverma6cf28612021-06-23 04:53:34 -0400345}
346
dhirajverma60f8bef2021-06-29 07:22:58 -0400347void create_asnSuccessfulMsg_Procedure_RICsubscription(E2AP_PDU_t *pdu,
348 Sctp_Map_t *sctpMap,
349 ReportingMessages_t &message,
350 RmrMessagesBuffer_t &rmrMessageBuffer,
351 sctp_params_t &sctp_ut_params) {
352
353 init_memories(message, rmrMessageBuffer, sctp_ut_params);
dhirajverma6cf28612021-06-23 04:53:34 -0400354 /* Sending E2AP_PDU_PR_successfulOutcome and procedure code as: ProcedureCode_id_RICsubscription */
355 pdu->choice.successfulOutcome->procedureCode = ProcedureCode_id_RICsubscription;
356 asnSuccessfulMsg(pdu, sctpMap, message, rmrMessageBuffer);
dhirajverma60f8bef2021-06-29 07:22:58 -0400357 delete_memories_successfulOutcome(pdu, rmrMessageBuffer);
dhirajverma6cf28612021-06-23 04:53:34 -0400358}
359
dhirajverma60f8bef2021-06-29 07:22:58 -0400360void create_asnSuccessfulMsg_Procedure_RICsubscriptionDelete(E2AP_PDU_t *pdu,
361 Sctp_Map_t *sctpMap,
362 ReportingMessages_t &message,
363 RmrMessagesBuffer_t &rmrMessageBuffer,
364 sctp_params_t &sctp_ut_params) {
365
366 init_memories(message, rmrMessageBuffer, sctp_ut_params);
dhirajverma6cf28612021-06-23 04:53:34 -0400367 /* Sending E2AP_PDU_PR_successfulOutcome and procedure code as: ProcedureCode_id_RICsubscriptionDelete */
368 pdu->choice.successfulOutcome->procedureCode = ProcedureCode_id_RICsubscriptionDelete;
369 asnSuccessfulMsg(pdu, sctpMap, message, rmrMessageBuffer);
dhirajverma60f8bef2021-06-29 07:22:58 -0400370 delete_memories_successfulOutcome(pdu, rmrMessageBuffer);
dhirajverma6cf28612021-06-23 04:53:34 -0400371}
372
373TEST(sctp, TEST8) {
374 E2AP_PDU_t pdu;
375 Sctp_Map_t *sctpMap = new Sctp_Map_t();
376 ReportingMessages_t message;
377 RmrMessagesBuffer_t rmrMessageBuffer;
378 sctp_params_t sctp_ut_params;
dhirajverma60f8bef2021-06-29 07:22:58 -0400379
dhirajverma6cf28612021-06-23 04:53:34 -0400380 pdu.present = E2AP_PDU_PR_successfulOutcome;
381 pdu.choice.successfulOutcome = (SuccessfulOutcome*) malloc(sizeof(SuccessfulOutcome));
382 memset( (void*)pdu.choice.successfulOutcome, 0, sizeof(pdu.choice.successfulOutcome));
383 memset( (void*)&message, 0, sizeof(message));
384 memset( (void*)&rmrMessageBuffer, 0, sizeof(rmrMessageBuffer));
dhirajverma60f8bef2021-06-29 07:22:58 -0400385
386 snprintf(sctp_ut_params.rmrAddress, strlen("127.0.0.1 "), "%s", (char*)"127.0.0.1");
387
dhirajverma6cf28612021-06-23 04:53:34 -0400388 /* Sending E2AP_PDU_PR_successfulOutcome and procedure code as: ProcedureCode_id_Reset */
dhirajverma60f8bef2021-06-29 07:22:58 -0400389 create_asnSuccessfulMsg_Procedure_Reset(&pdu, sctpMap, message, rmrMessageBuffer, sctp_ut_params);
dhirajverma6cf28612021-06-23 04:53:34 -0400390 /* Sending E2AP_PDU_PR_successfulOutcome and procedure code as: ProcedureCode_id_RICcontrol */
dhirajverma60f8bef2021-06-29 07:22:58 -0400391 create_asnSuccessfulMsg_Procedure_RICcontrol(&pdu, sctpMap, message, rmrMessageBuffer, sctp_ut_params);
dhirajverma6cf28612021-06-23 04:53:34 -0400392 /* Sending E2AP_PDU_PR_successfulOutcome and procedure code as: ProcedureCode_id_RICsubscription */
dhirajverma60f8bef2021-06-29 07:22:58 -0400393 create_asnSuccessfulMsg_Procedure_RICsubscription(&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_RICsubscriptionDelete */
dhirajverma60f8bef2021-06-29 07:22:58 -0400395 create_asnSuccessfulMsg_Procedure_RICsubscriptionDelete(&pdu, sctpMap, message, rmrMessageBuffer, sctp_ut_params);
dhirajverma6cf28612021-06-23 04:53:34 -0400396 /* For Procedure's Default case. */
397 pdu.choice.successfulOutcome->procedureCode = ((ProcedureCode_t)100);
398 asnSuccessfulMsg(&pdu, sctpMap, message, rmrMessageBuffer);
dhirajverma60f8bef2021-06-29 07:22:58 -0400399
400 if(pdu.choice.successfulOutcome) {
dhirajverma6cf28612021-06-23 04:53:34 -0400401 free(pdu.choice.successfulOutcome);
dhirajverma60f8bef2021-06-29 07:22:58 -0400402 pdu.choice.successfulOutcome = NULL;
403 }
404 if(sctpMap) {
405 delete sctpMap;
406 sctpMap = NULL;
407 }
dhirajverma6cf28612021-06-23 04:53:34 -0400408}
409
410/* TEST9 Begin: */
dhirajverma60f8bef2021-06-29 07:22:58 -0400411void delete_memories_unsuccessfulOutcome(E2AP_PDU_t *pdu, RmrMessagesBuffer_t &rmrMessageBuffer) {
dhirajverma6cf28612021-06-23 04:53:34 -0400412
dhirajverma60f8bef2021-06-29 07:22:58 -0400413 if( (pdu->choice.unsuccessfulOutcome->value.choice.RICcontrolFailure.protocolIEs.list.array) &&
414 (pdu->choice.unsuccessfulOutcome->value.choice.RICcontrolFailure.protocolIEs.list.array[0]) ) {
415 free(pdu->choice.unsuccessfulOutcome->value.choice.RICcontrolFailure.protocolIEs.list.array[0]);
416 pdu->choice.unsuccessfulOutcome->value.choice.RICcontrolFailure.protocolIEs.list.array[0] = NULL;
417 }
418 if(pdu->choice.unsuccessfulOutcome->value.choice.RICcontrolFailure.protocolIEs.list.array) {
419 free(pdu->choice.unsuccessfulOutcome->value.choice.RICcontrolFailure.protocolIEs.list.array);
420 pdu->choice.unsuccessfulOutcome->value.choice.RICcontrolFailure.protocolIEs.list.array = NULL;
421 }
422 pdu->choice.unsuccessfulOutcome->value.choice.RICcontrolFailure.protocolIEs.list.count = 0;
423 pdu->choice.unsuccessfulOutcome->value.choice.RICcontrolFailure.protocolIEs.list.size = 0;
424
425 if(rmrMessageBuffer.sendMessage && rmrMessageBuffer.sendMessage->header) {
426 free(rmrMessageBuffer.sendMessage->header);
427 rmrMessageBuffer.sendMessage->header = NULL;
428 }
429 if(rmrMessageBuffer.sendMessage->payload) {
430 free(rmrMessageBuffer.sendMessage->payload);
431 rmrMessageBuffer.sendMessage->payload = NULL;
432 }
dhirajverma60f8bef2021-06-29 07:22:58 -0400433 if(rmrMessageBuffer.sendMessage) {
434 free(rmrMessageBuffer.sendMessage);
435 rmrMessageBuffer.sendMessage = NULL;
436 }
437}
438
439void create_asnUnSuccsesfulMsg_Procedure_RICcontrol(E2AP_PDU_t *pdu,
440 Sctp_Map_t *sctpMap,
441 ReportingMessages_t &message,
442 RmrMessagesBuffer_t &rmrMessageBuffer,
443 sctp_params_t &sctp_ut_params) {
444
445 init_memories(message, rmrMessageBuffer, sctp_ut_params);
446
dhirajverma6cf28612021-06-23 04:53:34 -0400447 pdu->choice.unsuccessfulOutcome->value.choice.RICcontrolFailure.protocolIEs.list.array = (RICcontrolFailure_IEs_t**) malloc(1*sizeof(RICcontrolFailure_IEs_t*));
448 pdu->choice.unsuccessfulOutcome->value.choice.RICcontrolFailure.protocolIEs.list.count = 1;
449 pdu->choice.unsuccessfulOutcome->value.choice.RICcontrolFailure.protocolIEs.list.size = sizeof(RICcontrolFailure_IEs_t);
450 pdu->choice.unsuccessfulOutcome->value.choice.RICcontrolFailure.protocolIEs.list.array[0] = (RICcontrolFailure_IEs_t*) malloc(sizeof(RICcontrolFailure_IEs_t));
451 RICcontrolFailure_IEs_t *ie = pdu->choice.unsuccessfulOutcome->value.choice.RICcontrolFailure.protocolIEs.list.array[0];
452
453 ie->id = ProtocolIE_ID_id_RICrequestID;
454 ie->value.present = RICcontrolFailure_IEs__value_PR_RICrequestID;
455 /* Sending E2AP_PDU_PR_unsuccessfulOutcome and procedure code as: ProcedureCode_id_RICcontrol */
456 pdu->choice.unsuccessfulOutcome->procedureCode = ProcedureCode_id_RICcontrol;
457 asnUnSuccsesfulMsg(pdu, sctpMap, message, rmrMessageBuffer);
dhirajverma60f8bef2021-06-29 07:22:58 -0400458 delete_memories_unsuccessfulOutcome(pdu, rmrMessageBuffer);
dhirajverma6cf28612021-06-23 04:53:34 -0400459}
460
dhirajverma60f8bef2021-06-29 07:22:58 -0400461void create_asnUnSuccsesfulMsg_Procedure_RICsubscription(E2AP_PDU_t *pdu,
462 Sctp_Map_t *sctpMap,
463 ReportingMessages_t &message,
464 RmrMessagesBuffer_t &rmrMessageBuffer,
465 sctp_params_t &sctp_ut_params) {
466
467 init_memories(message, rmrMessageBuffer, sctp_ut_params);
dhirajverma6cf28612021-06-23 04:53:34 -0400468 /* Sending E2AP_PDU_PR_unsuccessfulOutcome and procedure code as: ProcedureCode_id_RICsubscription */
469 pdu->choice.unsuccessfulOutcome->procedureCode = ProcedureCode_id_RICsubscription;
470 asnUnSuccsesfulMsg(pdu, sctpMap, message, rmrMessageBuffer);
dhirajverma60f8bef2021-06-29 07:22:58 -0400471 delete_memories_unsuccessfulOutcome(pdu, rmrMessageBuffer);
dhirajverma6cf28612021-06-23 04:53:34 -0400472}
473
dhirajverma60f8bef2021-06-29 07:22:58 -0400474void create_asnUnSuccsesfulMsg_Procedure_RICsubscriptionDelete(E2AP_PDU_t *pdu,
475 Sctp_Map_t *sctpMap,
476 ReportingMessages_t &message,
477 RmrMessagesBuffer_t &rmrMessageBuffer,
478 sctp_params_t &sctp_ut_params) {
dhirajverma6cf28612021-06-23 04:53:34 -0400479
dhirajverma60f8bef2021-06-29 07:22:58 -0400480 init_memories(message, rmrMessageBuffer, sctp_ut_params);
dhirajverma6cf28612021-06-23 04:53:34 -0400481 /* Sending E2AP_PDU_PR_unsuccessfulOutcome and procedure code as: ProcedureCode_id_RICsubscriptionDelete */
482 pdu->choice.unsuccessfulOutcome->procedureCode = ProcedureCode_id_RICsubscriptionDelete;
483 asnUnSuccsesfulMsg(pdu, sctpMap, message, rmrMessageBuffer);
dhirajverma60f8bef2021-06-29 07:22:58 -0400484 delete_memories_unsuccessfulOutcome(pdu, rmrMessageBuffer);
dhirajverma6cf28612021-06-23 04:53:34 -0400485}
486
487TEST(sctp, TEST9) {
488 E2AP_PDU_t pdu;
489 Sctp_Map_t *sctpMap = new Sctp_Map_t();
490 ReportingMessages_t message;
491 RmrMessagesBuffer_t rmrMessageBuffer;
492 sctp_params_t sctp_ut_params;
dhirajverma60f8bef2021-06-29 07:22:58 -0400493
dhirajverma6cf28612021-06-23 04:53:34 -0400494 pdu.present = E2AP_PDU_PR_unsuccessfulOutcome;
495 pdu.choice.unsuccessfulOutcome = (UnsuccessfulOutcome*) malloc(sizeof(UnsuccessfulOutcome));
496 memset( (void*)pdu.choice.unsuccessfulOutcome, 0, sizeof(pdu.choice.unsuccessfulOutcome));
497 memset( (void*)&message, 0, sizeof(message));
498 memset( (void*)&rmrMessageBuffer, 0, sizeof(rmrMessageBuffer));
dhirajverma6cf28612021-06-23 04:53:34 -0400499
dhirajverma60f8bef2021-06-29 07:22:58 -0400500 snprintf(sctp_ut_params.rmrAddress, strlen("127.0.0.1 "), "%s", (char*)"127.0.0.1");
dhirajverma6cf28612021-06-23 04:53:34 -0400501
502 /* Sending E2AP_PDU_PR_unsuccessfulOutcome and procedure code as: ProcedureCode_id_RICcontrol */
dhirajverma60f8bef2021-06-29 07:22:58 -0400503 create_asnUnSuccsesfulMsg_Procedure_RICcontrol(&pdu, sctpMap, message, rmrMessageBuffer, sctp_ut_params);
dhirajverma6cf28612021-06-23 04:53:34 -0400504 /* Sending E2AP_PDU_PR_unsuccessfulOutcome and procedure code as: ProcedureCode_id_RICsubscription */
dhirajverma60f8bef2021-06-29 07:22:58 -0400505 create_asnUnSuccsesfulMsg_Procedure_RICsubscription(&pdu, sctpMap, message, rmrMessageBuffer, sctp_ut_params);
dhirajverma6cf28612021-06-23 04:53:34 -0400506 /* Sending E2AP_PDU_PR_unsuccessfulOutcome and procedure code as: ProcedureCode_id_RICsubscriptionDelete */
dhirajverma60f8bef2021-06-29 07:22:58 -0400507 create_asnUnSuccsesfulMsg_Procedure_RICsubscriptionDelete(&pdu, sctpMap, message, rmrMessageBuffer, sctp_ut_params);
dhirajverma6cf28612021-06-23 04:53:34 -0400508 /* For Procedure's Default case. */
509 pdu.choice.unsuccessfulOutcome->procedureCode = ((ProcedureCode_t)100);
510 asnUnSuccsesfulMsg(&pdu, sctpMap, message, rmrMessageBuffer);
dhirajverma60f8bef2021-06-29 07:22:58 -0400511
512 if(pdu.choice.unsuccessfulOutcome) {
dhirajverma6cf28612021-06-23 04:53:34 -0400513 free(pdu.choice.unsuccessfulOutcome);
dhirajverma60f8bef2021-06-29 07:22:58 -0400514 pdu.choice.unsuccessfulOutcome = NULL;
515 }
516 if(sctpMap) {
517 delete sctpMap;
518 sctpMap = NULL;
519 }
dhirajverma6cf28612021-06-23 04:53:34 -0400520}
521
dhirajverma60f8bef2021-06-29 07:22:58 -0400522
dhirajverma6cf28612021-06-23 04:53:34 -0400523TEST(sctp, TEST10) {
524 int epoll_fd = epoll_create1(0);
525 ConnectedCU_t cu;
526 ConnectedCU_t* peerinfo = &cu;
527 Sctp_Map_t m1;
528 Sctp_Map_t *m = &m1;
529 addToEpoll(epoll_fd, peerinfo, 2, m, (char*)"enodeb1", 0);
530}
531
532TEST(sctp, TEST11) {
533 sctp_params_t sctpParams;
534 int argc = 5;
dhirajverma60f8bef2021-06-29 07:22:58 -0400535 char **argv = (char**) calloc(argc, sizeof(char*));
536 argv[0] = (char*) malloc(40 * sizeof(char));
537 argv[1] = (char*) malloc(40 * sizeof(char));
538 argv[2] = (char*) malloc(40 * sizeof(char));
539 argv[3] = (char*) malloc(40 * sizeof(char));
540 argv[4] = (char*) malloc(40 * sizeof(char));
541 snprintf(argv[0], strlen("./e2 "), "%s", (char*)"./e2");
542 snprintf(argv[1], strlen("-p "), "%s", (char*)"-p");
543 snprintf(argv[2], strlen("/opt/e2/RIC-E2-TERMINATION/config "), "%s", (char*)"/opt/e2/RIC-E2-TERMINATION/config");
544 snprintf(argv[3], strlen("-f "), "%s", (char*)"-f");
545 snprintf(argv[4], strlen("config.conf "), "%s", (char*)"config.conf");
dhirajverma6cf28612021-06-23 04:53:34 -0400546
547 auto result = parse(argc, argv, sctpParams);
548 sctpParams.podName.assign("E2TermAlpha_pod");
dhirajverma60f8bef2021-06-29 07:22:58 -0400549 sctpParams.sctpMap = new mapWrapper();
dhirajverma6cf28612021-06-23 04:53:34 -0400550 sctpParams.epoll_fd = epoll_create1(0);
dhirajverma60f8bef2021-06-29 07:22:58 -0400551 buildConfiguration(sctpParams);
dhirajverma6cf28612021-06-23 04:53:34 -0400552 // getRmrContext(sctpParams);
553 buildInotify(sctpParams);
554 buildListeningPort(sctpParams);
dhirajverma6cf28612021-06-23 04:53:34 -0400555 listener(&sctpParams);
dhirajverma60f8bef2021-06-29 07:22:58 -0400556
557 if(sctpParams.sctpMap) {
558 delete sctpParams.sctpMap;
559 sctpParams.sctpMap = NULL;
560 }
561 if(argv) {
562 free(argv[0]);
563 argv[0] = NULL;
564 free(argv[1]);
565 argv[1] = NULL;
566 free(argv[2]);
567 argv[2] = NULL;
568 free(argv[3]);
569 argv[3] = NULL;
570 free(argv[4]);
571 argv[4] = NULL;
572 free(argv);
573 argv=NULL;
574 }
dhirajverma6cf28612021-06-23 04:53:34 -0400575}
576
577TEST(sctp, TEST12) {
578 ReportingMessages_t reporting_msg;
579 Sctp_Map_t *sctpMap = new Sctp_Map_t();
580 sendSctpMsg(peerInfo, reporting_msg, sctpMap);
dhirajverma60f8bef2021-06-29 07:22:58 -0400581
582 if(sctpMap) {
583 delete sctpMap;
584 sctpMap = NULL;
585 }
dhirajverma6cf28612021-06-23 04:53:34 -0400586}
587
dhirajverma60f8bef2021-06-29 07:22:58 -0400588/*TEST13 Begin*/
dhirajverma6cf28612021-06-23 04:53:34 -0400589
dhirajverma60f8bef2021-06-29 07:22:58 -0400590void inti_buffers_rcv(ReportingMessages_t &message, RmrMessagesBuffer_t &rmrMessageBuffer) {
591 message.peerInfo = peerInfo;
592 snprintf(message.message.enodbName, strlen("Nokia_enb "), "%s", (char*)"Nokia_enb");
593
594 rmrMessageBuffer.rcvMessage = (rmr_mbuf_t*) malloc(sizeof(rmr_mbuf_t));
595 rmrMessageBuffer.rcvMessage->header = (uta_mhdr_t*) malloc(sizeof(uta_mhdr_t));
596 rmrMessageBuffer.rcvMessage->len = strlen("Saying Hello from Ramji ");
597 rmrMessageBuffer.rcvMessage->payload = (unsigned char*)strdup("Saying Hello from Ramji");
598
599 rmrMessageBuffer.sendMessage = (rmr_mbuf_t*) malloc(sizeof(rmr_mbuf_t));
600 rmrMessageBuffer.sendMessage->header = (uta_mhdr_t*) malloc(sizeof(uta_mhdr_t));
601 rmrMessageBuffer.sendMessage->len = strlen("Saying Hello from Ramji ");
602 rmrMessageBuffer.sendMessage->payload = (unsigned char*)strdup("Saying Hello from Ramji");
603
604}
605
606void delete_memories_rcv(RmrMessagesBuffer_t &rmrMessageBuffer) {
607
608 if(rmrMessageBuffer.rcvMessage && rmrMessageBuffer.rcvMessage->header) {
609 free(rmrMessageBuffer.rcvMessage->header);
610 rmrMessageBuffer.rcvMessage->header = NULL;
611 }
612 if(rmrMessageBuffer.rcvMessage) {
613 free(rmrMessageBuffer.rcvMessage);
614 rmrMessageBuffer.rcvMessage = NULL;
615 }
616 if(rmrMessageBuffer.sendMessage && rmrMessageBuffer.sendMessage->header) {
617 free(rmrMessageBuffer.sendMessage->header);
618 rmrMessageBuffer.sendMessage->header = NULL;
619 }
620 if(rmrMessageBuffer.sendMessage) {
621 free(rmrMessageBuffer.sendMessage);
622 rmrMessageBuffer.sendMessage = NULL;
623 }
624
625}
626
627void create_receiveXappMessages_RIC_ERROR_INDICATION(Sctp_Map_t *sctpMap, ReportingMessages_t &message,
628 RmrMessagesBuffer_t &rmrMessageBuffer) {
629 inti_buffers_rcv(message, rmrMessageBuffer);
630 rmrMessageBuffer.rcvMessage->mtype = RIC_ERROR_INDICATION;
631 receiveXappMessages(sctpMap, rmrMessageBuffer, message.message.time);
632 delete_memories_rcv(rmrMessageBuffer);
633
634}
635void create_receiveXappMessages_RIC_E2_SETUP_FAILURE(Sctp_Map_t *sctpMap, ReportingMessages_t &message,
636 RmrMessagesBuffer_t &rmrMessageBuffer) {
637 inti_buffers_rcv(message, rmrMessageBuffer);
638 rmrMessageBuffer.rcvMessage->mtype = RIC_E2_SETUP_FAILURE;
639 receiveXappMessages(sctpMap, rmrMessageBuffer, message.message.time);
640 delete_memories_rcv(rmrMessageBuffer);
641}
642
643void create_receiveXappMessages_RIC_SUB_REQ(Sctp_Map_t *sctpMap, ReportingMessages_t &message,
644 RmrMessagesBuffer_t &rmrMessageBuffer) {
645 inti_buffers_rcv(message, rmrMessageBuffer);
646 rmrMessageBuffer.rcvMessage->mtype = RIC_SUB_REQ;
647 receiveXappMessages(sctpMap, rmrMessageBuffer, message.message.time);
648 delete_memories_rcv(rmrMessageBuffer);
649}
650
651void create_receiveXappMessages_RIC_CONTROL_REQ(Sctp_Map_t *sctpMap, ReportingMessages_t &message,
652 RmrMessagesBuffer_t &rmrMessageBuffer) {
653 inti_buffers_rcv(message, rmrMessageBuffer);
654 rmrMessageBuffer.rcvMessage->mtype = RIC_CONTROL_REQ;
655 receiveXappMessages(sctpMap, rmrMessageBuffer, message.message.time);
656 delete_memories_rcv(rmrMessageBuffer);
657}
658
659void create_receiveXappMessages_RIC_SERVICE_QUERY(Sctp_Map_t *sctpMap, ReportingMessages_t &message,
660 RmrMessagesBuffer_t &rmrMessageBuffer) {
661 inti_buffers_rcv(message, rmrMessageBuffer);
662 rmrMessageBuffer.rcvMessage->mtype = RIC_SERVICE_QUERY;
663 receiveXappMessages(sctpMap, rmrMessageBuffer, message.message.time);
664 delete_memories_rcv(rmrMessageBuffer);
665}
666
667void create_receiveXappMessages_RIC_SERVICE_UPDATE_ACK(Sctp_Map_t *sctpMap, ReportingMessages_t &message,
668 RmrMessagesBuffer_t &rmrMessageBuffer) {
669 inti_buffers_rcv(message, rmrMessageBuffer);
670 rmrMessageBuffer.rcvMessage->mtype = RIC_SERVICE_UPDATE_ACK;
671 receiveXappMessages(sctpMap, rmrMessageBuffer, message.message.time);
672 delete_memories_rcv(rmrMessageBuffer);
673}
674
675void create_receiveXappMessages_RIC_SERVICE_UPDATE_FAILURE(Sctp_Map_t *sctpMap, ReportingMessages_t &message,
676 RmrMessagesBuffer_t &rmrMessageBuffer) {
677 inti_buffers_rcv(message, rmrMessageBuffer);
678 rmrMessageBuffer.rcvMessage->mtype = RIC_SERVICE_UPDATE_FAILURE;
679 receiveXappMessages(sctpMap, rmrMessageBuffer, message.message.time);
680 delete_memories_rcv(rmrMessageBuffer);
681}
682
683
684void create_receiveXappMessages_RIC_E2_RESET_REQ(Sctp_Map_t *sctpMap, ReportingMessages_t &message,
685 RmrMessagesBuffer_t &rmrMessageBuffer) {
686 inti_buffers_rcv(message, rmrMessageBuffer);
687 rmrMessageBuffer.rcvMessage->mtype = RIC_E2_RESET_REQ;
688 receiveXappMessages(sctpMap, rmrMessageBuffer, message.message.time);
689 delete_memories_rcv(rmrMessageBuffer);
690}
691
692void create_receiveXappMessages_RIC_E2_RESET_RESP(Sctp_Map_t *sctpMap, ReportingMessages_t &message,
693 RmrMessagesBuffer_t &rmrMessageBuffer) {
694 inti_buffers_rcv(message, rmrMessageBuffer);
695 rmrMessageBuffer.rcvMessage->mtype = RIC_E2_RESET_RESP;
696 receiveXappMessages(sctpMap, rmrMessageBuffer, message.message.time);
697 delete_memories_rcv(rmrMessageBuffer);
698}
699
700void create_receiveXappMessages_RIC_SCTP_CLEAR_ALL(Sctp_Map_t *sctpMap, ReportingMessages_t &message,
701 RmrMessagesBuffer_t &rmrMessageBuffer) {
702 inti_buffers_rcv(message, rmrMessageBuffer);
703 rmrMessageBuffer.rcvMessage->mtype = RIC_SCTP_CLEAR_ALL;
704 receiveXappMessages(sctpMap, rmrMessageBuffer, message.message.time);
705 delete_memories_rcv(rmrMessageBuffer);
706}
707
708void create_receiveXappMessages_RIC_HEALTH_CHECK_REQ(Sctp_Map_t *sctpMap, ReportingMessages_t &message,
709 RmrMessagesBuffer_t &rmrMessageBuffer) {
710 inti_buffers_rcv(message, rmrMessageBuffer);
711 rmrMessageBuffer.rcvMessage->mtype = RIC_HEALTH_CHECK_REQ;
712 receiveXappMessages(sctpMap, rmrMessageBuffer, message.message.time);
713 delete_memories_rcv(rmrMessageBuffer);
714}
715
716void create_receiveXappMessages_E2_TERM_KEEP_ALIVE_REQ(Sctp_Map_t *sctpMap, ReportingMessages_t &message,
717 RmrMessagesBuffer_t &rmrMessageBuffer) {
718 inti_buffers_rcv(message, rmrMessageBuffer);
719 rmrMessageBuffer.rcvMessage->mtype = E2_TERM_KEEP_ALIVE_REQ;
720 receiveXappMessages(sctpMap, rmrMessageBuffer, message.message.time);
721 delete_memories_rcv(rmrMessageBuffer);
722}
723
dhirajverma99990292021-07-05 10:03:59 -0400724void create_receiveXappMessages_RIC_SUB_DEL_REQ(Sctp_Map_t *sctpMap, ReportingMessages_t &message,
725 RmrMessagesBuffer_t &rmrMessageBuffer) {
726 inti_buffers_rcv(message, rmrMessageBuffer);
727 rmrMessageBuffer.rcvMessage->mtype = E2_TERM_KEEP_ALIVE_REQ;
728 receiveXappMessages(sctpMap, rmrMessageBuffer, message.message.time);
729 delete_memories_rcv(rmrMessageBuffer);
730}
dhirajverma60f8bef2021-06-29 07:22:58 -0400731
732TEST(sctp, TEST13) {
733 Sctp_Map_t *sctpMap = new Sctp_Map_t();
734 ReportingMessages_t message;
735 RmrMessagesBuffer_t rmrMessageBuffer;
736
dhirajverma6cf28612021-06-23 04:53:34 -0400737 memset( (void*)&message, 0, sizeof(message));
738 memset( (void*)&rmrMessageBuffer, 0, sizeof(rmrMessageBuffer));
739
dhirajverma60f8bef2021-06-29 07:22:58 -0400740 // Sending E2AP_PDU_PR_successfulOutcome and procedure code as: ProcedureCode_id_Reset
741 create_receiveXappMessages_RIC_E2_SETUP_FAILURE(sctpMap, message, rmrMessageBuffer);
742 create_receiveXappMessages_RIC_ERROR_INDICATION(sctpMap, message, rmrMessageBuffer);
743 create_receiveXappMessages_RIC_SUB_REQ(sctpMap, message, rmrMessageBuffer);
744 create_receiveXappMessages_RIC_CONTROL_REQ(sctpMap, message, rmrMessageBuffer);
745 create_receiveXappMessages_RIC_HEALTH_CHECK_REQ(sctpMap, message, rmrMessageBuffer);
746 create_receiveXappMessages_E2_TERM_KEEP_ALIVE_REQ(sctpMap, message, rmrMessageBuffer);
747 create_receiveXappMessages_RIC_SCTP_CLEAR_ALL(sctpMap, message, rmrMessageBuffer);
dhirajverma60f8bef2021-06-29 07:22:58 -0400748 create_receiveXappMessages_RIC_E2_RESET_RESP(sctpMap, message, rmrMessageBuffer);
749 create_receiveXappMessages_RIC_E2_RESET_REQ(sctpMap, message, rmrMessageBuffer);
750 create_receiveXappMessages_RIC_SERVICE_UPDATE_FAILURE(sctpMap, message, rmrMessageBuffer);
751 create_receiveXappMessages_RIC_SERVICE_UPDATE_ACK(sctpMap, message, rmrMessageBuffer);
752 create_receiveXappMessages_RIC_SERVICE_QUERY(sctpMap, message, rmrMessageBuffer);
dhirajverma99990292021-07-05 10:03:59 -0400753 create_receiveXappMessages_RIC_SUB_DEL_REQ(sctpMap, message, rmrMessageBuffer);
dhirajverma6cf28612021-06-23 04:53:34 -0400754
dhirajverma60f8bef2021-06-29 07:22:58 -0400755 inti_buffers_rcv(message, rmrMessageBuffer);
dhirajverma99990292021-07-05 10:03:59 -0400756 rmrMessageBuffer.rcvMessage->mtype = 52345; /*Dummy Integer Value for default case*/
dhirajverma60f8bef2021-06-29 07:22:58 -0400757 receiveXappMessages(sctpMap, rmrMessageBuffer, message.message.time);
758 delete_memories_rcv(rmrMessageBuffer);
759
760 if(sctpMap) {
761 delete sctpMap;
762 sctpMap = NULL;
763 }
764}
dhirajverma99990292021-07-05 10:03:59 -0400765/* TEST 14 Begin: */
766void receiveDataFromSctp_asnSuccessfulMsg_Procedure_Default( E2AP_PDU_t *pdu,
767 RmrMessagesBuffer_t &rmrMessageBuffer) {
768 pdu->present = E2AP_PDU_PR_successfulOutcome;
769 pdu->choice.successfulOutcome = (SuccessfulOutcome*) malloc(sizeof(SuccessfulOutcome));
770 memset( (void*)pdu->choice.successfulOutcome, 0, sizeof(pdu->choice.successfulOutcome));
771 pdu->choice.successfulOutcome->procedureCode = ((ProcedureCode_t)100);
772
773 rmrMessageBuffer.sendMessage->tp_buf = pdu;
774}
775
776void delete_pdu_memories(E2AP_PDU_t *pdu) {
777 if(pdu->choice.successfulOutcome) {
778 free(pdu->choice.successfulOutcome);
779 pdu->choice.successfulOutcome = NULL;
780 }
781 if(pdu->choice.unsuccessfulOutcome) {
782 free(pdu->choice.unsuccessfulOutcome);
783 pdu->choice.unsuccessfulOutcome = NULL;
784 }
785}
786
dhirajvermac40ea1f2021-07-08 12:52:30 -0400787/*void receiveDataFromSctp_asnUnSuccsesfulMsg_Procedure_Default(E2AP_PDU_t *pdu,
dhirajverma99990292021-07-05 10:03:59 -0400788 RmrMessagesBuffer_t &rmrMessageBuffer) {
789 pdu->present = E2AP_PDU_PR_unsuccessfulOutcome;
790 pdu->choice.unsuccessfulOutcome = (UnsuccessfulOutcome*) malloc(sizeof(UnsuccessfulOutcome));
791 memset( (void*)pdu->choice.unsuccessfulOutcome, 0, sizeof(pdu->choice.unsuccessfulOutcome));
792 pdu->choice.unsuccessfulOutcome->procedureCode = ((ProcedureCode_t)100);
793
794 rmrMessageBuffer.sendMessage->tp_buf = pdu;
dhirajvermac40ea1f2021-07-08 12:52:30 -0400795}*/
dhirajverma99990292021-07-05 10:03:59 -0400796
797TEST(sctp, TEST14) {
798 E2AP_PDU_t pdu;
799 struct epoll_event events;
800 Sctp_Map_t *sctpMap = new Sctp_Map_t();
801 int numOfMessages=0;
802 RmrMessagesBuffer_t rmrMessageBuffer;
803 struct timespec ts;
804 ConnectedCU_t *peerInfo = (ConnectedCU_t *) calloc(1, sizeof(ConnectedCU_t));
805 events.data.ptr = peerInfo;
806 snprintf(peerInfo->enodbName, strlen("Nokia_enb "), "%s", (char*)"Nokia_enb");
807
808 rmrMessageBuffer.sendMessage = (rmr_mbuf_t*) malloc(sizeof(rmr_mbuf_t));
809 rmrMessageBuffer.sendMessage->header = (uta_mhdr_t*) malloc(sizeof(uta_mhdr_t));
810 rmrMessageBuffer.sendMessage->len = strlen("Saying Hello from NOKIA ");
811 rmrMessageBuffer.sendMessage->payload = (unsigned char*)strdup("Saying Hello from NOKIA");
812
813 clock_gettime(CLOCK_MONOTONIC, &ts);
814
815 receiveDataFromSctp_asnSuccessfulMsg_Procedure_Default(&pdu, rmrMessageBuffer);
816 receiveDataFromSctp(&events, sctpMap, numOfMessages, rmrMessageBuffer, ts);
817 delete_pdu_memories(&pdu);
818
819 if(rmrMessageBuffer.sendMessage->payload) {
820 free(rmrMessageBuffer.sendMessage->payload);
821 rmrMessageBuffer.sendMessage->payload = NULL;
822 }
823
dhirajvermac40ea1f2021-07-08 12:52:30 -0400824 /*rmrMessageBuffer.sendMessage->payload = (unsigned char*)strdup("Saying Hello from NOKIA");
dhirajverma99990292021-07-05 10:03:59 -0400825 receiveDataFromSctp_asnUnSuccsesfulMsg_Procedure_Default(&pdu, rmrMessageBuffer);
826 receiveDataFromSctp(&events, sctpMap, numOfMessages, rmrMessageBuffer, ts);
827 delete_pdu_memories(&pdu);
828
829 if(rmrMessageBuffer.sendMessage->payload) {
830 free(rmrMessageBuffer.sendMessage->payload);
831 rmrMessageBuffer.sendMessage->payload = NULL;
dhirajvermac40ea1f2021-07-08 12:52:30 -0400832 }*/
dhirajverma99990292021-07-05 10:03:59 -0400833 if(rmrMessageBuffer.sendMessage->header) {
834 free(rmrMessageBuffer.sendMessage->header);
835 rmrMessageBuffer.sendMessage->header = NULL;
836 }
837 if(rmrMessageBuffer.sendMessage) {
838 free(rmrMessageBuffer.sendMessage);
839 }
840 if(peerInfo) {
841 free(peerInfo);
842 peerInfo = NULL;
843 }
844 if(sctpMap) {
845 delete sctpMap;
846 sctpMap = NULL;
847 }
848}
dhirajverma60f8bef2021-06-29 07:22:58 -0400849
dhirajverma31768a92021-05-06 12:38:49 +0530850int main(int argc, char **argv) {
851
852 testing::InitGoogleTest(&argc, argv);
853 return RUN_ALL_TESTS();
854
855}