anjana_sreekumar@infosys.com | 991c206 | 2020-01-08 11:42:57 +0530 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (c) 2019, Infosys Ltd. |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #include <msgHandlers/s1MsgHandler.h> |
| 18 | |
| 19 | #include <event.h> |
| 20 | #include <ipcTypes.h> |
| 21 | #include <log.h> |
| 22 | #include <utils/mmeCommonUtils.h> |
| 23 | #include <contextManager/subsDataGroupManager.h> |
| 24 | |
| 25 | using namespace SM; |
| 26 | using namespace mme; |
| 27 | |
| 28 | S1MsgHandler::S1MsgHandler() |
| 29 | { |
| 30 | |
| 31 | } |
| 32 | |
| 33 | S1MsgHandler::~S1MsgHandler() |
| 34 | { |
| 35 | |
| 36 | } |
| 37 | |
| 38 | S1MsgHandler* S1MsgHandler::Instance() |
| 39 | { |
| 40 | static S1MsgHandler msgHandler; |
| 41 | return &msgHandler; |
| 42 | } |
| 43 | |
| 44 | void S1MsgHandler::handleS1Message_v(const cmn::utils::MsgBuffer* buf) |
| 45 | { |
| 46 | log_msg(LOG_INFO, "S1 - handleS1Message_v\n"); |
| 47 | |
| 48 | if (buf == NULL) |
| 49 | return; |
| 50 | |
| 51 | cmn::utils::MsgBuffer* msgBuf = const_cast<cmn::utils::MsgBuffer *>(buf); |
| 52 | |
| 53 | const s1_incoming_msg_data_t* msgData_p = (s1_incoming_msg_data_t*)(msgBuf->getDataPointer()); |
| 54 | |
| 55 | switch (msgData_p->msg_type) |
| 56 | { |
| 57 | case msg_type_t::attach_request: |
| 58 | handleInitUeAttachRequestMsg_v(msgBuf); |
| 59 | break; |
| 60 | |
| 61 | case msg_type_t::id_response: |
| 62 | handleIdentityResponseMsg_v(msgBuf, msgData_p->ue_idx); |
| 63 | break; |
| 64 | |
| 65 | case msg_type_t::auth_response: |
| 66 | handleAuthResponseMsg_v(msgBuf, msgData_p->ue_idx); |
| 67 | break; |
| 68 | |
| 69 | case msg_type_t::sec_mode_complete: |
| 70 | handleSecurityModeResponse_v(msgBuf, msgData_p->ue_idx); |
| 71 | break; |
| 72 | |
| 73 | case msg_type_t::esm_info_response: |
| 74 | handleEsmInfoResponse_v(msgBuf, msgData_p->ue_idx); |
| 75 | break; |
| 76 | |
| 77 | case msg_type_t::init_ctxt_response: |
| 78 | handleInitCtxtResponse_v(msgBuf, msgData_p->ue_idx); |
| 79 | break; |
| 80 | |
| 81 | case msg_type_t::attach_complete: |
| 82 | handleAttachComplete_v(msgBuf, msgData_p->ue_idx); |
| 83 | break; |
| 84 | |
| 85 | case msg_type_t::detach_request: |
| 86 | handleDetachRequest_v(msgBuf, msgData_p->ue_idx); |
| 87 | break; |
| 88 | |
| 89 | case msg_type_t::s1_release_request: |
| 90 | handleS1ReleaseRequestMsg_v(msgBuf, msgData_p->ue_idx); |
| 91 | break; |
| 92 | |
| 93 | case msg_type_t::s1_release_complete: |
| 94 | handleS1ReleaseComplete_v(msgBuf, msgData_p->ue_idx); |
| 95 | break; |
| 96 | |
| 97 | case msg_type_t::detach_accept_from_ue: |
| 98 | handleDetachAcceptFromUE_v(msgBuf, msgData_p->ue_idx); |
| 99 | break; |
| 100 | |
| 101 | case msg_type_t::service_request: |
| 102 | handleServiceRequest_v(msgBuf, msgData_p->ue_idx); |
| 103 | break; |
| 104 | |
| 105 | case msg_type_t::tau_request: |
| 106 | handleTauRequestMsg_v(msgBuf, msgData_p->ue_idx); |
| 107 | break; |
| 108 | |
| 109 | default: |
| 110 | log_msg(LOG_INFO, "Unhandled S1 Message %d \n", msgData_p->msg_type); |
| 111 | delete msgBuf; |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | void S1MsgHandler::handleInitUeAttachRequestMsg_v(const cmn::utils::MsgBuffer* msgData_p) |
| 116 | { |
| 117 | log_msg(LOG_INFO, "S1 - handleInitUeAttachRequestMsg_v\n"); |
| 118 | |
| 119 | SM::ControlBlock* controlBlk_p = MmeCommonUtils::findControlBlock( |
| 120 | const_cast<cmn::utils::MsgBuffer*>(msgData_p)); |
| 121 | if (controlBlk_p == NULL) |
| 122 | { |
| 123 | log_msg(LOG_ERROR, "Failed to allocate ControlBlock \n"); |
| 124 | |
| 125 | return; |
| 126 | } |
| 127 | |
| 128 | // Fire attach-start event, insert cb to procedure queue |
| 129 | SM::Event evt(Event_e::ATTACH_REQ_FROM_UE, (void *)msgData_p); |
| 130 | controlBlk_p->addEventToProcQ(evt); |
| 131 | } |
| 132 | |
| 133 | void S1MsgHandler::handleIdentityResponseMsg_v(const cmn::utils::MsgBuffer* msgData_p, uint32_t ueIdx) |
| 134 | { |
| 135 | log_msg(LOG_INFO, "S1 - handleIdentityResponseMsg_v\n"); |
| 136 | |
| 137 | SM::ControlBlock* controlBlk_p = SubsDataGroupManager::Instance()->findControlBlock(ueIdx); |
| 138 | if(controlBlk_p == NULL) |
| 139 | { |
| 140 | log_msg(LOG_ERROR, "handleIdentityResponseMsg_v: " |
| 141 | "Failed to find UE context using idx %d\n", |
| 142 | ueIdx); |
| 143 | return; |
| 144 | } |
| 145 | |
| 146 | // Fire attach-start event, insert cb to procedure queue |
| 147 | SM::Event evt(Event_e::IDENTITY_RESPONSE_FROM_UE, (void *)msgData_p); |
| 148 | controlBlk_p->addEventToProcQ(evt); |
| 149 | } |
| 150 | |
| 151 | void S1MsgHandler::handleAuthResponseMsg_v(const cmn::utils::MsgBuffer* msgData_p, uint32_t ueIdx) |
| 152 | { |
| 153 | log_msg(LOG_INFO, "S1 - handleAuthResponseMsg_v\n"); |
| 154 | |
| 155 | SM::ControlBlock* controlBlk_p = SubsDataGroupManager::Instance()->findControlBlock(ueIdx); |
| 156 | if(controlBlk_p == NULL) |
| 157 | { |
| 158 | log_msg(LOG_ERROR, "handleAuthResponseMsg_v: " |
| 159 | "Failed to find UE context using idx %d\n", |
| 160 | ueIdx); |
| 161 | return; |
| 162 | } |
| 163 | |
| 164 | // Fire attach-start event, insert cb to procedure queue |
| 165 | SM::Event evt(Event_e::AUTH_RESP_FROM_UE, (void *)msgData_p); |
| 166 | controlBlk_p->addEventToProcQ(evt); |
| 167 | } |
| 168 | |
| 169 | void S1MsgHandler::handleSecurityModeResponse_v(const cmn::utils::MsgBuffer* msgData_p, uint32_t ueIdx) |
| 170 | { |
| 171 | log_msg(LOG_INFO, "S1 - handleSecurityModeResponse_v\n"); |
| 172 | |
| 173 | SM::ControlBlock* controlBlk_p = SubsDataGroupManager::Instance()->findControlBlock(ueIdx); |
| 174 | if(controlBlk_p == NULL) |
| 175 | { |
| 176 | log_msg(LOG_ERROR, "handleSecurityModeResponse_v: " |
| 177 | "Failed to find UE context using idx %d\n", |
| 178 | ueIdx); |
| 179 | return; |
| 180 | } |
| 181 | |
| 182 | // Fire attach-start event, insert cb to procedure queue |
| 183 | SM::Event evt(Event_e::SEC_MODE_RESP_FROM_UE, (void *)msgData_p); |
| 184 | controlBlk_p->addEventToProcQ(evt); |
| 185 | } |
| 186 | |
| 187 | void S1MsgHandler::handleEsmInfoResponse_v(const cmn::utils::MsgBuffer* msgData_p, uint32_t ueIdx) |
| 188 | { |
| 189 | log_msg(LOG_INFO, "S1 - handleEsmInfoResponse_v\n"); |
| 190 | |
| 191 | SM::ControlBlock* controlBlk_p = SubsDataGroupManager::Instance()->findControlBlock(ueIdx); |
| 192 | if(controlBlk_p == NULL) |
| 193 | { |
| 194 | log_msg(LOG_ERROR, "handleEsmInfoResponse_v: " |
| 195 | "Failed to find UE context using idx %d\n", |
| 196 | ueIdx); |
| 197 | return; |
| 198 | } |
| 199 | |
| 200 | // Fire attach-start event, insert cb to procedure queue |
| 201 | SM::Event evt(Event_e::ESM_INFO_RESP_FROM_UE, (void *)msgData_p); |
| 202 | controlBlk_p->addEventToProcQ(evt); |
| 203 | } |
| 204 | |
| 205 | void S1MsgHandler::handleInitCtxtResponse_v(const cmn::utils::MsgBuffer* msgData_p, uint32_t ueIdx) |
| 206 | { |
| 207 | log_msg(LOG_INFO, "S1 - handleInitCtxtResponse_v\n"); |
| 208 | |
| 209 | SM::ControlBlock* controlBlk_p = SubsDataGroupManager::Instance()->findControlBlock(ueIdx); |
| 210 | if(controlBlk_p == NULL) |
| 211 | { |
| 212 | log_msg(LOG_ERROR, "handleInitCtxtResponse_v: " |
| 213 | "Failed to find UE context using idx %d\n", |
| 214 | ueIdx); |
| 215 | return; |
| 216 | } |
| 217 | |
| 218 | // Fire attach-start event, insert cb to procedure queue |
| 219 | SM::Event evt(Event_e::INIT_CTXT_RESP_FROM_UE, (void *)msgData_p); |
| 220 | controlBlk_p->addEventToProcQ(evt); |
| 221 | } |
| 222 | |
| 223 | void S1MsgHandler::handleAttachComplete_v(const cmn::utils::MsgBuffer* msgData_p, uint32_t ueIdx) |
| 224 | { |
| 225 | log_msg(LOG_INFO, "S1 - handleAttachComplete_v\n"); |
| 226 | |
| 227 | SM::ControlBlock* controlBlk_p = SubsDataGroupManager::Instance()->findControlBlock(ueIdx); |
| 228 | if(controlBlk_p == NULL) |
| 229 | { |
| 230 | log_msg(LOG_ERROR, "handleAttachComplete_v: " |
| 231 | "Failed to find UE context using idx %d\n", |
| 232 | ueIdx); |
| 233 | return; |
| 234 | } |
| 235 | |
| 236 | // Fire attach-start event, insert cb to procedure queue |
| 237 | SM::Event evt(Event_e::ATT_CMP_FROM_UE, (void *)msgData_p); |
| 238 | controlBlk_p->addEventToProcQ(evt); |
| 239 | } |
| 240 | |
| 241 | void S1MsgHandler::handleDetachRequest_v(const cmn::utils::MsgBuffer* msgData_p, uint32_t ueIdx) |
| 242 | { |
| 243 | log_msg(LOG_INFO, "S1 - handleDetachRequest_v\n"); |
| 244 | |
| 245 | SM::ControlBlock* controlBlk_p = MmeCommonUtils::findControlBlock( |
| 246 | const_cast<cmn::utils::MsgBuffer*>(msgData_p)); |
| 247 | if(controlBlk_p == NULL) |
| 248 | { |
| 249 | log_msg(LOG_ERROR, "handleDetachRequest_v: " |
| 250 | "Failed to find UE context using idx %d\n", ueIdx); |
| 251 | return; |
| 252 | } |
| 253 | |
| 254 | // Fire detach request event, insert cb to procedure queue |
| 255 | SM::Event evt(Event_e::DETACH_REQ_FROM_UE, (void *)msgData_p); |
| 256 | controlBlk_p->addEventToProcQ(evt); |
| 257 | } |
| 258 | |
| 259 | void S1MsgHandler::handleS1ReleaseRequestMsg_v(const cmn::utils::MsgBuffer* msgData_p, uint32_t ueIdx) |
| 260 | { |
| 261 | log_msg(LOG_INFO, "S1 - handleS1ReleaseRequestMsg_v\n"); |
| 262 | |
| 263 | SM::ControlBlock* controlBlk_p = SubsDataGroupManager::Instance()->findControlBlock(ueIdx); |
| 264 | if(controlBlk_p == NULL) |
| 265 | { |
| 266 | log_msg(LOG_ERROR, ":handleS1ReleaseRequestMsg_v: " |
| 267 | "Failed to find UE context using idx %d\n", |
| 268 | ueIdx); |
| 269 | return; |
| 270 | } |
| 271 | |
| 272 | // Fire s1 release event, insert cb to procedure queue |
| 273 | SM::Event evt(Event_e::S1_REL_REQ_FROM_UE, (void *)msgData_p); |
| 274 | controlBlk_p->addEventToProcQ(evt); |
| 275 | } |
| 276 | |
| 277 | void S1MsgHandler::handleS1ReleaseComplete_v(const cmn::utils::MsgBuffer* msgData_p, uint32_t ueIdx) |
| 278 | { |
| 279 | log_msg(LOG_INFO, "S1 - handleS1ReleaseComplete_v\n"); |
| 280 | |
| 281 | SM::ControlBlock* controlBlk_p = SubsDataGroupManager::Instance()->findControlBlock(ueIdx); |
| 282 | if(controlBlk_p == NULL) |
| 283 | { |
| 284 | log_msg(LOG_ERROR, ":handleS1ReleaseComplete_v: " |
| 285 | "Failed to find UE context using idx %d\n", |
| 286 | ueIdx); |
| 287 | return; |
| 288 | } |
| 289 | |
| 290 | // Fire s1 release complete event, insert cb to procedure queue |
| 291 | SM::Event evt(Event_e::UE_CTXT_REL_COMP_FROM_ENB, (void *)msgData_p); |
| 292 | controlBlk_p->addEventToProcQ(evt); |
| 293 | } |
| 294 | |
| 295 | void S1MsgHandler::handleDetachAcceptFromUE_v(const cmn::utils::MsgBuffer* msgData_p, uint32_t ueIdx) |
| 296 | { |
| 297 | log_msg(LOG_INFO, "S1 - handleDetachAcceptFromUE_v\n"); |
| 298 | |
| 299 | SM::ControlBlock* controlBlk_p = SubsDataGroupManager::Instance()->findControlBlock(ueIdx); |
| 300 | if(controlBlk_p == NULL) |
| 301 | { |
| 302 | log_msg(LOG_ERROR, "handleDetachAcceptFromUE_v: " |
| 303 | "Failed to find UE Context using idx %d\n", |
| 304 | ueIdx); |
| 305 | return; |
| 306 | } |
| 307 | |
| 308 | //Fire NI_Detach Event, insert CB to procedure queue |
| 309 | SM::Event evt(Event_e::DETACH_ACCEPT_FROM_UE, (void *)msgData_p); |
| 310 | controlBlk_p->addEventToProcQ(evt); |
| 311 | } |
| 312 | |
| 313 | void S1MsgHandler::handleServiceRequest_v(const cmn::utils::MsgBuffer* msgData_p, uint32_t ueIdx) |
| 314 | { |
| 315 | log_msg(LOG_INFO, "S1 - handleServiceRequest_v\n"); |
| 316 | |
| 317 | SM::ControlBlock* controlBlk_p = MmeCommonUtils::findControlBlock( |
| 318 | const_cast<cmn::utils::MsgBuffer*>(msgData_p)); |
| 319 | if(controlBlk_p == NULL) |
| 320 | { |
| 321 | log_msg(LOG_ERROR, "handleServiceRequest_v: " |
| 322 | "Failed to find UE Context using idx %d\n", |
| 323 | ueIdx); |
| 324 | return; |
| 325 | } |
| 326 | |
| 327 | //Fire NI_Detach Event, insert CB to procedure queue |
| 328 | SM::Event evt(Event_e::SERVICE_REQUEST_FROM_UE, (void *)msgData_p); |
| 329 | controlBlk_p->addEventToProcQ(evt); |
| 330 | } |
| 331 | |
| 332 | void S1MsgHandler::handleTauRequestMsg_v(const cmn::utils::MsgBuffer* msgData_p, uint32_t ueIdx) |
| 333 | { |
| 334 | log_msg(LOG_INFO, "S1 - handleTauRequestMsg_v\n"); |
| 335 | |
| 336 | SM::ControlBlock* controlBlk_p = MmeCommonUtils::findControlBlock( |
| 337 | const_cast<cmn::utils::MsgBuffer*>(msgData_p)); |
| 338 | if(controlBlk_p == NULL) |
| 339 | { |
| 340 | log_msg(LOG_ERROR, "handleTauRequestMsg_v: " |
| 341 | "Failed to find UE Context using idx %d\n", |
| 342 | ueIdx); |
| 343 | return; |
| 344 | } |
| 345 | |
| 346 | // Fire tau-start event, insert cb to procedure queue |
| 347 | SM::Event evt(Event_e::TAU_REQUEST_FROM_UE, (void *)msgData_p); |
| 348 | controlBlk_p->addEventToProcQ(evt); |
| 349 | } |