anjana_sreekumar@infosys.com | 991c206 | 2020-01-08 11:42:57 +0530 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2019-present Infosys Limited |
| 3 | * |
| 4 | * SPDX-License-Identifier: Apache-2.0 |
| 5 | */ |
| 6 | |
| 7 | /****************************************************************************** |
| 8 | * |
| 9 | * This file has both generated and manual code. |
| 10 | * |
| 11 | * File template used for code generation: |
| 12 | * <TOP-DIR/scripts/SMCodeGen/templates/stateMachineTmpls/actionHandlers.cpp.tt> |
| 13 | * |
| 14 | ******************************************************************************/ |
| 15 | |
| 16 | #include <typeinfo> |
| 17 | #include "actionHandlers/actionHandlers.h" |
| 18 | #include "controlBlock.h" |
| 19 | #include "msgType.h" |
| 20 | #include "contextManager/subsDataGroupManager.h" |
| 21 | #include "contextManager/dataBlocks.h" |
| 22 | #include "procedureStats.h" |
| 23 | #include "log.h" |
| 24 | #include "secUtils.h" |
| 25 | #include "state.h" |
| 26 | #include <string.h> |
| 27 | #include <sstream> |
| 28 | #include <smTypes.h> |
| 29 | |
| 30 | #include <ipcTypes.h> |
| 31 | #include <tipcTypes.h> |
| 32 | #include <msgBuffer.h> |
| 33 | #include <interfaces/mmeIpcInterface.h> |
| 34 | #include <utils/mmeContextManagerUtils.h> |
| 35 | |
| 36 | using namespace SM; |
| 37 | using namespace mme; |
| 38 | using namespace cmn::utils; |
| 39 | |
| 40 | extern MmeIpcInterface* mmeIpcIf_g; |
| 41 | |
| 42 | ActStatus ActionHandlers:: send_rel_ab_req_to_sgw(SM::ControlBlock& cb) |
| 43 | { |
| 44 | log_msg(LOG_DEBUG, "Inside send_rel_ab_req_to_sgw \n"); |
| 45 | |
| 46 | UEContext *ue_ctxt = dynamic_cast<UEContext*>(cb.getPermDataBlock()); |
| 47 | if (ue_ctxt == NULL) |
| 48 | { |
| 49 | log_msg(LOG_DEBUG, "send_rel_ab_req_to_sgw: ue ctxt is NULL \n"); |
| 50 | return ActStatus::HALT; |
| 51 | } |
| 52 | |
| 53 | SessionContext* sessionCtxt = ue_ctxt->getSessionContext(); |
| 54 | if (sessionCtxt == NULL) |
| 55 | { |
| 56 | log_msg(LOG_DEBUG, " send_rel_ab_req_to_sgw: session ctxt is NULL \n"); |
| 57 | return ActStatus::HALT; |
| 58 | } |
| 59 | |
| 60 | BearerContext* bearerCtxt = sessionCtxt->getBearerContext(); |
| 61 | if (bearerCtxt == NULL) |
| 62 | { |
| 63 | log_msg(LOG_DEBUG, " send_rel_ab_req_to_sgw: bearer ctxt is NULL \n"); |
| 64 | return ActStatus::HALT; |
| 65 | } |
| 66 | |
| 67 | struct RB_Q_msg rb_msg; |
| 68 | rb_msg.msg_type = release_bearer_request; |
| 69 | rb_msg.ue_idx = ue_ctxt->getContextID(); |
| 70 | memset(rb_msg.indication, 0 , S11_RB_INDICATION_FLAG_SIZE); |
| 71 | rb_msg.bearer_id = bearerCtxt->getBearerId(); |
| 72 | memcpy(&(rb_msg.s11_sgw_c_fteid), &(sessionCtxt->getS11SgwCtrlFteid()), |
| 73 | sizeof(struct fteid)); |
| 74 | memcpy(&(rb_msg.s1u_enb_fteid), &(bearerCtxt->getS1uEnbUserFteid()), |
| 75 | sizeof(struct fteid)); |
| 76 | |
| 77 | cmn::ipc::IpcAddress destAddr; |
| 78 | destAddr.u32 = TipcServiceInstance::s11AppInstanceNum_c; |
| 79 | mmeIpcIf_g->dispatchIpcMsg((char *) &rb_msg, sizeof(rb_msg), destAddr); |
| 80 | |
| 81 | ProcedureStats::num_of_rel_access_bearer_req_sent ++; |
| 82 | |
| 83 | log_msg(LOG_DEBUG, "Inside send_rel_ab_req_to_sgw \n"); |
| 84 | |
| 85 | return ActStatus::PROCEED; |
| 86 | } |
| 87 | |
| 88 | ActStatus ActionHandlers:: process_rel_ab_resp_from_sgw(SM::ControlBlock& cb) |
| 89 | { |
| 90 | log_msg(LOG_DEBUG, "process_rel_ab_resp_from_sgw \n"); |
| 91 | |
| 92 | ProcedureStats::num_of_rel_access_bearer_resp_received ++; |
| 93 | |
| 94 | return ActStatus::PROCEED; |
| 95 | } |
| 96 | |
| 97 | ActStatus ActionHandlers:: send_s1_rel_cmd_to_ue(SM::ControlBlock& cb) |
| 98 | { |
| 99 | log_msg(LOG_DEBUG, "Inside send_s1_rel_cmd_to_ue\n"); |
| 100 | |
| 101 | UEContext *ue_ctxt = dynamic_cast<UEContext*>(cb.getPermDataBlock()); |
| 102 | if(ue_ctxt == NULL) |
| 103 | { |
| 104 | log_msg(LOG_DEBUG, "send_s1_rel_cmd_to_ue: ue context is NULL \n"); |
| 105 | |
| 106 | return ActStatus::HALT; |
| 107 | } |
| 108 | |
| 109 | struct s1relcmd_info s1relcmd; |
| 110 | s1relcmd.msg_type = s1_release_command; |
| 111 | s1relcmd.ue_idx = ue_ctxt->getContextID(); |
| 112 | s1relcmd.enb_fd = ue_ctxt->getEnbFd(); |
| 113 | s1relcmd.enb_s1ap_ue_id = ue_ctxt->getS1apEnbUeId(); |
| 114 | s1relcmd.cause.present = s1apCause_PR_radioNetwork; |
| 115 | s1relcmd.cause.choice.radioNetwork = s1apCauseRadioNetwork_user_inactivity; |
| 116 | |
| 117 | /*Send message to S1AP-APP*/ |
| 118 | cmn::ipc::IpcAddress destAddr; |
| 119 | destAddr.u32 = TipcServiceInstance::s1apAppInstanceNum_c; |
| 120 | mmeIpcIf_g->dispatchIpcMsg((char *) &s1relcmd, sizeof(s1relcmd), destAddr); |
| 121 | |
| 122 | ProcedureStats::num_of_s1_rel_cmd_sent ++; |
| 123 | |
| 124 | log_msg(LOG_DEBUG,"Leaving send_s1_rel_cmd_to_ue \n"); |
| 125 | |
| 126 | return ActStatus::PROCEED; |
| 127 | } |
| 128 | |
| 129 | ActStatus ActionHandlers:: process_ue_ctxt_rel_comp(SM::ControlBlock& cb) |
| 130 | { |
| 131 | log_msg(LOG_DEBUG, "Inside handle_ctxt_rel_comp \n"); |
| 132 | |
| 133 | UEContext *ue_ctxt = dynamic_cast<UEContext*>(cb.getPermDataBlock()); |
| 134 | if (ue_ctxt == NULL) |
| 135 | { |
| 136 | log_msg(LOG_DEBUG, "process_ue_ctxt_rel_comp: ue context is NULL\n"); |
| 137 | |
| 138 | return ActStatus::HALT; |
| 139 | } |
| 140 | |
| 141 | MmeContextManagerUtils::deallocateProcedureCtxt(cb, s1Release_c); |
| 142 | |
| 143 | ProcedureStats::num_of_s1_rel_comp_received++; |
| 144 | |
| 145 | log_msg(LOG_DEBUG, "Leaving process_ue_ctxt_rel_comp \n"); |
| 146 | |
| 147 | return ActStatus::PROCEED; |
| 148 | } |
| 149 | |
| 150 | |
| 151 | |