dhirajverma | 31768a9 | 2021-05-06 12:38:49 +0530 | [diff] [blame] | 1 | #include <gtest/gtest.h> |
| 2 | #include <gmock/gmock.h> |
| 3 | #include "sctpThread.h" |
| 4 | #include <sys/epoll.h> |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 5 | #include "E2AP-PDU.h" |
dhirajverma | 31768a9 | 2021-05-06 12:38:49 +0530 | [diff] [blame] | 6 | |
| 7 | using namespace testing; |
| 8 | |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 9 | typedef 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 | |
dhirajverma | 9999029 | 2021-07-05 10:03:59 -0400 | [diff] [blame] | 28 | void init_memories(ReportingMessages_t &message, RmrMessagesBuffer_t &rmrMessageBuffer, sctp_params_t &sctp_ut_params); |
| 29 | |
dhirajverma | 31768a9 | 2021-05-06 12:38:49 +0530 | [diff] [blame] | 30 | TEST(sctp, TEST1) { |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 31 | mdclog_level_set(MDCLOG_DEBUG); |
dhirajverma | 31768a9 | 2021-05-06 12:38:49 +0530 | [diff] [blame] | 32 | 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 | |
| 71 | auto *peerInfo = (ConnectedCU_t *)calloc(1, sizeof(ConnectedCU_t)); |
| 72 | |
| 73 | TEST(sctp, TEST2) { |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 74 | struct epoll_event event; |
dhirajverma | 31768a9 | 2021-05-06 12:38:49 +0530 | [diff] [blame] | 75 | 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 | |
| 87 | TEST(sctp, TEST3) { |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 88 | struct epoll_event event; |
dhirajverma | 31768a9 | 2021-05-06 12:38:49 +0530 | [diff] [blame] | 89 | 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 | |
dhirajverma | 31768a9 | 2021-05-06 12:38:49 +0530 | [diff] [blame] | 103 | TEST(sctp, TEST4) { |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 104 | 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); |
dhirajverma | 31768a9 | 2021-05-06 12:38:49 +0530 | [diff] [blame] | 109 | } |
| 110 | |
| 111 | TEST(sctp, TEST5) { |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 112 | sctp_params_t sctp_ut_params; |
| 113 | sctp_params_t* sctp = &sctp_ut_params; |
dhirajverma | 9999029 | 2021-07-05 10:03:59 -0400 | [diff] [blame] | 114 | sctp->configFilePath.assign("/opt/e2/RIC-E2-TERMINATION/config"); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 115 | sctp->configFileName.assign("config.conf"); |
| 116 | handleConfigChange(sctp); |
dhirajverma | 31768a9 | 2021-05-06 12:38:49 +0530 | [diff] [blame] | 117 | } |
| 118 | |
dhirajverma | 31768a9 | 2021-05-06 12:38:49 +0530 | [diff] [blame] | 119 | TEST(sctp, TEST6) { |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 120 | 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); |
dhirajverma | 31768a9 | 2021-05-06 12:38:49 +0530 | [diff] [blame] | 126 | } |
| 127 | |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 128 | |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 129 | /* TEST7 Begin: */ |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 130 | void 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"); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 134 | |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 135 | 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 | |
| 145 | void 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 | |
| 177 | void 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); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 184 | /* 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); |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 189 | delete_memories_initiatingMessage(pdu, rmrMessageBuffer); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 190 | } |
dhirajverma | 31768a9 | 2021-05-06 12:38:49 +0530 | [diff] [blame] | 191 | |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 192 | void 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) { |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 197 | |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 198 | init_memories(message, rmrMessageBuffer, sctp_ut_params); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 199 | /* 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); |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 213 | delete_memories_initiatingMessage(pdu, rmrMessageBuffer); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 214 | } |
| 215 | |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 216 | void 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) { |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 221 | |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 222 | init_memories(message, rmrMessageBuffer, sctp_ut_params); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 223 | /* 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); |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 227 | delete_memories_initiatingMessage(pdu, rmrMessageBuffer); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 228 | } |
| 229 | |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 230 | void 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); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 237 | /* 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); |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 241 | delete_memories_initiatingMessage(pdu, rmrMessageBuffer); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 242 | } |
| 243 | |
| 244 | TEST(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; |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 250 | |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 251 | 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)); |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 256 | |
| 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); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 259 | |
| 260 | /* Sending E2AP_PDU_PR_initiatingMessage and procedure code as: ProcedureCode_id_RICserviceUpdate */ |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 261 | create_asnInitiatingReq_Procedure_RICserviceUpdate(&pdu, sctpMap, message, rmrMessageBuffer, sctp_ut_params); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 262 | /* Sending E2AP_PDU_PR_initiatingMessage and procedure code as: ProcedureCode_id_RICindication */ |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 263 | create_asnInitiatingReq_Procedure_RICindication(&pdu, sctpMap, message, rmrMessageBuffer, sctp_ut_params); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 264 | /* Sending E2AP_PDU_PR_initiatingMessage and procedure code as: ProcedureCode_id_ErrorIndication */ |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 265 | create_asnInitiatingReq_Procedure_ErrorIndication(&pdu, sctpMap, message, rmrMessageBuffer, sctp_ut_params); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 266 | /* Sending E2AP_PDU_PR_initiatingMessage and procedure code as: ProcedureCode_id_Reset */ |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 267 | create_asnInitiatingReq_Procedure_Reset(&pdu, sctpMap, message, rmrMessageBuffer, sctp_ut_params); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 268 | /* For Procedure's Default case. */ |
| 269 | pdu.choice.initiatingMessage->procedureCode = ((ProcedureCode_t)100); |
| 270 | asnInitiatingRequest(&pdu, sctpMap, message, rmrMessageBuffer); |
| 271 | |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 272 | if(pdu.choice.initiatingMessage) { |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 273 | free(pdu.choice.initiatingMessage); |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 274 | pdu.choice.initiatingMessage = NULL; |
| 275 | } |
| 276 | if(sctpMap) { |
| 277 | delete sctpMap; |
| 278 | sctpMap = NULL; |
| 279 | } |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 280 | } |
| 281 | |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 282 | /* TEST8 Begin: */ |
| 283 | void 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 | } |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 305 | if(rmrMessageBuffer.sendMessage) { |
| 306 | free(rmrMessageBuffer.sendMessage); |
| 307 | rmrMessageBuffer.sendMessage = NULL; |
| 308 | } |
| 309 | } |
| 310 | |
| 311 | |
| 312 | void 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) { |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 317 | |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 318 | init_memories(message, rmrMessageBuffer, sctp_ut_params); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 319 | /* 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); |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 322 | delete_memories_successfulOutcome(pdu, rmrMessageBuffer); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 323 | } |
| 324 | |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 325 | void 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) { |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 330 | |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 331 | init_memories(message, rmrMessageBuffer, sctp_ut_params); |
| 332 | |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 333 | 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); |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 344 | delete_memories_successfulOutcome(pdu, rmrMessageBuffer); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 345 | } |
| 346 | |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 347 | void 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); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 354 | /* 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); |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 357 | delete_memories_successfulOutcome(pdu, rmrMessageBuffer); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 358 | } |
| 359 | |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 360 | void 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); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 367 | /* 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); |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 370 | delete_memories_successfulOutcome(pdu, rmrMessageBuffer); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 371 | } |
| 372 | |
| 373 | TEST(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; |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 379 | |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 380 | 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)); |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 385 | |
| 386 | snprintf(sctp_ut_params.rmrAddress, strlen("127.0.0.1 "), "%s", (char*)"127.0.0.1"); |
| 387 | |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 388 | /* Sending E2AP_PDU_PR_successfulOutcome and procedure code as: ProcedureCode_id_Reset */ |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 389 | create_asnSuccessfulMsg_Procedure_Reset(&pdu, sctpMap, message, rmrMessageBuffer, sctp_ut_params); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 390 | /* Sending E2AP_PDU_PR_successfulOutcome and procedure code as: ProcedureCode_id_RICcontrol */ |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 391 | create_asnSuccessfulMsg_Procedure_RICcontrol(&pdu, sctpMap, message, rmrMessageBuffer, sctp_ut_params); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 392 | /* Sending E2AP_PDU_PR_successfulOutcome and procedure code as: ProcedureCode_id_RICsubscription */ |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 393 | create_asnSuccessfulMsg_Procedure_RICsubscription(&pdu, sctpMap, message, rmrMessageBuffer, sctp_ut_params); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 394 | /* Sending E2AP_PDU_PR_successfulOutcome and procedure code as: ProcedureCode_id_RICsubscriptionDelete */ |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 395 | create_asnSuccessfulMsg_Procedure_RICsubscriptionDelete(&pdu, sctpMap, message, rmrMessageBuffer, sctp_ut_params); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 396 | /* For Procedure's Default case. */ |
| 397 | pdu.choice.successfulOutcome->procedureCode = ((ProcedureCode_t)100); |
| 398 | asnSuccessfulMsg(&pdu, sctpMap, message, rmrMessageBuffer); |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 399 | |
| 400 | if(pdu.choice.successfulOutcome) { |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 401 | free(pdu.choice.successfulOutcome); |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 402 | pdu.choice.successfulOutcome = NULL; |
| 403 | } |
| 404 | if(sctpMap) { |
| 405 | delete sctpMap; |
| 406 | sctpMap = NULL; |
| 407 | } |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 408 | } |
| 409 | |
| 410 | /* TEST9 Begin: */ |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 411 | void delete_memories_unsuccessfulOutcome(E2AP_PDU_t *pdu, RmrMessagesBuffer_t &rmrMessageBuffer) { |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 412 | |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 413 | 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 | } |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 433 | if(rmrMessageBuffer.sendMessage) { |
| 434 | free(rmrMessageBuffer.sendMessage); |
| 435 | rmrMessageBuffer.sendMessage = NULL; |
| 436 | } |
| 437 | } |
| 438 | |
| 439 | void 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 | |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 447 | 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); |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 458 | delete_memories_unsuccessfulOutcome(pdu, rmrMessageBuffer); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 459 | } |
| 460 | |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 461 | void 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); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 468 | /* 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); |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 471 | delete_memories_unsuccessfulOutcome(pdu, rmrMessageBuffer); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 472 | } |
| 473 | |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 474 | void 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) { |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 479 | |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 480 | init_memories(message, rmrMessageBuffer, sctp_ut_params); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 481 | /* 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); |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 484 | delete_memories_unsuccessfulOutcome(pdu, rmrMessageBuffer); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 485 | } |
| 486 | |
| 487 | TEST(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; |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 493 | |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 494 | 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)); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 499 | |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 500 | snprintf(sctp_ut_params.rmrAddress, strlen("127.0.0.1 "), "%s", (char*)"127.0.0.1"); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 501 | |
| 502 | /* Sending E2AP_PDU_PR_unsuccessfulOutcome and procedure code as: ProcedureCode_id_RICcontrol */ |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 503 | create_asnUnSuccsesfulMsg_Procedure_RICcontrol(&pdu, sctpMap, message, rmrMessageBuffer, sctp_ut_params); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 504 | /* Sending E2AP_PDU_PR_unsuccessfulOutcome and procedure code as: ProcedureCode_id_RICsubscription */ |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 505 | create_asnUnSuccsesfulMsg_Procedure_RICsubscription(&pdu, sctpMap, message, rmrMessageBuffer, sctp_ut_params); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 506 | /* Sending E2AP_PDU_PR_unsuccessfulOutcome and procedure code as: ProcedureCode_id_RICsubscriptionDelete */ |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 507 | create_asnUnSuccsesfulMsg_Procedure_RICsubscriptionDelete(&pdu, sctpMap, message, rmrMessageBuffer, sctp_ut_params); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 508 | /* For Procedure's Default case. */ |
| 509 | pdu.choice.unsuccessfulOutcome->procedureCode = ((ProcedureCode_t)100); |
| 510 | asnUnSuccsesfulMsg(&pdu, sctpMap, message, rmrMessageBuffer); |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 511 | |
| 512 | if(pdu.choice.unsuccessfulOutcome) { |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 513 | free(pdu.choice.unsuccessfulOutcome); |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 514 | pdu.choice.unsuccessfulOutcome = NULL; |
| 515 | } |
| 516 | if(sctpMap) { |
| 517 | delete sctpMap; |
| 518 | sctpMap = NULL; |
| 519 | } |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 520 | } |
| 521 | |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 522 | |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 523 | TEST(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 | |
| 532 | TEST(sctp, TEST11) { |
| 533 | sctp_params_t sctpParams; |
| 534 | int argc = 5; |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 535 | 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"); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 546 | |
| 547 | auto result = parse(argc, argv, sctpParams); |
| 548 | sctpParams.podName.assign("E2TermAlpha_pod"); |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 549 | sctpParams.sctpMap = new mapWrapper(); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 550 | sctpParams.epoll_fd = epoll_create1(0); |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 551 | buildConfiguration(sctpParams); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 552 | // getRmrContext(sctpParams); |
| 553 | buildInotify(sctpParams); |
| 554 | buildListeningPort(sctpParams); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 555 | listener(&sctpParams); |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 556 | |
| 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 | } |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 575 | } |
| 576 | |
| 577 | TEST(sctp, TEST12) { |
| 578 | ReportingMessages_t reporting_msg; |
| 579 | Sctp_Map_t *sctpMap = new Sctp_Map_t(); |
| 580 | sendSctpMsg(peerInfo, reporting_msg, sctpMap); |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 581 | |
| 582 | if(sctpMap) { |
| 583 | delete sctpMap; |
| 584 | sctpMap = NULL; |
| 585 | } |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 586 | } |
| 587 | |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 588 | /*TEST13 Begin*/ |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 589 | |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 590 | void 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 | |
| 606 | void 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 | |
| 627 | void 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 | } |
| 635 | void 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 | |
| 643 | void 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 | |
| 651 | void 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 | |
| 659 | void 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 | |
| 667 | void 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 | |
| 675 | void 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 | |
| 684 | void 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 | |
| 692 | void 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 | |
| 700 | void 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 | |
| 708 | void 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 | |
| 716 | void 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 | |
dhirajverma | 9999029 | 2021-07-05 10:03:59 -0400 | [diff] [blame] | 724 | void 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 | } |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 731 | |
| 732 | TEST(sctp, TEST13) { |
| 733 | Sctp_Map_t *sctpMap = new Sctp_Map_t(); |
| 734 | ReportingMessages_t message; |
| 735 | RmrMessagesBuffer_t rmrMessageBuffer; |
| 736 | |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 737 | memset( (void*)&message, 0, sizeof(message)); |
| 738 | memset( (void*)&rmrMessageBuffer, 0, sizeof(rmrMessageBuffer)); |
| 739 | |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 740 | // 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); |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 748 | 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); |
dhirajverma | 9999029 | 2021-07-05 10:03:59 -0400 | [diff] [blame] | 753 | create_receiveXappMessages_RIC_SUB_DEL_REQ(sctpMap, message, rmrMessageBuffer); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 754 | |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 755 | inti_buffers_rcv(message, rmrMessageBuffer); |
dhirajverma | 9999029 | 2021-07-05 10:03:59 -0400 | [diff] [blame] | 756 | rmrMessageBuffer.rcvMessage->mtype = 52345; /*Dummy Integer Value for default case*/ |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 757 | receiveXappMessages(sctpMap, rmrMessageBuffer, message.message.time); |
| 758 | delete_memories_rcv(rmrMessageBuffer); |
| 759 | |
| 760 | if(sctpMap) { |
| 761 | delete sctpMap; |
| 762 | sctpMap = NULL; |
| 763 | } |
| 764 | } |
dhirajverma | 9999029 | 2021-07-05 10:03:59 -0400 | [diff] [blame] | 765 | /* TEST 14 Begin: */ |
| 766 | void 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 | |
| 776 | void 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 | |
dhirajverma | c40ea1f | 2021-07-08 12:52:30 -0400 | [diff] [blame^] | 787 | /*void receiveDataFromSctp_asnUnSuccsesfulMsg_Procedure_Default(E2AP_PDU_t *pdu, |
dhirajverma | 9999029 | 2021-07-05 10:03:59 -0400 | [diff] [blame] | 788 | 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; |
dhirajverma | c40ea1f | 2021-07-08 12:52:30 -0400 | [diff] [blame^] | 795 | }*/ |
dhirajverma | 9999029 | 2021-07-05 10:03:59 -0400 | [diff] [blame] | 796 | |
| 797 | TEST(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 | |
dhirajverma | c40ea1f | 2021-07-08 12:52:30 -0400 | [diff] [blame^] | 824 | /*rmrMessageBuffer.sendMessage->payload = (unsigned char*)strdup("Saying Hello from NOKIA"); |
dhirajverma | 9999029 | 2021-07-05 10:03:59 -0400 | [diff] [blame] | 825 | 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; |
dhirajverma | c40ea1f | 2021-07-08 12:52:30 -0400 | [diff] [blame^] | 832 | }*/ |
dhirajverma | 9999029 | 2021-07-05 10:03:59 -0400 | [diff] [blame] | 833 | 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 | } |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 849 | |
dhirajverma | 31768a9 | 2021-05-06 12:38:49 +0530 | [diff] [blame] | 850 | int main(int argc, char **argv) { |
| 851 | |
| 852 | testing::InitGoogleTest(&argc, argv); |
| 853 | return RUN_ALL_TESTS(); |
| 854 | |
| 855 | } |