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; |
czichy | 2175dd3 | 2022-05-17 15:24:51 +0300 | [diff] [blame] | 187 | |
| 188 | int streamId = 0; |
| 189 | asnInitiatingRequest(pdu, sctpMap, message, rmrMessageBuffer,streamId); |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 190 | delete_memories_initiatingMessage(pdu, rmrMessageBuffer); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 191 | } |
dhirajverma | 31768a9 | 2021-05-06 12:38:49 +0530 | [diff] [blame] | 192 | |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 193 | void create_asnInitiatingReq_Procedure_RICindication(E2AP_PDU_t *pdu, |
| 194 | Sctp_Map_t *sctpMap, |
| 195 | ReportingMessages_t &message, |
| 196 | RmrMessagesBuffer_t &rmrMessageBuffer, |
| 197 | sctp_params_t &sctp_ut_params) { |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 198 | |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 199 | init_memories(message, rmrMessageBuffer, sctp_ut_params); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 200 | /* Sending E2AP_PDU_PR_initiatingMessage and procedure code as: ProcedureCode_id_RICindication */ |
| 201 | pdu->choice.initiatingMessage->procedureCode = ProcedureCode_id_RICindication; |
| 202 | pdu->choice.initiatingMessage->value.present = InitiatingMessage__value_PR_RICindication; |
| 203 | pdu->choice.initiatingMessage->value.choice.RICindication.protocolIEs.list.array = (RICindication_IEs**) malloc(1 * sizeof(RICindication_IEs*)); |
| 204 | pdu->choice.initiatingMessage->value.choice.RICindication.protocolIEs.list.count = 1; |
| 205 | pdu->choice.initiatingMessage->value.choice.RICindication.protocolIEs.list.size = sizeof(RICindication_IEs); |
| 206 | pdu->choice.initiatingMessage->value.choice.RICindication.protocolIEs.list.array[0] = (RICindication_IEs*) malloc(sizeof(RICindication_IEs)); |
| 207 | RICindication_IEs_t *ie = pdu->choice.initiatingMessage->value.choice.RICindication.protocolIEs.list.array[0]; |
| 208 | ie->id = ProtocolIE_ID_id_RICrequestID; |
| 209 | ie->value.present = RICindication_IEs__value_PR_RICrequestID; |
| 210 | ie->value.choice.RICrequestID.ricRequestorID = 12345; |
| 211 | ie->value.choice.RICrequestID.ricInstanceID = 1; |
czichy | 2175dd3 | 2022-05-17 15:24:51 +0300 | [diff] [blame] | 212 | int streamId = 0; |
| 213 | asnInitiatingRequest(pdu, sctpMap, message, rmrMessageBuffer,streamId); |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 214 | delete_memories_initiatingMessage(pdu, rmrMessageBuffer); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 215 | } |
| 216 | |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 217 | void create_asnInitiatingReq_Procedure_ErrorIndication(E2AP_PDU_t *pdu, |
| 218 | Sctp_Map_t *sctpMap, |
| 219 | ReportingMessages_t &message, |
| 220 | RmrMessagesBuffer_t &rmrMessageBuffer, |
| 221 | sctp_params_t &sctp_ut_params) { |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 222 | |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 223 | init_memories(message, rmrMessageBuffer, sctp_ut_params); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 224 | /* Sending E2AP_PDU_PR_initiatingMessage and procedure code as: ProcedureCode_id_ErrorIndication */ |
| 225 | pdu->choice.initiatingMessage->procedureCode = ProcedureCode_id_ErrorIndication; |
| 226 | pdu->choice.initiatingMessage->value.present = InitiatingMessage__value_PR_ErrorIndication; |
czichy | 2175dd3 | 2022-05-17 15:24:51 +0300 | [diff] [blame] | 227 | int streamId = 0; |
| 228 | asnInitiatingRequest(pdu, sctpMap, message, rmrMessageBuffer, streamId); |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 229 | delete_memories_initiatingMessage(pdu, rmrMessageBuffer); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 230 | } |
| 231 | |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 232 | void create_asnInitiatingReq_Procedure_Reset(E2AP_PDU_t *pdu, |
| 233 | Sctp_Map_t *sctpMap, |
| 234 | ReportingMessages_t &message, |
| 235 | RmrMessagesBuffer_t &rmrMessageBuffer, |
| 236 | sctp_params_t &sctp_ut_params) { |
| 237 | |
| 238 | init_memories(message, rmrMessageBuffer, sctp_ut_params); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 239 | /* Sending E2AP_PDU_PR_initiatingMessage and procedure code as: ProcedureCode_id_Reset */ |
| 240 | pdu->choice.initiatingMessage->procedureCode = ProcedureCode_id_Reset; |
| 241 | pdu->choice.initiatingMessage->value.present = InitiatingMessage__value_PR_ResetRequest; |
czichy | 2175dd3 | 2022-05-17 15:24:51 +0300 | [diff] [blame] | 242 | int streamId =0; |
| 243 | asnInitiatingRequest(pdu, sctpMap, message, rmrMessageBuffer,streamId); |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 244 | delete_memories_initiatingMessage(pdu, rmrMessageBuffer); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 245 | } |
| 246 | |
| 247 | TEST(sctp, TEST7) { |
| 248 | E2AP_PDU_t pdu; |
| 249 | Sctp_Map_t *sctpMap = new Sctp_Map_t(); |
| 250 | ReportingMessages_t message; |
| 251 | RmrMessagesBuffer_t rmrMessageBuffer; |
| 252 | sctp_params_t sctp_ut_params; |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 253 | |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 254 | pdu.present = E2AP_PDU_PR_initiatingMessage; |
| 255 | pdu.choice.initiatingMessage = (InitiatingMessage*) malloc(sizeof(InitiatingMessage)); |
| 256 | memset( (void*)pdu.choice.initiatingMessage, 0, sizeof(pdu.choice.initiatingMessage)); |
| 257 | memset( (void*)&message, 0, sizeof(message)); |
| 258 | memset( (void*)&rmrMessageBuffer, 0, sizeof(rmrMessageBuffer)); |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 259 | |
| 260 | snprintf(sctp_ut_params.rmrAddress, strlen("tcp:4560 "), "%s", (char*)"tcp:4560"); |
| 261 | rmrMessageBuffer.rmrCtx = rmr_init(sctp_ut_params.rmrAddress, RECEIVE_XAPP_BUFFER_SIZE, 0x01); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 262 | |
| 263 | /* Sending E2AP_PDU_PR_initiatingMessage and procedure code as: ProcedureCode_id_RICserviceUpdate */ |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 264 | create_asnInitiatingReq_Procedure_RICserviceUpdate(&pdu, sctpMap, message, rmrMessageBuffer, sctp_ut_params); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 265 | /* Sending E2AP_PDU_PR_initiatingMessage and procedure code as: ProcedureCode_id_RICindication */ |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 266 | create_asnInitiatingReq_Procedure_RICindication(&pdu, sctpMap, message, rmrMessageBuffer, sctp_ut_params); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 267 | /* Sending E2AP_PDU_PR_initiatingMessage and procedure code as: ProcedureCode_id_ErrorIndication */ |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 268 | create_asnInitiatingReq_Procedure_ErrorIndication(&pdu, sctpMap, message, rmrMessageBuffer, sctp_ut_params); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 269 | /* Sending E2AP_PDU_PR_initiatingMessage and procedure code as: ProcedureCode_id_Reset */ |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 270 | create_asnInitiatingReq_Procedure_Reset(&pdu, sctpMap, message, rmrMessageBuffer, sctp_ut_params); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 271 | /* For Procedure's Default case. */ |
| 272 | pdu.choice.initiatingMessage->procedureCode = ((ProcedureCode_t)100); |
czichy | 2175dd3 | 2022-05-17 15:24:51 +0300 | [diff] [blame] | 273 | int streamId =0; |
| 274 | asnInitiatingRequest(&pdu, sctpMap, message, rmrMessageBuffer,streamId); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 275 | |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 276 | if(pdu.choice.initiatingMessage) { |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 277 | free(pdu.choice.initiatingMessage); |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 278 | pdu.choice.initiatingMessage = NULL; |
| 279 | } |
| 280 | if(sctpMap) { |
| 281 | delete sctpMap; |
| 282 | sctpMap = NULL; |
| 283 | } |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 284 | } |
| 285 | |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 286 | /* TEST8 Begin: */ |
| 287 | void delete_memories_successfulOutcome(E2AP_PDU_t *pdu, RmrMessagesBuffer_t &rmrMessageBuffer) { |
| 288 | |
| 289 | if( (pdu->choice.successfulOutcome->value.choice.RICcontrolAcknowledge.protocolIEs.list.array) && |
| 290 | (pdu->choice.successfulOutcome->value.choice.RICcontrolAcknowledge.protocolIEs.list.array[0]) ) { |
| 291 | free(pdu->choice.successfulOutcome->value.choice.RICcontrolAcknowledge.protocolIEs.list.array[0]); |
| 292 | pdu->choice.successfulOutcome->value.choice.RICcontrolAcknowledge.protocolIEs.list.array[0] = NULL; |
| 293 | } |
| 294 | if(pdu->choice.successfulOutcome->value.choice.RICcontrolAcknowledge.protocolIEs.list.array) { |
| 295 | free(pdu->choice.successfulOutcome->value.choice.RICcontrolAcknowledge.protocolIEs.list.array); |
| 296 | pdu->choice.successfulOutcome->value.choice.RICcontrolAcknowledge.protocolIEs.list.array = NULL; |
| 297 | } |
| 298 | pdu->choice.successfulOutcome->value.choice.RICcontrolAcknowledge.protocolIEs.list.count = 0; |
| 299 | pdu->choice.successfulOutcome->value.choice.RICcontrolAcknowledge.protocolIEs.list.size = 0; |
| 300 | |
| 301 | if(rmrMessageBuffer.sendMessage && rmrMessageBuffer.sendMessage->header) { |
| 302 | free(rmrMessageBuffer.sendMessage->header); |
| 303 | rmrMessageBuffer.sendMessage->header = NULL; |
| 304 | } |
| 305 | if(rmrMessageBuffer.sendMessage->payload) { |
| 306 | free(rmrMessageBuffer.sendMessage->payload); |
| 307 | rmrMessageBuffer.sendMessage->payload = NULL; |
| 308 | } |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 309 | if(rmrMessageBuffer.sendMessage) { |
| 310 | free(rmrMessageBuffer.sendMessage); |
| 311 | rmrMessageBuffer.sendMessage = NULL; |
| 312 | } |
| 313 | } |
| 314 | |
| 315 | |
| 316 | void create_asnSuccessfulMsg_Procedure_Reset(E2AP_PDU_t *pdu, |
| 317 | Sctp_Map_t *sctpMap, |
| 318 | ReportingMessages_t &message, |
| 319 | RmrMessagesBuffer_t &rmrMessageBuffer, |
| 320 | sctp_params_t &sctp_ut_params) { |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 321 | |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 322 | init_memories(message, rmrMessageBuffer, sctp_ut_params); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 323 | /* Sending E2AP_PDU_PR_successfulOutcome and procedure code as: ProcedureCode_id_Reset */ |
| 324 | pdu->choice.successfulOutcome->procedureCode = ProcedureCode_id_Reset; |
| 325 | asnSuccessfulMsg(pdu, sctpMap, message, rmrMessageBuffer); |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 326 | delete_memories_successfulOutcome(pdu, rmrMessageBuffer); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 327 | } |
| 328 | |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 329 | void create_asnSuccessfulMsg_Procedure_RICcontrol(E2AP_PDU_t *pdu, |
| 330 | Sctp_Map_t *sctpMap, |
| 331 | ReportingMessages_t &message, |
| 332 | RmrMessagesBuffer_t &rmrMessageBuffer, |
| 333 | sctp_params_t &sctp_ut_params) { |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 334 | |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 335 | init_memories(message, rmrMessageBuffer, sctp_ut_params); |
| 336 | |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 337 | pdu->choice.successfulOutcome->value.choice.RICcontrolAcknowledge.protocolIEs.list.array = (RICcontrolAcknowledge_IEs_t**) malloc(1 * sizeof(RICcontrolAcknowledge_IEs_t*)); |
| 338 | pdu->choice.successfulOutcome->value.choice.RICcontrolAcknowledge.protocolIEs.list.count = 1; |
| 339 | pdu->choice.successfulOutcome->value.choice.RICcontrolAcknowledge.protocolIEs.list.size = sizeof(RICcontrolAcknowledge_IEs_t); |
| 340 | pdu->choice.successfulOutcome->value.choice.RICcontrolAcknowledge.protocolIEs.list.array[0] = (RICcontrolAcknowledge_IEs_t*) malloc(sizeof(RICcontrolAcknowledge_IEs_t)); |
| 341 | RICcontrolAcknowledge_IEs_t *ie = pdu->choice.successfulOutcome->value.choice.RICcontrolAcknowledge.protocolIEs.list.array[0]; |
| 342 | |
| 343 | ie->id = ProtocolIE_ID_id_RICrequestID; |
| 344 | ie->value.present = RICcontrolAcknowledge_IEs__value_PR_RICrequestID; |
| 345 | /* Sending E2AP_PDU_PR_successfulOutcome and procedure code as: ProcedureCode_id_RICcontrol */ |
| 346 | pdu->choice.successfulOutcome->procedureCode = ProcedureCode_id_RICcontrol; |
| 347 | asnSuccessfulMsg(pdu, sctpMap, message, rmrMessageBuffer); |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 348 | delete_memories_successfulOutcome(pdu, rmrMessageBuffer); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 349 | } |
| 350 | |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 351 | void create_asnSuccessfulMsg_Procedure_RICsubscription(E2AP_PDU_t *pdu, |
| 352 | Sctp_Map_t *sctpMap, |
| 353 | ReportingMessages_t &message, |
| 354 | RmrMessagesBuffer_t &rmrMessageBuffer, |
| 355 | sctp_params_t &sctp_ut_params) { |
| 356 | |
| 357 | init_memories(message, rmrMessageBuffer, sctp_ut_params); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 358 | /* Sending E2AP_PDU_PR_successfulOutcome and procedure code as: ProcedureCode_id_RICsubscription */ |
| 359 | pdu->choice.successfulOutcome->procedureCode = ProcedureCode_id_RICsubscription; |
| 360 | asnSuccessfulMsg(pdu, sctpMap, message, rmrMessageBuffer); |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 361 | delete_memories_successfulOutcome(pdu, rmrMessageBuffer); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 362 | } |
| 363 | |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 364 | void create_asnSuccessfulMsg_Procedure_RICsubscriptionDelete(E2AP_PDU_t *pdu, |
| 365 | Sctp_Map_t *sctpMap, |
| 366 | ReportingMessages_t &message, |
| 367 | RmrMessagesBuffer_t &rmrMessageBuffer, |
| 368 | sctp_params_t &sctp_ut_params) { |
| 369 | |
| 370 | init_memories(message, rmrMessageBuffer, sctp_ut_params); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 371 | /* Sending E2AP_PDU_PR_successfulOutcome and procedure code as: ProcedureCode_id_RICsubscriptionDelete */ |
| 372 | pdu->choice.successfulOutcome->procedureCode = ProcedureCode_id_RICsubscriptionDelete; |
| 373 | asnSuccessfulMsg(pdu, sctpMap, message, rmrMessageBuffer); |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 374 | delete_memories_successfulOutcome(pdu, rmrMessageBuffer); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 375 | } |
| 376 | |
| 377 | TEST(sctp, TEST8) { |
| 378 | E2AP_PDU_t pdu; |
| 379 | Sctp_Map_t *sctpMap = new Sctp_Map_t(); |
| 380 | ReportingMessages_t message; |
| 381 | RmrMessagesBuffer_t rmrMessageBuffer; |
| 382 | sctp_params_t sctp_ut_params; |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 383 | |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 384 | pdu.present = E2AP_PDU_PR_successfulOutcome; |
| 385 | pdu.choice.successfulOutcome = (SuccessfulOutcome*) malloc(sizeof(SuccessfulOutcome)); |
| 386 | memset( (void*)pdu.choice.successfulOutcome, 0, sizeof(pdu.choice.successfulOutcome)); |
| 387 | memset( (void*)&message, 0, sizeof(message)); |
| 388 | memset( (void*)&rmrMessageBuffer, 0, sizeof(rmrMessageBuffer)); |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 389 | |
| 390 | snprintf(sctp_ut_params.rmrAddress, strlen("127.0.0.1 "), "%s", (char*)"127.0.0.1"); |
| 391 | |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 392 | /* Sending E2AP_PDU_PR_successfulOutcome and procedure code as: ProcedureCode_id_Reset */ |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 393 | create_asnSuccessfulMsg_Procedure_Reset(&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_RICcontrol */ |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 395 | create_asnSuccessfulMsg_Procedure_RICcontrol(&pdu, sctpMap, message, rmrMessageBuffer, sctp_ut_params); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 396 | /* Sending E2AP_PDU_PR_successfulOutcome and procedure code as: ProcedureCode_id_RICsubscription */ |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 397 | create_asnSuccessfulMsg_Procedure_RICsubscription(&pdu, sctpMap, message, rmrMessageBuffer, sctp_ut_params); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 398 | /* Sending E2AP_PDU_PR_successfulOutcome and procedure code as: ProcedureCode_id_RICsubscriptionDelete */ |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 399 | create_asnSuccessfulMsg_Procedure_RICsubscriptionDelete(&pdu, sctpMap, message, rmrMessageBuffer, sctp_ut_params); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 400 | /* For Procedure's Default case. */ |
| 401 | pdu.choice.successfulOutcome->procedureCode = ((ProcedureCode_t)100); |
| 402 | asnSuccessfulMsg(&pdu, sctpMap, message, rmrMessageBuffer); |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 403 | |
| 404 | if(pdu.choice.successfulOutcome) { |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 405 | free(pdu.choice.successfulOutcome); |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 406 | pdu.choice.successfulOutcome = NULL; |
| 407 | } |
| 408 | if(sctpMap) { |
| 409 | delete sctpMap; |
| 410 | sctpMap = NULL; |
| 411 | } |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 412 | } |
| 413 | |
| 414 | /* TEST9 Begin: */ |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 415 | void delete_memories_unsuccessfulOutcome(E2AP_PDU_t *pdu, RmrMessagesBuffer_t &rmrMessageBuffer) { |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 416 | |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 417 | if( (pdu->choice.unsuccessfulOutcome->value.choice.RICcontrolFailure.protocolIEs.list.array) && |
| 418 | (pdu->choice.unsuccessfulOutcome->value.choice.RICcontrolFailure.protocolIEs.list.array[0]) ) { |
| 419 | free(pdu->choice.unsuccessfulOutcome->value.choice.RICcontrolFailure.protocolIEs.list.array[0]); |
| 420 | pdu->choice.unsuccessfulOutcome->value.choice.RICcontrolFailure.protocolIEs.list.array[0] = NULL; |
| 421 | } |
| 422 | if(pdu->choice.unsuccessfulOutcome->value.choice.RICcontrolFailure.protocolIEs.list.array) { |
| 423 | free(pdu->choice.unsuccessfulOutcome->value.choice.RICcontrolFailure.protocolIEs.list.array); |
| 424 | pdu->choice.unsuccessfulOutcome->value.choice.RICcontrolFailure.protocolIEs.list.array = NULL; |
| 425 | } |
| 426 | pdu->choice.unsuccessfulOutcome->value.choice.RICcontrolFailure.protocolIEs.list.count = 0; |
| 427 | pdu->choice.unsuccessfulOutcome->value.choice.RICcontrolFailure.protocolIEs.list.size = 0; |
| 428 | |
| 429 | if(rmrMessageBuffer.sendMessage && rmrMessageBuffer.sendMessage->header) { |
| 430 | free(rmrMessageBuffer.sendMessage->header); |
| 431 | rmrMessageBuffer.sendMessage->header = NULL; |
| 432 | } |
| 433 | if(rmrMessageBuffer.sendMessage->payload) { |
| 434 | free(rmrMessageBuffer.sendMessage->payload); |
| 435 | rmrMessageBuffer.sendMessage->payload = NULL; |
| 436 | } |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 437 | if(rmrMessageBuffer.sendMessage) { |
| 438 | free(rmrMessageBuffer.sendMessage); |
| 439 | rmrMessageBuffer.sendMessage = NULL; |
| 440 | } |
| 441 | } |
| 442 | |
| 443 | void create_asnUnSuccsesfulMsg_Procedure_RICcontrol(E2AP_PDU_t *pdu, |
| 444 | Sctp_Map_t *sctpMap, |
| 445 | ReportingMessages_t &message, |
| 446 | RmrMessagesBuffer_t &rmrMessageBuffer, |
| 447 | sctp_params_t &sctp_ut_params) { |
| 448 | |
| 449 | init_memories(message, rmrMessageBuffer, sctp_ut_params); |
| 450 | |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 451 | pdu->choice.unsuccessfulOutcome->value.choice.RICcontrolFailure.protocolIEs.list.array = (RICcontrolFailure_IEs_t**) malloc(1*sizeof(RICcontrolFailure_IEs_t*)); |
| 452 | pdu->choice.unsuccessfulOutcome->value.choice.RICcontrolFailure.protocolIEs.list.count = 1; |
| 453 | pdu->choice.unsuccessfulOutcome->value.choice.RICcontrolFailure.protocolIEs.list.size = sizeof(RICcontrolFailure_IEs_t); |
| 454 | pdu->choice.unsuccessfulOutcome->value.choice.RICcontrolFailure.protocolIEs.list.array[0] = (RICcontrolFailure_IEs_t*) malloc(sizeof(RICcontrolFailure_IEs_t)); |
| 455 | RICcontrolFailure_IEs_t *ie = pdu->choice.unsuccessfulOutcome->value.choice.RICcontrolFailure.protocolIEs.list.array[0]; |
| 456 | |
| 457 | ie->id = ProtocolIE_ID_id_RICrequestID; |
| 458 | ie->value.present = RICcontrolFailure_IEs__value_PR_RICrequestID; |
| 459 | /* Sending E2AP_PDU_PR_unsuccessfulOutcome and procedure code as: ProcedureCode_id_RICcontrol */ |
| 460 | pdu->choice.unsuccessfulOutcome->procedureCode = ProcedureCode_id_RICcontrol; |
| 461 | asnUnSuccsesfulMsg(pdu, sctpMap, message, rmrMessageBuffer); |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 462 | delete_memories_unsuccessfulOutcome(pdu, rmrMessageBuffer); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 463 | } |
| 464 | |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 465 | void create_asnUnSuccsesfulMsg_Procedure_RICsubscription(E2AP_PDU_t *pdu, |
| 466 | Sctp_Map_t *sctpMap, |
| 467 | ReportingMessages_t &message, |
| 468 | RmrMessagesBuffer_t &rmrMessageBuffer, |
| 469 | sctp_params_t &sctp_ut_params) { |
| 470 | |
| 471 | init_memories(message, rmrMessageBuffer, sctp_ut_params); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 472 | /* Sending E2AP_PDU_PR_unsuccessfulOutcome and procedure code as: ProcedureCode_id_RICsubscription */ |
| 473 | pdu->choice.unsuccessfulOutcome->procedureCode = ProcedureCode_id_RICsubscription; |
| 474 | asnUnSuccsesfulMsg(pdu, sctpMap, message, rmrMessageBuffer); |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 475 | delete_memories_unsuccessfulOutcome(pdu, rmrMessageBuffer); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 476 | } |
| 477 | |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 478 | void create_asnUnSuccsesfulMsg_Procedure_RICsubscriptionDelete(E2AP_PDU_t *pdu, |
| 479 | Sctp_Map_t *sctpMap, |
| 480 | ReportingMessages_t &message, |
| 481 | RmrMessagesBuffer_t &rmrMessageBuffer, |
| 482 | sctp_params_t &sctp_ut_params) { |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 483 | |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 484 | init_memories(message, rmrMessageBuffer, sctp_ut_params); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 485 | /* Sending E2AP_PDU_PR_unsuccessfulOutcome and procedure code as: ProcedureCode_id_RICsubscriptionDelete */ |
| 486 | pdu->choice.unsuccessfulOutcome->procedureCode = ProcedureCode_id_RICsubscriptionDelete; |
| 487 | asnUnSuccsesfulMsg(pdu, sctpMap, message, rmrMessageBuffer); |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 488 | delete_memories_unsuccessfulOutcome(pdu, rmrMessageBuffer); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 489 | } |
| 490 | |
| 491 | TEST(sctp, TEST9) { |
| 492 | E2AP_PDU_t pdu; |
| 493 | Sctp_Map_t *sctpMap = new Sctp_Map_t(); |
| 494 | ReportingMessages_t message; |
| 495 | RmrMessagesBuffer_t rmrMessageBuffer; |
| 496 | sctp_params_t sctp_ut_params; |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 497 | |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 498 | pdu.present = E2AP_PDU_PR_unsuccessfulOutcome; |
| 499 | pdu.choice.unsuccessfulOutcome = (UnsuccessfulOutcome*) malloc(sizeof(UnsuccessfulOutcome)); |
| 500 | memset( (void*)pdu.choice.unsuccessfulOutcome, 0, sizeof(pdu.choice.unsuccessfulOutcome)); |
| 501 | memset( (void*)&message, 0, sizeof(message)); |
| 502 | memset( (void*)&rmrMessageBuffer, 0, sizeof(rmrMessageBuffer)); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 503 | |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 504 | 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] | 505 | |
| 506 | /* Sending E2AP_PDU_PR_unsuccessfulOutcome and procedure code as: ProcedureCode_id_RICcontrol */ |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 507 | create_asnUnSuccsesfulMsg_Procedure_RICcontrol(&pdu, sctpMap, message, rmrMessageBuffer, sctp_ut_params); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 508 | /* Sending E2AP_PDU_PR_unsuccessfulOutcome and procedure code as: ProcedureCode_id_RICsubscription */ |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 509 | create_asnUnSuccsesfulMsg_Procedure_RICsubscription(&pdu, sctpMap, message, rmrMessageBuffer, sctp_ut_params); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 510 | /* Sending E2AP_PDU_PR_unsuccessfulOutcome and procedure code as: ProcedureCode_id_RICsubscriptionDelete */ |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 511 | create_asnUnSuccsesfulMsg_Procedure_RICsubscriptionDelete(&pdu, sctpMap, message, rmrMessageBuffer, sctp_ut_params); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 512 | /* For Procedure's Default case. */ |
| 513 | pdu.choice.unsuccessfulOutcome->procedureCode = ((ProcedureCode_t)100); |
| 514 | asnUnSuccsesfulMsg(&pdu, sctpMap, message, rmrMessageBuffer); |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 515 | |
| 516 | if(pdu.choice.unsuccessfulOutcome) { |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 517 | free(pdu.choice.unsuccessfulOutcome); |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 518 | pdu.choice.unsuccessfulOutcome = NULL; |
| 519 | } |
| 520 | if(sctpMap) { |
| 521 | delete sctpMap; |
| 522 | sctpMap = NULL; |
| 523 | } |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 524 | } |
| 525 | |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 526 | |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 527 | TEST(sctp, TEST10) { |
| 528 | int epoll_fd = epoll_create1(0); |
| 529 | ConnectedCU_t cu; |
| 530 | ConnectedCU_t* peerinfo = &cu; |
| 531 | Sctp_Map_t m1; |
| 532 | Sctp_Map_t *m = &m1; |
| 533 | addToEpoll(epoll_fd, peerinfo, 2, m, (char*)"enodeb1", 0); |
| 534 | } |
| 535 | |
| 536 | TEST(sctp, TEST11) { |
| 537 | sctp_params_t sctpParams; |
| 538 | int argc = 5; |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 539 | char **argv = (char**) calloc(argc, sizeof(char*)); |
| 540 | argv[0] = (char*) malloc(40 * sizeof(char)); |
| 541 | argv[1] = (char*) malloc(40 * sizeof(char)); |
| 542 | argv[2] = (char*) malloc(40 * sizeof(char)); |
| 543 | argv[3] = (char*) malloc(40 * sizeof(char)); |
| 544 | argv[4] = (char*) malloc(40 * sizeof(char)); |
| 545 | snprintf(argv[0], strlen("./e2 "), "%s", (char*)"./e2"); |
| 546 | snprintf(argv[1], strlen("-p "), "%s", (char*)"-p"); |
| 547 | snprintf(argv[2], strlen("/opt/e2/RIC-E2-TERMINATION/config "), "%s", (char*)"/opt/e2/RIC-E2-TERMINATION/config"); |
| 548 | snprintf(argv[3], strlen("-f "), "%s", (char*)"-f"); |
| 549 | snprintf(argv[4], strlen("config.conf "), "%s", (char*)"config.conf"); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 550 | |
| 551 | auto result = parse(argc, argv, sctpParams); |
| 552 | sctpParams.podName.assign("E2TermAlpha_pod"); |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 553 | sctpParams.sctpMap = new mapWrapper(); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 554 | sctpParams.epoll_fd = epoll_create1(0); |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 555 | buildConfiguration(sctpParams); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 556 | // getRmrContext(sctpParams); |
| 557 | buildInotify(sctpParams); |
| 558 | buildListeningPort(sctpParams); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 559 | listener(&sctpParams); |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 560 | |
| 561 | if(sctpParams.sctpMap) { |
| 562 | delete sctpParams.sctpMap; |
| 563 | sctpParams.sctpMap = NULL; |
| 564 | } |
| 565 | if(argv) { |
| 566 | free(argv[0]); |
| 567 | argv[0] = NULL; |
| 568 | free(argv[1]); |
| 569 | argv[1] = NULL; |
| 570 | free(argv[2]); |
| 571 | argv[2] = NULL; |
| 572 | free(argv[3]); |
| 573 | argv[3] = NULL; |
| 574 | free(argv[4]); |
| 575 | argv[4] = NULL; |
| 576 | free(argv); |
| 577 | argv=NULL; |
| 578 | } |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 579 | } |
| 580 | |
| 581 | TEST(sctp, TEST12) { |
| 582 | ReportingMessages_t reporting_msg; |
| 583 | Sctp_Map_t *sctpMap = new Sctp_Map_t(); |
| 584 | sendSctpMsg(peerInfo, reporting_msg, sctpMap); |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 585 | |
| 586 | if(sctpMap) { |
| 587 | delete sctpMap; |
| 588 | sctpMap = NULL; |
| 589 | } |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 590 | } |
| 591 | |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 592 | /*TEST13 Begin*/ |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 593 | |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 594 | void inti_buffers_rcv(ReportingMessages_t &message, RmrMessagesBuffer_t &rmrMessageBuffer) { |
| 595 | message.peerInfo = peerInfo; |
| 596 | snprintf(message.message.enodbName, strlen("Nokia_enb "), "%s", (char*)"Nokia_enb"); |
| 597 | |
| 598 | rmrMessageBuffer.rcvMessage = (rmr_mbuf_t*) malloc(sizeof(rmr_mbuf_t)); |
| 599 | rmrMessageBuffer.rcvMessage->header = (uta_mhdr_t*) malloc(sizeof(uta_mhdr_t)); |
| 600 | rmrMessageBuffer.rcvMessage->len = strlen("Saying Hello from Ramji "); |
| 601 | rmrMessageBuffer.rcvMessage->payload = (unsigned char*)strdup("Saying Hello from Ramji"); |
| 602 | |
| 603 | rmrMessageBuffer.sendMessage = (rmr_mbuf_t*) malloc(sizeof(rmr_mbuf_t)); |
| 604 | rmrMessageBuffer.sendMessage->header = (uta_mhdr_t*) malloc(sizeof(uta_mhdr_t)); |
| 605 | rmrMessageBuffer.sendMessage->len = strlen("Saying Hello from Ramji "); |
| 606 | rmrMessageBuffer.sendMessage->payload = (unsigned char*)strdup("Saying Hello from Ramji"); |
| 607 | |
| 608 | } |
| 609 | |
| 610 | void delete_memories_rcv(RmrMessagesBuffer_t &rmrMessageBuffer) { |
| 611 | |
| 612 | if(rmrMessageBuffer.rcvMessage && rmrMessageBuffer.rcvMessage->header) { |
| 613 | free(rmrMessageBuffer.rcvMessage->header); |
| 614 | rmrMessageBuffer.rcvMessage->header = NULL; |
| 615 | } |
| 616 | if(rmrMessageBuffer.rcvMessage) { |
| 617 | free(rmrMessageBuffer.rcvMessage); |
| 618 | rmrMessageBuffer.rcvMessage = NULL; |
| 619 | } |
| 620 | if(rmrMessageBuffer.sendMessage && rmrMessageBuffer.sendMessage->header) { |
| 621 | free(rmrMessageBuffer.sendMessage->header); |
| 622 | rmrMessageBuffer.sendMessage->header = NULL; |
| 623 | } |
| 624 | if(rmrMessageBuffer.sendMessage) { |
| 625 | free(rmrMessageBuffer.sendMessage); |
| 626 | rmrMessageBuffer.sendMessage = NULL; |
| 627 | } |
| 628 | |
| 629 | } |
| 630 | |
| 631 | void create_receiveXappMessages_RIC_ERROR_INDICATION(Sctp_Map_t *sctpMap, ReportingMessages_t &message, |
| 632 | RmrMessagesBuffer_t &rmrMessageBuffer) { |
| 633 | inti_buffers_rcv(message, rmrMessageBuffer); |
| 634 | rmrMessageBuffer.rcvMessage->mtype = RIC_ERROR_INDICATION; |
| 635 | receiveXappMessages(sctpMap, rmrMessageBuffer, message.message.time); |
| 636 | delete_memories_rcv(rmrMessageBuffer); |
| 637 | |
| 638 | } |
| 639 | void create_receiveXappMessages_RIC_E2_SETUP_FAILURE(Sctp_Map_t *sctpMap, ReportingMessages_t &message, |
| 640 | RmrMessagesBuffer_t &rmrMessageBuffer) { |
| 641 | inti_buffers_rcv(message, rmrMessageBuffer); |
| 642 | rmrMessageBuffer.rcvMessage->mtype = RIC_E2_SETUP_FAILURE; |
| 643 | receiveXappMessages(sctpMap, rmrMessageBuffer, message.message.time); |
| 644 | delete_memories_rcv(rmrMessageBuffer); |
| 645 | } |
| 646 | |
| 647 | void create_receiveXappMessages_RIC_SUB_REQ(Sctp_Map_t *sctpMap, ReportingMessages_t &message, |
| 648 | RmrMessagesBuffer_t &rmrMessageBuffer) { |
| 649 | inti_buffers_rcv(message, rmrMessageBuffer); |
| 650 | rmrMessageBuffer.rcvMessage->mtype = RIC_SUB_REQ; |
| 651 | receiveXappMessages(sctpMap, rmrMessageBuffer, message.message.time); |
| 652 | delete_memories_rcv(rmrMessageBuffer); |
| 653 | } |
| 654 | |
| 655 | void create_receiveXappMessages_RIC_CONTROL_REQ(Sctp_Map_t *sctpMap, ReportingMessages_t &message, |
| 656 | RmrMessagesBuffer_t &rmrMessageBuffer) { |
| 657 | inti_buffers_rcv(message, rmrMessageBuffer); |
| 658 | rmrMessageBuffer.rcvMessage->mtype = RIC_CONTROL_REQ; |
| 659 | receiveXappMessages(sctpMap, rmrMessageBuffer, message.message.time); |
| 660 | delete_memories_rcv(rmrMessageBuffer); |
| 661 | } |
| 662 | |
| 663 | void create_receiveXappMessages_RIC_SERVICE_QUERY(Sctp_Map_t *sctpMap, ReportingMessages_t &message, |
| 664 | RmrMessagesBuffer_t &rmrMessageBuffer) { |
| 665 | inti_buffers_rcv(message, rmrMessageBuffer); |
| 666 | rmrMessageBuffer.rcvMessage->mtype = RIC_SERVICE_QUERY; |
| 667 | receiveXappMessages(sctpMap, rmrMessageBuffer, message.message.time); |
| 668 | delete_memories_rcv(rmrMessageBuffer); |
| 669 | } |
| 670 | |
| 671 | void create_receiveXappMessages_RIC_SERVICE_UPDATE_ACK(Sctp_Map_t *sctpMap, ReportingMessages_t &message, |
| 672 | RmrMessagesBuffer_t &rmrMessageBuffer) { |
| 673 | inti_buffers_rcv(message, rmrMessageBuffer); |
| 674 | rmrMessageBuffer.rcvMessage->mtype = RIC_SERVICE_UPDATE_ACK; |
| 675 | receiveXappMessages(sctpMap, rmrMessageBuffer, message.message.time); |
| 676 | delete_memories_rcv(rmrMessageBuffer); |
| 677 | } |
| 678 | |
| 679 | void create_receiveXappMessages_RIC_SERVICE_UPDATE_FAILURE(Sctp_Map_t *sctpMap, ReportingMessages_t &message, |
| 680 | RmrMessagesBuffer_t &rmrMessageBuffer) { |
| 681 | inti_buffers_rcv(message, rmrMessageBuffer); |
| 682 | rmrMessageBuffer.rcvMessage->mtype = RIC_SERVICE_UPDATE_FAILURE; |
| 683 | receiveXappMessages(sctpMap, rmrMessageBuffer, message.message.time); |
| 684 | delete_memories_rcv(rmrMessageBuffer); |
| 685 | } |
| 686 | |
| 687 | |
| 688 | void create_receiveXappMessages_RIC_E2_RESET_REQ(Sctp_Map_t *sctpMap, ReportingMessages_t &message, |
| 689 | RmrMessagesBuffer_t &rmrMessageBuffer) { |
| 690 | inti_buffers_rcv(message, rmrMessageBuffer); |
| 691 | rmrMessageBuffer.rcvMessage->mtype = RIC_E2_RESET_REQ; |
| 692 | receiveXappMessages(sctpMap, rmrMessageBuffer, message.message.time); |
| 693 | delete_memories_rcv(rmrMessageBuffer); |
| 694 | } |
| 695 | |
| 696 | void create_receiveXappMessages_RIC_E2_RESET_RESP(Sctp_Map_t *sctpMap, ReportingMessages_t &message, |
| 697 | RmrMessagesBuffer_t &rmrMessageBuffer) { |
| 698 | inti_buffers_rcv(message, rmrMessageBuffer); |
| 699 | rmrMessageBuffer.rcvMessage->mtype = RIC_E2_RESET_RESP; |
| 700 | receiveXappMessages(sctpMap, rmrMessageBuffer, message.message.time); |
| 701 | delete_memories_rcv(rmrMessageBuffer); |
| 702 | } |
| 703 | |
| 704 | void create_receiveXappMessages_RIC_SCTP_CLEAR_ALL(Sctp_Map_t *sctpMap, ReportingMessages_t &message, |
| 705 | RmrMessagesBuffer_t &rmrMessageBuffer) { |
| 706 | inti_buffers_rcv(message, rmrMessageBuffer); |
| 707 | rmrMessageBuffer.rcvMessage->mtype = RIC_SCTP_CLEAR_ALL; |
| 708 | receiveXappMessages(sctpMap, rmrMessageBuffer, message.message.time); |
| 709 | delete_memories_rcv(rmrMessageBuffer); |
| 710 | } |
| 711 | |
| 712 | void create_receiveXappMessages_RIC_HEALTH_CHECK_REQ(Sctp_Map_t *sctpMap, ReportingMessages_t &message, |
| 713 | RmrMessagesBuffer_t &rmrMessageBuffer) { |
| 714 | inti_buffers_rcv(message, rmrMessageBuffer); |
| 715 | rmrMessageBuffer.rcvMessage->mtype = RIC_HEALTH_CHECK_REQ; |
| 716 | receiveXappMessages(sctpMap, rmrMessageBuffer, message.message.time); |
| 717 | delete_memories_rcv(rmrMessageBuffer); |
| 718 | } |
| 719 | |
| 720 | void create_receiveXappMessages_E2_TERM_KEEP_ALIVE_REQ(Sctp_Map_t *sctpMap, ReportingMessages_t &message, |
| 721 | RmrMessagesBuffer_t &rmrMessageBuffer) { |
| 722 | inti_buffers_rcv(message, rmrMessageBuffer); |
| 723 | rmrMessageBuffer.rcvMessage->mtype = E2_TERM_KEEP_ALIVE_REQ; |
| 724 | receiveXappMessages(sctpMap, rmrMessageBuffer, message.message.time); |
| 725 | delete_memories_rcv(rmrMessageBuffer); |
| 726 | } |
| 727 | |
dhirajverma | 9999029 | 2021-07-05 10:03:59 -0400 | [diff] [blame] | 728 | void create_receiveXappMessages_RIC_SUB_DEL_REQ(Sctp_Map_t *sctpMap, ReportingMessages_t &message, |
| 729 | RmrMessagesBuffer_t &rmrMessageBuffer) { |
| 730 | inti_buffers_rcv(message, rmrMessageBuffer); |
dhirajverma | 93b6d9c | 2021-07-10 00:49:13 -0400 | [diff] [blame] | 731 | rmrMessageBuffer.rcvMessage->mtype = RIC_SUB_DEL_REQ; |
dhirajverma | 9999029 | 2021-07-05 10:03:59 -0400 | [diff] [blame] | 732 | receiveXappMessages(sctpMap, rmrMessageBuffer, message.message.time); |
| 733 | delete_memories_rcv(rmrMessageBuffer); |
| 734 | } |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 735 | |
dhirajverma | 93b6d9c | 2021-07-10 00:49:13 -0400 | [diff] [blame] | 736 | void create_receiveXappMessages_RIC_E2_SETUP_RESP(Sctp_Map_t *sctpMap, ReportingMessages_t &message, |
| 737 | RmrMessagesBuffer_t &rmrMessageBuffer) { |
| 738 | inti_buffers_rcv(message, rmrMessageBuffer); |
| 739 | rmrMessageBuffer.rcvMessage->mtype = RIC_E2_SETUP_RESP; |
| 740 | receiveXappMessages(sctpMap, rmrMessageBuffer, message.message.time); |
| 741 | delete_memories_rcv(rmrMessageBuffer); |
| 742 | } |
| 743 | |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 744 | TEST(sctp, TEST13) { |
| 745 | Sctp_Map_t *sctpMap = new Sctp_Map_t(); |
| 746 | ReportingMessages_t message; |
| 747 | RmrMessagesBuffer_t rmrMessageBuffer; |
| 748 | |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 749 | memset( (void*)&message, 0, sizeof(message)); |
| 750 | memset( (void*)&rmrMessageBuffer, 0, sizeof(rmrMessageBuffer)); |
| 751 | |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 752 | // Sending E2AP_PDU_PR_successfulOutcome and procedure code as: ProcedureCode_id_Reset |
| 753 | create_receiveXappMessages_RIC_E2_SETUP_FAILURE(sctpMap, message, rmrMessageBuffer); |
| 754 | create_receiveXappMessages_RIC_ERROR_INDICATION(sctpMap, message, rmrMessageBuffer); |
| 755 | create_receiveXappMessages_RIC_SUB_REQ(sctpMap, message, rmrMessageBuffer); |
| 756 | create_receiveXappMessages_RIC_CONTROL_REQ(sctpMap, message, rmrMessageBuffer); |
| 757 | create_receiveXappMessages_RIC_HEALTH_CHECK_REQ(sctpMap, message, rmrMessageBuffer); |
| 758 | create_receiveXappMessages_E2_TERM_KEEP_ALIVE_REQ(sctpMap, message, rmrMessageBuffer); |
| 759 | create_receiveXappMessages_RIC_SCTP_CLEAR_ALL(sctpMap, message, rmrMessageBuffer); |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 760 | create_receiveXappMessages_RIC_E2_RESET_RESP(sctpMap, message, rmrMessageBuffer); |
| 761 | create_receiveXappMessages_RIC_E2_RESET_REQ(sctpMap, message, rmrMessageBuffer); |
| 762 | create_receiveXappMessages_RIC_SERVICE_UPDATE_FAILURE(sctpMap, message, rmrMessageBuffer); |
| 763 | create_receiveXappMessages_RIC_SERVICE_UPDATE_ACK(sctpMap, message, rmrMessageBuffer); |
| 764 | create_receiveXappMessages_RIC_SERVICE_QUERY(sctpMap, message, rmrMessageBuffer); |
dhirajverma | 9999029 | 2021-07-05 10:03:59 -0400 | [diff] [blame] | 765 | create_receiveXappMessages_RIC_SUB_DEL_REQ(sctpMap, message, rmrMessageBuffer); |
dhirajverma | 93b6d9c | 2021-07-10 00:49:13 -0400 | [diff] [blame] | 766 | create_receiveXappMessages_RIC_E2_SETUP_RESP(sctpMap, message, rmrMessageBuffer); |
dhirajverma | 6cf2861 | 2021-06-23 04:53:34 -0400 | [diff] [blame] | 767 | |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 768 | inti_buffers_rcv(message, rmrMessageBuffer); |
dhirajverma | 9999029 | 2021-07-05 10:03:59 -0400 | [diff] [blame] | 769 | rmrMessageBuffer.rcvMessage->mtype = 52345; /*Dummy Integer Value for default case*/ |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 770 | receiveXappMessages(sctpMap, rmrMessageBuffer, message.message.time); |
| 771 | delete_memories_rcv(rmrMessageBuffer); |
| 772 | |
| 773 | if(sctpMap) { |
| 774 | delete sctpMap; |
| 775 | sctpMap = NULL; |
| 776 | } |
| 777 | } |
dhirajverma | 9999029 | 2021-07-05 10:03:59 -0400 | [diff] [blame] | 778 | /* TEST 14 Begin: */ |
| 779 | void receiveDataFromSctp_asnSuccessfulMsg_Procedure_Default( E2AP_PDU_t *pdu, |
| 780 | RmrMessagesBuffer_t &rmrMessageBuffer) { |
| 781 | pdu->present = E2AP_PDU_PR_successfulOutcome; |
| 782 | pdu->choice.successfulOutcome = (SuccessfulOutcome*) malloc(sizeof(SuccessfulOutcome)); |
| 783 | memset( (void*)pdu->choice.successfulOutcome, 0, sizeof(pdu->choice.successfulOutcome)); |
| 784 | pdu->choice.successfulOutcome->procedureCode = ((ProcedureCode_t)100); |
| 785 | |
| 786 | rmrMessageBuffer.sendMessage->tp_buf = pdu; |
| 787 | } |
| 788 | |
| 789 | void delete_pdu_memories(E2AP_PDU_t *pdu) { |
| 790 | if(pdu->choice.successfulOutcome) { |
| 791 | free(pdu->choice.successfulOutcome); |
| 792 | pdu->choice.successfulOutcome = NULL; |
| 793 | } |
| 794 | if(pdu->choice.unsuccessfulOutcome) { |
| 795 | free(pdu->choice.unsuccessfulOutcome); |
| 796 | pdu->choice.unsuccessfulOutcome = NULL; |
| 797 | } |
| 798 | } |
| 799 | |
dhirajverma | c40ea1f | 2021-07-08 12:52:30 -0400 | [diff] [blame] | 800 | /*void receiveDataFromSctp_asnUnSuccsesfulMsg_Procedure_Default(E2AP_PDU_t *pdu, |
dhirajverma | 9999029 | 2021-07-05 10:03:59 -0400 | [diff] [blame] | 801 | RmrMessagesBuffer_t &rmrMessageBuffer) { |
| 802 | pdu->present = E2AP_PDU_PR_unsuccessfulOutcome; |
| 803 | pdu->choice.unsuccessfulOutcome = (UnsuccessfulOutcome*) malloc(sizeof(UnsuccessfulOutcome)); |
| 804 | memset( (void*)pdu->choice.unsuccessfulOutcome, 0, sizeof(pdu->choice.unsuccessfulOutcome)); |
| 805 | pdu->choice.unsuccessfulOutcome->procedureCode = ((ProcedureCode_t)100); |
| 806 | |
| 807 | rmrMessageBuffer.sendMessage->tp_buf = pdu; |
dhirajverma | c40ea1f | 2021-07-08 12:52:30 -0400 | [diff] [blame] | 808 | }*/ |
dhirajverma | 9999029 | 2021-07-05 10:03:59 -0400 | [diff] [blame] | 809 | |
| 810 | TEST(sctp, TEST14) { |
| 811 | E2AP_PDU_t pdu; |
| 812 | struct epoll_event events; |
| 813 | Sctp_Map_t *sctpMap = new Sctp_Map_t(); |
| 814 | int numOfMessages=0; |
| 815 | RmrMessagesBuffer_t rmrMessageBuffer; |
| 816 | struct timespec ts; |
| 817 | ConnectedCU_t *peerInfo = (ConnectedCU_t *) calloc(1, sizeof(ConnectedCU_t)); |
| 818 | events.data.ptr = peerInfo; |
| 819 | snprintf(peerInfo->enodbName, strlen("Nokia_enb "), "%s", (char*)"Nokia_enb"); |
| 820 | |
| 821 | rmrMessageBuffer.sendMessage = (rmr_mbuf_t*) malloc(sizeof(rmr_mbuf_t)); |
| 822 | rmrMessageBuffer.sendMessage->header = (uta_mhdr_t*) malloc(sizeof(uta_mhdr_t)); |
| 823 | rmrMessageBuffer.sendMessage->len = strlen("Saying Hello from NOKIA "); |
| 824 | rmrMessageBuffer.sendMessage->payload = (unsigned char*)strdup("Saying Hello from NOKIA"); |
| 825 | |
| 826 | clock_gettime(CLOCK_MONOTONIC, &ts); |
| 827 | |
| 828 | receiveDataFromSctp_asnSuccessfulMsg_Procedure_Default(&pdu, rmrMessageBuffer); |
| 829 | receiveDataFromSctp(&events, sctpMap, numOfMessages, rmrMessageBuffer, ts); |
| 830 | delete_pdu_memories(&pdu); |
| 831 | |
| 832 | if(rmrMessageBuffer.sendMessage->payload) { |
| 833 | free(rmrMessageBuffer.sendMessage->payload); |
| 834 | rmrMessageBuffer.sendMessage->payload = NULL; |
| 835 | } |
| 836 | |
dhirajverma | c40ea1f | 2021-07-08 12:52:30 -0400 | [diff] [blame] | 837 | /*rmrMessageBuffer.sendMessage->payload = (unsigned char*)strdup("Saying Hello from NOKIA"); |
dhirajverma | 9999029 | 2021-07-05 10:03:59 -0400 | [diff] [blame] | 838 | receiveDataFromSctp_asnUnSuccsesfulMsg_Procedure_Default(&pdu, rmrMessageBuffer); |
| 839 | receiveDataFromSctp(&events, sctpMap, numOfMessages, rmrMessageBuffer, ts); |
| 840 | delete_pdu_memories(&pdu); |
| 841 | |
| 842 | if(rmrMessageBuffer.sendMessage->payload) { |
| 843 | free(rmrMessageBuffer.sendMessage->payload); |
| 844 | rmrMessageBuffer.sendMessage->payload = NULL; |
dhirajverma | c40ea1f | 2021-07-08 12:52:30 -0400 | [diff] [blame] | 845 | }*/ |
dhirajverma | 9999029 | 2021-07-05 10:03:59 -0400 | [diff] [blame] | 846 | if(rmrMessageBuffer.sendMessage->header) { |
| 847 | free(rmrMessageBuffer.sendMessage->header); |
| 848 | rmrMessageBuffer.sendMessage->header = NULL; |
| 849 | } |
| 850 | if(rmrMessageBuffer.sendMessage) { |
| 851 | free(rmrMessageBuffer.sendMessage); |
| 852 | } |
| 853 | if(peerInfo) { |
| 854 | free(peerInfo); |
| 855 | peerInfo = NULL; |
| 856 | } |
| 857 | if(sctpMap) { |
| 858 | delete sctpMap; |
| 859 | sctpMap = NULL; |
| 860 | } |
| 861 | } |
dhirajverma | 60f8bef | 2021-06-29 07:22:58 -0400 | [diff] [blame] | 862 | |
dhirajverma | 31768a9 | 2021-05-06 12:38:49 +0530 | [diff] [blame] | 863 | int main(int argc, char **argv) { |
| 864 | |
| 865 | testing::InitGoogleTest(&argc, argv); |
| 866 | return RUN_ALL_TESTS(); |
| 867 | |
| 868 | } |