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 "actionHandlers/actionHandlers.h" |
| 17 | #include "contextManager/subsDataGroupManager.h" |
| 18 | #include "contextManager/dataBlocks.h" |
| 19 | #include "msgType.h" |
| 20 | #include "controlBlock.h" |
| 21 | #include "procedureStats.h" |
| 22 | #include "log.h" |
| 23 | #include <string.h> |
| 24 | #include <smTypes.h> |
| 25 | |
| 26 | #include <ipcTypes.h> |
| 27 | #include <tipcTypes.h> |
| 28 | #include <msgBuffer.h> |
| 29 | #include <interfaces/mmeIpcInterface.h> |
| 30 | #include <utils/mmeContextManagerUtils.h> |
| 31 | |
| 32 | using namespace SM; |
| 33 | using namespace mme; |
| 34 | using namespace cmn::utils; |
| 35 | |
| 36 | extern MmeIpcInterface* mmeIpcIf_g; |
| 37 | |
| 38 | ActStatus ActionHandlers::del_session_req(SM::ControlBlock& cb) |
| 39 | { |
| 40 | log_msg(LOG_DEBUG, "Inside delete_session_req \n"); |
| 41 | |
| 42 | UEContext *ue_ctxt = dynamic_cast<UEContext*>(cb.getPermDataBlock()); |
| 43 | |
| 44 | if (ue_ctxt == NULL) |
| 45 | { |
| 46 | log_msg(LOG_DEBUG, "delete_session_req: ue context is NULL\n"); |
| 47 | return ActStatus::HALT; |
| 48 | } |
| 49 | |
| 50 | ue_ctxt->setUpLnkSeqNo(ue_ctxt->getUpLnkSeqNo()+1); |
| 51 | |
| 52 | struct DS_Q_msg g_ds_msg; |
| 53 | g_ds_msg.msg_type = delete_session_request; |
| 54 | |
| 55 | memset(g_ds_msg.indication, 0, S11_DS_INDICATION_FLAG_SIZE); |
| 56 | g_ds_msg.indication[0] = 8; /* TODO : define macro or enum */ |
| 57 | |
| 58 | SessionContext* sessionCtxt = ue_ctxt->getSessionContext(); |
| 59 | BearerContext* bearerCtxt = sessionCtxt->getBearerContext(); |
| 60 | g_ds_msg.bearer_id = bearerCtxt->getBearerId(); |
| 61 | |
| 62 | memcpy(&(g_ds_msg.s11_sgw_c_fteid), &(sessionCtxt->getS11SgwCtrlFteid().fteid_m), sizeof(struct fteid)); |
| 63 | |
| 64 | /* Send message to S11app in S11q*/ |
| 65 | cmn::ipc::IpcAddress destAddr; |
| 66 | destAddr.u32 = TipcServiceInstance::s11AppInstanceNum_c; |
| 67 | |
| 68 | mmeIpcIf_g->dispatchIpcMsg((char *) &g_ds_msg, sizeof(g_ds_msg), destAddr); |
| 69 | |
| 70 | log_msg(LOG_DEBUG, "Leaving delete_session_req \n"); |
| 71 | ProcedureStats::num_of_del_session_req_sent ++; |
| 72 | return ActStatus::PROCEED; |
| 73 | |
| 74 | } |
| 75 | #if 0 |
| 76 | ActStatus ActionHandlers::purge_req(SM::ControlBlock& cb) |
| 77 | { |
| 78 | log_msg(LOG_DEBUG, "Inside purge_req \n"); |
| 79 | UEContext *ue_ctxt = dynamic_cast<UEContext*>(cb.getPermDataBlock()); |
| 80 | |
| 81 | if (ue_ctxt == NULL) |
| 82 | { |
| 83 | log_msg(LOG_DEBUG, "purge_req: ue context is NULL\n"); |
| 84 | return ActStatus::HALT; |
| 85 | } |
| 86 | |
| 87 | s6a_purge_Q_msg g_purge_msg; |
| 88 | |
| 89 | g_purge_msg.ue_idx = ue_ctxt->getContextId(); |
| 90 | memcpy(g_purge_msg.IMSI, ue_ctxt->getIMSIInfo(), BINARY_IMSI_LEN); |
| 91 | |
| 92 | /* Send message to S6app in S6q*/ |
| 93 | mmeS6If_gp->sendMessage_v((char*)(&g_purge_msg), purge_request); |
| 94 | |
| 95 | |
| 96 | log_msg(LOG_DEBUG, "Leaving purge_req \n"); |
| 97 | ProcedureStats::num_of_purge_req_sent ++; |
| 98 | return ActStatus::PROCEED; |
| 99 | |
| 100 | } |
| 101 | #endif |
| 102 | |
| 103 | ActStatus ActionHandlers::process_del_session_resp(SM::ControlBlock& cb) |
| 104 | { |
| 105 | log_msg(LOG_DEBUG, "Inside handle_delete_session_resp \n"); |
| 106 | |
| 107 | UEContext *ue_ctxt = dynamic_cast<UEContext*>(cb.getPermDataBlock()); |
| 108 | if (ue_ctxt == NULL) |
| 109 | { |
| 110 | log_msg(LOG_DEBUG, "delete_session_req: ue context is NULL\n"); |
| 111 | return ActStatus::HALT; |
| 112 | } |
| 113 | |
| 114 | SessionContext* sessionCtxt = ue_ctxt->getSessionContext(); |
| 115 | if (sessionCtxt != NULL) |
| 116 | { |
| 117 | BearerContext* bearerCtxt = sessionCtxt->getBearerContext(); |
| 118 | if (bearerCtxt) |
| 119 | { |
| 120 | SubsDataGroupManager::Instance()->deleteBearerContext( bearerCtxt ); |
| 121 | } |
| 122 | SubsDataGroupManager::Instance()->deleteSessionContext( sessionCtxt ); |
| 123 | } |
| 124 | |
| 125 | ue_ctxt->setSessionContext(NULL); |
| 126 | |
| 127 | log_msg(LOG_DEBUG, "Leaving handle_delete_session_resp \n"); |
| 128 | ProcedureStats::num_of_processed_del_session_resp ++; |
| 129 | return ActStatus::PROCEED; |
| 130 | |
| 131 | } |
| 132 | |
| 133 | #if 0 |
| 134 | ActStatus ActionHandlers::process_pur_resp(SM::ControlBlock& cb) |
| 135 | { |
| 136 | log_msg(LOG_DEBUG, "Inside handle_purge_resp \n"); |
| 137 | |
| 138 | UEContext *ue_ctxt = dynamic_cast<UEContext*>(cb.getPermDataBlock()); |
| 139 | |
| 140 | if (ue_ctxt == NULL) |
| 141 | { |
| 142 | log_msg(LOG_DEBUG, "handle_purge_resp: ue context is NULL \n"); |
| 143 | return ActStatus::HALT; |
| 144 | } |
| 145 | //struct purge_resp_Q_msg *purge_msg = nullptr; |
| 146 | |
| 147 | /*Nothing is been done. Only takes the UE Index |
| 148 | * increment the stats counter and changes the state*/ |
| 149 | |
| 150 | |
| 151 | log_msg(LOG_DEBUG, "Leaving handle_purge_resp for UE-%d.\n", ue_ctxt->getContextId()); |
| 152 | ProcedureStats::num_of_processed_pur_resp ++; |
| 153 | return ActStatus::PROCEED; |
| 154 | |
| 155 | } |
| 156 | #endif |
| 157 | ActStatus ActionHandlers::detach_accept_to_ue(SM::ControlBlock& cb) |
| 158 | { |
| 159 | log_msg(LOG_DEBUG, "Inside send_detach_accept \n"); |
| 160 | |
| 161 | UEContext *ue_ctxt = dynamic_cast<UEContext*>(cb.getPermDataBlock()); |
| 162 | |
| 163 | if (ue_ctxt == NULL) |
| 164 | { |
| 165 | log_msg(LOG_DEBUG, "send_detach_accept: ue context is NULL\n"); |
| 166 | return ActStatus::HALT; |
| 167 | } |
| 168 | |
| 169 | detach_accept_Q_msg detach_accpt; |
| 170 | detach_accpt.msg_type = detach_accept; |
| 171 | detach_accpt.enb_fd = ue_ctxt->getEnbFd(); |
| 172 | detach_accpt.ue_idx = ue_ctxt->getContextID(); |
| 173 | detach_accpt.enb_s1ap_ue_id = ue_ctxt->getS1apEnbUeId(); |
| 174 | |
| 175 | ue_ctxt->setDwnLnkSeqNo(ue_ctxt->getDwnLnkSeqNo()+1); |
| 176 | detach_accpt.dl_seq_no = ue_ctxt->getDwnLnkSeqNo(); |
| 177 | |
| 178 | memcpy(&(detach_accpt.int_key), &(ue_ctxt->getUeSecInfo().secinfo_m.int_key), NAS_INT_KEY_SIZE); |
| 179 | |
| 180 | /* Send message to S11app in S11q*/ |
| 181 | cmn::ipc::IpcAddress destAddr; |
| 182 | destAddr.u32 = TipcServiceInstance::s1apAppInstanceNum_c; |
| 183 | |
| 184 | mmeIpcIf_g->dispatchIpcMsg((char *) &detach_accpt, sizeof(detach_accpt), destAddr); |
| 185 | |
| 186 | MmeContextManagerUtils::deallocateProcedureCtxt(cb, detach_c ); |
| 187 | |
| 188 | MmContext* mmCtxt = ue_ctxt->getMmContext(); |
| 189 | mmCtxt->setMmState( EpsDetached ); |
| 190 | |
| 191 | log_msg(LOG_DEBUG, "Leaving send_detach_accept for UE \n"); |
| 192 | |
| 193 | ProcedureStats::num_of_detach_accept_to_ue_sent ++; |
| 194 | ProcedureStats::num_of_subscribers_attached --; |
| 195 | |
| 196 | return ActStatus::PROCEED; |
| 197 | |
| 198 | } |