MME2 changes - Propped commits from openmme/paging branch. Added scripts
for code gen
Change-Id: Ie55032217232214ac8544ca76ea34335205329e4
diff --git a/src/mme-app/Makefile b/src/mme-app/Makefile
new file mode 100644
index 0000000..499ef09
--- /dev/null
+++ b/src/mme-app/Makefile
@@ -0,0 +1,88 @@
+#
+# Copyright (c) 2019, Infosys Ltd.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+include ../../Makefile.common
+
+CC := g++
+CFLAGS += -Wall -DSTATS -I$(GRPC_ROOT)/include -I$(GRPC_ROOT)/third_party/protobuf/src -std=c++11
+LFLAGS += -L$(GRPC_ROOT)/libs/opt -L$(GRPC_ROOT)/libs/opt/protobuf
+
+ifeq ($(DEBUG),true)
+ CFLAGS += -g
+endif
+ifeq ($(DEBUG),false)
+ CFLAGS += -O3
+endif
+
+LIB_PATH +=-L../common/
+
+LIBS := -lpthread \
+ -lcrypto \
+ -lcmnUtils \
+ -ldatagroupmgr \
+ -ljson \
+ -llog \
+ -linterface \
+ -lipcfwk \
+ -lstatemachinefwk \
+ -lmmeGrpcProtoBuf \
+ -lgrpc++ \
+ -lgrpc \
+ -lgpr \
+ -lprotobuf
+
+SRCDIR := .
+SRCEXT := cpp
+SOURCES := $(shell find $(SRCDIR) -type f -name '*.$(SRCEXT)')
+OBJECTS := $(patsubst $(SRCDIR)/%,$(OBJDIR)/mme-app/%,$(SOURCES:.$(SRCEXT)=.o))
+
+TARGET := $(BINDIR)/mme-app
+
+$(TARGET): $(OBJECTS)
+ @echo "Linking..."
+ @mkdir -p $(BINDIR)
+ $(CC) $(LFLAGS) $^ -o $(TARGET) $(LIB_PATH) $(LIBS)
+
+$(OBJDIR)/mme-app/%.o: $(SRCDIR)/%.$(SRCEXT)
+ echo "Compiling..."
+ @mkdir -p $(OBJDIR)
+ @mkdir -p $(OBJDIR)/mme-app/contextManager
+ @mkdir -p $(OBJDIR)/mme-app/interfaces
+ @mkdir -p $(OBJDIR)/mme-app/msgHandlers
+ @mkdir -p $(OBJDIR)/mme-app/actionHandlers
+ @mkdir -p $(OBJDIR)/mme-app/sec
+ @mkdir -p $(OBJDIR)/mme-app/mmeGrpcServer
+ @mkdir -p $(OBJDIR)/mme-app/mmeStates
+ @mkdir -p $(OBJDIR)/mme-app/utils
+ $(CC) $(CFLAGS) $(INC_DIRS) -c -o $@ $<
+
+all:$(TARGET)
+
+clean:
+ @echo "Cleaning...";
+ -@rm -rf $(OBJDIR)/mme-app $(TARGET)
+
+install:
+ @echo "Installing mme-app"
+ -@mkdir -p $(TARGET_DIR)/bin
+ -@cp $(TARGET) $(TARGET_DIR)/bin
+ -@cp run.sh $(TARGET_DIR)
+ -@cp stop.sh $(TARGET_DIR)
+ -@mkdir -p $(TARGET_DIR)/conf
+ -@cp conf/*.json $(TARGET_DIR)/conf/
+
+.PHONY: clean
+
diff --git a/src/mme-app/actionHandlers/attachActionHandlers.cpp b/src/mme-app/actionHandlers/attachActionHandlers.cpp
new file mode 100644
index 0000000..78b8761
--- /dev/null
+++ b/src/mme-app/actionHandlers/attachActionHandlers.cpp
@@ -0,0 +1,980 @@
+/*
+ * Copyright 2019-present Infosys Limited
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/******************************************************************************
+ *
+ * This file has both generated and manual code.
+ *
+ * File template used for code generation:
+ * <TOP-DIR/scripts/SMCodeGen/templates/stateMachineTmpls/actionHandlers.cpp.tt>
+ *
+ ******************************************************************************/
+
+#include <3gpp_24008.h>
+#include <typeinfo>
+#include "actionHandlers/actionHandlers.h"
+#include "controlBlock.h"
+#include "msgType.h"
+#include "contextManager/subsDataGroupManager.h"
+#include "contextManager/dataBlocks.h"
+#include "procedureStats.h"
+#include "log.h"
+#include "secUtils.h"
+#include "state.h"
+#include <string.h>
+#include <sstream>
+#include <smTypes.h>
+#include <cstring>
+#include <event.h>
+#include <ipcTypes.h>
+#include <tipcTypes.h>
+#include <msgBuffer.h>
+#include <interfaces/mmeIpcInterface.h>
+#include <utils/mmeCommonUtils.h>
+#include <utils/mmeContextManagerUtils.h>
+
+using namespace SM;
+using namespace mme;
+using namespace cmn::utils;
+
+extern MmeIpcInterface* mmeIpcIf_g;
+
+ActStatus ActionHandlers::validate_imsi_in_ue_context(ControlBlock& cb)
+{
+ UEContext* ueCtxt_p = static_cast<UEContext*>(cb.getPermDataBlock());
+ if (ueCtxt_p == NULL)
+ {
+ log_msg(LOG_DEBUG, "send_identity_request_to_ue: ue context is NULL \n");
+ return ActStatus::HALT;
+ }
+
+ if (ueCtxt_p->getImsi().isValid())
+ {
+ SM::Event evt(Event_e::IMSI_VALIDATION_SUCCESS, NULL);
+ cb.addEventToProcQ(evt);
+ }
+ else
+ {
+ // TODO: If known GUTI, IMSI_VALIDATION_FAILURE_KNOWN_GUTI to trigger id req to UE
+ // If unknown GUTI, IMSI_VALIDATION_FAILURE_UNKNOWN_GUTI to query old mme
+ // when s10 is supported in MME
+ SM::Event evt(Event_e::IMSI_VALIDATION_FAILURE, NULL);
+ cb.addEventToProcQ(evt);
+ }
+ return ActStatus::PROCEED;
+}
+
+ActStatus ActionHandlers::send_identity_request_to_ue(ControlBlock& cb)
+{
+ log_msg(LOG_DEBUG, "Inside send_identity_request_to_ue \n");
+
+ UEContext* ueCtxt_p = static_cast<UEContext*>(cb.getPermDataBlock());
+ if (ueCtxt_p == NULL)
+ {
+ log_msg(LOG_DEBUG, "send_identity_request_to_ue: ue context is NULL \n");
+ return ActStatus::HALT;
+ }
+
+ struct attachIdReq_info idReqMsg;
+ idReqMsg.msg_type = id_request;
+ idReqMsg.enb_fd = ueCtxt_p->getEnbFd();
+ idReqMsg.s1ap_enb_ue_id = ueCtxt_p->getS1apEnbUeId();
+ idReqMsg.ue_idx = ueCtxt_p->getContextID();
+ idReqMsg.ue_type = ID_IMSI;
+
+ cmn::ipc::IpcAddress destAddr;
+ destAddr.u32 = TipcServiceInstance::s1apAppInstanceNum_c;
+
+ mmeIpcIf_g->dispatchIpcMsg((char *) &idReqMsg, sizeof(idReqMsg), destAddr);
+
+ return ActStatus::PROCEED;
+}
+
+ActStatus ActionHandlers::process_identity_response(ControlBlock& cb)
+{
+ log_msg(LOG_DEBUG, "Inside process_identity_response \n");
+
+ UEContext *ueCtxt_p = static_cast<UEContext*>(cb.getPermDataBlock());
+ if (ueCtxt_p == NULL)
+ {
+ log_msg(LOG_DEBUG, "process_identity_response: ue context is NULL \n");
+ return ActStatus::HALT;
+ }
+
+ MsgBuffer* msgBuf = static_cast<MsgBuffer*>(cb.getMsgData());
+ if (msgBuf == NULL)
+ {
+ log_msg(LOG_DEBUG, "process_identity_response: msgBuf is NULL \n");
+ return ActStatus::HALT;
+ }
+
+ const s1_incoming_msg_data_t* s1_msg_data = static_cast<const s1_incoming_msg_data_t*>(msgBuf->getDataPointer());
+ if (s1_msg_data == NULL)
+ {
+ log_msg(LOG_DEBUG, "process_identity_response: s1MsgData is NULL \n");
+ return ActStatus::HALT;
+ }
+
+ const struct identityResp_Q_msg &id_resp = s1_msg_data->msg_data.identityResp_Q_msg_m;
+ if(SUCCESS != id_resp.status)
+ {
+ log_msg(LOG_DEBUG, "process_identity_response: ID Response Failure NULL \n");
+ return ActStatus::HALT;
+ }
+
+ uint8_t imsi[BINARY_IMSI_LEN] = {0};
+ memcpy( imsi, id_resp.IMSI, BINARY_IMSI_LEN );
+
+ // Only upper nibble of first octect in imsi need to be considered
+ // Changing the lower nibble to 0x0f for handling
+ uint8_t first = imsi[0] >> 4;
+ imsi[0] = (uint8_t)(( first << 4 ) | 0x0f );
+
+ DigitRegister15 IMSIInfo;
+ IMSIInfo.convertFromBcdArray(imsi);
+ ueCtxt_p->setImsi(IMSIInfo);
+
+ SubsDataGroupManager::Instance()->addimsikey(ueCtxt_p->getImsi(), ueCtxt_p->getContextID());
+
+ return ActStatus::PROCEED;
+}
+
+
+ActStatus ActionHandlers::send_air_to_hss(SM::ControlBlock& cb)
+{
+ log_msg(LOG_DEBUG, "Inside send_air_to_hss \n");
+
+ UEContext *ue_ctxt = dynamic_cast<UEContext*>(cb.getPermDataBlock());
+ if (ue_ctxt == NULL)
+ {
+ log_msg(LOG_DEBUG, "send_air_to_hss: ue context is NULL \n");
+ return ActStatus::HALT;
+ }
+
+ s6a_Q_msg s6a_req;
+
+ memset(s6a_req.imsi, '\0', sizeof(s6a_req.imsi));
+ ue_ctxt->getImsi().getImsiDigits(s6a_req.imsi);
+
+ memcpy(&(s6a_req.tai), &(ue_ctxt->getTai().tai_m), sizeof(struct TAI));
+
+ s6a_req.ue_idx = ue_ctxt->getContextID();
+ s6a_req.msg_type = auth_info_request;
+
+ cmn::ipc::IpcAddress destAddr;
+ destAddr.u32 = TipcServiceInstance::s6AppInstanceNum_c;
+
+ mmeIpcIf_g->dispatchIpcMsg((char *) &s6a_req, sizeof(s6a_req), destAddr);
+
+ ProcedureStats::num_of_air_sent ++;
+ log_msg(LOG_DEBUG, "Leaving send_air_to_hss \n");
+
+ return ActStatus::PROCEED;
+
+}
+
+ActStatus ActionHandlers::send_ulr_to_hss(SM::ControlBlock& cb)
+{
+ log_msg(LOG_DEBUG, "Inside send_ulr_to_hss \n");
+
+ UEContext *ue_ctxt = dynamic_cast<UEContext*>(cb.getPermDataBlock());
+ if (ue_ctxt == NULL)
+ {
+ log_msg(LOG_DEBUG, "send_ulr_to_hss: ue context is NULL \n");
+ return ActStatus::HALT;
+ }
+
+ s6a_Q_msg s6a_req;
+
+ memset(s6a_req.imsi, '\0', sizeof(s6a_req.imsi));
+ ue_ctxt->getImsi().getImsiDigits(s6a_req.imsi);
+
+ memcpy(&(s6a_req.tai), &(ue_ctxt->getTai().tai_m), sizeof(struct TAI));
+
+ s6a_req.ue_idx = ue_ctxt->getContextID();
+ s6a_req.msg_type = update_loc_request;
+
+ cmn::ipc::IpcAddress destAddr;
+ destAddr.u32 = TipcServiceInstance::s6AppInstanceNum_c;
+
+ mmeIpcIf_g->dispatchIpcMsg((char *) &s6a_req, sizeof(s6a_req), destAddr);
+
+ ProcedureStats::num_of_ulr_sent ++;
+ log_msg(LOG_DEBUG, "Leaving send_ulr_to_hss \n");
+
+ return ActStatus::PROCEED;
+}
+
+
+ActStatus ActionHandlers::process_aia(SM::ControlBlock& cb)
+{
+ log_msg(LOG_DEBUG, "Inside handle_aia \n");
+
+ UEContext *ue_ctxt = dynamic_cast<UEContext*>(cb.getPermDataBlock());
+ if (ue_ctxt == NULL)
+ {
+ log_msg(LOG_DEBUG, "handle_aia: ue context is NULL \n");
+ return ActStatus::HALT;
+ }
+
+ MsgBuffer* msgBuf = static_cast<MsgBuffer*>(cb.getMsgData());
+
+ if (msgBuf == NULL)
+ return ActStatus::HALT;
+
+ const s6_incoming_msg_data_t* msgData_p = static_cast<const s6_incoming_msg_data_t*>(msgBuf->getDataPointer());
+
+ ue_ctxt->setAiaSecInfo(E_utran_sec_vector(msgData_p->msg_data.aia_Q_msg_m.sec));
+
+ ProcedureStats::num_of_processed_aia ++;
+ log_msg(LOG_DEBUG, "Leaving handle_aia \n");
+
+ return ActStatus::PROCEED;
+}
+
+ActStatus ActionHandlers::process_ula(SM::ControlBlock& cb)
+{
+ log_msg(LOG_DEBUG, "Inside handle_ula \n");
+
+ UEContext *ue_ctxt = dynamic_cast<UEContext*>(cb.getPermDataBlock());
+ if (ue_ctxt == NULL)
+ {
+ log_msg(LOG_DEBUG, "handle_ula: ue context is NULL \n");
+ return ActStatus::HALT;
+ }
+
+ SessionContext* sessionCtxt = ue_ctxt->getSessionContext();
+ if( sessionCtxt == NULL )
+ {
+ log_msg(LOG_ERROR, "Failed to retrieve Session Context for UE IDX %d\n", cb.getCBIndex());
+ return ActStatus::HALT;
+ }
+
+ MsgBuffer* msgBuf = static_cast<MsgBuffer*>(cb.getMsgData());
+
+ if (msgBuf == NULL)
+ return ActStatus::HALT;
+
+ const s6_incoming_msg_data_t* s6_msg_data = static_cast<const s6_incoming_msg_data_t*>(msgBuf->getDataPointer());
+ const struct ula_Q_msg &ula_msg = s6_msg_data->msg_data.ula_Q_msg_m;
+
+ sessionCtxt->setApnConfigProfileCtxId(ula_msg.apn_config_profile_ctx_id);
+ DigitRegister15 ueMSISDN;
+ ueMSISDN.convertFromBcdArray( reinterpret_cast<const uint8_t*>( ula_msg.MSISDN ));
+ ue_ctxt->setMsisdn(ueMSISDN);
+ ue_ctxt->setRauTauTimer(ula_msg.RAU_TAU_timer);
+ ue_ctxt->setSubscriptionStatus(ula_msg.subscription_status);
+ ue_ctxt->setNetAccessMode(ula_msg.net_access_mode);
+ ue_ctxt->setAccessRestrictionData(ula_msg.access_restriction_data);
+
+ struct AMBR ambr;
+ ambr.max_requested_bw_dl = ula_msg.max_requested_bw_dl;
+ ambr.max_requested_bw_ul = ula_msg.max_requested_bw_ul;
+
+ ue_ctxt->setAmbr(Ambr(ambr));
+
+ ProcedureStats::num_of_processed_ula ++;
+ log_msg(LOG_DEBUG, "Leaving handle_ula_v \n");
+
+ return ActStatus::PROCEED;
+}
+
+ActStatus ActionHandlers::auth_req_to_ue(SM::ControlBlock& cb)
+{
+ UEContext *ue_ctxt = dynamic_cast<UEContext*>(cb.getPermDataBlock());
+
+ if (ue_ctxt == NULL)
+ {
+ log_msg(LOG_DEBUG, "auth_req_to_ue: ue context is NULL \n");
+ return ActStatus::HALT;
+ }
+
+ authreq_info authreq;
+ authreq.msg_type = auth_request;
+ authreq.ue_idx = ue_ctxt->getContextID();
+ authreq.enb_fd = ue_ctxt->getEnbFd();
+ authreq.enb_s1ap_ue_id = ue_ctxt->getS1apEnbUeId();
+
+ ue_ctxt->setDwnLnkSeqNo(0);
+
+ E_UTRAN_sec_vector *secVect = const_cast<E_UTRAN_sec_vector*>(ue_ctxt->getAiaSecInfo().AiaSecInfo_mp);
+
+ secinfo& secInfo = const_cast<secinfo&>(ue_ctxt->getUeSecInfo().secinfo_m);
+
+ SecUtils::create_integrity_key(secVect->kasme.val, secInfo.int_key);
+
+ memcpy(&(authreq.rand), &(secVect->rand.val), NAS_RAND_SIZE);
+ memcpy(&(authreq.autn), &(secVect->autn.val), NAS_AUTN_SIZE);
+
+ cmn::ipc::IpcAddress destAddr;
+ destAddr.u32 = TipcServiceInstance::s1apAppInstanceNum_c;
+
+ mmeIpcIf_g->dispatchIpcMsg((char *) &authreq, sizeof(authreq), destAddr);
+
+
+ ProcedureStats::num_of_auth_req_to_ue_sent ++;
+ log_msg(LOG_DEBUG, "Leaving auth_req_to_ue_v \n");
+
+ return ActStatus::PROCEED;
+}
+
+ActStatus ActionHandlers::auth_response_validate(SM::ControlBlock& cb)
+{
+ log_msg(LOG_DEBUG, "Inside auth_response_validate \n");
+ SM::ControlBlock* controlBlk_p = SubsDataGroupManager::Instance()->findControlBlock(cb.getCBIndex());
+
+ UEContext *ue_ctxt = dynamic_cast<UEContext*>(cb.getPermDataBlock());
+ if (ue_ctxt == NULL)
+ {
+ log_msg(LOG_DEBUG, "auth_response_validate: ue context or procedure ctxt is NULL \n");
+ return ActStatus::HALT;
+ }
+
+ MsgBuffer* msgBuf = static_cast<MsgBuffer*>(cb.getMsgData());
+
+ if (msgBuf == NULL)
+ return ActStatus::HALT;
+
+ const s1_incoming_msg_data_t* s1_msg_data = static_cast<const s1_incoming_msg_data_t*>(msgBuf->getDataPointer());
+ const struct authresp_Q_msg &auth_resp = s1_msg_data->msg_data.authresp_Q_msg_m;
+
+ /*Check the state*/
+ if(SUCCESS != auth_resp.status) {
+ log_msg(LOG_ERROR, "eNB authentication failure for UE-%d.\n", ue_ctxt->getContextID());
+ if(auth_resp.auts.len == 0)
+ {
+ log_msg(LOG_ERROR,"No AUTS.Not Synch Failure\n");
+ SM::Event evt(Event_e::AUTH_RESP_FAILURE,NULL);
+ controlBlk_p->addEventToProcQ(evt);
+ }
+ else
+ {
+ log_msg(LOG_INFO,"AUTS recvd. Synch failure. send AIR\n");
+ SM::Event evt(Event_e::AUTH_RESP_SYNC_FAILURE,NULL);
+ controlBlk_p->addEventToProcQ(evt);
+ }
+ }
+ else{
+ log_msg(LOG_INFO,"Auth response validation success. Proceeding to Sec mode Command\n");
+ SM::Event evt(Event_e::AUTH_RESP_SUCCESS,NULL);
+ controlBlk_p->addEventToProcQ(evt);
+
+ }
+ //TODO: XRES comparison
+ #if 0
+ log_msg(LOG_ERROR, "stage 3 processing memcmp - %d, %d, %d", &(ue_ctxt->getaiaSecInfo().AiaSecInfo_mp->xres.val),
+ &(auth_resp->res.val),
+ auth_resp->res.len);
+ if(memcmp(&(ue_ctxt->getaiaSecInfo().AiaSecInfo_mp->xres.val),
+ &(auth_resp->res.val),
+ auth_resp->res.len) != 0) {
+ log_msg(LOG_ERROR, "Invalid auth result received for UE %d",
+ auth_resp->ue_idx);
+ return E_FAIL;//report failure
+ }
+ #endif
+
+ ProcedureStats::num_of_processed_auth_response ++;
+ log_msg(LOG_DEBUG, "Leaving auth_response_validate \n");
+
+ return ActStatus::PROCEED;
+}
+
+ActStatus ActionHandlers::send_auth_reject(SM::ControlBlock& cb)
+{
+ log_msg(LOG_DEBUG, "Inside send_auth_reject \n");
+
+ UEContext *ue_ctxt = dynamic_cast<UEContext*>(cb.getPermDataBlock());
+ if (ue_ctxt == NULL)
+ {
+ log_msg(LOG_DEBUG, "send_auth_reject: ue context is NULL \n");
+ return ActStatus::HALT;
+ }
+ return ActStatus::HALT;
+}
+
+
+ActStatus ActionHandlers::sec_mode_cmd_to_ue(SM::ControlBlock& cb)
+{
+ log_msg(LOG_DEBUG, "Inside sec_mode_cmd_to_ue \n");
+
+ UEContext *ue_ctxt = dynamic_cast<UEContext*>(cb.getPermDataBlock());
+ if (ue_ctxt == NULL)
+ {
+ log_msg(LOG_DEBUG, "sec_mode_cmd_to_ue: ue context is NULL \n");
+ return ActStatus::HALT;
+ }
+ sec_mode_Q_msg sec_mode_msg;
+ sec_mode_msg.msg_type = sec_mode_command;
+ sec_mode_msg.ue_idx = ue_ctxt->getContextID();
+ sec_mode_msg.enb_fd = ue_ctxt->getEnbFd();
+ sec_mode_msg.enb_s1ap_ue_id = ue_ctxt->getS1apEnbUeId();
+
+ memcpy(&(sec_mode_msg.ue_network), &(ue_ctxt->getUeNetCapab().ue_net_capab_m),
+ sizeof(struct UE_net_capab));
+
+ memcpy(&(sec_mode_msg.ms_net_capab), &(ue_ctxt->getMsNetCapab().ms_net_capab_m),
+ sizeof(struct MS_net_capab));
+
+ memcpy(&(sec_mode_msg.key), &(ue_ctxt->getAiaSecInfo().AiaSecInfo_mp->kasme),
+ sizeof(struct KASME));
+
+ memcpy(&(sec_mode_msg.int_key), &(ue_ctxt->getUeSecInfo().secinfo_m.int_key),
+ NAS_INT_KEY_SIZE);
+
+ sec_mode_msg.dl_seq_no = ue_ctxt->getDwnLnkSeqNo();
+ ue_ctxt->setDwnLnkSeqNo(sec_mode_msg.dl_seq_no + 1);
+
+ cmn::ipc::IpcAddress destAddr;
+ destAddr.u32 = TipcServiceInstance::s1apAppInstanceNum_c;
+
+ mmeIpcIf_g->dispatchIpcMsg((char *) &sec_mode_msg, sizeof(sec_mode_msg), destAddr);
+
+ ProcedureStats::num_of_sec_mode_cmd_to_ue_sent ++;
+ log_msg(LOG_DEBUG, "Leaving sec_mode_cmd_to_ue \n");
+
+ return ActStatus::PROCEED;
+}
+
+
+ActStatus ActionHandlers::process_sec_mode_resp(SM::ControlBlock& cb)
+{
+ log_msg(LOG_DEBUG, "Inside handle_sec_mode_resp \n");
+
+ UEContext *ue_ctxt = dynamic_cast<UEContext*>(cb.getPermDataBlock());
+ if (ue_ctxt == NULL)
+ {
+ log_msg(LOG_DEBUG, "handle_sec_mode_resp: ue context is NULL \n");
+ return ActStatus::HALT;
+ }
+
+ MsgBuffer* msgBuf = static_cast<MsgBuffer*>(cb.getMsgData());
+
+ if (msgBuf == NULL)
+ return ActStatus::HALT;
+
+ const s1_incoming_msg_data_t* s1_msg_data = static_cast<const s1_incoming_msg_data_t*>(msgBuf->getDataPointer());
+ const secmode_resp_Q_msg &secmode_resp = s1_msg_data->msg_data.secmode_resp_Q_msg_m;
+ if(SUCCESS == secmode_resp.status)
+ {
+ log_msg(LOG_INFO, "Sec mode complete rcv. UE - %d.\n",
+ ue_ctxt->getContextID());
+
+ }
+ else
+ {
+ log_msg(LOG_INFO, "Sec mode failed. UE %d", ue_ctxt->getContextID());
+ }
+
+ ProcedureStats::num_of_processed_sec_mode_resp ++;
+ log_msg(LOG_DEBUG, "Leaving handle_sec_mode_resp \n");
+
+ return ActStatus::PROCEED;
+}
+
+ActStatus ActionHandlers::check_esm_info_req_required(SM::ControlBlock& cb)
+{
+ log_msg(LOG_DEBUG, "Inside check_esm_info_req_required \n");
+
+ UEContext *ue_ctxt = dynamic_cast<UEContext*>(cb.getPermDataBlock());
+ if (ue_ctxt == NULL)
+ {
+ log_msg(LOG_DEBUG, "check_esm_info_req_required: ue context is NULL \n");
+ return ActStatus::HALT;
+ }
+
+ MmeProcedureCtxt* procedure_p = dynamic_cast<MmeProcedureCtxt*>(cb.getTempDataBlock());
+ if (procedure_p == NULL)
+ {
+ log_msg(LOG_DEBUG, "check_esm_info_req_required: procedure context is NULL \n");
+ return ActStatus::HALT;
+ }
+ SessionContext* sessionCtxt = SubsDataGroupManager::Instance()->getSessionContext();
+ if( sessionCtxt == NULL )
+ {
+ log_msg(LOG_ERROR, "Failed to allocate Session Context for UE IDX %d\n", cb.getCBIndex());
+
+ return ActStatus::HALT;
+ }
+ BearerContext* bearerCtxt_p = SubsDataGroupManager::Instance()->getBearerContext();
+ if( bearerCtxt_p == NULL )
+ {
+ log_msg(LOG_ERROR, "Failed to allocate Bearer context for UE IDx %d\n", cb.getCBIndex());
+
+ return ActStatus::HALT;
+ }
+
+ bearerCtxt_p->setBearerId(5);
+ sessionCtxt->setPti(procedure_p->getPti());
+ sessionCtxt->setBearerContext( bearerCtxt_p );
+ ue_ctxt->setSessionContext(sessionCtxt);
+
+ if (procedure_p->getEsmInfoTxRequired() == false)
+ {
+ // hardcoding APN, if ESM info request is not to be sent
+ std::string apnName = "apn1";
+ struct apn_name apn = {0};
+ apn.len = apnName.length() + 1;
+ apn.val[0] = apnName.length();
+ memcpy(&(apn.val[1]), apnName.c_str(), apnName.length());
+
+ sessionCtxt->setAccessPtName(Apn_name(apn));
+
+ SM::Event evt(Event_e::ESM_INFO_NOT_REQUIRED, NULL);
+ cb.addEventToProcQ(evt);
+ }
+ else
+ {
+ SM::Event evt(Event_e::ESM_INFO_REQUIRED, NULL);
+ cb.addEventToProcQ(evt);
+ }
+
+ return ActStatus::PROCEED;
+}
+
+ActStatus ActionHandlers::send_esm_info_req_to_ue(SM::ControlBlock& cb)
+{
+ UEContext *ue_ctxt = dynamic_cast<UEContext*>(cb.getPermDataBlock());
+
+ if (ue_ctxt == NULL)
+ {
+ log_msg(LOG_DEBUG, "send_esm_info_req_to_ue: ue context is NULL \n");
+ return ActStatus::HALT;
+ }
+
+ SessionContext *sessionCtxt = ue_ctxt->getSessionContext();
+ esm_req_Q_msg esmreq;
+ esmreq.msg_type = esm_info_request;
+ esmreq.ue_idx = ue_ctxt->getContextID();
+ esmreq.enb_fd = ue_ctxt->getEnbFd();
+ esmreq.enb_s1ap_ue_id = ue_ctxt->getS1apEnbUeId();
+ esmreq.pti = sessionCtxt->getPti();
+ esmreq.dl_seq_no = ue_ctxt->getDwnLnkSeqNo();
+ memcpy(&(esmreq.int_key), &((ue_ctxt->getUeSecInfo().secinfo_m).int_key),
+ NAS_INT_KEY_SIZE);
+ ue_ctxt->setDwnLnkSeqNo(esmreq.dl_seq_no+1);
+
+ cmn::ipc::IpcAddress destAddr;
+ destAddr.u32 = TipcServiceInstance::s1apAppInstanceNum_c;
+
+ mmeIpcIf_g->dispatchIpcMsg((char *) &esmreq, sizeof(esmreq), destAddr);
+
+ log_msg(LOG_DEBUG, "Leaving send_esm_info_req_to_ue \n");
+
+ return ActStatus::PROCEED;
+}
+
+ActStatus ActionHandlers::process_esm_info_resp(SM::ControlBlock& cb)
+{
+ UEContext *ue_ctxt = dynamic_cast<UEContext*>(cb.getPermDataBlock());
+ if (ue_ctxt == NULL)
+ {
+ log_msg(LOG_DEBUG, "handle_ula: ue context is NULL \n");
+ return ActStatus::HALT;
+ }
+
+ SessionContext* sessionCtxt = ue_ctxt->getSessionContext();
+ if( sessionCtxt == NULL )
+ {
+ log_msg(LOG_ERROR, "Failed to allocate Session "
+ "Context for UE IDX %d\n", cb.getCBIndex());
+ return ActStatus::HALT;
+ }
+
+ MsgBuffer* msgBuf = static_cast<MsgBuffer*>(cb.getMsgData());
+
+ if (msgBuf == NULL)
+ return ActStatus::HALT;
+
+ const s1_incoming_msg_data_t* s1_msg_data = static_cast<const s1_incoming_msg_data_t*>(msgBuf->getDataPointer());
+ const struct esm_resp_Q_msg &esm_res =s1_msg_data->msg_data.esm_resp_Q_msg_m;
+
+ sessionCtxt->setAccessPtName(Apn_name(esm_res.apn));
+
+ return ActStatus::PROCEED;
+}
+
+ActStatus ActionHandlers::cs_req_to_sgw(SM::ControlBlock& cb)
+{
+ log_msg(LOG_DEBUG, "Inside cs_req_to_sgw \n");
+
+ UEContext *ue_ctxt = dynamic_cast<UEContext*>(cb.getPermDataBlock());
+ MmeProcedureCtxt *procCtxt = dynamic_cast<MmeProcedureCtxt*>(cb.getTempDataBlock());
+ if (ue_ctxt == NULL || procCtxt == NULL)
+ {
+ log_msg(LOG_DEBUG, "handle_ula: UE context or Procedure Context is NULL \n");
+
+ return ActStatus::HALT;
+ }
+
+ SessionContext* sessionCtxt = ue_ctxt->getSessionContext();
+ if( sessionCtxt == NULL )
+ {
+ log_msg(LOG_ERROR, "Failed to allocate Session Context for UE IDX %d\n", cb.getCBIndex());
+
+ return ActStatus::HALT;
+ }
+
+ BearerContext* bearerCtxt_p = sessionCtxt->getBearerContext();
+ if( bearerCtxt_p == NULL )
+ {
+ log_msg(LOG_ERROR, "Failed to allocate Bearer context for UE IDx %d\n", cb.getCBIndex());
+
+ return ActStatus::HALT;
+ }
+
+ struct CS_Q_msg cs_msg;
+ cs_msg.msg_type = create_session_request;
+ cs_msg.ue_idx = ue_ctxt->getContextID();
+
+ const DigitRegister15& ueImsi = ue_ctxt->getImsi();
+ ueImsi.convertToBcdArray( cs_msg.IMSI );
+
+ /*uint8_t plmn_id[3] = {0};
+ memcpy(plmn_id, ue_ctxt->gettai().tai_m.plmn_id.idx, 3);
+ if ((plmn_id[1] & 0xF0) == 0xF0)
+ plmn_id[1] = plmn_id[1] & 0x0F;
+
+ const Apn_name &apnName = sessionCtxt->getaccessPtName();
+ std::string apnStr((const char *)apnName.apnname_m.val, apnName.apnname_m.len);
+
+ stringstream formattedApn;
+ formattedApn << apnStr <<
+ "\x6" << "mnc" <<
+ ((plmn_id[1] & 0xF0) >> 4) <<
+ (plmn_id[2] & 0x0F) <<
+ ((plmn_id[2] & 0xF0) >> 4) <<
+ "\x6" << "mcc" <<
+ (plmn_id[0] & 0x0F) <<
+ ((plmn_id[0] & 0xF0) >> 4) <<
+ ((plmn_id[1] & 0x0F)) <<
+ "\x4" << "gprs";
+
+ uint32_t formattedApnLen = formattedApn.str().length();
+ cs_msg.apn.len = formattedApnLen + 1;
+ cs_msg.apn.val[0] = apnStr.length();
+ memcpy(&cs_msg.apn.val[1], formattedApn.str().c_str(),
+ formattedApn.str().length()); */
+
+ const Apn_name &apnName = sessionCtxt->getAccessPtName();
+ memcpy(&(cs_msg.apn), &(apnName.apnname_m), sizeof(struct apn_name));
+ memcpy(&(cs_msg.tai), &(ue_ctxt->getTai().tai_m), sizeof(struct TAI));
+ memcpy(&(cs_msg.utran_cgi), &(ue_ctxt->getUtranCgi().cgi_m), sizeof(struct CGI));
+ memcpy(&(cs_msg.pco_options[0]), procCtxt->getPcoOptions(),sizeof(cs_msg.pco_options));
+
+ const AMBR& ambr = ue_ctxt->getAmbr().ambr_m;
+
+ cs_msg.max_requested_bw_dl = ambr.max_requested_bw_dl;
+ cs_msg.max_requested_bw_ul = ambr.max_requested_bw_ul;
+
+ memset(cs_msg.MSISDN, 0, BINARY_IMSI_LEN);
+
+ const DigitRegister15& ueMSISDN = ue_ctxt->getMsisdn();
+ ueMSISDN.convertToBcdArray(cs_msg.MSISDN);
+
+ cmn::ipc::IpcAddress destAddr;
+ destAddr.u32 = TipcServiceInstance::s11AppInstanceNum_c;
+
+ mmeIpcIf_g->dispatchIpcMsg((char *) &cs_msg, sizeof(cs_msg), destAddr);
+
+ ProcedureStats::num_of_cs_req_to_sgw_sent ++;
+ log_msg(LOG_DEBUG, "Leaving cs_req_to_sgw \n");
+
+ return ActStatus::PROCEED;
+}
+
+ActStatus ActionHandlers::process_cs_resp(SM::ControlBlock& cb)
+{
+ log_msg(LOG_DEBUG, "Entering handle_cs_resp \n");
+
+ UEContext *ue_ctxt = dynamic_cast<UEContext*>(cb.getPermDataBlock());
+ if (ue_ctxt == NULL)
+ {
+ log_msg(LOG_DEBUG, "handle_cs_resp: ue context is NULL \n");
+ return ActStatus::HALT;
+ }
+
+ SessionContext* sessionCtxt = ue_ctxt->getSessionContext();
+ if (sessionCtxt == NULL)
+ {
+ log_msg(LOG_DEBUG, "handle_cs_resp: session ctxt is NULL \n");
+ return ActStatus::HALT;
+ }
+
+ MsgBuffer* msgBuf = static_cast<MsgBuffer*>(cb.getMsgData());
+
+ if (msgBuf == NULL)
+ return ActStatus::HALT;
+
+ const gtp_incoming_msg_data_t* gtp_msg_data= static_cast<const gtp_incoming_msg_data_t*>(msgBuf->getDataPointer());
+ const struct csr_Q_msg& csr_info = gtp_msg_data->msg_data.csr_Q_msg_m;
+
+ BearerContext* bearerCtxt = sessionCtxt->getBearerContext();
+ if( bearerCtxt == NULL )
+ {
+ log_msg(LOG_ERROR, "Failed to retrive Bearer context for UE IDx %d\n", cb.getCBIndex());
+
+ return ActStatus::HALT;
+ }
+
+ sessionCtxt->setS11SgwCtrlFteid(Fteid(csr_info.s11_sgw_fteid));
+ sessionCtxt->setS5S8PgwCtrlFteid(Fteid(csr_info.s5s8_pgwc_fteid));
+
+ bearerCtxt->setS1uSgwUserFteid(Fteid(csr_info.s1u_sgw_fteid));
+ bearerCtxt->setS5S8PgwUserFteid(Fteid(csr_info.s5s8_pgwu_fteid));
+
+ sessionCtxt->setPdnAddr(Paa(csr_info.pdn_addr));
+
+ ProcedureStats::num_of_processed_cs_resp ++;
+ log_msg(LOG_DEBUG, "Leaving handle_cs_resp \n");
+
+ return ActStatus::PROCEED;
+}
+
+ActStatus ActionHandlers::send_init_ctxt_req_to_ue(SM::ControlBlock& cb)
+{
+ log_msg(LOG_DEBUG, "Inside send_init_ctxt_req_to_ue \n");
+
+ UEContext *ue_ctxt = dynamic_cast<UEContext*>(cb.getPermDataBlock());
+ if (ue_ctxt == NULL )
+ {
+ log_msg(LOG_DEBUG, "send_init_ctxt_req_to_ue: ue context is NULL \n");
+ return ActStatus::HALT;
+ }
+
+ MmeProcedureCtxt* procedure_p = dynamic_cast<MmeProcedureCtxt*>(cb.getTempDataBlock());
+ if (procedure_p == NULL)
+ {
+ log_msg(LOG_DEBUG, "send_init_ctxt_req_to_ue: procedure context is NULL \n");
+ return ActStatus::HALT;
+ }
+
+ if (procedure_p->getAttachType() == imsiAttach_c ||
+ procedure_p->getAttachType() == unknownGutiAttach_c)
+ {
+ uint32_t mTmsi = MmeCommonUtils::allocateMtmsi();
+ if (mTmsi == 0)
+ {
+ log_msg(LOG_DEBUG, "send_init_ctxt_req_to_ue: Failed to allocate mTmsi \n");
+ return ActStatus::HALT;
+ }
+
+ ue_ctxt->setMtmsi(mTmsi);
+
+ // TODO: Should this be done here or attach_done method
+ SubsDataGroupManager::Instance()->addmTmsikey(mTmsi, ue_ctxt->getContextID());
+ }
+
+ SessionContext* sessionCtxt = ue_ctxt->getSessionContext();
+ if (sessionCtxt == NULL)
+ {
+ log_msg(LOG_DEBUG, "send_init_ctxt_req_to_ue: session ctxt is NULL \n");
+ return ActStatus::HALT;
+ }
+
+ unsigned int nas_count = 0;
+ E_UTRAN_sec_vector* secVect = const_cast<E_UTRAN_sec_vector*>(ue_ctxt->getAiaSecInfo().AiaSecInfo_mp);
+ secinfo& secInfo = const_cast<secinfo&>(ue_ctxt->getUeSecInfo().secinfo_m);
+
+ SecUtils::create_kenb_key(secVect->kasme.val, secInfo.kenb_key, nas_count);
+
+ init_ctx_req_Q_msg icr_msg;
+ icr_msg.msg_type = init_ctxt_request;
+ icr_msg.ue_idx = ue_ctxt->getContextID();
+ icr_msg.enb_fd = ue_ctxt->getEnbFd();
+ icr_msg.enb_s1ap_ue_id = ue_ctxt->getS1apEnbUeId();
+
+ icr_msg.exg_max_dl_bitrate = (ue_ctxt->getAmbr().ambr_m).max_requested_bw_dl;
+ icr_msg.exg_max_ul_bitrate = (ue_ctxt->getAmbr().ambr_m).max_requested_bw_ul;
+ BearerContext* bearerCtxt = sessionCtxt->getBearerContext();
+ if( bearerCtxt == NULL )
+ {
+ log_msg(LOG_ERROR, "Failed to retrive Bearer context for UE IDx %d\n", cb.getCBIndex());
+
+ return ActStatus::HALT;
+ }
+
+ icr_msg.bearer_id = bearerCtxt->getBearerId();
+
+ icr_msg.dl_seq_no = ue_ctxt->getDwnLnkSeqNo();
+ memcpy(&(icr_msg.tai), &(ue_ctxt->getTai().tai_m), sizeof(struct TAI));
+ memcpy(&(icr_msg.gtp_teid), &(bearerCtxt->getS1uSgwUserFteid().fteid_m), sizeof(struct fteid));
+ memcpy(&(icr_msg.apn), &(sessionCtxt->getAccessPtName().apnname_m), sizeof(struct apn_name));
+ memcpy(&(icr_msg.pdn_addr), &(sessionCtxt->getPdnAddr().paa_m), sizeof(struct PAA));
+ memcpy(&(icr_msg.int_key), &((ue_ctxt->getUeSecInfo().secinfo_m).int_key),
+ NAS_INT_KEY_SIZE);
+ memcpy(&(icr_msg.sec_key), &((ue_ctxt->getUeSecInfo().secinfo_m).kenb_key),
+ KENB_SIZE);
+ icr_msg.pti = sessionCtxt->getPti();
+ icr_msg.m_tmsi = ue_ctxt->getMtmsi();
+ ue_ctxt->setDwnLnkSeqNo(icr_msg.dl_seq_no+1);
+
+ cmn::ipc::IpcAddress destAddr;
+ destAddr.u32 = TipcServiceInstance::s1apAppInstanceNum_c;
+
+ mmeIpcIf_g->dispatchIpcMsg((char *) &icr_msg, sizeof(icr_msg), destAddr);
+
+ ProcedureStats::num_of_init_ctxt_req_to_ue_sent ++;
+ log_msg(LOG_DEBUG, "Leaving send_init_ctxt_req_to_ue_v \n");
+
+ return ActStatus::PROCEED;
+}
+
+ActStatus ActionHandlers::process_init_ctxt_resp(SM::ControlBlock& cb)
+{
+ log_msg(LOG_DEBUG, "Inside process_init_ctxt_resp \n");
+
+ UEContext *ue_ctxt = dynamic_cast<UEContext*>(cb.getPermDataBlock());
+ MmeProcedureCtxt *procCtxt = dynamic_cast<MmeProcedureCtxt*>(cb.getTempDataBlock());
+
+ if (ue_ctxt == NULL || procCtxt == NULL)
+ {
+ log_msg(LOG_DEBUG, "process_init_ctxt_resp: ue context or procedure ctxt is NULL \n");
+ return ActStatus::HALT;
+ }
+
+ SessionContext* sessionCtxt = ue_ctxt->getSessionContext();
+ if (sessionCtxt == NULL)
+ {
+ log_msg(LOG_DEBUG, "process_init_ctxt_resp: session ctxt is NULL \n");
+ return ActStatus::HALT;
+ }
+
+ MsgBuffer* msgBuf = static_cast<MsgBuffer*>(cb.getMsgData());
+
+ if (msgBuf == NULL)
+ return ActStatus::HALT;
+
+ const s1_incoming_msg_data_t* s1_msg_data = static_cast<const s1_incoming_msg_data_t*>(msgBuf->getDataPointer());
+ const struct initctx_resp_Q_msg &ics_res =s1_msg_data->msg_data.initctx_resp_Q_msg_m;
+
+ fteid S1uEnbUserFteid;
+ S1uEnbUserFteid.header.iface_type = 0;
+ S1uEnbUserFteid.header.v4 = 1;
+ S1uEnbUserFteid.header.teid_gre = ics_res.gtp_teid;
+ S1uEnbUserFteid.ip.ipv4 = *(struct in_addr*)&ics_res.transp_layer_addr;
+
+ BearerContext* bearerCtxt = sessionCtxt->getBearerContext();
+ if (bearerCtxt == NULL)
+ {
+ log_msg(LOG_DEBUG, "process_init_ctxt_resp: bearer ctxt is NULL \n");
+ return ActStatus::HALT;
+ }
+
+ bearerCtxt->setS1uEnbUserFteid(Fteid(S1uEnbUserFteid));
+
+ ProcedureStats::num_of_processed_init_ctxt_resp ++;
+ log_msg(LOG_DEBUG, "Leaving process_init_ctxt_resp \n");
+
+ return ActStatus::PROCEED;
+}
+
+ActStatus ActionHandlers::send_mb_req_to_sgw(SM::ControlBlock& cb)
+{
+ log_msg(LOG_DEBUG, "Inside send_mb_req_to_sgw \n");
+
+ UEContext *ue_ctxt = dynamic_cast<UEContext*>(cb.getPermDataBlock());
+ if (ue_ctxt == NULL)
+ {
+ log_msg(LOG_DEBUG, "send_mb_req_to_sgw: ue context or procedure ctxt is NULL \n");
+ return ActStatus::HALT;
+ }
+
+ SessionContext* sessionCtxt = ue_ctxt->getSessionContext();
+ if (sessionCtxt == NULL)
+ {
+ log_msg(LOG_DEBUG, "send_mb_req_to_sgw: session ctxt is NULL \n");
+ return ActStatus::HALT;
+ }
+
+ struct MB_Q_msg mb_msg;
+ mb_msg.msg_type = modify_bearer_request;
+ mb_msg.ue_idx = ue_ctxt->getContextID();
+
+ memset(mb_msg.indication, 0, S11_MB_INDICATION_FLAG_SIZE); /*TODO : future*/
+ BearerContext* bearerCtxt = sessionCtxt->getBearerContext();
+ if (bearerCtxt == NULL)
+ {
+ log_msg(LOG_DEBUG, "send_mb_req_to_sgw: bearer ctxt is NULL \n");
+ return ActStatus::HALT;
+ }
+
+ mb_msg.bearer_id = bearerCtxt->getBearerId();
+
+ memcpy(&(mb_msg.s11_sgw_c_fteid), &(sessionCtxt->getS11SgwCtrlFteid().fteid_m),
+ sizeof(struct fteid));
+
+ memcpy(&(mb_msg.s1u_enb_fteid), &(bearerCtxt->getS1uEnbUserFteid().fteid_m),
+ sizeof(struct fteid));
+
+
+ cmn::ipc::IpcAddress destAddr;
+ destAddr.u32 = TipcServiceInstance::s11AppInstanceNum_c;
+
+ mmeIpcIf_g->dispatchIpcMsg((char *) &mb_msg, sizeof(mb_msg), destAddr);
+
+ ProcedureStats::num_of_mb_req_to_sgw_sent ++;
+ log_msg(LOG_DEBUG, "Leaving send_mb_req_to_sgw \n");
+
+ return ActStatus::PROCEED;
+
+}
+
+ActStatus ActionHandlers::process_attach_cmp_from_ue(SM::ControlBlock& cb)
+{
+ log_msg(LOG_DEBUG, "Inside handle_attach_cmp_from_ue \n");
+
+ UEContext *ue_ctxt = dynamic_cast<UEContext*>(cb.getPermDataBlock());
+ if (ue_ctxt == NULL)
+ {
+ log_msg(LOG_ERROR, "attach_done: ue context is NULL \n");
+ return ActStatus::HALT;
+ }
+
+ ue_ctxt->setUpLnkSeqNo(ue_ctxt->getUpLnkSeqNo()+1);
+
+ ProcedureStats::num_of_processed_attach_cmp_from_ue ++;
+ log_msg(LOG_DEBUG, "Leaving handle_attach_cmp_from_ue \n");
+
+ return ActStatus::PROCEED;
+}
+
+ActStatus ActionHandlers::process_mb_resp(SM::ControlBlock& cb)
+{
+ log_msg(LOG_DEBUG, "Inside handle_mb_resp \n");
+ ProcedureStats::num_of_processed_mb_resp ++;
+ return ActStatus::PROCEED;
+}
+
+ActStatus ActionHandlers::attach_done(SM::ControlBlock& cb)
+{
+ log_msg(LOG_DEBUG, "Inside attach_done \n");
+
+ UEContext *ue_ctxt = dynamic_cast<UEContext*>(cb.getPermDataBlock());
+ if (ue_ctxt == NULL)
+ {
+ log_msg(LOG_ERROR, "attach_done: ue context is NULL \n");
+ return ActStatus::HALT;
+ }
+
+ MmContext* mmCtxt = ue_ctxt->getMmContext();
+ if (mmCtxt == NULL)
+ {
+ log_msg(LOG_ERROR, "attach_done: MMcontext is NULL \n");
+ return ActStatus::HALT;
+ }
+
+ mmCtxt->setMmState(EpsAttached);
+
+ MmeContextManagerUtils::deallocateProcedureCtxt(cb, attach_c);
+
+ ProcedureStats::num_of_attach_done++;
+ ProcedureStats::num_of_subscribers_attached ++;
+
+ log_msg(LOG_DEBUG,"Leaving attach done\n");
+
+ return ActStatus::PROCEED;
+}
diff --git a/src/mme-app/actionHandlers/defaultMmeProcedureActionHandlers.cpp b/src/mme-app/actionHandlers/defaultMmeProcedureActionHandlers.cpp
new file mode 100644
index 0000000..269b7fc
--- /dev/null
+++ b/src/mme-app/actionHandlers/defaultMmeProcedureActionHandlers.cpp
@@ -0,0 +1,382 @@
+/*
+ * Copyright 2019-present Infosys Limited
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/******************************************************************************
+ *
+ * This file has both generated and manual code.
+ *
+ * File template used for code generation:
+ * <TOP-DIR/scripts/SMCodeGen/templates/stateMachineTmpls/actionHandlers.cpp.tt>
+ *
+ ******************************************************************************/
+
+#include <actionHandlers/actionHandlers.h>
+#include <contextManager/dataBlocks.h>
+#include <contextManager/subsDataGroupManager.h>
+#include <controlBlock.h>
+#include <event.h>
+#include <mmeStates/attachStart.h>
+#include <mmeStates/detachStart.h>
+#include <mmeStates/niDetachStart.h>
+#include <mmeStates/pagingStart.h>
+#include <mmeStates/s1ReleaseStart.h>
+#include <mmeStates/serviceRequestStart.h>
+#include "mmeStates/tauStart.h"
+#include <msgBuffer.h>
+#include <msgType.h>
+#include <log.h>
+#include <procedureStats.h>
+#include <s1ap_structs.h>
+#include <state.h>
+#include <string.h>
+#include <sstream>
+#include <smTypes.h>
+#include <typeinfo>
+#include <utils/mmeProcedureTypes.h>
+#include <utils/mmeCommonUtils.h>
+#include <utils/mmeContextManagerUtils.h>
+
+using namespace mme;
+using namespace SM;
+
+/***************************************
+* Action handler : default_attach_req_handler
+***************************************/
+ActStatus ActionHandlers::default_attach_req_handler(ControlBlock& cb)
+{
+ log_msg(LOG_ERROR, "default_attach_req_handler \n");
+
+ UEContext* ueCtxt_p = NULL;
+ MmContext* mmctxt = NULL;
+
+ ueCtxt_p = static_cast <UEContext *>(cb.getPermDataBlock());
+ if (ueCtxt_p != NULL)
+ mmctxt = ueCtxt_p->getMmContext();
+
+ MsgBuffer* msgBuf = static_cast<MsgBuffer*>(cb.getMsgData());
+ if (msgBuf == NULL)
+ {
+ log_msg(LOG_ERROR, "Failed to retrieve message buffer \n");
+ return ActStatus::HALT;
+ }
+
+ const s1_incoming_msg_data_t* msgData_p =
+ static_cast<const s1_incoming_msg_data_t*>(msgBuf->getDataPointer());
+ if (msgData_p == NULL)
+ {
+ log_msg(LOG_ERROR, "Failed to retrieve data buffer \n");
+ return ActStatus::HALT;
+ }
+
+ const struct ue_attach_info &ue_info = (msgData_p->msg_data.ue_attach_info_m);
+
+ AttachType attachType = MmeCommonUtils::getAttachType(ueCtxt_p, ue_info);
+ if (attachType == maxAttachType_c)
+ {
+ log_msg(LOG_ERROR, "Failed to identify attach type \n");
+ return ActStatus::HALT;
+ }
+
+ if (ueCtxt_p == NULL)
+ {
+ ueCtxt_p = SubsDataGroupManager::Instance()->getUEContext();
+ if (ueCtxt_p == NULL)
+ {
+ log_msg(LOG_ERROR, "Failed to allocate UE context \n");
+
+ return ActStatus::HALT;
+ }
+
+ mmctxt = SubsDataGroupManager::Instance()->getMmContext();
+ if( mmctxt == NULL )
+ {
+ log_msg(LOG_ERROR, "Failed to allocate MM Context \n");
+
+ SubsDataGroupManager::Instance()->deleteUEContext( ueCtxt_p );
+ return ActStatus::HALT;
+ }
+
+ ueCtxt_p->setContextID(cb.getCBIndex());
+ ueCtxt_p->setMmContext( mmctxt );
+
+ cb.setPermDataBlock(ueCtxt_p);
+ cb.setFastAccessBlock(ueCtxt_p, 1);
+ }
+
+ MmeProcedureCtxt* prcdCtxt_p = SubsDataGroupManager::Instance()->getMmeProcedureCtxt();
+ if( prcdCtxt_p == NULL )
+ {
+ log_msg(LOG_ERROR, "Failed to allocate Procedure Context \n");
+
+ return ActStatus::HALT;
+ }
+
+ prcdCtxt_p->setCtxtType( ProcedureType::attach_c );
+ prcdCtxt_p->setNextState(AttachStart::Instance());
+
+ cb.setCurrentTempDataBlock(prcdCtxt_p);
+
+ // Copy attach request message data into UE Context
+
+ ueCtxt_p->setS1apEnbUeId(ue_info.s1ap_enb_ue_id);
+ ueCtxt_p->setEnbFd(ue_info.enb_fd);
+ ueCtxt_p->setTai(Tai(ue_info.tai));
+ ueCtxt_p->setUtranCgi(Cgi(ue_info.utran_cgi));
+ ueCtxt_p->setUeNetCapab(Ue_net_capab(ue_info.ue_net_capab));
+ ueCtxt_p->setMsNetCapab(Ms_net_capab(ue_info.ms_net_capab));
+ prcdCtxt_p->setPti(ue_info.pti);
+ prcdCtxt_p->setPcoOptions(ue_info.pco_options);
+ prcdCtxt_p->setEsmInfoTxRequired(ue_info.esm_info_tx_required);
+ prcdCtxt_p->setAttachType(attachType);
+
+ switch(attachType)
+ {
+ case imsiAttach_c:
+ {
+ uint8_t imsi[BINARY_IMSI_LEN] = {0};
+ memcpy( imsi, ue_info.IMSI, BINARY_IMSI_LEN );
+
+ // Only upper nibble of first octect in imsi need to be considered
+ // Changing the lower nibble to 0x0f for handling
+ uint8_t first = imsi[0] >> 4;
+ imsi[0] = (uint8_t)(( first << 4 ) | 0x0f );
+
+ DigitRegister15 IMSIInfo;
+ IMSIInfo.convertFromBcdArray(imsi);
+ ueCtxt_p->setImsi(IMSIInfo);
+
+ SubsDataGroupManager::Instance()->addimsikey(ueCtxt_p->getImsi(), ueCtxt_p->getContextID());
+
+ SM::Event evt(Event_e::VALIDATE_IMSI, NULL);
+ cb.addEventToProcQ(evt);
+
+ break;
+ }
+ case knownGutiAttach_c:
+ {
+ // copy seq num?
+
+ SM::Event evt(Event_e::VALIDATE_IMSI, NULL);
+ cb.addEventToProcQ(evt);
+
+ break;
+ }
+ case unknownGutiAttach_c:
+ {
+ SM::Event evt(Event_e::VALIDATE_IMSI, NULL);
+ cb.addEventToProcQ(evt);
+
+ break;
+ }
+ default:
+ {
+ log_msg(LOG_ERROR, "Unhandled attach type %s", attachType);
+ }
+ }
+
+ return ActStatus::PROCEED;
+}
+
+/***************************************
+* Action handler : default_detach_req_handler
+***************************************/
+ActStatus ActionHandlers::default_detach_req_handler(ControlBlock& cb)
+{
+ MmeDetachProcedureCtxt* prcdCtxt_p = SubsDataGroupManager::Instance()->getMmeDetachProcedureCtxt();
+ if( prcdCtxt_p == NULL )
+ {
+ log_msg(LOG_ERROR, "Failed to allocate procedure context for detach cbIndex %d\n", cb.getCBIndex());
+
+ return ActStatus::HALT;
+ }
+
+ prcdCtxt_p->setCtxtType( ProcedureType::detach_c );
+ prcdCtxt_p->setDetachType( DetachType::ueInitDetach_c );
+ prcdCtxt_p->setNextState(DetachStart::Instance());
+ cb.setCurrentTempDataBlock(prcdCtxt_p);
+
+ SM::Event evt(Event_e::DETACH_REQ_FROM_UE, NULL);
+ cb.addEventToProcQ(evt);
+
+ return ActStatus::PROCEED;
+}
+
+/***************************************
+* Action handler : default_ddn_handler
+***************************************/
+ActStatus ActionHandlers::default_ddn_handler(ControlBlock& cb)
+{
+ MmeSvcReqProcedureCtxt* svcReqProc_p = SubsDataGroupManager::Instance()->getMmeSvcReqProcedureCtxt();
+ if (svcReqProc_p == NULL)
+ {
+ log_msg(LOG_ERROR, "Failed to allocate procedure context"
+ " for DDN handling cbIndex %d\n", cb.getCBIndex());
+
+ return ActStatus::HALT;
+ }
+
+ MsgBuffer* msgBuf = static_cast<MsgBuffer*>(cb.getMsgData());
+
+ if (msgBuf == NULL)
+ {
+ log_msg(LOG_DEBUG,"process_ddn: msgBuf is NULL \n");
+ return ActStatus::HALT;
+ }
+
+ const gtp_incoming_msg_data_t* gtp_msg_data= static_cast<const gtp_incoming_msg_data_t*>(msgBuf->getDataPointer());
+ const struct ddn_Q_msg& ddn_info = gtp_msg_data->msg_data.ddn_Q_msg_m;
+
+ svcReqProc_p->setCtxtType(ProcedureType::serviceRequest_c);
+ svcReqProc_p->setNextState(PagingStart::Instance());
+ svcReqProc_p->setPagingTrigger(ddnInit_c);
+ svcReqProc_p->setDdnSeqNo(ddn_info.seq_no);
+ svcReqProc_p->setArp(Arp(ddn_info.arp));
+ svcReqProc_p->setEpsBearerId(ddn_info.eps_bearer_id);
+
+ cb.setCurrentTempDataBlock(svcReqProc_p);
+
+ SM::Event evt(Event_e::DDN_FROM_SGW, NULL);
+ cb.addEventToProcQ(evt);
+ return ActStatus::PROCEED;
+}
+
+/***************************************
+* Action handler : default_service_req_handler
+***************************************/
+ActStatus ActionHandlers::default_service_req_handler(ControlBlock& cb)
+{
+ MmeSvcReqProcedureCtxt* svcReqProc_p = SubsDataGroupManager::Instance()->getMmeSvcReqProcedureCtxt();
+ if (svcReqProc_p == NULL)
+ {
+ log_msg(LOG_ERROR, "Failed to allocate procedure context"
+ " for service request cbIndex %d\n", cb.getCBIndex());
+
+ return ActStatus::HALT;
+ }
+
+ svcReqProc_p->setCtxtType(ProcedureType::serviceRequest_c);
+ svcReqProc_p->setNextState(ServiceRequestStart::Instance());
+ cb.setCurrentTempDataBlock(svcReqProc_p);
+
+ SM::Event evt(Event_e::SERVICE_REQUEST_FROM_UE, NULL);
+ cb.addEventToProcQ(evt);
+
+ return ActStatus::PROCEED;
+}
+
+/***************************************
+* Action handler : default_cancel_loc_req_handler
+***************************************/
+ActStatus ActionHandlers::default_cancel_loc_req_handler(ControlBlock& cb)
+{
+ UEContext *ueCtxt = dynamic_cast<UEContext*>(cb.getPermDataBlock());
+ if (ueCtxt == NULL)
+ {
+ log_msg(LOG_DEBUG, "ue context is NULL \n");
+ return ActStatus::HALT;
+ }
+
+ MmContext* mmCtxt = ueCtxt->getMmContext();
+ if (mmCtxt == NULL)
+ {
+ log_msg(LOG_DEBUG, "mm context is NULL \n");
+ return ActStatus::HALT;
+ }
+
+ if (mmCtxt->getMmState() == EpsDetached)
+ {
+ log_msg(LOG_INFO, "Subscriber is already detached. "
+ "Cleaning up the contexts. UE IDx %d\n", cb.getCBIndex());
+
+ MmeContextManagerUtils::deleteUEContext(cb.getCBIndex());
+
+ return ActStatus::PROCEED;
+ }
+
+ MmeDetachProcedureCtxt* prcdCtxt_p = SubsDataGroupManager::Instance()->getMmeDetachProcedureCtxt();
+ if(prcdCtxt_p == NULL)
+ {
+ log_msg(LOG_ERROR, "Failed to allocate Procedure Ctxt\n");
+ return ActStatus::HALT;
+ }
+ prcdCtxt_p->setCtxtType( ProcedureType::detach_c );
+ prcdCtxt_p->setDetachType(DetachType::hssInitDetach_c);
+ prcdCtxt_p->setNextState(NiDetachStart::Instance());
+ prcdCtxt_p->setCancellationType(SUBSCRIPTION_WITHDRAWAL);
+ cb.setCurrentTempDataBlock(prcdCtxt_p);
+
+ SM::Event evt(Event_e::CLR_FROM_HSS, NULL);
+ cb.addEventToProcQ(evt);
+
+ return ActStatus::PROCEED;
+}
+
+/***************************************
+* Action handler : default_s1_release_req_handler
+***************************************/
+ActStatus ActionHandlers::default_s1_release_req_handler(ControlBlock& cb)
+{
+ MmeProcedureCtxt* prcdCtxt_p = SubsDataGroupManager::Instance()->getMmeProcedureCtxt();
+ if( prcdCtxt_p == NULL )
+ {
+ log_msg(LOG_ERROR, "Failed to allocate procedure Ctxt \n");
+ return ActStatus::HALT;
+ }
+
+ prcdCtxt_p->setCtxtType( ProcedureType::s1Release_c );
+ prcdCtxt_p->setNextState(S1ReleaseStart::Instance());
+ cb.setCurrentTempDataBlock(prcdCtxt_p);
+
+ ProcedureStats::num_of_s1_rel_req_received ++;
+
+ SM::Event evt(Event_e::S1_REL_REQ_FROM_UE, NULL);
+ cb.addEventToProcQ(evt);
+
+ return ActStatus::PROCEED;
+}
+
+/***************************************
+* Action handler : default_tau_req_handler
+***************************************/
+ActStatus ActionHandlers::default_tau_req_handler(ControlBlock& cb)
+{
+ MmeTauProcedureCtxt* tauReqProc_p = SubsDataGroupManager::Instance()->getMmeTauProcedureCtxt();
+ if (tauReqProc_p == NULL)
+ {
+ log_msg(LOG_ERROR, "Failed to allocate procedure context"
+ " for tau request cbIndex %d\n", cb.getCBIndex());
+
+ return ActStatus::HALT;
+ }
+
+ MsgBuffer* msgBuf = static_cast<MsgBuffer*>(cb.getMsgData());
+ if (msgBuf == NULL)
+ {
+ log_msg(LOG_DEBUG,"process_tau_req: msgBuf is NULL \n");
+ return ActStatus::HALT;
+ }
+
+ const s1_incoming_msg_data_t* msgData_p =
+ static_cast<const s1_incoming_msg_data_t*>(msgBuf->getDataPointer());
+ if (msgData_p == NULL)
+ {
+ log_msg(LOG_ERROR, "Failed to retrieve data buffer \n");
+ return ActStatus::HALT;
+ }
+
+ const struct tauReq_Q_msg &tauReq = (msgData_p->msg_data.tauReq_Q_msg_m);
+
+ tauReqProc_p->setCtxtType(ProcedureType::tau_c);
+ tauReqProc_p->setNextState(TauStart::Instance());
+ tauReqProc_p->setS1apEnbUeId(msgData_p->s1ap_enb_ue_id);
+ tauReqProc_p->setEnbFd(tauReq.enb_fd);
+ cb.setCurrentTempDataBlock(tauReqProc_p);
+
+ SM::Event evt(Event_e::TAU_REQUEST_FROM_UE, NULL);
+ cb.addEventToProcQ(evt);
+ return ActStatus::PROCEED;
+}
+
diff --git a/src/mme-app/actionHandlers/networkInitDetachActionHandlers.cpp b/src/mme-app/actionHandlers/networkInitDetachActionHandlers.cpp
new file mode 100644
index 0000000..2b75249
--- /dev/null
+++ b/src/mme-app/actionHandlers/networkInitDetachActionHandlers.cpp
@@ -0,0 +1,168 @@
+/*
+ * Copyright 2019-present Infosys Limited
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#include <typeinfo>
+#include "actionHandlers/actionHandlers.h"
+#include "controlBlock.h"
+#include "msgType.h"
+#include "contextManager/subsDataGroupManager.h"
+#include "contextManager/dataBlocks.h"
+#include "procedureStats.h"
+#include "log.h"
+#include "secUtils.h"
+#include "state.h"
+#include <string.h>
+#include <sstream>
+#include <smTypes.h>
+
+#include <ipcTypes.h>
+#include <tipcTypes.h>
+#include <msgBuffer.h>
+#include <interfaces/mmeIpcInterface.h>
+#include <utils/mmeContextManagerUtils.h>
+
+using namespace SM;
+using namespace mme;
+using namespace cmn::utils;
+
+extern MmeIpcInterface* mmeIpcIf_g;
+
+ActStatus ActionHandlers::ni_detach_req_to_ue(SM::ControlBlock& cb)
+{
+ log_msg(LOG_DEBUG, "Inside ni_detach_req_to_ue \n");
+
+ UEContext *ue_ctxt = dynamic_cast<UEContext*>(cb.getPermDataBlock());
+
+ if (ue_ctxt == NULL)
+ {
+ log_msg(LOG_DEBUG, "ni_detach_req_to_ue: ue context is NULL\n");
+ return ActStatus::HALT;
+ }
+
+ ni_detach_request_Q_msg ni_detach_req;
+
+ ni_detach_req.msg_type = ni_detach_request;
+ ni_detach_req.enb_fd = ue_ctxt->getEnbFd();
+ ni_detach_req.ue_idx = ue_ctxt->getContextID();
+ ni_detach_req.enb_s1ap_ue_id = ue_ctxt->getS1apEnbUeId();
+ ni_detach_req.detach_type = 00000010;
+
+ ue_ctxt->setDwnLnkSeqNo(ue_ctxt->getDwnLnkSeqNo()+1);
+ ni_detach_req.dl_seq_no = ue_ctxt->getDwnLnkSeqNo();
+
+ memcpy(&(ni_detach_req.int_key), &(ue_ctxt->getUeSecInfo().secinfo_m.int_key), NAS_INT_KEY_SIZE);
+
+ /* Send message to S1app in S1q*/
+ cmn::ipc::IpcAddress destAddr;
+ destAddr.u32 = TipcServiceInstance::s1apAppInstanceNum_c;
+
+ mmeIpcIf_g->dispatchIpcMsg((char *) &ni_detach_req, sizeof(ni_detach_req), destAddr);
+
+ log_msg(LOG_DEBUG, "Leaving ni_detach_req_to_ue \n");
+
+ ProcedureStats::num_of_clr_received ++;
+ ProcedureStats::num_of_detach_req_to_ue_sent ++;
+
+ return ActStatus::PROCEED;
+}
+
+ActStatus ActionHandlers::process_detach_accept_from_ue(SM::ControlBlock& cb)
+{
+ log_msg(LOG_DEBUG, "Inside process_detach_accept_from_ue \n");
+
+ UEContext *ue_ctxt = dynamic_cast<UEContext*>(cb.getPermDataBlock());
+
+ if (ue_ctxt == NULL)
+ {
+ log_msg(LOG_DEBUG, "process_detach_accept_from_ue: ue context is NULL\n");
+ return ActStatus::HALT;
+ }
+
+ ue_ctxt->setUpLnkSeqNo(ue_ctxt->getUpLnkSeqNo()+1);
+
+ log_msg(LOG_DEBUG, "Leaving process_detach_accept_from_ue \n");
+
+ ProcedureStats::num_of_cla_sent ++;
+ ProcedureStats::num_of_detach_accept_from_ue ++;
+
+ return ActStatus::PROCEED;
+}
+
+/***************************************
+* Action handler : send_s1_rel_cmd_to_ue_for_detach
+***************************************/
+ActStatus ActionHandlers::send_s1_rel_cmd_to_ue_for_detach(ControlBlock& cb)
+{
+ log_msg(LOG_DEBUG, "Inside send_s1_rel_cmd_to_ue_for_detach\n");
+
+ UEContext *ue_ctxt = dynamic_cast<UEContext*>(cb.getPermDataBlock());
+ if(ue_ctxt == NULL)
+ {
+ log_msg(LOG_DEBUG, "send_s1_rel_cmd_to_ue_for_detach: ue context is NULL \n");
+ return ActStatus::HALT;
+ }
+
+ struct s1relcmd_info s1relcmd;
+
+ s1relcmd.msg_type = s1_release_command;
+ s1relcmd.ue_idx = ue_ctxt->getContextID();
+ s1relcmd.enb_fd = ue_ctxt->getEnbFd();
+ s1relcmd.enb_s1ap_ue_id = ue_ctxt->getS1apEnbUeId();
+ s1relcmd.cause.present = s1apCause_PR_radioNetwork;
+ s1relcmd.cause.choice.radioNetwork = s1apCauseRadioNetwork_user_inactivity;
+
+ /*Send message to S1AP-APP*/
+ cmn::ipc::IpcAddress destAddr;
+ destAddr.u32 = TipcServiceInstance::s1apAppInstanceNum_c;
+ mmeIpcIf_g->dispatchIpcMsg((char *) &s1relcmd, sizeof(s1relcmd), destAddr);
+
+ log_msg(LOG_DEBUG,"Leaving send_s1_rel_cmd_to_ue \n");
+
+ ProcedureStats::num_of_s1_rel_cmd_sent ++;
+ return ActStatus::PROCEED;
+}
+
+/************************************************************
+* Action handler : process_ue_ctxt_rel_comp_for_detach
+**************************************************************/
+ActStatus ActionHandlers::process_ue_ctxt_rel_comp_for_detach(ControlBlock& cb)
+{
+ log_msg(LOG_DEBUG, "Inside process_ue_ctxt_rel_comp_for_detach \n");
+
+ UEContext *ueCtxt = dynamic_cast<UEContext*>(cb.getPermDataBlock());
+ MmeDetachProcedureCtxt *procCtxt = dynamic_cast<MmeDetachProcedureCtxt*>(cb.getTempDataBlock());
+ if (ueCtxt == NULL || procCtxt == NULL)
+ {
+ log_msg(LOG_DEBUG, "UE context or procedure context is NULL\n");
+ return ActStatus::HALT;
+ }
+
+ MmContext* mmCtxt = ueCtxt->getMmContext();
+ if (mmCtxt == NULL)
+ {
+ log_msg(LOG_DEBUG, "MM context is NULL \n");
+ return ActStatus::HALT;
+ }
+
+ if(procCtxt->getCancellationType() == SUBSCRIPTION_WITHDRAWAL)
+ {
+ MmeContextManagerUtils::deleteUEContext(cb.getCBIndex());
+ }
+ else
+ {
+ mmCtxt->setMmState( EpsDetached );
+ MmeContextManagerUtils::deallocateProcedureCtxt(cb, detach_c);
+ }
+
+ ProcedureStats::num_of_subscribers_detached ++;
+ ProcedureStats::num_of_subscribers_attached --;
+
+ log_msg(LOG_DEBUG, "Leaving process_ue_ctxt_rel_comp_for_detach \n");
+
+ return ActStatus::PROCEED;
+
+}
+
diff --git a/src/mme-app/actionHandlers/s1releaseActionHandlers.cpp b/src/mme-app/actionHandlers/s1releaseActionHandlers.cpp
new file mode 100644
index 0000000..de3d16f
--- /dev/null
+++ b/src/mme-app/actionHandlers/s1releaseActionHandlers.cpp
@@ -0,0 +1,151 @@
+/*
+ * Copyright 2019-present Infosys Limited
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/******************************************************************************
+ *
+ * This file has both generated and manual code.
+ *
+ * File template used for code generation:
+ * <TOP-DIR/scripts/SMCodeGen/templates/stateMachineTmpls/actionHandlers.cpp.tt>
+ *
+ ******************************************************************************/
+
+#include <typeinfo>
+#include "actionHandlers/actionHandlers.h"
+#include "controlBlock.h"
+#include "msgType.h"
+#include "contextManager/subsDataGroupManager.h"
+#include "contextManager/dataBlocks.h"
+#include "procedureStats.h"
+#include "log.h"
+#include "secUtils.h"
+#include "state.h"
+#include <string.h>
+#include <sstream>
+#include <smTypes.h>
+
+#include <ipcTypes.h>
+#include <tipcTypes.h>
+#include <msgBuffer.h>
+#include <interfaces/mmeIpcInterface.h>
+#include <utils/mmeContextManagerUtils.h>
+
+using namespace SM;
+using namespace mme;
+using namespace cmn::utils;
+
+extern MmeIpcInterface* mmeIpcIf_g;
+
+ActStatus ActionHandlers:: send_rel_ab_req_to_sgw(SM::ControlBlock& cb)
+{
+ log_msg(LOG_DEBUG, "Inside send_rel_ab_req_to_sgw \n");
+
+ UEContext *ue_ctxt = dynamic_cast<UEContext*>(cb.getPermDataBlock());
+ if (ue_ctxt == NULL)
+ {
+ log_msg(LOG_DEBUG, "send_rel_ab_req_to_sgw: ue ctxt is NULL \n");
+ return ActStatus::HALT;
+ }
+
+ SessionContext* sessionCtxt = ue_ctxt->getSessionContext();
+ if (sessionCtxt == NULL)
+ {
+ log_msg(LOG_DEBUG, " send_rel_ab_req_to_sgw: session ctxt is NULL \n");
+ return ActStatus::HALT;
+ }
+
+ BearerContext* bearerCtxt = sessionCtxt->getBearerContext();
+ if (bearerCtxt == NULL)
+ {
+ log_msg(LOG_DEBUG, " send_rel_ab_req_to_sgw: bearer ctxt is NULL \n");
+ return ActStatus::HALT;
+ }
+
+ struct RB_Q_msg rb_msg;
+ rb_msg.msg_type = release_bearer_request;
+ rb_msg.ue_idx = ue_ctxt->getContextID();
+ memset(rb_msg.indication, 0 , S11_RB_INDICATION_FLAG_SIZE);
+ rb_msg.bearer_id = bearerCtxt->getBearerId();
+ memcpy(&(rb_msg.s11_sgw_c_fteid), &(sessionCtxt->getS11SgwCtrlFteid()),
+ sizeof(struct fteid));
+ memcpy(&(rb_msg.s1u_enb_fteid), &(bearerCtxt->getS1uEnbUserFteid()),
+ sizeof(struct fteid));
+
+ cmn::ipc::IpcAddress destAddr;
+ destAddr.u32 = TipcServiceInstance::s11AppInstanceNum_c;
+ mmeIpcIf_g->dispatchIpcMsg((char *) &rb_msg, sizeof(rb_msg), destAddr);
+
+ ProcedureStats::num_of_rel_access_bearer_req_sent ++;
+
+ log_msg(LOG_DEBUG, "Inside send_rel_ab_req_to_sgw \n");
+
+ return ActStatus::PROCEED;
+}
+
+ActStatus ActionHandlers:: process_rel_ab_resp_from_sgw(SM::ControlBlock& cb)
+{
+ log_msg(LOG_DEBUG, "process_rel_ab_resp_from_sgw \n");
+
+ ProcedureStats::num_of_rel_access_bearer_resp_received ++;
+
+ return ActStatus::PROCEED;
+}
+
+ActStatus ActionHandlers:: send_s1_rel_cmd_to_ue(SM::ControlBlock& cb)
+{
+ log_msg(LOG_DEBUG, "Inside send_s1_rel_cmd_to_ue\n");
+
+ UEContext *ue_ctxt = dynamic_cast<UEContext*>(cb.getPermDataBlock());
+ if(ue_ctxt == NULL)
+ {
+ log_msg(LOG_DEBUG, "send_s1_rel_cmd_to_ue: ue context is NULL \n");
+
+ return ActStatus::HALT;
+ }
+
+ struct s1relcmd_info s1relcmd;
+ s1relcmd.msg_type = s1_release_command;
+ s1relcmd.ue_idx = ue_ctxt->getContextID();
+ s1relcmd.enb_fd = ue_ctxt->getEnbFd();
+ s1relcmd.enb_s1ap_ue_id = ue_ctxt->getS1apEnbUeId();
+ s1relcmd.cause.present = s1apCause_PR_radioNetwork;
+ s1relcmd.cause.choice.radioNetwork = s1apCauseRadioNetwork_user_inactivity;
+
+ /*Send message to S1AP-APP*/
+ cmn::ipc::IpcAddress destAddr;
+ destAddr.u32 = TipcServiceInstance::s1apAppInstanceNum_c;
+ mmeIpcIf_g->dispatchIpcMsg((char *) &s1relcmd, sizeof(s1relcmd), destAddr);
+
+ ProcedureStats::num_of_s1_rel_cmd_sent ++;
+
+ log_msg(LOG_DEBUG,"Leaving send_s1_rel_cmd_to_ue \n");
+
+ return ActStatus::PROCEED;
+}
+
+ActStatus ActionHandlers:: process_ue_ctxt_rel_comp(SM::ControlBlock& cb)
+{
+ log_msg(LOG_DEBUG, "Inside handle_ctxt_rel_comp \n");
+
+ UEContext *ue_ctxt = dynamic_cast<UEContext*>(cb.getPermDataBlock());
+ if (ue_ctxt == NULL)
+ {
+ log_msg(LOG_DEBUG, "process_ue_ctxt_rel_comp: ue context is NULL\n");
+
+ return ActStatus::HALT;
+ }
+
+ MmeContextManagerUtils::deallocateProcedureCtxt(cb, s1Release_c);
+
+ ProcedureStats::num_of_s1_rel_comp_received++;
+
+ log_msg(LOG_DEBUG, "Leaving process_ue_ctxt_rel_comp \n");
+
+ return ActStatus::PROCEED;
+}
+
+
+
diff --git a/src/mme-app/actionHandlers/serviceRequestActionHandlers.cpp b/src/mme-app/actionHandlers/serviceRequestActionHandlers.cpp
new file mode 100644
index 0000000..3cbe859
--- /dev/null
+++ b/src/mme-app/actionHandlers/serviceRequestActionHandlers.cpp
@@ -0,0 +1,328 @@
+
+/*
+ * Copyright 2019-present Infosys Limited
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/******************************************************************************
+ *
+ * This file has both generated and manual code.
+ *
+ * File template used for code generation:
+ * <TOP-DIR/scripts/SMCodeGen/templates/stateMachineTmpls/actionHandlers.cpp.tt>
+ *
+ ******************************************************************************/
+
+#include <typeinfo>
+#include "actionHandlers/actionHandlers.h"
+#include "controlBlock.h"
+#include "msgType.h"
+#include "contextManager/subsDataGroupManager.h"
+#include "contextManager/dataBlocks.h"
+#include "procedureStats.h"
+#include "log.h"
+#include "secUtils.h"
+#include "state.h"
+#include <string.h>
+#include <sstream>
+#include <smTypes.h>
+#include "common_proc_info.h"
+#include <ipcTypes.h>
+#include <tipcTypes.h>
+#include <msgBuffer.h>
+#include <interfaces/mmeIpcInterface.h>
+#include <event.h>
+#include <stateMachineEngine.h>
+#include <utils/mmeContextManagerUtils.h>
+
+using namespace mme;
+using namespace SM;
+using namespace cmn::utils;
+
+extern MmeIpcInterface* mmeIpcIf_g;
+
+/***************************************
+* Action handler :send_paging_req_to_ue
+***************************************/
+ActStatus ActionHandlers::send_paging_req_to_ue(ControlBlock& cb)
+{
+ log_msg(LOG_INFO,"Inside send_paging_req\n");
+
+ UEContext *ue_ctxt = dynamic_cast<UEContext*>(cb.getPermDataBlock());
+
+ if (ue_ctxt == NULL)
+ {
+ log_msg(LOG_DEBUG, "send_paging_req: ue context is NULL\n");
+ return ActStatus::HALT;
+ }
+
+ struct paging_req_Q_msg pag_req;
+ pag_req.msg_type = paging_request;
+ pag_req.ue_idx = ue_ctxt->getContextID();
+ pag_req.enb_s1ap_ue_id = ue_ctxt->getS1apEnbUeId();
+ pag_req.enb_fd = ue_ctxt->getEnbFd();
+ pag_req.cn_domain = CN_DOMAIN_PS;
+
+ const DigitRegister15& ueImsi = ue_ctxt->getImsi();
+ ueImsi.convertToBcdArray( pag_req.IMSI );
+ memcpy(&pag_req.tai, &(ue_ctxt->getTai().tai_m), sizeof(struct TAI));
+
+ cmn::ipc::IpcAddress destAddr;
+ destAddr.u32 = TipcServiceInstance::s1apAppInstanceNum_c;
+ mmeIpcIf_g->dispatchIpcMsg((char *) &pag_req, sizeof(pag_req), destAddr);
+
+ ProcedureStats::num_of_ddn_received++;
+
+ log_msg(LOG_INFO,"Leaving send_paging_req\n");
+
+ return ActStatus::PROCEED;
+}
+
+/***************************************
+* Action handler : process_service_request
+***************************************/
+ActStatus ActionHandlers::process_service_request(ControlBlock& cb)
+{
+ log_msg(LOG_DEBUG, "Inside process_service_request \n");
+
+ UEContext *ue_ctxt = dynamic_cast<UEContext*>(cb.getPermDataBlock());
+
+ if (ue_ctxt == NULL )
+ {
+ log_msg(LOG_DEBUG, "process_service_request: ue ctxt is NULL \n");
+ return ActStatus::HALT;
+ }
+
+ log_msg(LOG_DEBUG, "Leaving process_service_request \n");
+
+ ProcedureStats::num_of_service_request_received ++;
+
+ return ActStatus::PROCEED;
+}
+
+/***************************************
+* Action handler : send_ddn_ack_to_sgw
+***************************************/
+ActStatus ActionHandlers::send_ddn_ack_to_sgw(ControlBlock& cb)
+{
+ log_msg(LOG_DEBUG, "Inside send_ddn_ack_to_sgw \n");
+
+ UEContext *ue_ctxt = static_cast<UEContext*>(cb.getPermDataBlock());
+ MmeSvcReqProcedureCtxt* srPrcdCtxt_p = dynamic_cast<MmeSvcReqProcedureCtxt*>(cb.getTempDataBlock());
+
+ if (ue_ctxt == NULL || srPrcdCtxt_p == NULL)
+ {
+ log_msg(LOG_DEBUG, "send_ddn_ack_to_sgw: ue ctxt or MmeSvcReqProcedureCtxt is NULL \n");
+ return ActStatus::HALT;
+ }
+
+ DDN_ACK_Q_msg ddn_ack;
+ ddn_ack.msg_type = ddn_acknowledgement;
+ ddn_ack.ue_idx= ue_ctxt->getContextID();
+ ddn_ack.seq_no= srPrcdCtxt_p->getDdnSeqNo();
+ ddn_ack.cause = 16;
+
+ cmn::ipc::IpcAddress destAddr;
+ destAddr.u32 = TipcServiceInstance::s11AppInstanceNum_c;
+
+ mmeIpcIf_g->dispatchIpcMsg((char *) &ddn_ack, sizeof(ddn_ack), destAddr);
+
+ log_msg(LOG_DEBUG, "Leaving send_ddn_ack_to_sgw \n");
+
+ ProcedureStats::num_of_ddn_ack_sent ++;
+
+ return ActStatus::PROCEED;
+}
+
+/***************************************
+* Action handler : perform_auth_and_sec_check
+***************************************/
+ActStatus ActionHandlers::perform_auth_and_sec_check(ControlBlock& cb)
+{
+ log_msg(LOG_DEBUG, "Inside auth_and_sec_check \n");
+ SM::ControlBlock* controlBlk_p = SubsDataGroupManager::Instance()->findControlBlock(cb.getCBIndex());
+ UEContext *ue_ctxt = dynamic_cast<UEContext*>(cb.getPermDataBlock());
+
+ if (ue_ctxt == NULL)
+ {
+ log_msg(LOG_DEBUG, "auth_and_sec_check: ue context is NULL\n");
+ return ActStatus::HALT;
+ }
+
+ log_msg(LOG_DEBUG, "Leaving auth_and_sec_check \n");
+
+
+ SM::Event evt(Event_e::AUTH_AND_SEC_CHECK_COMPLETE, NULL);
+
+ controlBlk_p->addEventToProcQ(evt);
+
+
+ return ActStatus::PROCEED;
+}
+/***************************************************
+* Action handler : send_init_ctxt_req_to_ue_svc_req
+****************************************************/
+ActStatus ActionHandlers::send_init_ctxt_req_to_ue_svc_req(ControlBlock& cb)
+{
+ log_msg(LOG_DEBUG, "Inside send_init_ctxt_req_to_ue_svc_req \n");
+
+ UEContext *ue_ctxt = dynamic_cast<UEContext*>(cb.getPermDataBlock());
+ if (ue_ctxt == NULL )
+ {
+ log_msg(LOG_DEBUG, "send_init_ctxt_req_to_ue_svc_req : ue context is NULL \n");
+ return ActStatus::HALT;
+ }
+
+ SessionContext* sessionCtxt = ue_ctxt->getSessionContext();
+ if (sessionCtxt == NULL)
+ {
+ log_msg(LOG_DEBUG, "send_init_ctxt_req_to_ue_svc_req : session ctxt is NULL \n");
+ return ActStatus::HALT;
+ }
+
+ unsigned int nas_count = 0;
+ E_UTRAN_sec_vector* secVect = const_cast<E_UTRAN_sec_vector*>(ue_ctxt->getAiaSecInfo().AiaSecInfo_mp);
+ secinfo& secInfo = const_cast<secinfo&>(ue_ctxt->getUeSecInfo().secinfo_m);
+
+ SecUtils::create_kenb_key(secVect->kasme.val, secInfo.kenb_key, nas_count);
+
+ ics_req_paging_Q_msg icr_msg;
+ icr_msg.msg_type = ics_req_paging;
+ icr_msg.ue_idx = ue_ctxt->getContextID();
+ icr_msg.enb_fd = ue_ctxt->getEnbFd();
+ icr_msg.enb_s1ap_ue_id = ue_ctxt->getS1apEnbUeId();
+
+ icr_msg.ueag_max_ul_bitrate = (ue_ctxt->getAmbr().ambr_m).max_requested_bw_dl;
+ icr_msg.ueag_max_dl_bitrate = (ue_ctxt->getAmbr().ambr_m).max_requested_bw_ul;
+ BearerContext* bearerCtxt = sessionCtxt->getBearerContext();
+ icr_msg.bearer_id = bearerCtxt->getBearerId();
+
+
+ memcpy(&(icr_msg.gtp_teid), &(bearerCtxt->getS1uSgwUserFteid().fteid_m), sizeof(struct fteid));
+ memcpy(&(icr_msg.sec_key), &((ue_ctxt->getUeSecInfo().secinfo_m).kenb_key),
+ KENB_SIZE);
+
+ //ue_ctxt->setdwnLnkSeqNo(icr_msg.dl_seq_no+1);
+
+ cmn::ipc::IpcAddress destAddr;
+ destAddr.u32 = TipcServiceInstance::s1apAppInstanceNum_c;
+
+ mmeIpcIf_g->dispatchIpcMsg((char *) &icr_msg, sizeof(icr_msg), destAddr);
+
+ ProcedureStats::num_of_init_ctxt_req_to_ue_sent ++;
+ log_msg(LOG_DEBUG, "Leaving send_init_ctxt_req_to_ue_svc_req_ \n");
+
+ return ActStatus::PROCEED;
+}
+
+/***************************************
+* Action handler : process_init_ctxt_resp_svc_req
+***************************************/
+ActStatus ActionHandlers::process_init_ctxt_resp_svc_req(ControlBlock& cb)
+{
+ log_msg(LOG_DEBUG, "Inside process_init_ctxt_resp_svc_req \n");
+
+ UEContext *ue_ctxt = dynamic_cast<UEContext*>(cb.getPermDataBlock());
+ MmeProcedureCtxt *procCtxt = dynamic_cast<MmeProcedureCtxt*>(cb.getTempDataBlock());
+
+ if (ue_ctxt == NULL || procCtxt == NULL)
+ {
+ log_msg(LOG_DEBUG, "process_init_ctxt_resp_svc_req: ue context or procedure ctxt is NULL \n");
+ return ActStatus::HALT;
+ }
+
+ SessionContext* sessionCtxt = ue_ctxt->getSessionContext();
+ if (sessionCtxt == NULL)
+ {
+ log_msg(LOG_DEBUG, "process_init_ctxt_resp_svc_req: session ctxt is NULL \n");
+ return ActStatus::HALT;
+ }
+
+ MsgBuffer* msgBuf = static_cast<MsgBuffer*>(cb.getMsgData());
+
+ if (msgBuf == NULL)
+ return ActStatus::HALT;
+
+ const s1_incoming_msg_data_t* s1_msg_data = static_cast<const s1_incoming_msg_data_t*>(msgBuf->getDataPointer());
+ const struct initctx_resp_Q_msg &ics_res =s1_msg_data->msg_data.initctx_resp_Q_msg_m;
+
+ fteid S1uEnbUserFteid;
+ S1uEnbUserFteid.header.iface_type = 0;
+ S1uEnbUserFteid.header.v4 = 1;
+ S1uEnbUserFteid.header.teid_gre = ics_res.gtp_teid;
+ S1uEnbUserFteid.ip.ipv4 = *(struct in_addr*)&ics_res.transp_layer_addr;
+
+ BearerContext* bearerCtxt = sessionCtxt->getBearerContext();
+ if (bearerCtxt)
+ bearerCtxt->setS1uEnbUserFteid(Fteid(S1uEnbUserFteid));
+
+ ProcedureStats::num_of_processed_init_ctxt_resp ++;
+ log_msg(LOG_DEBUG, "Leaving process_init_ctxt_resp_svc_req \n");
+
+ return ActStatus::PROCEED;
+}
+
+
+/***************************************
+* Action handler : send_mb_req_to_sgw_svc_req
+***************************************/
+ActStatus ActionHandlers::send_mb_req_to_sgw_svc_req(ControlBlock& cb)
+{
+ log_msg(LOG_DEBUG, "Inside send_mb_req_to_sgw_svc_req \n");
+
+ UEContext *ue_ctxt = dynamic_cast<UEContext*>(cb.getPermDataBlock());
+ MmeProcedureCtxt *procCtxt = dynamic_cast<MmeProcedureCtxt*>(cb.getTempDataBlock());
+
+ if (ue_ctxt == NULL || procCtxt == NULL)
+ {
+ log_msg(LOG_DEBUG, "send_mb_req_to_sgw_svc_req: ue context or procedure ctxt is NULL \n");
+ return ActStatus::HALT;
+ }
+
+ SessionContext* sessionCtxt = ue_ctxt->getSessionContext();
+ if (sessionCtxt == NULL)
+ {
+ log_msg(LOG_DEBUG, "send_mb_req_to_sgw_svc_req: session ctxt is NULL \n");
+ return ActStatus::HALT;
+ }
+
+ struct MB_Q_msg mb_msg;
+ mb_msg.msg_type = modify_bearer_request;
+ mb_msg.ue_idx = ue_ctxt->getContextID();
+
+ memset(mb_msg.indication, 0, S11_MB_INDICATION_FLAG_SIZE); /*TODO : future*/
+ BearerContext* bearerCtxt = sessionCtxt->getBearerContext();
+ mb_msg.bearer_id = bearerCtxt->getBearerId();
+
+ memcpy(&(mb_msg.s11_sgw_c_fteid), &(sessionCtxt->getS11SgwCtrlFteid().fteid_m),
+ sizeof(struct fteid));
+
+ memcpy(&(mb_msg.s1u_enb_fteid), &(bearerCtxt->getS1uEnbUserFteid().fteid_m),
+ sizeof(struct fteid));
+
+
+ cmn::ipc::IpcAddress destAddr;
+ destAddr.u32 = TipcServiceInstance::s11AppInstanceNum_c;
+
+ mmeIpcIf_g->dispatchIpcMsg((char *) &mb_msg, sizeof(mb_msg), destAddr);
+
+ ProcedureStats::num_of_mb_req_to_sgw_sent ++;
+ log_msg(LOG_DEBUG, "Leaving send_mb_req_to_sgw_svc_req \n");
+
+ return ActStatus::PROCEED;
+}
+
+/***************************************
+* Action handler : process_mb_resp_svc_req
+***************************************/
+ActStatus ActionHandlers::process_mb_resp_svc_req(ControlBlock& cb)
+{
+ log_msg(LOG_DEBUG, "Inside process_mb_resp_svc_req \n");
+
+ ProcedureStats::num_of_processed_mb_resp ++;
+
+ MmeContextManagerUtils::deallocateProcedureCtxt(cb, serviceRequest_c);
+
+ return ActStatus::PROCEED;
+}
diff --git a/src/mme-app/actionHandlers/tauActionHandlers.cpp b/src/mme-app/actionHandlers/tauActionHandlers.cpp
new file mode 100644
index 0000000..6bf70da
--- /dev/null
+++ b/src/mme-app/actionHandlers/tauActionHandlers.cpp
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2019-present Infosys Limited
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/******************************************************************************
+ *
+ * This file has both generated and manual code.
+ *
+ * File template used for code generation:
+ * <TOP-DIR/scripts/SMCodeGen/templates/stateMachineTmpls/actionHandlers.cpp.tt>
+ *
+ ******************************************************************************/
+
+#include <typeinfo>
+#include "actionHandlers/actionHandlers.h"
+#include "controlBlock.h"
+#include "msgType.h"
+#include "contextManager/dataBlocks.h"
+#include "procedureStats.h"
+#include "log.h"
+#include "secUtils.h"
+#include "state.h"
+#include <string.h>
+#include <sstream>
+#include <smTypes.h>
+#include "common_proc_info.h"
+#include <ipcTypes.h>
+#include <tipcTypes.h>
+#include <msgBuffer.h>
+#include <interfaces/mmeIpcInterface.h>
+#include <event.h>
+#include <stateMachineEngine.h>
+#include <utils/mmeContextManagerUtils.h>
+
+using namespace mme;
+using namespace SM;
+using namespace cmn::utils;
+
+extern MmeIpcInterface* mmeIpcIf_g;
+
+/***************************************
+* Action handler : send_tau_response_to_ue
+***************************************/
+ActStatus ActionHandlers::send_tau_response_to_ue(ControlBlock& cb)
+{
+ log_msg(LOG_INFO,"Inside send_tau_response_to_ue\n");
+
+ UEContext *ue_ctxt = static_cast<UEContext*>(cb.getPermDataBlock());
+ if (ue_ctxt == NULL)
+ {
+ log_msg(LOG_ERROR, "send_tau_response_to_ue: ue context is NULL\n",cb.getCBIndex());
+ return ActStatus::HALT;
+ }
+
+ MmeTauProcedureCtxt* tauPrcdCtxt_p = dynamic_cast<MmeTauProcedureCtxt*>(cb.getTempDataBlock());
+ if (tauPrcdCtxt_p == NULL)
+ {
+ log_msg(LOG_DEBUG, "send_tau_response_to_ue: MmeTauProcedureCtxt is NULL\n");
+ return ActStatus::HALT;
+ }
+
+ struct tauResp_Q_msg tau_resp;
+
+ tau_resp.msg_type = tau_response;
+ tau_resp.status = 0;
+ tau_resp.ue_idx = ue_ctxt->getContextID();
+ tau_resp.enb_fd = tauPrcdCtxt_p->getEnbFd();
+ tau_resp.s1ap_enb_ue_id = tauPrcdCtxt_p->getS1apEnbUeId();
+ tau_resp.dl_seq_no = ue_ctxt->getDwnLnkSeqNo();
+ memcpy(&(tau_resp.int_key), &(ue_ctxt->getUeSecInfo().secinfo_m.int_key),
+ NAS_INT_KEY_SIZE);
+ memcpy(&tau_resp.tai, &(ue_ctxt->getTai().tai_m), sizeof(struct TAI));
+ tau_resp.m_tmsi = ue_ctxt->getMtmsi();
+
+ cmn::ipc::IpcAddress destAddr;
+ destAddr.u32 = TipcServiceInstance::s1apAppInstanceNum_c;
+ mmeIpcIf_g->dispatchIpcMsg((char *) &tau_resp, sizeof(tau_resp), destAddr);
+
+ MmeContextManagerUtils::deallocateProcedureCtxt(cb, tau_c );
+ ProcedureStats::num_of_tau_response_to_ue_sent++;
+
+ log_msg(LOG_INFO,"Leaving send_tau_response_to_ue\n");
+ return ActStatus::PROCEED;
+}
+
diff --git a/src/mme-app/actionHandlers/ueInitDetachActionHandlers.cpp b/src/mme-app/actionHandlers/ueInitDetachActionHandlers.cpp
new file mode 100644
index 0000000..d37c02e
--- /dev/null
+++ b/src/mme-app/actionHandlers/ueInitDetachActionHandlers.cpp
@@ -0,0 +1,198 @@
+/*
+ * Copyright 2019-present Infosys Limited
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/******************************************************************************
+ *
+ * This file has both generated and manual code.
+ *
+ * File template used for code generation:
+ * <TOP-DIR/scripts/SMCodeGen/templates/stateMachineTmpls/actionHandlers.cpp.tt>
+ *
+ ******************************************************************************/
+
+#include "actionHandlers/actionHandlers.h"
+#include "contextManager/subsDataGroupManager.h"
+#include "contextManager/dataBlocks.h"
+#include "msgType.h"
+#include "controlBlock.h"
+#include "procedureStats.h"
+#include "log.h"
+#include <string.h>
+#include <smTypes.h>
+
+#include <ipcTypes.h>
+#include <tipcTypes.h>
+#include <msgBuffer.h>
+#include <interfaces/mmeIpcInterface.h>
+#include <utils/mmeContextManagerUtils.h>
+
+using namespace SM;
+using namespace mme;
+using namespace cmn::utils;
+
+extern MmeIpcInterface* mmeIpcIf_g;
+
+ActStatus ActionHandlers::del_session_req(SM::ControlBlock& cb)
+{
+ log_msg(LOG_DEBUG, "Inside delete_session_req \n");
+
+ UEContext *ue_ctxt = dynamic_cast<UEContext*>(cb.getPermDataBlock());
+
+ if (ue_ctxt == NULL)
+ {
+ log_msg(LOG_DEBUG, "delete_session_req: ue context is NULL\n");
+ return ActStatus::HALT;
+ }
+
+ ue_ctxt->setUpLnkSeqNo(ue_ctxt->getUpLnkSeqNo()+1);
+
+ struct DS_Q_msg g_ds_msg;
+ g_ds_msg.msg_type = delete_session_request;
+
+ memset(g_ds_msg.indication, 0, S11_DS_INDICATION_FLAG_SIZE);
+ g_ds_msg.indication[0] = 8; /* TODO : define macro or enum */
+
+ SessionContext* sessionCtxt = ue_ctxt->getSessionContext();
+ BearerContext* bearerCtxt = sessionCtxt->getBearerContext();
+ g_ds_msg.bearer_id = bearerCtxt->getBearerId();
+
+ memcpy(&(g_ds_msg.s11_sgw_c_fteid), &(sessionCtxt->getS11SgwCtrlFteid().fteid_m), sizeof(struct fteid));
+
+ /* Send message to S11app in S11q*/
+ cmn::ipc::IpcAddress destAddr;
+ destAddr.u32 = TipcServiceInstance::s11AppInstanceNum_c;
+
+ mmeIpcIf_g->dispatchIpcMsg((char *) &g_ds_msg, sizeof(g_ds_msg), destAddr);
+
+ log_msg(LOG_DEBUG, "Leaving delete_session_req \n");
+ ProcedureStats::num_of_del_session_req_sent ++;
+ return ActStatus::PROCEED;
+
+}
+#if 0
+ActStatus ActionHandlers::purge_req(SM::ControlBlock& cb)
+{
+ log_msg(LOG_DEBUG, "Inside purge_req \n");
+ UEContext *ue_ctxt = dynamic_cast<UEContext*>(cb.getPermDataBlock());
+
+ if (ue_ctxt == NULL)
+ {
+ log_msg(LOG_DEBUG, "purge_req: ue context is NULL\n");
+ return ActStatus::HALT;
+ }
+
+ s6a_purge_Q_msg g_purge_msg;
+
+ g_purge_msg.ue_idx = ue_ctxt->getContextId();
+ memcpy(g_purge_msg.IMSI, ue_ctxt->getIMSIInfo(), BINARY_IMSI_LEN);
+
+ /* Send message to S6app in S6q*/
+ mmeS6If_gp->sendMessage_v((char*)(&g_purge_msg), purge_request);
+
+
+ log_msg(LOG_DEBUG, "Leaving purge_req \n");
+ ProcedureStats::num_of_purge_req_sent ++;
+ return ActStatus::PROCEED;
+
+}
+#endif
+
+ActStatus ActionHandlers::process_del_session_resp(SM::ControlBlock& cb)
+{
+ log_msg(LOG_DEBUG, "Inside handle_delete_session_resp \n");
+
+ UEContext *ue_ctxt = dynamic_cast<UEContext*>(cb.getPermDataBlock());
+ if (ue_ctxt == NULL)
+ {
+ log_msg(LOG_DEBUG, "delete_session_req: ue context is NULL\n");
+ return ActStatus::HALT;
+ }
+
+ SessionContext* sessionCtxt = ue_ctxt->getSessionContext();
+ if (sessionCtxt != NULL)
+ {
+ BearerContext* bearerCtxt = sessionCtxt->getBearerContext();
+ if (bearerCtxt)
+ {
+ SubsDataGroupManager::Instance()->deleteBearerContext( bearerCtxt );
+ }
+ SubsDataGroupManager::Instance()->deleteSessionContext( sessionCtxt );
+ }
+
+ ue_ctxt->setSessionContext(NULL);
+
+ log_msg(LOG_DEBUG, "Leaving handle_delete_session_resp \n");
+ ProcedureStats::num_of_processed_del_session_resp ++;
+ return ActStatus::PROCEED;
+
+}
+
+#if 0
+ActStatus ActionHandlers::process_pur_resp(SM::ControlBlock& cb)
+{
+ log_msg(LOG_DEBUG, "Inside handle_purge_resp \n");
+
+ UEContext *ue_ctxt = dynamic_cast<UEContext*>(cb.getPermDataBlock());
+
+ if (ue_ctxt == NULL)
+ {
+ log_msg(LOG_DEBUG, "handle_purge_resp: ue context is NULL \n");
+ return ActStatus::HALT;
+ }
+ //struct purge_resp_Q_msg *purge_msg = nullptr;
+
+ /*Nothing is been done. Only takes the UE Index
+ * increment the stats counter and changes the state*/
+
+
+ log_msg(LOG_DEBUG, "Leaving handle_purge_resp for UE-%d.\n", ue_ctxt->getContextId());
+ ProcedureStats::num_of_processed_pur_resp ++;
+ return ActStatus::PROCEED;
+
+}
+#endif
+ActStatus ActionHandlers::detach_accept_to_ue(SM::ControlBlock& cb)
+{
+ log_msg(LOG_DEBUG, "Inside send_detach_accept \n");
+
+ UEContext *ue_ctxt = dynamic_cast<UEContext*>(cb.getPermDataBlock());
+
+ if (ue_ctxt == NULL)
+ {
+ log_msg(LOG_DEBUG, "send_detach_accept: ue context is NULL\n");
+ return ActStatus::HALT;
+ }
+
+ detach_accept_Q_msg detach_accpt;
+ detach_accpt.msg_type = detach_accept;
+ detach_accpt.enb_fd = ue_ctxt->getEnbFd();
+ detach_accpt.ue_idx = ue_ctxt->getContextID();
+ detach_accpt.enb_s1ap_ue_id = ue_ctxt->getS1apEnbUeId();
+
+ ue_ctxt->setDwnLnkSeqNo(ue_ctxt->getDwnLnkSeqNo()+1);
+ detach_accpt.dl_seq_no = ue_ctxt->getDwnLnkSeqNo();
+
+ memcpy(&(detach_accpt.int_key), &(ue_ctxt->getUeSecInfo().secinfo_m.int_key), NAS_INT_KEY_SIZE);
+
+ /* Send message to S11app in S11q*/
+ cmn::ipc::IpcAddress destAddr;
+ destAddr.u32 = TipcServiceInstance::s1apAppInstanceNum_c;
+
+ mmeIpcIf_g->dispatchIpcMsg((char *) &detach_accpt, sizeof(detach_accpt), destAddr);
+
+ MmeContextManagerUtils::deallocateProcedureCtxt(cb, detach_c );
+
+ MmContext* mmCtxt = ue_ctxt->getMmContext();
+ mmCtxt->setMmState( EpsDetached );
+
+ log_msg(LOG_DEBUG, "Leaving send_detach_accept for UE \n");
+
+ ProcedureStats::num_of_detach_accept_to_ue_sent ++;
+ ProcedureStats::num_of_subscribers_attached --;
+
+ return ActStatus::PROCEED;
+
+}
diff --git a/src/mme-app/conf/mme.json b/src/mme-app/conf/mme.json
new file mode 100644
index 0000000..852b92d
--- /dev/null
+++ b/src/mme-app/conf/mme.json
@@ -0,0 +1,37 @@
+{
+ "mme": {
+ "egtp_default_port": 2123,
+ "ip_addr": "192.168.1.52",
+ "s1ap_addr": "192.168.1.52",
+ "egtp_addr": "192.168.1.52",
+ "sctp_port": 36412,
+ "name": "vmmestandalone",
+ "egtp_default_hostname": "sutlej.ccin.ccpu.com",
+ "group_id": 1,
+ "code": 1,
+ "__comment__": "Here is comment",
+ "mcc": {
+ "dig1": 2,
+ "dig2": 0,
+ "dig3": 8
+ },
+ "mnc": {
+ "dig1": 0,
+ "dig2": 1,
+ "dig3": -1
+ }
+ },
+ "enb": {
+ "enb_addr": "192.168.1.52",
+ "enb_port": "5003"
+ },
+ "s11": {
+ "sgw_addr": "127.0.0.1",
+ "pgw_addr": "192.168.1.105"
+ },
+ "s6a": {
+ "host_type": "freediameter",
+ "host": "hss.openair4G.eur",
+ "realm": "openair4G.eur"
+ }
+}
diff --git a/src/mme-app/contextManager/bearerContextManager.cpp b/src/mme-app/contextManager/bearerContextManager.cpp
new file mode 100644
index 0000000..72fd2cf
--- /dev/null
+++ b/src/mme-app/contextManager/bearerContextManager.cpp
@@ -0,0 +1,52 @@
+ /*
+ * Copyright 2019-present Infosys Limited
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+/******************************************************************************
+ * bearerContextManager.cpp
+ * This is an auto generated file.
+ * Please do not edit this file.
+ * All edits to be made through template source file
+ * <TOP-DIR/scripts/SMCodeGen/templates/ctxtManagerTmpls/blockPoolManager.cpp.tt>
+ ******************************************************************************/
+
+#include "memPoolManager.h"
+#include "contextManager/dataBlocks.h"
+#include "contextManager/bearerContextManager.h"
+
+using namespace cmn::memPool;
+
+namespace mme
+{
+ /******************************************************************************
+ * Constructor
+ ******************************************************************************/
+ BearerContextManager::BearerContextManager(int numOfBlocks): poolManager_m(numOfBlocks)
+ {
+ }
+
+ /******************************************************************************
+ * Destructor
+ ******************************************************************************/
+ BearerContextManager::~BearerContextManager()
+ {
+ }
+
+ /******************************************************************************
+ * allocate BearerContext data block
+ ******************************************************************************/
+ BearerContext* BearerContextManager::allocateBearerContext()
+ {
+ BearerContext* BearerContext_p = poolManager_m.allocate();
+ return BearerContext_p;
+ }
+
+ /******************************************************************************
+ * Deallocate a BearerContext data block
+ ******************************************************************************/
+ void BearerContextManager::deallocateBearerContext(BearerContext* BearerContextp )
+ {
+ poolManager_m.free( BearerContextp );
+ }
+}
diff --git a/src/mme-app/contextManager/dataBlocks.cpp b/src/mme-app/contextManager/dataBlocks.cpp
new file mode 100644
index 0000000..4134d7f
--- /dev/null
+++ b/src/mme-app/contextManager/dataBlocks.cpp
@@ -0,0 +1,970 @@
+/*
+ * Copyright 2019-present Infosys Limited
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/**************************************
+*
+* This is an auto generated file.
+* Please do not edit this file.
+* All edits to be made through template source file
+* <TOP-DIR/scripts/SMCodeGen/templates/ctxtManagerTmpls/dataBlock.cpp.tt>
+***************************************/
+#include "contextManager/dataBlocks.h"
+
+namespace mme
+{
+ /******************************************************************************
+ *******************************************************************************
+ * UEContext
+ *******************************************************************************
+ ******************************************************************************/
+
+ /******************************************************************************
+ * Constructor
+ ******************************************************************************/
+ UEContext::UEContext(): enbFd_m(0), s1apEnbUeId_m(0), subscriptionStatus_m(0),
+ netAccessMode_m(0), contextID_m(0), rauTauTimer_m(0),
+ accessRestrictionData_m(0), imsi_m(), msisdn_m(),
+ dwnLnkSeqNo_m(0), upLnkSeqNo_m(0), ueState_m(InvalidState),
+ tai_m(), utranCgi_m(), msNetCapab_m(), ueNetCapab_m(),
+ ueSecInfo_m(), ambr_m(), aiaSecInfo_m(),
+ mTmsi_m(0), MmContext_mp(NULL), SessionContext_mp(NULL)
+ {
+ }
+
+ /******************************************************************************
+ * Destructor
+ ******************************************************************************/
+ UEContext::~UEContext()
+ {
+ }
+
+ /******************************************************************************
+ * sets enbFd
+ ******************************************************************************/
+ void UEContext::setEnbFd( int enbFd_i )
+ {
+ enbFd_m = enbFd_i;
+ }
+
+ /******************************************************************************
+ * returns enbFd
+ ******************************************************************************/
+ int UEContext::getEnbFd()
+ {
+ return enbFd_m;
+ }
+ /******************************************************************************
+ * sets s1apEnbUeId
+ ******************************************************************************/
+ void UEContext::setS1apEnbUeId( int s1apEnbUeId_i )
+ {
+ s1apEnbUeId_m = s1apEnbUeId_i;
+ }
+
+ /******************************************************************************
+ * returns s1apEnbUeId
+ ******************************************************************************/
+ int UEContext::getS1apEnbUeId()
+ {
+ return s1apEnbUeId_m;
+ }
+ /******************************************************************************
+ * sets subscriptionStatus
+ ******************************************************************************/
+ void UEContext::setSubscriptionStatus( int subscriptionStatus_i )
+ {
+ subscriptionStatus_m = subscriptionStatus_i;
+ }
+
+ /******************************************************************************
+ * returns subscriptionStatus
+ ******************************************************************************/
+ int UEContext::getSubscriptionStatus()
+ {
+ return subscriptionStatus_m;
+ }
+ /******************************************************************************
+ * sets netAccessMode
+ ******************************************************************************/
+ void UEContext::setNetAccessMode( int netAccessMode_i )
+ {
+ netAccessMode_m = netAccessMode_i;
+ }
+
+ /******************************************************************************
+ * returns netAccessMode
+ ******************************************************************************/
+ int UEContext::getNetAccessMode()
+ {
+ return netAccessMode_m;
+ }
+ /******************************************************************************
+ * sets contextID
+ ******************************************************************************/
+ void UEContext::setContextID( uint32_t contextID_i )
+ {
+ contextID_m = contextID_i;
+ }
+
+ /******************************************************************************
+ * returns contextID
+ ******************************************************************************/
+ uint32_t UEContext::getContextID()
+ {
+ return contextID_m;
+ }
+ /******************************************************************************
+ * sets rauTauTimer
+ ******************************************************************************/
+ void UEContext::setRauTauTimer( unsigned int rauTauTimer_i )
+ {
+ rauTauTimer_m = rauTauTimer_i;
+ }
+
+ /******************************************************************************
+ * returns rauTauTimer
+ ******************************************************************************/
+ unsigned int UEContext::getRauTauTimer()
+ {
+ return rauTauTimer_m;
+ }
+ /******************************************************************************
+ * sets accessRestrictionData
+ ******************************************************************************/
+ void UEContext::setAccessRestrictionData( unsigned int accessRestrictionData_i )
+ {
+ accessRestrictionData_m = accessRestrictionData_i;
+ }
+
+ /******************************************************************************
+ * returns accessRestrictionData
+ ******************************************************************************/
+ unsigned int UEContext::getAccessRestrictionData()
+ {
+ return accessRestrictionData_m;
+ }
+ /******************************************************************************
+ * sets imsi
+ ******************************************************************************/
+ void UEContext::setImsi( const DigitRegister15& imsi_i )
+ {
+ imsi_m = imsi_i;
+ }
+
+ /******************************************************************************
+ * returns imsi
+ ******************************************************************************/
+ const DigitRegister15& UEContext::getImsi()const
+ {
+ return imsi_m;
+ }
+ /******************************************************************************
+ * sets msisdn
+ ******************************************************************************/
+ void UEContext::setMsisdn( const DigitRegister15& msisdn_i )
+ {
+ msisdn_m = msisdn_i;
+ }
+
+ /******************************************************************************
+ * returns msisdn
+ ******************************************************************************/
+ const DigitRegister15& UEContext::getMsisdn()const
+ {
+ return msisdn_m;
+ }
+ /******************************************************************************
+ * sets dwnLnkSeqNo
+ ******************************************************************************/
+ void UEContext::setDwnLnkSeqNo( unsigned short dwnLnkSeqNo_i )
+ {
+ dwnLnkSeqNo_m = dwnLnkSeqNo_i;
+ }
+
+ /******************************************************************************
+ * returns dwnLnkSeqNo
+ ******************************************************************************/
+ unsigned short UEContext::getDwnLnkSeqNo()
+ {
+ return dwnLnkSeqNo_m;
+ }
+ /******************************************************************************
+ * sets upLnkSeqNo
+ ******************************************************************************/
+ void UEContext::setUpLnkSeqNo( unsigned short upLnkSeqNo_i )
+ {
+ upLnkSeqNo_m = upLnkSeqNo_i;
+ }
+
+ /******************************************************************************
+ * returns upLnkSeqNo
+ ******************************************************************************/
+ unsigned short UEContext::getUpLnkSeqNo()
+ {
+ return upLnkSeqNo_m;
+ }
+
+ /******************************************************************************
+ * sets ueState
+ ******************************************************************************/
+ void UEContext::setUeState( UE_State_e ueState_i )
+ {
+ ueState_m = ueState_i;
+ }
+
+ /******************************************************************************
+ * returns ueState
+ ******************************************************************************/
+ UE_State_e UEContext::getUeState()
+ {
+ return ueState_m;
+ }
+ /******************************************************************************
+ * sets tai
+ ******************************************************************************/
+ void UEContext::setTai( const Tai& tai_i )
+ {
+ tai_m = tai_i;
+ }
+
+ /******************************************************************************
+ * returns tai
+ ******************************************************************************/
+ const Tai& UEContext::getTai()const
+ {
+ return tai_m;
+ }
+ /******************************************************************************
+ * sets utranCgi
+ ******************************************************************************/
+ void UEContext::setUtranCgi( const Cgi& utranCgi_i )
+ {
+ utranCgi_m = utranCgi_i;
+ }
+
+ /******************************************************************************
+ * returns utranCgi
+ ******************************************************************************/
+ const Cgi& UEContext::getUtranCgi()const
+ {
+ return utranCgi_m;
+ }
+ /******************************************************************************
+ * sets msNetCapab
+ ******************************************************************************/
+ void UEContext::setMsNetCapab( const Ms_net_capab& msNetCapab_i )
+ {
+ msNetCapab_m = msNetCapab_i;
+ }
+
+ /******************************************************************************
+ * returns msNetCapab
+ ******************************************************************************/
+ const Ms_net_capab& UEContext::getMsNetCapab()const
+ {
+ return msNetCapab_m;
+ }
+ /******************************************************************************
+ * sets ueNetCapab
+ ******************************************************************************/
+ void UEContext::setUeNetCapab( const Ue_net_capab& ueNetCapab_i )
+ {
+ ueNetCapab_m = ueNetCapab_i;
+ }
+
+ /******************************************************************************
+ * returns ueNetCapab
+ ******************************************************************************/
+ const Ue_net_capab& UEContext::getUeNetCapab()const
+ {
+ return ueNetCapab_m;
+ }
+ /******************************************************************************
+ * sets ueSecInfo
+ ******************************************************************************/
+ void UEContext::setUeSecInfo( const Secinfo& ueSecInfo_i )
+ {
+ ueSecInfo_m = ueSecInfo_i;
+ }
+
+ /******************************************************************************
+ * returns ueSecInfo
+ ******************************************************************************/
+ const Secinfo& UEContext::getUeSecInfo()const
+ {
+ return ueSecInfo_m;
+ }
+ /******************************************************************************
+ * sets ambr
+ ******************************************************************************/
+ void UEContext::setAmbr( const Ambr& ambr_i )
+ {
+ ambr_m = ambr_i;
+ }
+
+ /******************************************************************************
+ * returns ambr
+ ******************************************************************************/
+ const Ambr& UEContext::getAmbr()const
+ {
+ return ambr_m;
+ }
+ /******************************************************************************
+ * sets aiaSecInfo
+ ******************************************************************************/
+ void UEContext::setAiaSecInfo( const E_utran_sec_vector& aiaSecInfo_i )
+ {
+ aiaSecInfo_m = aiaSecInfo_i;
+ }
+
+ /******************************************************************************
+ * returns aiaSecInfo
+ ******************************************************************************/
+ const E_utran_sec_vector& UEContext::getAiaSecInfo()const
+ {
+ return aiaSecInfo_m;
+ }
+
+ /******************************************************************************
+ * sets mTmsi
+ ******************************************************************************/
+ void UEContext::setMtmsi( uint32_t mTmsi_i )
+ {
+ mTmsi_m = mTmsi_i;
+ }
+
+ /******************************************************************************
+ * returns ambr
+ ******************************************************************************/
+ uint32_t UEContext::getMtmsi()
+ {
+ return mTmsi_m;
+ }
+
+ /******************************************************************************
+ * sets MmContext
+ ******************************************************************************/
+ void UEContext::setMmContext( MmContext* MmContextp )
+ {
+ MmContext_mp = MmContextp;
+ }
+
+ /******************************************************************************
+ * returns MmContext
+ ******************************************************************************/
+ MmContext* UEContext::getMmContext()
+ {
+ return MmContext_mp;
+ }
+ /******************************************************************************
+ * sets SessionContext
+ ******************************************************************************/
+ void UEContext::setSessionContext( SessionContext* SessionContextp )
+ {
+ SessionContext_mp = SessionContextp;
+ }
+
+ /******************************************************************************
+ * returns SessionContext
+ ******************************************************************************/
+ SessionContext* UEContext::getSessionContext()
+ {
+ return SessionContext_mp;
+ }
+ /******************************************************************************
+ *******************************************************************************
+ * MmContext
+ *******************************************************************************
+ ******************************************************************************/
+
+ /******************************************************************************
+ * Constructor
+ ******************************************************************************/
+ MmContext::MmContext(): mmState_m(InvalidState)
+ {
+ }
+
+ /******************************************************************************
+ * Destructor
+ ******************************************************************************/
+ MmContext::~MmContext()
+ {
+ }
+
+ /******************************************************************************
+ * sets mmState
+ ******************************************************************************/
+ void MmContext::setMmState( EmmState mmState_i )
+ {
+ mmState_m = mmState_i;
+ }
+
+ /******************************************************************************
+ * returns mmState
+ ******************************************************************************/
+ EmmState MmContext::getMmState()
+ {
+ return mmState_m;
+ }
+
+ /******************************************************************************
+ *******************************************************************************
+ * SessionContext
+ *******************************************************************************
+ ******************************************************************************/
+
+ /******************************************************************************
+ * Constructor
+ ******************************************************************************/
+ SessionContext::SessionContext(): sessionId_m(0), s11SgwCtrlFteid_m(),
+ s5S8PgwCtrlFteid_m(), pdnAddr_m(), accessPtName_m(), apnConfigProfileCtxId_m(),
+ pti_m(0), BearerContext_mp(NULL)
+ {
+ }
+
+ /******************************************************************************
+ * Destructor
+ ******************************************************************************/
+ SessionContext::~SessionContext()
+ {
+ }
+
+ /******************************************************************************
+ * sets sessionId
+ ******************************************************************************/
+ void SessionContext::setSessionId( uint8_t sessionId_i )
+ {
+ sessionId_m = sessionId_i;
+ }
+
+ /******************************************************************************
+ * returns sessionId
+ ******************************************************************************/
+ uint8_t SessionContext::getSessionId()
+ {
+ return sessionId_m;
+ }
+
+ /******************************************************************************
+ * sets s11SgwCtrlFteid
+ ******************************************************************************/
+ void SessionContext::setS11SgwCtrlFteid( const Fteid& s11SgwCtrlFteid_i )
+ {
+ s11SgwCtrlFteid_m = s11SgwCtrlFteid_i;
+ }
+
+ /******************************************************************************
+ * returns s11SgwCtrlFteid
+ ******************************************************************************/
+ const Fteid& SessionContext::getS11SgwCtrlFteid()const
+ {
+ return s11SgwCtrlFteid_m;
+ }
+ /******************************************************************************
+ * sets s5S8PgwCtrlFteid
+ ******************************************************************************/
+ void SessionContext::setS5S8PgwCtrlFteid( const Fteid& s5S8PgwCtrlFteid_i )
+ {
+ s5S8PgwCtrlFteid_m = s5S8PgwCtrlFteid_i;
+ }
+
+ /******************************************************************************
+ * returns s5S8PgwCtrlFteid
+ ******************************************************************************/
+ const Fteid& SessionContext::getS5S8PgwCtrlFteid()const
+ {
+ return s5S8PgwCtrlFteid_m;
+ }
+ /******************************************************************************
+ * sets pdnAddr
+ ******************************************************************************/
+ void SessionContext::setPdnAddr( const Paa& pdnAddr_i )
+ {
+ pdnAddr_m = pdnAddr_i;
+ }
+
+ /******************************************************************************
+ * returns pdnAddr
+ ******************************************************************************/
+ const Paa& SessionContext::getPdnAddr()const
+ {
+ return pdnAddr_m;
+ }
+ /******************************************************************************
+ * sets accessPtName
+ ******************************************************************************/
+ void SessionContext::setAccessPtName( const Apn_name& accessPtName_i )
+ {
+ accessPtName_m = accessPtName_i;
+ }
+
+ /******************************************************************************
+ * returns accessPtName
+ ******************************************************************************/
+ const Apn_name& SessionContext::getAccessPtName()const
+ {
+ return accessPtName_m;
+ }
+
+ /******************************************************************************
+ * sets apnConfigProfileCtxId
+ ******************************************************************************/
+ void SessionContext::setApnConfigProfileCtxId( unsigned int apnConfigProfileCtxId_i )
+ {
+ apnConfigProfileCtxId_m = apnConfigProfileCtxId_i;
+ }
+
+ /******************************************************************************
+ * returns apnConfigProfileCtxId
+ ******************************************************************************/
+ unsigned int SessionContext::getApnConfigProfileCtxId()
+ {
+ return apnConfigProfileCtxId_m;
+ }
+
+ /******************************************************************************
+ * sets pti
+ *******************************************************************************/
+ void SessionContext::setPti( uint8_t pti_i )
+ {
+ pti_m = pti_i;
+ }
+
+ /******************************************************************************
+ * returns pti
+ ******************************************************************************/
+ uint8_t SessionContext::getPti()
+ {
+ return pti_m;
+ }
+
+ /******************************************************************************
+ * sets BearerContext
+ ******************************************************************************/
+ void SessionContext::setBearerContext( BearerContext* BearerContextp )
+ {
+ BearerContext_mp = BearerContextp;
+ }
+
+ /******************************************************************************
+ * returns BearerContext
+ ******************************************************************************/
+ BearerContext* SessionContext::getBearerContext()
+ {
+ return BearerContext_mp;
+ }
+ /******************************************************************************
+ *******************************************************************************
+ * BearerContext
+ *******************************************************************************
+ ******************************************************************************/
+
+ /******************************************************************************
+ * Constructor
+ ******************************************************************************/
+ BearerContext::BearerContext():s1uSgwUserFteid_m(), s5S8PgwUserFteid_m(),
+ s1uEnbUserFteid_m(), bearerId_m(0)
+ {
+ }
+
+ /******************************************************************************
+ * Destructor
+ ******************************************************************************/
+ BearerContext::~BearerContext()
+ {
+ }
+
+ /******************************************************************************
+ * sets s1uSgwUserFteid
+ ******************************************************************************/
+ void BearerContext::setS1uSgwUserFteid( const Fteid& s1uSgwUserFteid_i )
+ {
+ s1uSgwUserFteid_m = s1uSgwUserFteid_i;
+ }
+
+ /******************************************************************************
+ * returns s1uSgwUserFteid
+ ******************************************************************************/
+ const Fteid& BearerContext::getS1uSgwUserFteid()const
+ {
+ return s1uSgwUserFteid_m;
+ }
+ /******************************************************************************
+ * sets s5S8PgwUserFteid
+ ******************************************************************************/
+ void BearerContext::setS5S8PgwUserFteid( const Fteid& s5S8PgwUserFteid_i )
+ {
+ s5S8PgwUserFteid_m = s5S8PgwUserFteid_i;
+ }
+
+ /******************************************************************************
+ * returns s5S8PgwUserFteid
+ ******************************************************************************/
+ const Fteid& BearerContext::getS5S8PgwUserFteid()const
+ {
+ return s5S8PgwUserFteid_m;
+ }
+ /******************************************************************************
+ * sets s1uEnbUserFteid
+ ******************************************************************************/
+ void BearerContext::setS1uEnbUserFteid( const Fteid& s1uEnbUserFteid_i )
+ {
+ s1uEnbUserFteid_m = s1uEnbUserFteid_i;
+ }
+
+ /******************************************************************************
+ * returns s1uEnbUserFteid
+ ******************************************************************************/
+ const Fteid& BearerContext::getS1uEnbUserFteid()const
+ {
+ return s1uEnbUserFteid_m;
+ }
+ /******************************************************************************
+ * sets bearerId
+ ******************************************************************************/
+ void BearerContext::setBearerId( unsigned char bearerId_i )
+ {
+ bearerId_m = bearerId_i;
+ }
+
+ /******************************************************************************
+ * returns bearerId
+ ******************************************************************************/
+ unsigned char BearerContext::getBearerId()
+ {
+ return bearerId_m;
+ }
+
+ /******************************************************************************
+ *******************************************************************************
+ * MmeProcedureCtxt
+ *******************************************************************************
+ ******************************************************************************/
+
+ /******************************************************************************
+ * Constructor
+ ******************************************************************************/
+ MmeProcedureCtxt::MmeProcedureCtxt(): ctxtType_m(invalidProcedureType_c),
+ mmeErrorCause_m(noError_c), attachType_m(invalidAttachType_c),
+ pti_m(0), esmInfoTxRequired_m(false)
+ {
+ memset(pcoOptions_m, 0, sizeof(pcoOptions_m));
+ }
+
+ /******************************************************************************
+ * Destructor
+ ******************************************************************************/
+ MmeProcedureCtxt::~MmeProcedureCtxt()
+ {
+ }
+
+ /******************************************************************************
+ * sets ctxtType
+ ******************************************************************************/
+ void MmeProcedureCtxt::setCtxtType( ProcedureType ctxtType_i )
+ {
+ ctxtType_m = ctxtType_i;
+ }
+
+ /******************************************************************************
+ * returns ctxtType
+ ******************************************************************************/
+ ProcedureType MmeProcedureCtxt::getCtxtType()
+ {
+ return ctxtType_m;
+ }
+
+ /******************************************************************************
+ * sets pcoOptions
+ ******************************************************************************/
+ void MmeProcedureCtxt::setPcoOptions(const unsigned short int* pcoOptions_i )
+ {
+ memcpy(pcoOptions_m,pcoOptions_i,10);
+ }
+
+ /******************************************************************************
+ * returns pcoOptions
+ ******************************************************************************/
+ const unsigned short int* MmeProcedureCtxt::getPcoOptions()const
+ {
+ return &pcoOptions_m[0];
+ }
+
+ /******************************************************************************
+ * sets esmInfoTxRequired
+ ******************************************************************************/
+ void MmeProcedureCtxt::setEsmInfoTxRequired ( bool esmInfoTxRequired_i )
+ {
+ esmInfoTxRequired_m = esmInfoTxRequired_i;
+ }
+
+ /******************************************************************************
+ * returns esmInfoTxRequired
+ ******************************************************************************/
+ bool MmeProcedureCtxt::getEsmInfoTxRequired()
+ {
+ return esmInfoTxRequired_m;
+ }
+
+ /******************************************************************************
+ * sets attachType
+ ******************************************************************************/
+ void MmeProcedureCtxt::setAttachType( AttachType attachType_i )
+ {
+ attachType_m = attachType_i;
+ }
+
+ /******************************************************************************
+ * returns attachType
+ ******************************************************************************/
+ AttachType MmeProcedureCtxt::getAttachType()
+ {
+ return attachType_m;
+ }
+
+ /******************************************************************************
+ * sets pti
+ * ******************************************************************************/
+ void MmeProcedureCtxt::setPti( uint8_t pti_i )
+ {
+ pti_m = pti_i;
+ }
+
+ /******************************************************************************
+ * returns pti
+ ******************************************************************************/
+ uint8_t MmeProcedureCtxt::getPti()
+ {
+ return pti_m;
+ }
+
+ /******************************************************************************
+ * sets mmeErrorCause
+ * ******************************************************************************/
+ void MmeProcedureCtxt::setMmeErrorCause( MmeErrorCause mmeErrorCause_i )
+ {
+ mmeErrorCause_m = mmeErrorCause_i;
+ }
+
+ /******************************************************************************
+ * returns mmeErrorCause
+ *******************************************************************************/
+ MmeErrorCause MmeProcedureCtxt::getMmeErrorCause()
+ {
+ return mmeErrorCause_m;
+ }
+
+
+ /******************************************************************************
+ *******************************************************************************
+ * MmeDetachProcedureCtxt
+ *******************************************************************************
+ ******************************************************************************/
+
+ /******************************************************************************
+ * Constructor
+ ******************************************************************************/
+ MmeDetachProcedureCtxt::MmeDetachProcedureCtxt():
+ detachType_m(invalidDetachType_c), cancellationType_m(INVALID_TYPE)
+ {
+ }
+
+ /******************************************************************************
+ * Destructor
+ ******************************************************************************/
+ MmeDetachProcedureCtxt::~MmeDetachProcedureCtxt()
+ {
+ }
+
+ /******************************************************************************
+ * sets detachType
+ ******************************************************************************/
+ void MmeDetachProcedureCtxt::setDetachType( DetachType detachType_i )
+ {
+ detachType_m = detachType_i;
+ }
+
+ /******************************************************************************
+ * returns detachType
+ *******************************************************************************/
+ DetachType MmeDetachProcedureCtxt::getDetachType()
+ {
+ return detachType_m;
+ }
+
+ /******************************************************************************
+ * sets cancellationType
+ *******************************************************************************/
+ void MmeDetachProcedureCtxt::setCancellationType( CancellationType cancellationType_i )
+ {
+ cancellationType_m = cancellationType_i;
+ }
+
+ /******************************************************************************
+ * returns cancellationType
+ *******************************************************************************/
+ CancellationType MmeDetachProcedureCtxt::getCancellationType()
+ {
+ return cancellationType_m;
+ }
+
+
+ /******************************************************************************
+ *******************************************************************************
+ MmeSvcReqProcedureContext
+ *******************************************************************************
+ ******************************************************************************/
+
+ /******************************************************************************
+ * Constructor
+ ******************************************************************************/
+ MmeSvcReqProcedureCtxt::MmeSvcReqProcedureCtxt(): pagingTrigger_m(none_c),
+ epsBearerId_m(0), arp_m(), ddnSeqNum_m()
+ {
+ }
+
+ /******************************************************************************
+ * Destructor
+ ******************************************************************************/
+ MmeSvcReqProcedureCtxt::~MmeSvcReqProcedureCtxt()
+ {
+ }
+
+ /******************************************************************************
+ * sets ddnSeqNo
+ *******************************************************************************/
+ void MmeSvcReqProcedureCtxt::setDdnSeqNo( uint32_t ddnSeqNum_i )
+ {
+ ddnSeqNum_m = ddnSeqNum_i;
+ }
+
+ /******************************************************************************
+ * returns ddnSeqNo
+ *******************************************************************************/
+ uint32_t MmeSvcReqProcedureCtxt::getDdnSeqNo()
+ {
+ return ddnSeqNum_m;
+ }
+
+ /******************************************************************************
+ * sets pagingTrigger
+ ******************************************************************************/
+ void MmeSvcReqProcedureCtxt::setPagingTrigger( PagingTrigger pagingTrigger_i )
+ {
+ pagingTrigger_m = pagingTrigger_i;
+ }
+
+ /******************************************************************************
+ * returns pagingTrigger
+ ******************************************************************************/
+ PagingTrigger MmeSvcReqProcedureCtxt::getPagingTrigger()
+ {
+ return pagingTrigger_m;
+ }
+
+ /******************************************************************************
+ * sets epsBearerId
+ ******************************************************************************/
+ void MmeSvcReqProcedureCtxt::setEpsBearerId( unsigned char epsBearerId_i )
+ {
+ epsBearerId_m = epsBearerId_i;
+ }
+
+ /******************************************************************************
+ * returns epsBearerId
+ ******************************************************************************/
+ unsigned char MmeSvcReqProcedureCtxt::getEpsBearerId()
+ {
+ return epsBearerId_m;
+ }
+
+
+ /******************************************************************************
+ * sets arp
+ ******************************************************************************/
+ void MmeSvcReqProcedureCtxt::setArp( const Arp& arp_i )
+ {
+ arp_m = arp_i;
+ }
+
+ /******************************************************************************
+ * returns arp
+ ******************************************************************************/
+ const Arp& MmeSvcReqProcedureCtxt::getArp()const
+ {
+ return arp_m;
+ }
+
+
+ /******************************************************************************
+ *******************************************************************************
+ MmeTauProcedureCtxt
+ *******************************************************************************
+ ******************************************************************************/
+
+ /******************************************************************************
+ * Constructor
+ ******************************************************************************/
+ MmeTauProcedureCtxt::MmeTauProcedureCtxt():s1apEnbUeId_m(0), tai_m(), enbFd_m()
+ {
+ }
+
+ /******************************************************************************
+ * Destructor
+ ******************************************************************************/
+ MmeTauProcedureCtxt::~MmeTauProcedureCtxt()
+ {
+ }
+
+ /******************************************************************************
+ * sets s1apEnbUeId
+ ******************************************************************************/
+ void MmeTauProcedureCtxt::setS1apEnbUeId( int s1apEnbUeId_i )
+ {
+ s1apEnbUeId_m = s1apEnbUeId_i;
+ }
+
+ /******************************************************************************
+ * returns s1apEnbUeId
+ ******************************************************************************/
+ int MmeTauProcedureCtxt::getS1apEnbUeId()
+ {
+ return s1apEnbUeId_m;
+ }
+
+ /******************************************************************************
+ * sets tai
+ ******************************************************************************/
+ void MmeTauProcedureCtxt::setTai( const Tai& tai_i )
+ {
+ tai_m = tai_i;
+ }
+
+ /******************************************************************************
+ * returns tai
+ ******************************************************************************/
+ const Tai& MmeTauProcedureCtxt::getTai()const
+ {
+ return tai_m;
+ }
+
+ /******************************************************************************
+ * sets enbFd
+ ******************************************************************************/
+ void MmeTauProcedureCtxt::setEnbFd( int enbFd_i )
+ {
+ enbFd_m = enbFd_i;
+ }
+
+ /******************************************************************************
+ * returns enbFd
+ ******************************************************************************/
+ int MmeTauProcedureCtxt::getEnbFd()
+ {
+ return enbFd_m;
+ }
+
+} // mme
diff --git a/src/mme-app/contextManager/mmContextManager.cpp b/src/mme-app/contextManager/mmContextManager.cpp
new file mode 100644
index 0000000..ad702f1
--- /dev/null
+++ b/src/mme-app/contextManager/mmContextManager.cpp
@@ -0,0 +1,52 @@
+ /*
+ * Copyright 2019-present Infosys Limited
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+/******************************************************************************
+ * mmContextManager.cpp
+ * This is an auto generated file.
+ * Please do not edit this file.
+ * All edits to be made through template source file
+ * <TOP-DIR/scripts/SMCodeGen/templates/ctxtManagerTmpls/blockPoolManager.cpp.tt>
+ ******************************************************************************/
+
+#include "memPoolManager.h"
+#include "contextManager/dataBlocks.h"
+#include "contextManager/mmContextManager.h"
+
+using namespace cmn::memPool;
+
+namespace mme
+{
+ /******************************************************************************
+ * Constructor
+ ******************************************************************************/
+ MmContextManager::MmContextManager( int numOfBlocks ):poolManager_m(numOfBlocks)
+ {
+ }
+
+ /******************************************************************************
+ * Destructor
+ ******************************************************************************/
+ MmContextManager::~MmContextManager()
+ {
+ }
+
+ /******************************************************************************
+ * Allocate MmContext data block
+ ******************************************************************************/
+ MmContext* MmContextManager::allocateMmContext()
+ {
+ MmContext* MmContext_p = poolManager_m.allocate();
+ return MmContext_p;
+ }
+
+ /******************************************************************************
+ * Deallocate a MmContext data block
+ ******************************************************************************/
+ void MmContextManager::deallocateMmContext(MmContext* MmContextp )
+ {
+ poolManager_m.free( MmContextp );
+ }
+}
diff --git a/src/mme-app/contextManager/mmeDetachProcedureCtxtManager.cpp b/src/mme-app/contextManager/mmeDetachProcedureCtxtManager.cpp
new file mode 100644
index 0000000..d9f6997
--- /dev/null
+++ b/src/mme-app/contextManager/mmeDetachProcedureCtxtManager.cpp
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2019-present Infosys Limited
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+/******************************************************************************
+ * mmeDetachProcedureCtxtManager.cpp
+ * This is an auto generated file.
+ * Please do not edit this file.
+ * All edits to be made through template source file
+ * <TOP-DIR/scripts/SMCodeGen/templates/ctxtManagerTmpls/blockPoolManager.cpp.tt>
+ ******************************************************************************/
+
+#include "memPoolManager.h"
+#include "contextManager/dataBlocks.h"
+#include "contextManager/mmeDetachProcedureCtxtManager.h"
+
+using namespace cmn::memPool;
+
+namespace mme
+{
+ /******************************************************************************
+ * Constructor
+ ******************************************************************************/
+ MmeDetachProcedureCtxtManager::MmeDetachProcedureCtxtManager(int numOfBlocks):poolManager_m(numOfBlocks)
+ {
+ }
+
+ /******************************************************************************
+ * Destructor
+ ******************************************************************************/
+ MmeDetachProcedureCtxtManager::~MmeDetachProcedureCtxtManager()
+ {
+ }
+
+ /******************************************************************************
+ * Allocate MmeDetachProcedureCtxt data block
+ ******************************************************************************/
+ MmeDetachProcedureCtxt* MmeDetachProcedureCtxtManager::allocateMmeDetachProcedureCtxt()
+ {
+ MmeDetachProcedureCtxt* MmeDetachProcedureCtxt_p = poolManager_m.allocate();
+ return MmeDetachProcedureCtxt_p;
+ }
+
+ /******************************************************************************
+ * Deallocate a MmeDetachProcedureCtxt data block
+ ******************************************************************************/
+ void MmeDetachProcedureCtxtManager::deallocateMmeDetachProcedureCtxt(MmeDetachProcedureCtxt* MmeDetachProcedureCtxtp )
+ {
+ poolManager_m.free( MmeDetachProcedureCtxtp );
+ }
+}
diff --git a/src/mme-app/contextManager/mmeProcedureCtxtManager.cpp b/src/mme-app/contextManager/mmeProcedureCtxtManager.cpp
new file mode 100644
index 0000000..84c25dc
--- /dev/null
+++ b/src/mme-app/contextManager/mmeProcedureCtxtManager.cpp
@@ -0,0 +1,52 @@
+ /*
+ * Copyright 2019-present Infosys Limited
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+/******************************************************************************
+ * mmeProcedureCtxtManager.cpp
+ * This is an auto generated file.
+ * Please do not edit this file.
+ * All edits to be made through template source file
+ * <TOP-DIR/scripts/SMCodeGen/templates/ctxtManagerTmpls/blockPoolManager.cpp.tt>
+ ******************************************************************************/
+
+#include "memPoolManager.h"
+#include "contextManager/dataBlocks.h"
+#include "contextManager/mmeProcedureCtxtManager.h"
+
+using namespace cmn::memPool;
+
+namespace mme
+{
+ /******************************************************************************
+ * Constructor
+ ******************************************************************************/
+ MmeProcedureCtxtManager::MmeProcedureCtxtManager(int numOfBlocks):poolManager_m(numOfBlocks)
+ {
+ }
+
+ /******************************************************************************
+ * Destructor
+ ******************************************************************************/
+ MmeProcedureCtxtManager::~MmeProcedureCtxtManager()
+ {
+ }
+
+ /******************************************************************************
+ * Allocate MmeProcedureCtxt data block
+ ******************************************************************************/
+ MmeProcedureCtxt* MmeProcedureCtxtManager::allocateMmeProcedureCtxt()
+ {
+ MmeProcedureCtxt* MmeProcedureCtxt_p = poolManager_m.allocate();
+ return MmeProcedureCtxt_p;
+ }
+
+ /******************************************************************************
+ * Deallocate a MmeProcedureCtxt data block
+ ******************************************************************************/
+ void MmeProcedureCtxtManager::deallocateMmeProcedureCtxt(MmeProcedureCtxt* MmeProcedureCtxtp )
+ {
+ poolManager_m.free( MmeProcedureCtxtp );
+ }
+}
diff --git a/src/mme-app/contextManager/mmeSvcReqProcedureCtxtManager.cpp b/src/mme-app/contextManager/mmeSvcReqProcedureCtxtManager.cpp
new file mode 100644
index 0000000..fd70058
--- /dev/null
+++ b/src/mme-app/contextManager/mmeSvcReqProcedureCtxtManager.cpp
@@ -0,0 +1,52 @@
+ /*
+ * Copyright 2019-present Infosys Limited
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+/******************************************************************************
+ * mmeSvcReqProcedureCtxtManager.cpp
+ * This is an auto generated file.
+ * Please do not edit this file.
+ * All edits to be made through template source file
+ * <TOP-DIR/scripts/SMCodeGen/templates/ctxtManagerTmpls/blockPoolManager.cpp.tt>
+ ******************************************************************************/
+
+#include "memPoolManager.h"
+#include "contextManager/dataBlocks.h"
+#include "contextManager/mmeSvcReqProcedureCtxtManager.h"
+
+using namespace cmn::memPool;
+
+namespace mme
+{
+ /******************************************************************************
+ * Constructor
+ ******************************************************************************/
+ MmeSvcReqProcedureCtxtManager::MmeSvcReqProcedureCtxtManager(int numOfBlocks):poolManager_m(numOfBlocks)
+ {
+ }
+
+ /******************************************************************************
+ * Destructor
+ ******************************************************************************/
+ MmeSvcReqProcedureCtxtManager::~MmeSvcReqProcedureCtxtManager()
+ {
+ }
+
+ /******************************************************************************
+ * Allocate MmeSvcReqProcedureCtxt data block
+ ******************************************************************************/
+ MmeSvcReqProcedureCtxt* MmeSvcReqProcedureCtxtManager::allocateMmeSvcReqProcedureCtxt()
+ {
+ MmeSvcReqProcedureCtxt* MmeSvcReqProcedureCtxt_p = poolManager_m.allocate();
+ return MmeSvcReqProcedureCtxt_p;
+ }
+
+ /******************************************************************************
+ * Deallocate a MmeSvcReqProcedureCtxt data block
+ ******************************************************************************/
+ void MmeSvcReqProcedureCtxtManager::deallocateMmeSvcReqProcedureCtxt(MmeSvcReqProcedureCtxt* MmeSvcReqProcedureCtxtp )
+ {
+ poolManager_m.free( MmeSvcReqProcedureCtxtp );
+ }
+}
diff --git a/src/mme-app/contextManager/mmeTauProcedureCtxtManager.cpp b/src/mme-app/contextManager/mmeTauProcedureCtxtManager.cpp
new file mode 100644
index 0000000..92149ac
--- /dev/null
+++ b/src/mme-app/contextManager/mmeTauProcedureCtxtManager.cpp
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2019-present Infosys Limited
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+/******************************************************************************
+ * mmeTauProcedureCtxtManager.cpp
+ * This is an auto generated file.
+ * Please do not edit this file.
+ * All edits to be made through template source file
+ * <TOP-DIR/scripts/SMCodeGen/templates/ctxtManagerTmpls/blockPoolManager.cpp.tt>
+ ******************************************************************************/
+
+#include "memPoolManager.h"
+#include "contextManager/dataBlocks.h"
+#include "contextManager/mmeTauProcedureCtxtManager.h"
+
+using namespace cmn::memPool;
+
+namespace mme
+{
+ /******************************************************************************
+ * Constructor
+ ******************************************************************************/
+ MmeTauProcedureCtxtManager::MmeTauProcedureCtxtManager(int numOfBlocks):poolManager_m(numOfBlocks)
+ {
+ }
+
+ /******************************************************************************
+ * Destructor
+ ******************************************************************************/
+ MmeTauProcedureCtxtManager::~MmeTauProcedureCtxtManager()
+ {
+ }
+
+ /******************************************************************************
+ * Allocate MmeTauProcedureCtxt data block
+ ******************************************************************************/
+ MmeTauProcedureCtxt* MmeTauProcedureCtxtManager::allocateMmeTauProcedureCtxt()
+ {
+ MmeTauProcedureCtxt* MmeTauProcedureCtxt_p = poolManager_m.allocate();
+ return MmeTauProcedureCtxt_p;
+ }
+
+ /******************************************************************************
+ * Deallocate a MmeTauProcedureCtxt data block
+ ******************************************************************************/
+ void MmeTauProcedureCtxtManager::deallocateMmeTauProcedureCtxt(MmeTauProcedureCtxt* MmeTauProcedureCtxtp)
+ {
+ poolManager_m.free( MmeTauProcedureCtxtp );
+ }
+}
diff --git a/src/mme-app/contextManager/sessionContextManager.cpp b/src/mme-app/contextManager/sessionContextManager.cpp
new file mode 100644
index 0000000..0dad793
--- /dev/null
+++ b/src/mme-app/contextManager/sessionContextManager.cpp
@@ -0,0 +1,52 @@
+ /*
+ * Copyright 2019-present Infosys Limited
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+/******************************************************************************
+ * sessionContextManager.cpp
+ * This is an auto generated file.
+ * Please do not edit this file.
+ * All edits to be made through template source file
+ * <TOP-DIR/scripts/SMCodeGen/templates/ctxtManagerTmpls/blockPoolManager.cpp.tt>
+ ******************************************************************************/
+
+#include "memPoolManager.h"
+#include "contextManager/dataBlocks.h"
+#include "contextManager/sessionContextManager.h"
+
+using namespace cmn::memPool;
+
+namespace mme
+{
+ /******************************************************************************
+ * Constructor
+ ******************************************************************************/
+ SessionContextManager::SessionContextManager(int numOfBlocks):poolManager_m(numOfBlocks)
+ {
+ }
+
+ /******************************************************************************
+ * Destructor
+ ******************************************************************************/
+ SessionContextManager::~SessionContextManager()
+ {
+ }
+
+ /******************************************************************************
+ * Allocate SessionContext data block
+ ******************************************************************************/
+ SessionContext* SessionContextManager::allocateSessionContext()
+ {
+ SessionContext* SessionContext_p = poolManager_m.allocate();
+ return SessionContext_p;
+ }
+
+ /******************************************************************************
+ * Deallocate a SessionContext data block
+ ******************************************************************************/
+ void SessionContextManager::deallocateSessionContext(SessionContext* SessionContextp )
+ {
+ poolManager_m.free( SessionContextp );
+ }
+}
diff --git a/src/mme-app/contextManager/subsDataGroupManager.cpp b/src/mme-app/contextManager/subsDataGroupManager.cpp
new file mode 100644
index 0000000..b3a5154
--- /dev/null
+++ b/src/mme-app/contextManager/subsDataGroupManager.cpp
@@ -0,0 +1,242 @@
+/*
+ * Copyright 2019-present Infosys Limited
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/**************************************
+ *
+ * This is an auto generated file.
+ * Please do not edit this file.
+ * All edits to be made through template source file
+ * <TOP-DIR/scripts/SMCodeGen/templates/ctxtManagerTmpls/subsDataGroupManager.cpp.tt>
+ ***************************************/
+#include "contextManager/subsDataGroupManager.h"
+#include "log.h"
+#include "mmeStates/defaultMmeState.h"
+#include <sstream>
+
+namespace mme
+{
+ /******************************************************************************
+ * Constructor
+ ******************************************************************************/
+ SubsDataGroupManager::SubsDataGroupManager()
+ {
+ UEContextManagerm_p = NULL;
+ MmContextManagerm_p = NULL;
+ SessionContextManagerm_p = NULL;
+ BearerContextManagerm_p = NULL;
+ MmeProcedureCtxtManagerm_p = NULL;
+ MmeDetachProcedureCtxtManagerm_p = NULL;
+ MmeSvcReqProcedureCtxtManagerm_p = NULL;
+ MmeTauProcedureCtxtManagerm_p = NULL;
+
+ initialize();
+ }
+
+ /******************************************************************************
+ * Destructor
+ ******************************************************************************/
+ SubsDataGroupManager::~SubsDataGroupManager()
+ {
+ delete UEContextManagerm_p;
+ delete MmContextManagerm_p;
+ delete SessionContextManagerm_p;
+ delete BearerContextManagerm_p;
+ delete MmeProcedureCtxtManagerm_p;
+ delete MmeDetachProcedureCtxtManagerm_p;
+ delete MmeSvcReqProcedureCtxtManagerm_p;
+ delete MmeTauProcedureCtxtManagerm_p;
+ }
+
+ /******************************************
+ * Initializes control block and pool managers
+ ******************************************/
+ void SubsDataGroupManager::initialize()
+ {
+ initializeCBStore(8000);
+
+ UEContextManagerm_p = new UEContextManager(8000);
+ MmContextManagerm_p = new MmContextManager(8000);
+ SessionContextManagerm_p = new SessionContextManager(8000);
+ BearerContextManagerm_p = new BearerContextManager(8000);
+ MmeProcedureCtxtManagerm_p = new MmeProcedureCtxtManager(8000);
+ MmeDetachProcedureCtxtManagerm_p = new MmeDetachProcedureCtxtManager(8000);
+ MmeSvcReqProcedureCtxtManagerm_p = new MmeSvcReqProcedureCtxtManager(8000);
+ MmeTauProcedureCtxtManagerm_p = new MmeTauProcedureCtxtManager(8000);
+ }
+
+ /******************************************************************************
+ * creates and returns static instance
+ ******************************************************************************/
+ SubsDataGroupManager* SubsDataGroupManager::Instance()
+ {
+ static SubsDataGroupManager subDataGroupMgr;
+ return &subDataGroupMgr;
+ }
+
+ UEContext* SubsDataGroupManager::getUEContext()
+ {
+ return UEContextManagerm_p->allocateUEContext();
+ }
+
+ void SubsDataGroupManager::deleteUEContext(UEContext* UEContextp )
+ {
+ UEContextManagerm_p->deallocateUEContext( UEContextp );
+ }
+
+ MmContext* SubsDataGroupManager::getMmContext()
+ {
+ return MmContextManagerm_p->allocateMmContext();
+ }
+
+ void SubsDataGroupManager::deleteMmContext(MmContext* MmContextp )
+ {
+ MmContextManagerm_p->deallocateMmContext( MmContextp );
+ }
+
+ SessionContext* SubsDataGroupManager::getSessionContext()
+ {
+ return SessionContextManagerm_p->allocateSessionContext();
+ }
+
+ void SubsDataGroupManager::deleteSessionContext(SessionContext* SessionContextp )
+ {
+ SessionContextManagerm_p->deallocateSessionContext( SessionContextp );
+ }
+
+ BearerContext* SubsDataGroupManager::getBearerContext()
+ {
+ return BearerContextManagerm_p->allocateBearerContext();
+ }
+
+ void SubsDataGroupManager::deleteBearerContext(BearerContext* BearerContextp )
+ {
+ BearerContextManagerm_p->deallocateBearerContext( BearerContextp );
+ }
+
+ MmeProcedureCtxt* SubsDataGroupManager::getMmeProcedureCtxt()
+ {
+ return MmeProcedureCtxtManagerm_p->allocateMmeProcedureCtxt();
+ }
+
+ void SubsDataGroupManager::deleteMmeProcedureCtxt(MmeProcedureCtxt* MmeProcedureCtxtp )
+ {
+ MmeProcedureCtxtManagerm_p->deallocateMmeProcedureCtxt( MmeProcedureCtxtp );
+ }
+
+ MmeDetachProcedureCtxt* SubsDataGroupManager::getMmeDetachProcedureCtxt()
+ {
+ return MmeDetachProcedureCtxtManagerm_p->allocateMmeDetachProcedureCtxt();
+ }
+
+ void SubsDataGroupManager::deleteMmeDetachProcedureCtxt(MmeDetachProcedureCtxt* MmeDetachProcedureCtxtp )
+ {
+ MmeDetachProcedureCtxtManagerm_p->deallocateMmeDetachProcedureCtxt( MmeDetachProcedureCtxtp );
+ }
+
+ MmeSvcReqProcedureCtxt* SubsDataGroupManager::getMmeSvcReqProcedureCtxt()
+ {
+ return MmeSvcReqProcedureCtxtManagerm_p->allocateMmeSvcReqProcedureCtxt();
+ }
+
+ void SubsDataGroupManager::deleteMmeSvcReqProcedureCtxt(MmeSvcReqProcedureCtxt* MmeSvcReqProcedureCtxtp )
+ {
+ MmeSvcReqProcedureCtxtManagerm_p->deallocateMmeSvcReqProcedureCtxt( MmeSvcReqProcedureCtxtp );
+ }
+
+ MmeTauProcedureCtxt* SubsDataGroupManager::getMmeTauProcedureCtxt()
+ {
+ return MmeTauProcedureCtxtManagerm_p->allocateMmeTauProcedureCtxt();
+ }
+
+ void SubsDataGroupManager::deleteMmeTauProcedureCtxt(MmeTauProcedureCtxt* MmeTauProcedureCtxtp )
+ {
+ MmeTauProcedureCtxtManagerm_p->deallocateMmeTauProcedureCtxt( MmeTauProcedureCtxtp );
+ }
+
+ /******************************************
+ * Add a imsi as key and cb index as value to imsi_cb_id_map
+ ******************************************/
+ int SubsDataGroupManager::addimsikey( DigitRegister15 key, int cb_index )
+ {
+ std::lock_guard<std::mutex> lock(imsi_cb_id_map_mutex);
+
+ int rc = 1;
+ auto itr = imsi_cb_id_map.insert(std::pair<DigitRegister15, int>( key, cb_index ));
+ if (itr.second == false)
+ {
+ rc = -1;
+ }
+ return rc;
+ }
+
+ /******************************************
+ * Delete a imsi key from imsi_cb_id_map
+ ******************************************/
+ int SubsDataGroupManager::deleteimsikey( DigitRegister15 key )
+ {
+ std::lock_guard<std::mutex> lock(imsi_cb_id_map_mutex);
+
+ return imsi_cb_id_map.erase( key );
+ }
+
+ /******************************************
+ * Find cb with given imsi from imsi_cb_id_map
+ * returns -1 if not found, else cb index
+ ******************************************/
+ int SubsDataGroupManager::findCBWithimsi( DigitRegister15 key )
+ {
+ std::lock_guard<std::mutex> lock(imsi_cb_id_map_mutex);
+
+ auto itr = imsi_cb_id_map.find( key );
+ if( itr != imsi_cb_id_map.end())
+ {
+ return itr->second;
+ }
+ return -1;
+ }
+
+ /******************************************
+ * Add a mTmsi as key and cb index as value to mTmsi_cb_id_map
+ ******************************************/
+ int SubsDataGroupManager::addmTmsikey( uint32_t key, int cb_index )
+ {
+ std::lock_guard<std::mutex> lock(mTmsi_cb_id_map_mutex);
+
+ int rc = 1;
+ auto itr = mTmsi_cb_id_map.insert(std::pair<uint32_t, int>( key, cb_index ));
+ if (itr.second == false)
+ {
+ rc = -1;
+ }
+ return rc;
+ }
+
+ /******************************************
+ * Delete a mTmsi key from mTmsi_cb_id_map
+ ******************************************/
+ int SubsDataGroupManager::deletemTmsikey( uint32_t key )
+ {
+ std::lock_guard<std::mutex> lock(mTmsi_cb_id_map_mutex);
+
+ return mTmsi_cb_id_map.erase( key );
+ }
+
+ /******************************************
+ * Find cb with given mTmsi from mTmsi_cb_id_map
+ * returns -1 if not found, else cb index
+ ******************************************/
+ int SubsDataGroupManager::findCBWithmTmsi( uint32_t key )
+ {
+ std::lock_guard<std::mutex> lock(mTmsi_cb_id_map_mutex);
+
+ auto itr = mTmsi_cb_id_map.find( key );
+ if( itr != mTmsi_cb_id_map.end())
+ {
+ return itr->second;
+ }
+ return -1;
+ }
+}
diff --git a/src/mme-app/contextManager/uEContextManager.cpp b/src/mme-app/contextManager/uEContextManager.cpp
new file mode 100644
index 0000000..62362bc
--- /dev/null
+++ b/src/mme-app/contextManager/uEContextManager.cpp
@@ -0,0 +1,52 @@
+ /*
+ * Copyright 2019-present Infosys Limited
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+/******************************************************************************
+ * uEContextManager.cpp
+ * This is an auto generated file.
+ * Please do not edit this file.
+ * All edits to be made through template source file
+ * <TOP-DIR/scripts/SMCodeGen/templates/ctxtManagerTmpls/blockPoolManager.cpp.tt>
+ ******************************************************************************/
+
+#include "memPoolManager.h"
+#include "contextManager/dataBlocks.h"
+#include "contextManager/uEContextManager.h"
+
+using namespace cmn::memPool;
+
+namespace mme
+{
+ /******************************************************************************
+ * Constructor
+ ******************************************************************************/
+ UEContextManager::UEContextManager(int numOfBlocks):poolManager_m(numOfBlocks)
+ {
+ }
+
+ /******************************************************************************
+ * Destructor
+ ******************************************************************************/
+ UEContextManager::~UEContextManager()
+ {
+ }
+
+ /******************************************************************************
+ * Allocate UEContext data block
+ ******************************************************************************/
+ UEContext* UEContextManager::allocateUEContext()
+ {
+ UEContext* UEContext_p = poolManager_m.allocate();
+ return UEContext_p;
+ }
+
+ /******************************************************************************
+ * Deallocate a UEContext data block
+ ******************************************************************************/
+ void UEContextManager::deallocateUEContext(UEContext* UEContextp )
+ {
+ poolManager_m.free( UEContextp );
+ }
+}
diff --git a/src/mme-app/interfaces/mmeIpcInterface.cpp b/src/mme-app/interfaces/mmeIpcInterface.cpp
new file mode 100644
index 0000000..15950f7
--- /dev/null
+++ b/src/mme-app/interfaces/mmeIpcInterface.cpp
@@ -0,0 +1,153 @@
+/*
+ * Copyright (c) 2019, Infosys Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <interfaces/mmeIpcInterface.h>
+#include <blockingCircularFifo.h>
+#include <ipcTypes.h>
+#include <tipcSocket.h>
+#include <tipcTypes.h>
+#include <msgBuffer.h>
+#include <mme_app.h>
+#include <msgHandlers/gtpMsgHandler.h>
+#include <msgHandlers/s1MsgHandler.h>
+#include <msgHandlers/s6MsgHandler.h>
+
+extern "C" {
+ #include "log.h"
+}
+
+using namespace cmn::ipc;
+using namespace cmn::utils;
+
+extern BlockingCircularFifo<MsgBuffer, fifoQSize_c> mmeIpcEgressFifo_g;
+
+MmeIpcInterface::MmeIpcInterface():sender_mp(), reader_mp()
+{
+
+}
+
+MmeIpcInterface::~MmeIpcInterface()
+{
+ teardown();
+}
+
+bool MmeIpcInterface::setup()
+{
+
+ // INIT socket for receiving ipc message
+ TipcSocket* receiver_sock = new TipcSocket();
+
+ IpcAddress myAddress;
+ myAddress.u32 = mmeAppInstanceNum_c;
+
+ if (receiver_sock->bindTipcSocket(myAddress) == false)
+ {
+ log_msg(LOG_ERROR, "MmeIpcInterface Setup Failed!!!\n");
+
+ delete receiver_sock;
+
+ return false;
+ }
+
+ // INIT socket for sending ipc message
+ TipcSocket* sender_sock = new TipcSocket();
+
+ sender_mp = sender_sock;
+ reader_mp = receiver_sock;
+
+ return true;
+}
+
+void MmeIpcInterface::teardown()
+{
+ if (sender_mp != NULL)
+ delete sender_mp;
+
+ if (reader_mp != NULL)
+ delete reader_mp;
+}
+
+cmn::ipc::IpcChannel* MmeIpcInterface::sender()
+{
+ if (sender_mp != NULL)
+ return sender_mp;
+ else
+ return NULL;
+}
+
+cmn::ipc::IpcChannel* MmeIpcInterface::reader()
+{
+ if (reader_mp != NULL)
+ return reader_mp;
+ else
+ return NULL;
+}
+
+void MmeIpcInterface::handleIpcMsg(MsgBuffer* msgBuf)
+{
+ uint32_t srcAddr, destAddr;
+
+ msgBuf->readUint32(destAddr);
+ msgBuf->readUint32(srcAddr);
+
+ log_msg(LOG_INFO, "IPC Message from src %u to dest %u\n", srcAddr, destAddr);
+
+ switch (srcAddr)
+
+ {
+ case TipcInstanceTypes::s1apAppInstanceNum_c:
+ S1MsgHandler::Instance()->handleS1Message_v(msgBuf);
+ break;
+ case TipcInstanceTypes::s11AppInstanceNum_c:
+ GtpMsgHandler::Instance()->handleGtpMessage_v(msgBuf);
+ break;
+ case TipcInstanceTypes::s6AppInstanceNum_c:
+ S6MsgHandler::Instance()->handleS6Message_v(msgBuf);
+ break;
+ default:
+ log_msg(LOG_INFO, "IPC Message from unsupported instance\n");
+ }
+}
+
+bool MmeIpcInterface::dispatchIpcMsg(char* buf, uint32_t len, cmn::ipc::IpcAddress& destAddr)
+{
+ cmn::ipc::IpcMsgHeader msgHeader;
+ msgHeader.srcAddr.u32 = TipcInstanceTypes::mmeAppInstanceNum_c;
+ msgHeader.destAddr.u32 = destAddr.u32;
+
+ MsgBuffer *msgBuf = new MsgBuffer(len + sizeof(cmn::ipc::IpcMsgHeader));
+ msgBuf->writeUint32(msgHeader.destAddr.u32);
+ msgBuf->writeUint32(msgHeader.srcAddr.u32);
+ msgBuf->writeBytes((uint8_t*)buf, len);
+
+ log_msg(LOG_INFO, "Dispatch IPC msg\n");
+
+ return mmeIpcEgressFifo_g.push(msgBuf);
+}
+
+bool MmeIpcInterface::dispatchIpcMsg(cmn::utils::MsgBuffer* msgBuf, cmn::ipc::IpcAddress& destAddr)
+{
+ cmn::ipc::IpcMsgHeader msgHeader;
+ msgHeader.srcAddr.u32 = TipcInstanceTypes::mmeAppInstanceNum_c;
+ msgHeader.destAddr.u32 = destAddr.u32;
+
+ msgBuf->rewind();
+ msgBuf->writeUint32(msgHeader.destAddr.u32, false);
+ msgBuf->writeUint32(msgHeader.srcAddr.u32, false);
+
+ return mmeIpcEgressFifo_g.push(msgBuf);
+}
+
diff --git a/src/mme-app/main.cpp b/src/mme-app/main.cpp
new file mode 100644
index 0000000..4c2bd41
--- /dev/null
+++ b/src/mme-app/main.cpp
@@ -0,0 +1,144 @@
+/*
+ * Copyright (c) 2019, Infosys Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <iostream>
+#include <pthread.h>
+#include <thread>
+#include <string.h>
+#include <sys/stat.h>
+
+#include <blockingCircularFifo.h>
+#include <msgBuffer.h>
+#include "err_codes.h"
+#include <interfaces/mmeIpcInterface.h>
+#include <mmeStates/stateFactory.h>
+#include "message_queues.h"
+#include "mme_app.h"
+#include "msgType.h"
+#include "stateMachineEngine.h"
+#include <sys/types.h>
+#include "mmeThreads.h"
+
+extern "C"
+{
+ #include "log.h"
+ #include "json_data.h"
+}
+
+extern void* RunServer(void * data);
+using namespace std;
+using namespace mme;
+
+/*********************************************************
+ *
+ * Circular FIFOs for sender IPC and Reader IPC threads
+ *
+ **********************************************************/
+cmn::utils::BlockingCircularFifo<cmn::utils::MsgBuffer, fifoQSize_c> mmeIpcIngressFifo_g;
+cmn::utils::BlockingCircularFifo<cmn::utils::MsgBuffer, fifoQSize_c> mmeIpcEgressFifo_g;
+
+/*********************************************************
+ *
+ * Externs
+ *
+ **********************************************************/
+extern char processName[255];
+extern int pid;
+
+mme_config g_mme_cfg;
+pthread_t stage_tid[5];
+
+MmeIpcInterface* mmeIpcIf_g = NULL;
+void
+init_parser(char *path)
+{
+ load_json(path);
+}
+
+int
+parse_mme_conf()
+{
+ /*mme own information*/
+ g_mme_cfg.mme_name = get_string_scalar("mme.name");
+ if(NULL == g_mme_cfg.mme_name) return E_PARSING_FAILED;
+
+ g_mme_cfg.mme_ip_addr = get_ip_scalar("mme.ip_addr");
+ if(E_PARSING_FAILED == g_mme_cfg.mme_ip_addr) return E_PARSING_FAILED;
+
+ g_mme_cfg.mcc_dig1 = get_int_scalar("mme.mcc.dig1");
+ if(E_PARSING_FAILED == g_mme_cfg.mcc_dig1) return E_PARSING_FAILED;
+ g_mme_cfg.mcc_dig2 = get_int_scalar("mme.mcc.dig2");
+ if(E_PARSING_FAILED == g_mme_cfg.mcc_dig1) return E_PARSING_FAILED;
+ g_mme_cfg.mcc_dig3 = get_int_scalar("mme.mcc.dig3");
+ if(E_PARSING_FAILED == g_mme_cfg.mcc_dig1) return E_PARSING_FAILED;
+ g_mme_cfg.mcc_dig1 = get_int_scalar("mme.mnc.dig1");
+ if(E_PARSING_FAILED == g_mme_cfg.mcc_dig1) return E_PARSING_FAILED;
+ g_mme_cfg.mnc_dig2 = get_int_scalar("mme.mnc.dig2");
+ if(E_PARSING_FAILED == g_mme_cfg.mcc_dig1) return E_PARSING_FAILED;
+ g_mme_cfg.mnc_dig3 = get_int_scalar("mme.mnc.dig3");
+ if(E_PARSING_FAILED == g_mme_cfg.mcc_dig1) return E_PARSING_FAILED;
+
+ return SUCCESS;
+}
+
+void setThreadName(std::thread* thread, const char* threadName)
+{
+ auto handle = thread->native_handle();
+ pthread_setname_np(handle,threadName);
+}
+
+int main(int argc, char *argv[])
+{
+ memcpy (processName, argv[0], strlen(argv[0]));
+ pid = getpid();
+
+ StateFactory::Instance()->initialize();
+
+ mmeIpcIf_g = new MmeIpcInterface();
+ mmeIpcIf_g->setup();
+
+ init_parser("conf/mme.json");
+ parse_mme_conf();
+
+ MmeIngressIpcProducerThread ipcReader;
+ std::thread t1(ipcReader);
+ setThreadName(&t1, "IpcReader");
+ t1.detach();
+
+ MmeIngressIpcConsumerThread msgHandlerThread;
+ std::thread t2(msgHandlerThread);
+ setThreadName(&t2, "MMEMsgHandlerThread");
+ t2.detach();
+
+ MmeEgressIpcConsumerThread ipcWriter;
+ std::thread t3(ipcWriter);
+ setThreadName(&t3, "IpcWriter");
+ t3.detach();
+
+ // start gRPC server
+ pthread_attr_t attr;
+ pthread_attr_init(&attr);
+ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+ pthread_create(&stage_tid[0], &attr, &RunServer, NULL);
+ pthread_attr_destroy(&attr);
+
+ while(1)
+ {
+ SM::StateMachineEngine::Instance()->run();
+ }
+
+ return 0;
+}
diff --git a/src/mme-app/mmeGrpcServer/mmeGrpcServer.cpp b/src/mme-app/mmeGrpcServer/mmeGrpcServer.cpp
new file mode 100644
index 0000000..105aee5
--- /dev/null
+++ b/src/mme-app/mmeGrpcServer/mmeGrpcServer.cpp
@@ -0,0 +1,290 @@
+#include <iostream>
+#include <memory>
+#include <string>
+#include <sstream>
+#include <time.h>
+#include <grpcpp/grpcpp.h>
+
+#include "mmeGrpc.grpc.pb.h"
+
+#include <controlBlock.h>
+#include <contextManager/dataBlocks.h>
+#include <contextManager/subsDataGroupManager.h>
+#include <procedureStats.h>
+
+using grpc::Server;
+using grpc::ServerBuilder;
+using grpc::ServerContext;
+using grpc::ServerReader;
+using grpc::ServerReaderWriter;
+using grpc::ServerWriter;
+using grpc::Status;
+using mmeGrpc::UeContextReqBuf;
+using mmeGrpc::UeContextRespBuf;
+using mmeGrpc::UeContextRespBuf_SessionContextRespBuf;
+using mmeGrpc::MmeGrpcCli;
+using mmeGrpc::Empty;
+using mmeGrpc::ProcedureStatsRespBuf;
+using mmeGrpc::EventInfoRespBuf;
+using mmeGrpc::EventInfoRespBuf_EventInfoBuf;
+
+using namespace mme;
+
+const string UEStates[4]={ "NoState", "EpsAttached", "Detached", "Idle" };
+// Logic and data behind the server's behavior.
+class MmeGrpcCliServiceImpl final : public MmeGrpcCli::Service {
+ Status GetUeContextInfo(SM::ControlBlock* controlBlk_p, UeContextRespBuf* reply) {
+ //time_t my_time = time(NULL);
+// SM::ControlBlock* controlBlk_p = mme::SubsDataGroupManager::Instance()->findControlBlock((uint32_t)request->id());
+ if (controlBlk_p)
+ {
+ UEContext* uecontext_p=dynamic_cast<UEContext*>(controlBlk_p->getPermDataBlock());
+ if (uecontext_p != NULL)
+ {
+ //cout << "MY TIME " << ctime(&my_time);
+
+ // Display IMSI
+ stringstream ss;
+ ss << uecontext_p->getImsi();
+ reply->set_imsi(ss.str());
+
+ // MSISDN
+ ss.str("");
+ ss << uecontext_p->getMsisdn();
+ string ms(ss.str());
+ ms.resize(10);
+ ms.shrink_to_fit();
+ reply->set_msisdn(ms);
+
+ // TAI
+ ss.str("");
+ const TAI& tai = uecontext_p->getTai().tai_m;
+ ss << "MCC : ";
+ ss << (unsigned char)((tai.plmn_id.idx[0] & 0x0f) + 0x30);
+ ss << (unsigned char)((tai.plmn_id.idx[0] >> 4) + 0x30);
+ ss << (unsigned char)((tai.plmn_id.idx[1] & 0x0f) + 0x30);
+ ss << " MNC : ";
+ ss << (unsigned char)((tai.plmn_id.idx[2] & 0x0f) + 0x30);
+ ss << (unsigned char)((tai.plmn_id.idx[2] >> 4) + 0x30);
+ ss << " TAC : " << tai.tac ;
+ reply->set_tai(ss.str());
+
+ // Cell Identity
+ ss.str("");
+ const CGI& cgi = uecontext_p->getUtranCgi().cgi_m;
+ ss << "0x" << std::hex << cgi.cell_id;
+ reply->set_eutran_cgi(ss.str());
+
+ reply->set_context_id(uecontext_p->getContextID());
+
+ reply->set_enb_ue_s1ap_id(uecontext_p->getS1apEnbUeId());
+
+ MmContext* mmCtxt = uecontext_p->getMmContext();
+ UE_State_e uestate = mmCtxt->getMmState();
+
+ reply->set_ue_state(UEStates[uestate]);
+
+ SessionContext* sessioncontext_p = uecontext_p->getSessionContext();
+ if (sessioncontext_p != NULL)
+ {
+ UeContextRespBuf_SessionContextRespBuf* session_ctxt = reply->add_sessioncontext();
+ if (session_ctxt)
+ {
+ // APN
+ const apn_name& apn = sessioncontext_p->getAccessPtName().apnname_m;
+ string apnStr((const char*)(apn.val), apn.len);
+ session_ctxt->set_apn(apnStr);
+
+ // PDN address
+ const PAA& PdnAddr = sessioncontext_p->getPdnAddr().paa_m;
+ char ipStr[INET_ADDRSTRLEN];
+ inet_ntop(AF_INET, &(PdnAddr.ip_type.ipv4), ipStr, INET_ADDRSTRLEN);
+ session_ctxt->set_pdn_address(ipStr);
+
+ // Bearer ID
+ session_ctxt->set_bearer_id(5);
+
+ // S11 SGW GTP-C TEID
+ const fteid& s11SgwCTeid = sessioncontext_p->getS11SgwCtrlFteid().fteid_m;
+
+ ss.str("");
+ memset(ipStr, 0, INET_ADDRSTRLEN);
+ uint32_t ip = ntohl(s11SgwCTeid.ip.ipv4.s_addr);
+
+ inet_ntop(AF_INET, &(ip), ipStr, INET_ADDRSTRLEN);
+ ss << "IP " << ipStr << " TEID " << s11SgwCTeid.header.teid_gre;
+ session_ctxt->set_s11_sgw_gtpc_teid(ss.str());
+
+ // S5S8 PGW GTP-C TEID
+ const fteid& s5s8PgwCTeid = sessioncontext_p->getS5S8PgwCtrlFteid().fteid_m;
+
+ ss.str("");
+ memset(ipStr, 0, INET_ADDRSTRLEN);
+ ip = ntohl(s5s8PgwCTeid.ip.ipv4.s_addr);
+
+ inet_ntop(AF_INET, &(ip), ipStr, INET_ADDRSTRLEN);
+ ss << "IP " << ipStr << " TEID " << s5s8PgwCTeid.header.teid_gre;
+ session_ctxt->set_s5_pgw_gtpc_teid(ss.str());
+
+ BearerContext* bearerCtxt = sessioncontext_p->getBearerContext();
+ // S1U ENB TEID
+ const fteid& s1uEnbTeid = bearerCtxt->getS1uEnbUserFteid().fteid_m;
+
+ ss.str("");
+ memset(ipStr, 0, INET_ADDRSTRLEN);
+ ip = ntohl(s1uEnbTeid.ip.ipv4.s_addr);
+
+ inet_ntop(AF_INET, &(ip), ipStr, INET_ADDRSTRLEN);
+ ss << "IP " << ipStr << " TEID " << s1uEnbTeid.header.teid_gre;
+ session_ctxt->set_s1u_enb_teid(ss.str());
+
+ // S1U SGW TEID
+ const fteid& s1uSgwTeid = bearerCtxt->getS1uSgwUserFteid().fteid_m;
+ ss.str("");
+ memset(ipStr, 0, INET_ADDRSTRLEN);
+ ip = ntohl(s1uSgwTeid.ip.ipv4.s_addr);
+
+ inet_ntop(AF_INET, &(ip), ipStr, INET_ADDRSTRLEN);
+ ss << "IP " << ipStr << " TEID " << s1uSgwTeid.header.teid_gre;
+ session_ctxt->set_s1u_sgw_teid(ss.str());
+
+ // S5-U PGW TEID
+ const fteid& s5uPgwTeid = bearerCtxt->getS5S8PgwUserFteid().fteid_m;
+ ss.str("");
+ memset(ipStr, 0, INET_ADDRSTRLEN);
+ ip = ntohl(s5uPgwTeid.ip.ipv4.s_addr);
+
+ inet_ntop(AF_INET, &(ip), ipStr, INET_ADDRSTRLEN);
+ ss << "IP " << ipStr << " TEID " << s5uPgwTeid.header.teid_gre;
+ session_ctxt->set_s5u_pgw_teid(ss.str());
+
+ }
+ }
+ }
+ }
+ return Status::OK;
+
+ }
+
+ Status GetUeContext(ServerContext* context, const UeContextReqBuf* request,
+ UeContextRespBuf* reply) override
+ {
+ SM::ControlBlock* controlBlk_p = mme::SubsDataGroupManager::Instance()->findControlBlock((uint32_t)request->id());
+ GetUeContextInfo(controlBlk_p, reply);
+
+ return Status::OK;
+ }
+
+ Status ShowAllMobileContexts(ServerContext* context, const Empty* request,
+ ServerWriter<UeContextRespBuf>* writer) override
+ {
+ for (uint32_t i = 1; i <= 8000; i++)
+ {
+ SM::ControlBlock* controlBlk_p = mme::SubsDataGroupManager::Instance()->findControlBlock(i);
+ if (controlBlk_p != NULL && controlBlk_p->getPermDataBlock() != NULL)
+ {
+ UeContextRespBuf reply;
+ GetUeContextInfo(controlBlk_p, &reply);
+ writer->Write(reply);
+ }
+ }
+ return Status::OK;
+ }
+
+ Status GetDebugUeContext(ServerContext* context, const UeContextReqBuf* request,
+ EventInfoRespBuf* reply) override {
+ SM::ControlBlock* controlBlk_p = mme::SubsDataGroupManager::Instance()->findControlBlock((uint32_t)request->id());
+ if( controlBlk_p )
+ {
+ UEContext* uecontext_p=dynamic_cast<UEContext*>(controlBlk_p->getPermDataBlock());
+ if( uecontext_p )
+ {
+ MmContext* mmCtxt = uecontext_p->getMmContext();
+ UE_State_e uestate = mmCtxt->getMmState();
+ reply->set_ue_state(UEStates[static_cast<int>(uestate)]);
+ }
+ deque<SM::debugEventInfo> evtQ = controlBlk_p->getDebugInfoQueue();
+ for(auto it=evtQ.begin();it!=evtQ.end();it++)
+ {
+ EventInfoRespBuf_EventInfoBuf* EvtInfo = reply->add_eventinfo();
+ string strEvent = Events[it->event];
+ EvtInfo->set_event(strEvent);
+ string strState = States[it->state];
+ EvtInfo->set_state(strState);
+ EvtInfo->set_time(ctime(&(it->evt_time)));
+ }
+ }
+ return Status::OK;
+ }
+
+ Status GetProcStats(ServerContext* context,const Empty* request,
+ ProcedureStatsRespBuf* reply) override {
+ /*time_t my_time = time(NULL);
+ my_time = time(NULL);
+ cout << "Req recieved at server" << ctime(&my_time);*/
+ reply->set_num_of_air_sent(ProcedureStats::num_of_air_sent);
+ reply->set_num_of_ulr_sent(ProcedureStats::num_of_ulr_sent);
+ reply->set_num_of_processed_aia(ProcedureStats::num_of_processed_aia);
+ reply->set_num_of_processed_ula(ProcedureStats::num_of_processed_ula);
+ reply->set_num_of_auth_req_to_ue_sent(ProcedureStats::num_of_auth_req_to_ue_sent);
+ reply->set_num_of_processed_auth_response(ProcedureStats::num_of_processed_auth_response);
+ reply->set_num_of_sec_mode_cmd_to_ue_sent(ProcedureStats::num_of_sec_mode_cmd_to_ue_sent);
+ reply->set_num_of_processed_sec_mode_resp(ProcedureStats::num_of_processed_sec_mode_resp);
+ reply->set_num_of_esm_info_req_to_ue_sent(ProcedureStats::num_of_esm_info_req_to_ue_sent);
+ reply->set_num_of_handled_esm_info_resp(ProcedureStats::num_of_handled_esm_info_resp);
+ reply->set_num_of_cs_req_to_sgw_sent(ProcedureStats::num_of_cs_req_to_sgw_sent);
+ reply->set_num_of_processed_cs_resp(ProcedureStats::num_of_processed_cs_resp);
+ reply->set_num_of_init_ctxt_req_to_ue_sent(ProcedureStats::num_of_init_ctxt_req_to_ue_sent);
+ reply->set_num_of_processed_init_ctxt_resp(ProcedureStats::num_of_processed_init_ctxt_resp);
+ reply->set_num_of_mb_req_to_sgw_sent(ProcedureStats::num_of_mb_req_to_sgw_sent);
+ reply->set_num_of_processed_attach_cmp_from_ue(ProcedureStats::num_of_processed_attach_cmp_from_ue);
+ reply->set_num_of_processed_mb_resp(ProcedureStats::num_of_processed_mb_resp);
+ reply->set_num_of_attach_done(ProcedureStats::num_of_attach_done);
+ reply->set_num_of_del_session_req_sent(ProcedureStats::num_of_del_session_req_sent);
+ reply->set_num_of_purge_req_sent(ProcedureStats::num_of_purge_req_sent);
+ reply->set_num_of_processed_del_session_resp(ProcedureStats::num_of_processed_del_session_resp);
+ reply->set_num_of_processed_pur_resp(ProcedureStats::num_of_processed_pur_resp);
+ reply->set_num_of_detach_accept_to_ue_sent(ProcedureStats::num_of_detach_accept_to_ue_sent);
+ reply->set_num_of_processed_detach_accept(ProcedureStats::num_of_processed_detach_accept);
+ reply->set_num_of_ue_ctxt_release(ProcedureStats::num_of_ue_ctxt_release);
+ reply->set_num_of_processed_ctxt_rel_resp(ProcedureStats::num_of_processed_ctxt_rel_resp);
+ reply->set_num_of_subscribers_attached(ProcedureStats::num_of_subscribers_attached);
+ reply->set_num_of_rel_access_bearer_req_sent(ProcedureStats::num_of_rel_access_bearer_req_sent);
+ reply->set_num_of_rel_access_bearer_resp_received(ProcedureStats::num_of_rel_access_bearer_resp_received);
+ reply->set_num_of_s1_rel_req_received(ProcedureStats::num_of_s1_rel_req_received);
+ reply->set_num_of_s1_rel_cmd_sent(ProcedureStats::num_of_s1_rel_cmd_sent);
+ reply->set_num_of_s1_rel_comp_received(ProcedureStats::num_of_s1_rel_comp_received);
+ reply->set_num_of_clr_received(ProcedureStats::num_of_clr_received);
+ reply->set_num_of_cla_sent(ProcedureStats::num_of_cla_sent);
+ reply->set_num_of_detach_req_to_ue_sent(ProcedureStats::num_of_detach_req_to_ue_sent);
+ reply->set_num_of_detach_accept_from_ue(ProcedureStats::num_of_detach_accept_from_ue);
+ reply->set_total_num_of_subscribers(ProcedureStats::total_num_of_subscribers);
+ reply->set_num_of_subscribers_detached(ProcedureStats::num_of_subscribers_detached);
+ reply->set_num_of_tau_response_to_ue_sent(ProcedureStats::num_of_tau_response_to_ue_sent);
+
+ //reply->set_num_of_ddn_received(ProcedureStats::num_of_ddn_received);
+ return Status::OK;
+ }
+
+};
+
+void * RunServer(void* data) {
+ std::string server_address("0.0.0.0:50051");
+ MmeGrpcCliServiceImpl service;
+
+ ServerBuilder builder;
+ // Listen on the given address without any authentication mechanism.
+ builder.AddListeningPort(server_address, grpc::InsecureServerCredentials());
+ // Register "service" as the instance through which we'll communicate with
+ // clients. In this case it corresponds to an *synchronous* service.
+ builder.RegisterService(&service);
+ // Finally assemble the server.
+ std::unique_ptr<Server> server(builder.BuildAndStart());
+ std::cout << "Server listening on " << server_address << std::endl;
+
+ // Wait for the server to shutdown. Note that some other thread must be
+ // responsible for shutting down the server for this call to ever return.
+ server->Wait();
+
+ return NULL;
+}
diff --git a/src/mme-app/mmeStates/attachStart.cpp b/src/mme-app/mmeStates/attachStart.cpp
new file mode 100644
index 0000000..3378e7f
--- /dev/null
+++ b/src/mme-app/mmeStates/attachStart.cpp
@@ -0,0 +1,60 @@
+
+/*
+ * Copyright 2019-present Infosys Limited
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/**************************************
+ * attachStart.cpp
+ * This is an auto generated file.
+ * Please do not edit this file.
+ * All edits to be made through template source file
+ * <TOP-DIR/scripts/SMCodeGen/templates/stateMachineTmpls/state.cpp.tt>
+ **************************************/
+
+#include "smEnumTypes.h"
+#include "actionTable.h"
+#include "actionHandlers/actionHandlers.h"
+
+#include "mmeStates/attachStart.h"
+#include "mmeStates/attachWfImsiValidateAction.h"
+
+using namespace mme;
+using namespace SM;
+
+/******************************************************************************
+* Constructor
+******************************************************************************/
+AttachStart::AttachStart():State(State_e::attach_start)
+{
+}
+
+/******************************************************************************
+* Destructor
+******************************************************************************/
+AttachStart::~AttachStart()
+{
+}
+
+/******************************************************************************
+* creates and returns static instance
+******************************************************************************/
+AttachStart* AttachStart::Instance()
+{
+ static AttachStart state;
+ return &state;
+}
+
+/******************************************************************************
+* initializes eventToActionsMap
+******************************************************************************/
+void AttachStart::initialize()
+{
+ {
+ ActionTable actionTable;
+ actionTable.addAction(&ActionHandlers::validate_imsi_in_ue_context);
+ actionTable.setNextState(AttachWfImsiValidateAction::Instance());
+ eventToActionsMap.insert(pair<Event_e, ActionTable>(Event_e::VALIDATE_IMSI, actionTable));
+ }
+}
diff --git a/src/mme-app/mmeStates/attachWfAia.cpp b/src/mme-app/mmeStates/attachWfAia.cpp
new file mode 100644
index 0000000..9e437b3
--- /dev/null
+++ b/src/mme-app/mmeStates/attachWfAia.cpp
@@ -0,0 +1,61 @@
+
+/*
+ * Copyright 2019-present Infosys Limited
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/**************************************
+ * attachWfAia.cpp
+ * This is an auto generated file.
+ * Please do not edit this file.
+ * All edits to be made through template source file
+ * <TOP-DIR/scripts/SMCodeGen/templates/stateMachineTmpls/state.cpp.tt>
+ **************************************/
+
+#include "smEnumTypes.h"
+#include "actionTable.h"
+#include "actionHandlers/actionHandlers.h"
+
+#include "mmeStates/attachWfAia.h"
+#include "mmeStates/attachWfAuthResp.h"
+
+using namespace mme;
+using namespace SM;
+
+/******************************************************************************
+* Constructor
+******************************************************************************/
+AttachWfAia::AttachWfAia():State(State_e::attach_wf_aia)
+{
+}
+
+/******************************************************************************
+* Destructor
+******************************************************************************/
+AttachWfAia::~AttachWfAia()
+{
+}
+
+/******************************************************************************
+* creates and returns static instance
+******************************************************************************/
+AttachWfAia* AttachWfAia::Instance()
+{
+ static AttachWfAia state;
+ return &state;
+}
+
+/******************************************************************************
+* initializes eventToActionsMap
+******************************************************************************/
+void AttachWfAia::initialize()
+{
+ {
+ ActionTable actionTable;
+ actionTable.addAction(&ActionHandlers::process_aia);
+ actionTable.addAction(&ActionHandlers::auth_req_to_ue);
+ actionTable.setNextState(AttachWfAuthResp::Instance());
+ eventToActionsMap.insert(pair<Event_e, ActionTable>(Event_e::AIA_FROM_HSS, actionTable));
+ }
+}
diff --git a/src/mme-app/mmeStates/attachWfAttCmp.cpp b/src/mme-app/mmeStates/attachWfAttCmp.cpp
new file mode 100644
index 0000000..4fc5e77
--- /dev/null
+++ b/src/mme-app/mmeStates/attachWfAttCmp.cpp
@@ -0,0 +1,61 @@
+
+/*
+ * Copyright 2019-present Infosys Limited
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/**************************************
+ * attachWfAttCmp.cpp
+ * This is an auto generated file.
+ * Please do not edit this file.
+ * All edits to be made through template source file
+ * <TOP-DIR/scripts/SMCodeGen/templates/stateMachineTmpls/state.cpp.tt>
+ **************************************/
+
+#include "smEnumTypes.h"
+#include "actionTable.h"
+#include "actionHandlers/actionHandlers.h"
+
+#include "mmeStates/attachWfAttCmp.h"
+#include "mmeStates/attachWfMbResp.h"
+
+using namespace mme;
+using namespace SM;
+
+/******************************************************************************
+* Constructor
+******************************************************************************/
+AttachWfAttCmp::AttachWfAttCmp():State(State_e::attach_wf_att_cmp)
+{
+}
+
+/******************************************************************************
+* Destructor
+******************************************************************************/
+AttachWfAttCmp::~AttachWfAttCmp()
+{
+}
+
+/******************************************************************************
+* creates and returns static instance
+******************************************************************************/
+AttachWfAttCmp* AttachWfAttCmp::Instance()
+{
+ static AttachWfAttCmp state;
+ return &state;
+}
+
+/******************************************************************************
+* initializes eventToActionsMap
+******************************************************************************/
+void AttachWfAttCmp::initialize()
+{
+ {
+ ActionTable actionTable;
+ actionTable.addAction(&ActionHandlers::process_attach_cmp_from_ue);
+ actionTable.addAction(&ActionHandlers::send_mb_req_to_sgw);
+ actionTable.setNextState(AttachWfMbResp::Instance());
+ eventToActionsMap.insert(pair<Event_e, ActionTable>(Event_e::ATT_CMP_FROM_UE, actionTable));
+ }
+}
diff --git a/src/mme-app/mmeStates/attachWfAuthResp.cpp b/src/mme-app/mmeStates/attachWfAuthResp.cpp
new file mode 100644
index 0000000..9ba6b10
--- /dev/null
+++ b/src/mme-app/mmeStates/attachWfAuthResp.cpp
@@ -0,0 +1,60 @@
+
+/*
+ * Copyright 2019-present Infosys Limited
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/**************************************
+ * attachWfAuthResp.cpp
+ * This is an auto generated file.
+ * Please do not edit this file.
+ * All edits to be made through template source file
+ * <TOP-DIR/scripts/SMCodeGen/templates/stateMachineTmpls/state.cpp.tt>
+ **************************************/
+
+#include "smEnumTypes.h"
+#include "actionTable.h"
+#include "actionHandlers/actionHandlers.h"
+
+#include "mmeStates/attachWfAuthResp.h"
+#include "mmeStates/attachWfAuthRespValidate.h"
+
+using namespace mme;
+using namespace SM;
+
+/******************************************************************************
+* Constructor
+******************************************************************************/
+AttachWfAuthResp::AttachWfAuthResp():State(State_e::attach_wf_auth_resp)
+{
+}
+
+/******************************************************************************
+* Destructor
+******************************************************************************/
+AttachWfAuthResp::~AttachWfAuthResp()
+{
+}
+
+/******************************************************************************
+* creates and returns static instance
+******************************************************************************/
+AttachWfAuthResp* AttachWfAuthResp::Instance()
+{
+ static AttachWfAuthResp state;
+ return &state;
+}
+
+/******************************************************************************
+* initializes eventToActionsMap
+******************************************************************************/
+void AttachWfAuthResp::initialize()
+{
+ {
+ ActionTable actionTable;
+ actionTable.addAction(&ActionHandlers::auth_response_validate);
+ actionTable.setNextState(AttachWfAuthRespValidate::Instance());
+ eventToActionsMap.insert(pair<Event_e, ActionTable>(Event_e::AUTH_RESP_FROM_UE, actionTable));
+ }
+}
diff --git a/src/mme-app/mmeStates/attachWfAuthRespValidate.cpp b/src/mme-app/mmeStates/attachWfAuthRespValidate.cpp
new file mode 100644
index 0000000..2aa31cd
--- /dev/null
+++ b/src/mme-app/mmeStates/attachWfAuthRespValidate.cpp
@@ -0,0 +1,72 @@
+
+/*
+ * Copyright 2019-present Infosys Limited
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/**************************************
+ * attachWfAuthRespValidate.cpp
+ * This is an auto generated file.
+ * Please do not edit this file.
+ * All edits to be made through template source file
+ * <TOP-DIR/scripts/SMCodeGen/templates/stateMachineTmpls/state.cpp.tt>
+ **************************************/
+
+#include "smEnumTypes.h"
+#include "actionTable.h"
+#include "actionHandlers/actionHandlers.h"
+
+#include "mmeStates/attachWfAuthRespValidate.h"
+#include "mmeStates/attachWfSecCmp.h"
+#include "mmeStates/attachWfAia.h"
+
+using namespace mme;
+using namespace SM;
+
+/******************************************************************************
+* Constructor
+******************************************************************************/
+AttachWfAuthRespValidate::AttachWfAuthRespValidate():State(State_e::attach_wf_auth_resp_validate)
+{
+}
+
+/******************************************************************************
+* Destructor
+******************************************************************************/
+AttachWfAuthRespValidate::~AttachWfAuthRespValidate()
+{
+}
+
+/******************************************************************************
+* creates and returns static instance
+******************************************************************************/
+AttachWfAuthRespValidate* AttachWfAuthRespValidate::Instance()
+{
+ static AttachWfAuthRespValidate state;
+ return &state;
+}
+
+/******************************************************************************
+* initializes eventToActionsMap
+******************************************************************************/
+void AttachWfAuthRespValidate::initialize()
+{
+ {
+ ActionTable actionTable;
+ actionTable.addAction(&ActionHandlers::sec_mode_cmd_to_ue);
+ actionTable.setNextState(AttachWfSecCmp::Instance());
+ eventToActionsMap.insert(pair<Event_e, ActionTable>(Event_e::AUTH_RESP_SUCCESS, actionTable));
+ }
+ {
+ ActionTable actionTable;
+ actionTable.addAction(&ActionHandlers::send_air_to_hss);
+ actionTable.setNextState(AttachWfAia::Instance());
+ eventToActionsMap.insert(pair<Event_e, ActionTable>(Event_e::AUTH_RESP_SYNC_FAILURE, actionTable));
+ }
+ {
+ ActionTable actionTable;
+ actionTable.addAction(&ActionHandlers::send_auth_reject);
+ eventToActionsMap.insert(pair<Event_e, ActionTable>(Event_e::AUTH_RESP_FAILURE, actionTable));
+ }
+}
diff --git a/src/mme-app/mmeStates/attachWfCsResp.cpp b/src/mme-app/mmeStates/attachWfCsResp.cpp
new file mode 100644
index 0000000..871c9c8
--- /dev/null
+++ b/src/mme-app/mmeStates/attachWfCsResp.cpp
@@ -0,0 +1,61 @@
+
+/*
+ * Copyright 2019-present Infosys Limited
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/**************************************
+ * attachWfCsResp.cpp
+ * This is an auto generated file.
+ * Please do not edit this file.
+ * All edits to be made through template source file
+ * <TOP-DIR/scripts/SMCodeGen/templates/stateMachineTmpls/state.cpp.tt>
+ **************************************/
+
+#include "smEnumTypes.h"
+#include "actionTable.h"
+#include "actionHandlers/actionHandlers.h"
+
+#include "mmeStates/attachWfCsResp.h"
+#include "mmeStates/attachWfInitCtxtRespAttCmp.h"
+
+using namespace mme;
+using namespace SM;
+
+/******************************************************************************
+* Constructor
+******************************************************************************/
+AttachWfCsResp::AttachWfCsResp():State(State_e::attach_wf_cs_resp)
+{
+}
+
+/******************************************************************************
+* Destructor
+******************************************************************************/
+AttachWfCsResp::~AttachWfCsResp()
+{
+}
+
+/******************************************************************************
+* creates and returns static instance
+******************************************************************************/
+AttachWfCsResp* AttachWfCsResp::Instance()
+{
+ static AttachWfCsResp state;
+ return &state;
+}
+
+/******************************************************************************
+* initializes eventToActionsMap
+******************************************************************************/
+void AttachWfCsResp::initialize()
+{
+ {
+ ActionTable actionTable;
+ actionTable.addAction(&ActionHandlers::process_cs_resp);
+ actionTable.addAction(&ActionHandlers::send_init_ctxt_req_to_ue);
+ actionTable.setNextState(AttachWfInitCtxtRespAttCmp::Instance());
+ eventToActionsMap.insert(pair<Event_e, ActionTable>(Event_e::CS_RESP_FROM_SGW, actionTable));
+ }
+}
diff --git a/src/mme-app/mmeStates/attachWfEsmInfoCheck.cpp b/src/mme-app/mmeStates/attachWfEsmInfoCheck.cpp
new file mode 100644
index 0000000..38c50f1
--- /dev/null
+++ b/src/mme-app/mmeStates/attachWfEsmInfoCheck.cpp
@@ -0,0 +1,67 @@
+
+/*
+ * Copyright 2019-present Infosys Limited
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/**************************************
+ * attachWfEsmInfoCheck.cpp
+ * This is an auto generated file.
+ * Please do not edit this file.
+ * All edits to be made through template source file
+ * <TOP-DIR/scripts/SMCodeGen/templates/stateMachineTmpls/state.cpp.tt>
+ **************************************/
+
+#include "smEnumTypes.h"
+#include "actionTable.h"
+#include "actionHandlers/actionHandlers.h"
+
+#include "mmeStates/attachWfEsmInfoCheck.h"
+#include "mmeStates/attachWfEsmInfoResp.h"
+#include "mmeStates/attachWfUla.h"
+
+using namespace mme;
+using namespace SM;
+
+/******************************************************************************
+* Constructor
+******************************************************************************/
+AttachWfEsmInfoCheck::AttachWfEsmInfoCheck():State(State_e::attach_wf_esm_info_check)
+{
+}
+
+/******************************************************************************
+* Destructor
+******************************************************************************/
+AttachWfEsmInfoCheck::~AttachWfEsmInfoCheck()
+{
+}
+
+/******************************************************************************
+* creates and returns static instance
+******************************************************************************/
+AttachWfEsmInfoCheck* AttachWfEsmInfoCheck::Instance()
+{
+ static AttachWfEsmInfoCheck state;
+ return &state;
+}
+
+/******************************************************************************
+* initializes eventToActionsMap
+******************************************************************************/
+void AttachWfEsmInfoCheck::initialize()
+{
+ {
+ ActionTable actionTable;
+ actionTable.addAction(&ActionHandlers::send_esm_info_req_to_ue);
+ actionTable.setNextState(AttachWfEsmInfoResp::Instance());
+ eventToActionsMap.insert(pair<Event_e, ActionTable>(Event_e::ESM_INFO_REQUIRED, actionTable));
+ }
+ {
+ ActionTable actionTable;
+ actionTable.addAction(&ActionHandlers::send_ulr_to_hss);
+ actionTable.setNextState(AttachWfUla::Instance());
+ eventToActionsMap.insert(pair<Event_e, ActionTable>(Event_e::ESM_INFO_NOT_REQUIRED, actionTable));
+ }
+}
diff --git a/src/mme-app/mmeStates/attachWfEsmInfoResp.cpp b/src/mme-app/mmeStates/attachWfEsmInfoResp.cpp
new file mode 100644
index 0000000..f78af08
--- /dev/null
+++ b/src/mme-app/mmeStates/attachWfEsmInfoResp.cpp
@@ -0,0 +1,61 @@
+
+/*
+ * Copyright 2019-present Infosys Limited
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/**************************************
+ * attachWfEsmInfoResp.cpp
+ * This is an auto generated file.
+ * Please do not edit this file.
+ * All edits to be made through template source file
+ * <TOP-DIR/scripts/SMCodeGen/templates/stateMachineTmpls/state.cpp.tt>
+ **************************************/
+
+#include "smEnumTypes.h"
+#include "actionTable.h"
+#include "actionHandlers/actionHandlers.h"
+
+#include "mmeStates/attachWfEsmInfoResp.h"
+#include "mmeStates/attachWfUla.h"
+
+using namespace mme;
+using namespace SM;
+
+/******************************************************************************
+* Constructor
+******************************************************************************/
+AttachWfEsmInfoResp::AttachWfEsmInfoResp():State(State_e::attach_wf_esm_info_resp)
+{
+}
+
+/******************************************************************************
+* Destructor
+******************************************************************************/
+AttachWfEsmInfoResp::~AttachWfEsmInfoResp()
+{
+}
+
+/******************************************************************************
+* creates and returns static instance
+******************************************************************************/
+AttachWfEsmInfoResp* AttachWfEsmInfoResp::Instance()
+{
+ static AttachWfEsmInfoResp state;
+ return &state;
+}
+
+/******************************************************************************
+* initializes eventToActionsMap
+******************************************************************************/
+void AttachWfEsmInfoResp::initialize()
+{
+ {
+ ActionTable actionTable;
+ actionTable.addAction(&ActionHandlers::process_esm_info_resp);
+ actionTable.addAction(&ActionHandlers::send_ulr_to_hss);
+ actionTable.setNextState(AttachWfUla::Instance());
+ eventToActionsMap.insert(pair<Event_e, ActionTable>(Event_e::ESM_INFO_RESP_FROM_UE, actionTable));
+ }
+}
diff --git a/src/mme-app/mmeStates/attachWfIdentityResponse.cpp b/src/mme-app/mmeStates/attachWfIdentityResponse.cpp
new file mode 100644
index 0000000..93af033
--- /dev/null
+++ b/src/mme-app/mmeStates/attachWfIdentityResponse.cpp
@@ -0,0 +1,61 @@
+
+/*
+ * Copyright 2019-present Infosys Limited
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/**************************************
+ * attachWfIdentityResponse.cpp
+ * This is an auto generated file.
+ * Please do not edit this file.
+ * All edits to be made through template source file
+ * <TOP-DIR/scripts/SMCodeGen/templates/stateMachineTmpls/state.cpp.tt>
+ **************************************/
+
+#include "smEnumTypes.h"
+#include "actionTable.h"
+#include "actionHandlers/actionHandlers.h"
+
+#include "mmeStates/attachWfIdentityResponse.h"
+#include "mmeStates/attachWfAia.h"
+
+using namespace mme;
+using namespace SM;
+
+/******************************************************************************
+* Constructor
+******************************************************************************/
+AttachWfIdentityResponse::AttachWfIdentityResponse():State(State_e::attach_wf_identity_response)
+{
+}
+
+/******************************************************************************
+* Destructor
+******************************************************************************/
+AttachWfIdentityResponse::~AttachWfIdentityResponse()
+{
+}
+
+/******************************************************************************
+* creates and returns static instance
+******************************************************************************/
+AttachWfIdentityResponse* AttachWfIdentityResponse::Instance()
+{
+ static AttachWfIdentityResponse state;
+ return &state;
+}
+
+/******************************************************************************
+* initializes eventToActionsMap
+******************************************************************************/
+void AttachWfIdentityResponse::initialize()
+{
+ {
+ ActionTable actionTable;
+ actionTable.addAction(&ActionHandlers::process_identity_response);
+ actionTable.addAction(&ActionHandlers::send_air_to_hss);
+ actionTable.setNextState(AttachWfAia::Instance());
+ eventToActionsMap.insert(pair<Event_e, ActionTable>(Event_e::IDENTITY_RESPONSE_FROM_UE, actionTable));
+ }
+}
diff --git a/src/mme-app/mmeStates/attachWfImsiValidateAction.cpp b/src/mme-app/mmeStates/attachWfImsiValidateAction.cpp
new file mode 100644
index 0000000..a0d974a
--- /dev/null
+++ b/src/mme-app/mmeStates/attachWfImsiValidateAction.cpp
@@ -0,0 +1,67 @@
+
+/*
+ * Copyright 2019-present Infosys Limited
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/**************************************
+ * attachWfImsiValidateAction.cpp
+ * This is an auto generated file.
+ * Please do not edit this file.
+ * All edits to be made through template source file
+ * <TOP-DIR/scripts/SMCodeGen/templates/stateMachineTmpls/state.cpp.tt>
+ **************************************/
+
+#include "smEnumTypes.h"
+#include "actionTable.h"
+#include "actionHandlers/actionHandlers.h"
+
+#include "mmeStates/attachWfImsiValidateAction.h"
+#include "mmeStates/attachWfAia.h"
+#include "mmeStates/attachWfIdentityResponse.h"
+
+using namespace mme;
+using namespace SM;
+
+/******************************************************************************
+* Constructor
+******************************************************************************/
+AttachWfImsiValidateAction::AttachWfImsiValidateAction():State(State_e::attach_wf_imsi_validate_action)
+{
+}
+
+/******************************************************************************
+* Destructor
+******************************************************************************/
+AttachWfImsiValidateAction::~AttachWfImsiValidateAction()
+{
+}
+
+/******************************************************************************
+* creates and returns static instance
+******************************************************************************/
+AttachWfImsiValidateAction* AttachWfImsiValidateAction::Instance()
+{
+ static AttachWfImsiValidateAction state;
+ return &state;
+}
+
+/******************************************************************************
+* initializes eventToActionsMap
+******************************************************************************/
+void AttachWfImsiValidateAction::initialize()
+{
+ {
+ ActionTable actionTable;
+ actionTable.addAction(&ActionHandlers::send_air_to_hss);
+ actionTable.setNextState(AttachWfAia::Instance());
+ eventToActionsMap.insert(pair<Event_e, ActionTable>(Event_e::IMSI_VALIDATION_SUCCESS, actionTable));
+ }
+ {
+ ActionTable actionTable;
+ actionTable.addAction(&ActionHandlers::send_identity_request_to_ue);
+ actionTable.setNextState(AttachWfIdentityResponse::Instance());
+ eventToActionsMap.insert(pair<Event_e, ActionTable>(Event_e::IMSI_VALIDATION_FAILURE, actionTable));
+ }
+}
diff --git a/src/mme-app/mmeStates/attachWfInitCtxtResp.cpp b/src/mme-app/mmeStates/attachWfInitCtxtResp.cpp
new file mode 100644
index 0000000..879fadb
--- /dev/null
+++ b/src/mme-app/mmeStates/attachWfInitCtxtResp.cpp
@@ -0,0 +1,61 @@
+
+/*
+ * Copyright 2019-present Infosys Limited
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/**************************************
+ * attachWfInitCtxtResp.cpp
+ * This is an auto generated file.
+ * Please do not edit this file.
+ * All edits to be made through template source file
+ * <TOP-DIR/scripts/SMCodeGen/templates/stateMachineTmpls/state.cpp.tt>
+ **************************************/
+
+#include "smEnumTypes.h"
+#include "actionTable.h"
+#include "actionHandlers/actionHandlers.h"
+
+#include "mmeStates/attachWfInitCtxtResp.h"
+#include "mmeStates/attachWfMbResp.h"
+
+using namespace mme;
+using namespace SM;
+
+/******************************************************************************
+* Constructor
+******************************************************************************/
+AttachWfInitCtxtResp::AttachWfInitCtxtResp():State(State_e::attach_wf_init_ctxt_resp)
+{
+}
+
+/******************************************************************************
+* Destructor
+******************************************************************************/
+AttachWfInitCtxtResp::~AttachWfInitCtxtResp()
+{
+}
+
+/******************************************************************************
+* creates and returns static instance
+******************************************************************************/
+AttachWfInitCtxtResp* AttachWfInitCtxtResp::Instance()
+{
+ static AttachWfInitCtxtResp state;
+ return &state;
+}
+
+/******************************************************************************
+* initializes eventToActionsMap
+******************************************************************************/
+void AttachWfInitCtxtResp::initialize()
+{
+ {
+ ActionTable actionTable;
+ actionTable.addAction(&ActionHandlers::process_init_ctxt_resp);
+ actionTable.addAction(&ActionHandlers::send_mb_req_to_sgw);
+ actionTable.setNextState(AttachWfMbResp::Instance());
+ eventToActionsMap.insert(pair<Event_e, ActionTable>(Event_e::INIT_CTXT_RESP_FROM_UE, actionTable));
+ }
+}
diff --git a/src/mme-app/mmeStates/attachWfInitCtxtRespAttCmp.cpp b/src/mme-app/mmeStates/attachWfInitCtxtRespAttCmp.cpp
new file mode 100644
index 0000000..5f7e404
--- /dev/null
+++ b/src/mme-app/mmeStates/attachWfInitCtxtRespAttCmp.cpp
@@ -0,0 +1,67 @@
+
+/*
+ * Copyright 2019-present Infosys Limited
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/**************************************
+ * attachWfInitCtxtRespAttCmp.cpp
+ * This is an auto generated file.
+ * Please do not edit this file.
+ * All edits to be made through template source file
+ * <TOP-DIR/scripts/SMCodeGen/templates/stateMachineTmpls/state.cpp.tt>
+ **************************************/
+
+#include "smEnumTypes.h"
+#include "actionTable.h"
+#include "actionHandlers/actionHandlers.h"
+
+#include "mmeStates/attachWfInitCtxtRespAttCmp.h"
+#include "mmeStates/attachWfAttCmp.h"
+#include "mmeStates/attachWfInitCtxtResp.h"
+
+using namespace mme;
+using namespace SM;
+
+/******************************************************************************
+* Constructor
+******************************************************************************/
+AttachWfInitCtxtRespAttCmp::AttachWfInitCtxtRespAttCmp():State(State_e::attach_wf_init_ctxt_resp_att_cmp)
+{
+}
+
+/******************************************************************************
+* Destructor
+******************************************************************************/
+AttachWfInitCtxtRespAttCmp::~AttachWfInitCtxtRespAttCmp()
+{
+}
+
+/******************************************************************************
+* creates and returns static instance
+******************************************************************************/
+AttachWfInitCtxtRespAttCmp* AttachWfInitCtxtRespAttCmp::Instance()
+{
+ static AttachWfInitCtxtRespAttCmp state;
+ return &state;
+}
+
+/******************************************************************************
+* initializes eventToActionsMap
+******************************************************************************/
+void AttachWfInitCtxtRespAttCmp::initialize()
+{
+ {
+ ActionTable actionTable;
+ actionTable.addAction(&ActionHandlers::process_init_ctxt_resp);
+ actionTable.setNextState(AttachWfAttCmp::Instance());
+ eventToActionsMap.insert(pair<Event_e, ActionTable>(Event_e::INIT_CTXT_RESP_FROM_UE, actionTable));
+ }
+ {
+ ActionTable actionTable;
+ actionTable.addAction(&ActionHandlers::process_attach_cmp_from_ue);
+ actionTable.setNextState(AttachWfInitCtxtResp::Instance());
+ eventToActionsMap.insert(pair<Event_e, ActionTable>(Event_e::ATT_CMP_FROM_UE, actionTable));
+ }
+}
diff --git a/src/mme-app/mmeStates/attachWfMbResp.cpp b/src/mme-app/mmeStates/attachWfMbResp.cpp
new file mode 100644
index 0000000..d2fb134
--- /dev/null
+++ b/src/mme-app/mmeStates/attachWfMbResp.cpp
@@ -0,0 +1,59 @@
+
+/*
+ * Copyright 2019-present Infosys Limited
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/**************************************
+ * attachWfMbResp.cpp
+ * This is an auto generated file.
+ * Please do not edit this file.
+ * All edits to be made through template source file
+ * <TOP-DIR/scripts/SMCodeGen/templates/stateMachineTmpls/state.cpp.tt>
+ **************************************/
+
+#include "smEnumTypes.h"
+#include "actionTable.h"
+#include "actionHandlers/actionHandlers.h"
+
+#include "mmeStates/attachWfMbResp.h"
+
+using namespace mme;
+using namespace SM;
+
+/******************************************************************************
+* Constructor
+******************************************************************************/
+AttachWfMbResp::AttachWfMbResp():State(State_e::attach_wf_mb_resp)
+{
+}
+
+/******************************************************************************
+* Destructor
+******************************************************************************/
+AttachWfMbResp::~AttachWfMbResp()
+{
+}
+
+/******************************************************************************
+* creates and returns static instance
+******************************************************************************/
+AttachWfMbResp* AttachWfMbResp::Instance()
+{
+ static AttachWfMbResp state;
+ return &state;
+}
+
+/******************************************************************************
+* initializes eventToActionsMap
+******************************************************************************/
+void AttachWfMbResp::initialize()
+{
+ {
+ ActionTable actionTable;
+ actionTable.addAction(&ActionHandlers::process_mb_resp);
+ actionTable.addAction(&ActionHandlers::attach_done);
+ eventToActionsMap.insert(pair<Event_e, ActionTable>(Event_e::MB_RESP_FROM_SGW, actionTable));
+ }
+}
diff --git a/src/mme-app/mmeStates/attachWfSecCmp.cpp b/src/mme-app/mmeStates/attachWfSecCmp.cpp
new file mode 100644
index 0000000..dccd562
--- /dev/null
+++ b/src/mme-app/mmeStates/attachWfSecCmp.cpp
@@ -0,0 +1,61 @@
+
+/*
+ * Copyright 2019-present Infosys Limited
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/**************************************
+ * attachWfSecCmp.cpp
+ * This is an auto generated file.
+ * Please do not edit this file.
+ * All edits to be made through template source file
+ * <TOP-DIR/scripts/SMCodeGen/templates/stateMachineTmpls/state.cpp.tt>
+ **************************************/
+
+#include "smEnumTypes.h"
+#include "actionTable.h"
+#include "actionHandlers/actionHandlers.h"
+
+#include "mmeStates/attachWfSecCmp.h"
+#include "mmeStates/attachWfEsmInfoCheck.h"
+
+using namespace mme;
+using namespace SM;
+
+/******************************************************************************
+* Constructor
+******************************************************************************/
+AttachWfSecCmp::AttachWfSecCmp():State(State_e::attach_wf_sec_cmp)
+{
+}
+
+/******************************************************************************
+* Destructor
+******************************************************************************/
+AttachWfSecCmp::~AttachWfSecCmp()
+{
+}
+
+/******************************************************************************
+* creates and returns static instance
+******************************************************************************/
+AttachWfSecCmp* AttachWfSecCmp::Instance()
+{
+ static AttachWfSecCmp state;
+ return &state;
+}
+
+/******************************************************************************
+* initializes eventToActionsMap
+******************************************************************************/
+void AttachWfSecCmp::initialize()
+{
+ {
+ ActionTable actionTable;
+ actionTable.addAction(&ActionHandlers::process_sec_mode_resp);
+ actionTable.addAction(&ActionHandlers::check_esm_info_req_required);
+ actionTable.setNextState(AttachWfEsmInfoCheck::Instance());
+ eventToActionsMap.insert(pair<Event_e, ActionTable>(Event_e::SEC_MODE_RESP_FROM_UE, actionTable));
+ }
+}
diff --git a/src/mme-app/mmeStates/attachWfUla.cpp b/src/mme-app/mmeStates/attachWfUla.cpp
new file mode 100644
index 0000000..eea1a8b
--- /dev/null
+++ b/src/mme-app/mmeStates/attachWfUla.cpp
@@ -0,0 +1,61 @@
+
+/*
+ * Copyright 2019-present Infosys Limited
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/**************************************
+ * attachWfUla.cpp
+ * This is an auto generated file.
+ * Please do not edit this file.
+ * All edits to be made through template source file
+ * <TOP-DIR/scripts/SMCodeGen/templates/stateMachineTmpls/state.cpp.tt>
+ **************************************/
+
+#include "smEnumTypes.h"
+#include "actionTable.h"
+#include "actionHandlers/actionHandlers.h"
+
+#include "mmeStates/attachWfUla.h"
+#include "mmeStates/attachWfCsResp.h"
+
+using namespace mme;
+using namespace SM;
+
+/******************************************************************************
+* Constructor
+******************************************************************************/
+AttachWfUla::AttachWfUla():State(State_e::attach_wf_ula)
+{
+}
+
+/******************************************************************************
+* Destructor
+******************************************************************************/
+AttachWfUla::~AttachWfUla()
+{
+}
+
+/******************************************************************************
+* creates and returns static instance
+******************************************************************************/
+AttachWfUla* AttachWfUla::Instance()
+{
+ static AttachWfUla state;
+ return &state;
+}
+
+/******************************************************************************
+* initializes eventToActionsMap
+******************************************************************************/
+void AttachWfUla::initialize()
+{
+ {
+ ActionTable actionTable;
+ actionTable.addAction(&ActionHandlers::process_ula);
+ actionTable.addAction(&ActionHandlers::cs_req_to_sgw);
+ actionTable.setNextState(AttachWfCsResp::Instance());
+ eventToActionsMap.insert(pair<Event_e, ActionTable>(Event_e::ULA_FROM_HSS, actionTable));
+ }
+}
diff --git a/src/mme-app/mmeStates/defaultMmeState.cpp b/src/mme-app/mmeStates/defaultMmeState.cpp
new file mode 100644
index 0000000..dcc9e14
--- /dev/null
+++ b/src/mme-app/mmeStates/defaultMmeState.cpp
@@ -0,0 +1,88 @@
+
+/*
+ * Copyright 2019-present Infosys Limited
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/**************************************
+ * defaultMmeState.cpp
+ * This is an auto generated file.
+ * Please do not edit this file.
+ * All edits to be made through template source file
+ * <TOP-DIR/scripts/SMCodeGen/templates/stateMachineTmpls/state.cpp.tt>
+ **************************************/
+
+#include "smEnumTypes.h"
+#include "actionTable.h"
+#include "actionHandlers/actionHandlers.h"
+
+#include "mmeStates/defaultMmeState.h"
+
+using namespace mme;
+using namespace SM;
+
+/******************************************************************************
+* Constructor
+******************************************************************************/
+DefaultMmeState::DefaultMmeState():State(State_e::default_mme_state)
+{
+}
+
+/******************************************************************************
+* Destructor
+******************************************************************************/
+DefaultMmeState::~DefaultMmeState()
+{
+}
+
+/******************************************************************************
+* creates and returns static instance
+******************************************************************************/
+DefaultMmeState* DefaultMmeState::Instance()
+{
+ static DefaultMmeState state;
+ return &state;
+}
+
+/******************************************************************************
+* initializes eventToActionsMap
+******************************************************************************/
+void DefaultMmeState::initialize()
+{
+ {
+ ActionTable actionTable;
+ actionTable.addAction(&ActionHandlers::default_attach_req_handler);
+ eventToActionsMap.insert(pair<Event_e, ActionTable>(Event_e::ATTACH_REQ_FROM_UE, actionTable));
+ }
+ {
+ ActionTable actionTable;
+ actionTable.addAction(&ActionHandlers::default_detach_req_handler);
+ eventToActionsMap.insert(pair<Event_e, ActionTable>(Event_e::DETACH_REQ_FROM_UE, actionTable));
+ }
+ {
+ ActionTable actionTable;
+ actionTable.addAction(&ActionHandlers::default_s1_release_req_handler);
+ eventToActionsMap.insert(pair<Event_e, ActionTable>(Event_e::S1_REL_REQ_FROM_UE, actionTable));
+ }
+ {
+ ActionTable actionTable;
+ actionTable.addAction(&ActionHandlers::default_ddn_handler);
+ eventToActionsMap.insert(pair<Event_e, ActionTable>(Event_e::DDN_FROM_SGW, actionTable));
+ }
+ {
+ ActionTable actionTable;
+ actionTable.addAction(&ActionHandlers::default_service_req_handler);
+ eventToActionsMap.insert(pair<Event_e, ActionTable>(Event_e::SERVICE_REQUEST_FROM_UE, actionTable));
+ }
+ {
+ ActionTable actionTable;
+ actionTable.addAction(&ActionHandlers::default_cancel_loc_req_handler);
+ eventToActionsMap.insert(pair<Event_e, ActionTable>(Event_e::CLR_FROM_HSS, actionTable));
+ }
+ {
+ ActionTable actionTable;
+ actionTable.addAction(&ActionHandlers::default_tau_req_handler);
+ eventToActionsMap.insert(pair<Event_e, ActionTable>(Event_e::TAU_REQUEST_FROM_UE, actionTable));
+ }
+}
diff --git a/src/mme-app/mmeStates/detachStart.cpp b/src/mme-app/mmeStates/detachStart.cpp
new file mode 100644
index 0000000..4381f9d
--- /dev/null
+++ b/src/mme-app/mmeStates/detachStart.cpp
@@ -0,0 +1,60 @@
+
+/*
+ * Copyright 2019-present Infosys Limited
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/**************************************
+ * detachStart.cpp
+ * This is an auto generated file.
+ * Please do not edit this file.
+ * All edits to be made through template source file
+ * <TOP-DIR/scripts/SMCodeGen/templates/stateMachineTmpls/state.cpp.tt>
+ **************************************/
+
+#include "smEnumTypes.h"
+#include "actionTable.h"
+#include "actionHandlers/actionHandlers.h"
+
+#include "mmeStates/detachStart.h"
+#include "mmeStates/detachWfDelSessionResp.h"
+
+using namespace mme;
+using namespace SM;
+
+/******************************************************************************
+* Constructor
+******************************************************************************/
+DetachStart::DetachStart():State(State_e::detach_start)
+{
+}
+
+/******************************************************************************
+* Destructor
+******************************************************************************/
+DetachStart::~DetachStart()
+{
+}
+
+/******************************************************************************
+* creates and returns static instance
+******************************************************************************/
+DetachStart* DetachStart::Instance()
+{
+ static DetachStart state;
+ return &state;
+}
+
+/******************************************************************************
+* initializes eventToActionsMap
+******************************************************************************/
+void DetachStart::initialize()
+{
+ {
+ ActionTable actionTable;
+ actionTable.addAction(&ActionHandlers::del_session_req);
+ actionTable.setNextState(DetachWfDelSessionResp::Instance());
+ eventToActionsMap.insert(pair<Event_e, ActionTable>(Event_e::DETACH_REQ_FROM_UE, actionTable));
+ }
+}
diff --git a/src/mme-app/mmeStates/detachWfDelSessionResp.cpp b/src/mme-app/mmeStates/detachWfDelSessionResp.cpp
new file mode 100644
index 0000000..a10f6a7
--- /dev/null
+++ b/src/mme-app/mmeStates/detachWfDelSessionResp.cpp
@@ -0,0 +1,59 @@
+
+/*
+ * Copyright 2019-present Infosys Limited
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/**************************************
+ * detachWfDelSessionResp.cpp
+ * This is an auto generated file.
+ * Please do not edit this file.
+ * All edits to be made through template source file
+ * <TOP-DIR/scripts/SMCodeGen/templates/stateMachineTmpls/state.cpp.tt>
+ **************************************/
+
+#include "smEnumTypes.h"
+#include "actionTable.h"
+#include "actionHandlers/actionHandlers.h"
+
+#include "mmeStates/detachWfDelSessionResp.h"
+
+using namespace mme;
+using namespace SM;
+
+/******************************************************************************
+* Constructor
+******************************************************************************/
+DetachWfDelSessionResp::DetachWfDelSessionResp():State(State_e::detach_wf_del_session_resp)
+{
+}
+
+/******************************************************************************
+* Destructor
+******************************************************************************/
+DetachWfDelSessionResp::~DetachWfDelSessionResp()
+{
+}
+
+/******************************************************************************
+* creates and returns static instance
+******************************************************************************/
+DetachWfDelSessionResp* DetachWfDelSessionResp::Instance()
+{
+ static DetachWfDelSessionResp state;
+ return &state;
+}
+
+/******************************************************************************
+* initializes eventToActionsMap
+******************************************************************************/
+void DetachWfDelSessionResp::initialize()
+{
+ {
+ ActionTable actionTable;
+ actionTable.addAction(&ActionHandlers::process_del_session_resp);
+ actionTable.addAction(&ActionHandlers::detach_accept_to_ue);
+ eventToActionsMap.insert(pair<Event_e, ActionTable>(Event_e::DEL_SESSION_RESP_FROM_SGW, actionTable));
+ }
+}
diff --git a/src/mme-app/mmeStates/niDetachStart.cpp b/src/mme-app/mmeStates/niDetachStart.cpp
new file mode 100644
index 0000000..7f16581
--- /dev/null
+++ b/src/mme-app/mmeStates/niDetachStart.cpp
@@ -0,0 +1,61 @@
+
+/*
+ * Copyright 2019-present Infosys Limited
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/**************************************
+ * niDetachStart.cpp
+ * This is an auto generated file.
+ * Please do not edit this file.
+ * All edits to be made through template source file
+ * <TOP-DIR/scripts/SMCodeGen/templates/stateMachineTmpls/state.cpp.tt>
+ **************************************/
+
+#include "smEnumTypes.h"
+#include "actionTable.h"
+#include "actionHandlers/actionHandlers.h"
+
+#include "mmeStates/niDetachStart.h"
+#include "mmeStates/niDetachWfDetAccptDelSessResp.h"
+
+using namespace mme;
+using namespace SM;
+
+/******************************************************************************
+* Constructor
+******************************************************************************/
+NiDetachStart::NiDetachStart():State(State_e::ni_detach_start)
+{
+}
+
+/******************************************************************************
+* Destructor
+******************************************************************************/
+NiDetachStart::~NiDetachStart()
+{
+}
+
+/******************************************************************************
+* creates and returns static instance
+******************************************************************************/
+NiDetachStart* NiDetachStart::Instance()
+{
+ static NiDetachStart state;
+ return &state;
+}
+
+/******************************************************************************
+* initializes eventToActionsMap
+******************************************************************************/
+void NiDetachStart::initialize()
+{
+ {
+ ActionTable actionTable;
+ actionTable.addAction(&ActionHandlers::ni_detach_req_to_ue);
+ actionTable.addAction(&ActionHandlers::del_session_req);
+ actionTable.setNextState(NiDetachWfDetAccptDelSessResp::Instance());
+ eventToActionsMap.insert(pair<Event_e, ActionTable>(Event_e::CLR_FROM_HSS, actionTable));
+ }
+}
diff --git a/src/mme-app/mmeStates/niDetachWfDelSessResp.cpp b/src/mme-app/mmeStates/niDetachWfDelSessResp.cpp
new file mode 100644
index 0000000..5d7dd12
--- /dev/null
+++ b/src/mme-app/mmeStates/niDetachWfDelSessResp.cpp
@@ -0,0 +1,61 @@
+
+/*
+ * Copyright 2019-present Infosys Limited
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/**************************************
+ * niDetachWfDelSessResp.cpp
+ * This is an auto generated file.
+ * Please do not edit this file.
+ * All edits to be made through template source file
+ * <TOP-DIR/scripts/SMCodeGen/templates/stateMachineTmpls/state.cpp.tt>
+ **************************************/
+
+#include "smEnumTypes.h"
+#include "actionTable.h"
+#include "actionHandlers/actionHandlers.h"
+
+#include "mmeStates/niDetachWfDelSessResp.h"
+#include "mmeStates/niDetachWfS1RelComp.h"
+
+using namespace mme;
+using namespace SM;
+
+/******************************************************************************
+* Constructor
+******************************************************************************/
+NiDetachWfDelSessResp::NiDetachWfDelSessResp():State(State_e::ni_detach_wf_del_sess_resp)
+{
+}
+
+/******************************************************************************
+* Destructor
+******************************************************************************/
+NiDetachWfDelSessResp::~NiDetachWfDelSessResp()
+{
+}
+
+/******************************************************************************
+* creates and returns static instance
+******************************************************************************/
+NiDetachWfDelSessResp* NiDetachWfDelSessResp::Instance()
+{
+ static NiDetachWfDelSessResp state;
+ return &state;
+}
+
+/******************************************************************************
+* initializes eventToActionsMap
+******************************************************************************/
+void NiDetachWfDelSessResp::initialize()
+{
+ {
+ ActionTable actionTable;
+ actionTable.addAction(&ActionHandlers::process_del_session_resp);
+ actionTable.addAction(&ActionHandlers::send_s1_rel_cmd_to_ue);
+ actionTable.setNextState(NiDetachWfS1RelComp::Instance());
+ eventToActionsMap.insert(pair<Event_e, ActionTable>(Event_e::DEL_SESSION_RESP_FROM_SGW, actionTable));
+ }
+}
diff --git a/src/mme-app/mmeStates/niDetachWfDetAccptDelSessResp.cpp b/src/mme-app/mmeStates/niDetachWfDetAccptDelSessResp.cpp
new file mode 100644
index 0000000..a6d76b3
--- /dev/null
+++ b/src/mme-app/mmeStates/niDetachWfDetAccptDelSessResp.cpp
@@ -0,0 +1,67 @@
+
+/*
+ * Copyright 2019-present Infosys Limited
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/**************************************
+ * niDetachWfDetAccptDelSessResp.cpp
+ * This is an auto generated file.
+ * Please do not edit this file.
+ * All edits to be made through template source file
+ * <TOP-DIR/scripts/SMCodeGen/templates/stateMachineTmpls/state.cpp.tt>
+ **************************************/
+
+#include "smEnumTypes.h"
+#include "actionTable.h"
+#include "actionHandlers/actionHandlers.h"
+
+#include "mmeStates/niDetachWfDetAccptDelSessResp.h"
+#include "mmeStates/niDetachWfDelSessResp.h"
+#include "mmeStates/niDetachWfDetachAccept.h"
+
+using namespace mme;
+using namespace SM;
+
+/******************************************************************************
+* Constructor
+******************************************************************************/
+NiDetachWfDetAccptDelSessResp::NiDetachWfDetAccptDelSessResp():State(State_e::ni_detach_wf_det_accpt_del_sess_resp)
+{
+}
+
+/******************************************************************************
+* Destructor
+******************************************************************************/
+NiDetachWfDetAccptDelSessResp::~NiDetachWfDetAccptDelSessResp()
+{
+}
+
+/******************************************************************************
+* creates and returns static instance
+******************************************************************************/
+NiDetachWfDetAccptDelSessResp* NiDetachWfDetAccptDelSessResp::Instance()
+{
+ static NiDetachWfDetAccptDelSessResp state;
+ return &state;
+}
+
+/******************************************************************************
+* initializes eventToActionsMap
+******************************************************************************/
+void NiDetachWfDetAccptDelSessResp::initialize()
+{
+ {
+ ActionTable actionTable;
+ actionTable.addAction(&ActionHandlers::process_detach_accept_from_ue);
+ actionTable.setNextState(NiDetachWfDelSessResp::Instance());
+ eventToActionsMap.insert(pair<Event_e, ActionTable>(Event_e::DETACH_ACCEPT_FROM_UE, actionTable));
+ }
+ {
+ ActionTable actionTable;
+ actionTable.addAction(&ActionHandlers::process_del_session_resp);
+ actionTable.setNextState(NiDetachWfDetachAccept::Instance());
+ eventToActionsMap.insert(pair<Event_e, ActionTable>(Event_e::DEL_SESSION_RESP_FROM_SGW, actionTable));
+ }
+}
diff --git a/src/mme-app/mmeStates/niDetachWfDetachAccept.cpp b/src/mme-app/mmeStates/niDetachWfDetachAccept.cpp
new file mode 100644
index 0000000..476a107
--- /dev/null
+++ b/src/mme-app/mmeStates/niDetachWfDetachAccept.cpp
@@ -0,0 +1,61 @@
+
+/*
+ * Copyright 2019-present Infosys Limited
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/**************************************
+ * niDetachWfDetachAccept.cpp
+ * This is an auto generated file.
+ * Please do not edit this file.
+ * All edits to be made through template source file
+ * <TOP-DIR/scripts/SMCodeGen/templates/stateMachineTmpls/state.cpp.tt>
+ **************************************/
+
+#include "smEnumTypes.h"
+#include "actionTable.h"
+#include "actionHandlers/actionHandlers.h"
+
+#include "mmeStates/niDetachWfDetachAccept.h"
+#include "mmeStates/niDetachWfS1RelComp.h"
+
+using namespace mme;
+using namespace SM;
+
+/******************************************************************************
+* Constructor
+******************************************************************************/
+NiDetachWfDetachAccept::NiDetachWfDetachAccept():State(State_e::ni_detach_wf_detach_accept)
+{
+}
+
+/******************************************************************************
+* Destructor
+******************************************************************************/
+NiDetachWfDetachAccept::~NiDetachWfDetachAccept()
+{
+}
+
+/******************************************************************************
+* creates and returns static instance
+******************************************************************************/
+NiDetachWfDetachAccept* NiDetachWfDetachAccept::Instance()
+{
+ static NiDetachWfDetachAccept state;
+ return &state;
+}
+
+/******************************************************************************
+* initializes eventToActionsMap
+******************************************************************************/
+void NiDetachWfDetachAccept::initialize()
+{
+ {
+ ActionTable actionTable;
+ actionTable.addAction(&ActionHandlers::process_detach_accept_from_ue);
+ actionTable.addAction(&ActionHandlers::send_s1_rel_cmd_to_ue_for_detach);
+ actionTable.setNextState(NiDetachWfS1RelComp::Instance());
+ eventToActionsMap.insert(pair<Event_e, ActionTable>(Event_e::DETACH_ACCEPT_FROM_UE, actionTable));
+ }
+}
diff --git a/src/mme-app/mmeStates/niDetachWfS1RelComp.cpp b/src/mme-app/mmeStates/niDetachWfS1RelComp.cpp
new file mode 100644
index 0000000..d9b9b11
--- /dev/null
+++ b/src/mme-app/mmeStates/niDetachWfS1RelComp.cpp
@@ -0,0 +1,58 @@
+
+/*
+ * Copyright 2019-present Infosys Limited
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/**************************************
+ * niDetachWfS1RelComp.cpp
+ * This is an auto generated file.
+ * Please do not edit this file.
+ * All edits to be made through template source file
+ * <TOP-DIR/scripts/SMCodeGen/templates/stateMachineTmpls/state.cpp.tt>
+ **************************************/
+
+#include "smEnumTypes.h"
+#include "actionTable.h"
+#include "actionHandlers/actionHandlers.h"
+
+#include "mmeStates/niDetachWfS1RelComp.h"
+
+using namespace mme;
+using namespace SM;
+
+/******************************************************************************
+* Constructor
+******************************************************************************/
+NiDetachWfS1RelComp::NiDetachWfS1RelComp():State(State_e::ni_detach_wf_s1_rel_comp)
+{
+}
+
+/******************************************************************************
+* Destructor
+******************************************************************************/
+NiDetachWfS1RelComp::~NiDetachWfS1RelComp()
+{
+}
+
+/******************************************************************************
+* creates and returns static instance
+******************************************************************************/
+NiDetachWfS1RelComp* NiDetachWfS1RelComp::Instance()
+{
+ static NiDetachWfS1RelComp state;
+ return &state;
+}
+
+/******************************************************************************
+* initializes eventToActionsMap
+******************************************************************************/
+void NiDetachWfS1RelComp::initialize()
+{
+ {
+ ActionTable actionTable;
+ actionTable.addAction(&ActionHandlers::process_ue_ctxt_rel_comp_for_detach);
+ eventToActionsMap.insert(pair<Event_e, ActionTable>(Event_e::UE_CTXT_REL_COMP_FROM_ENB, actionTable));
+ }
+}
diff --git a/src/mme-app/mmeStates/pagingStart.cpp b/src/mme-app/mmeStates/pagingStart.cpp
new file mode 100644
index 0000000..d4d1946
--- /dev/null
+++ b/src/mme-app/mmeStates/pagingStart.cpp
@@ -0,0 +1,60 @@
+
+/*
+ * Copyright 2019-present Infosys Limited
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/**************************************
+ * pagingStart.cpp
+ * This is an auto generated file.
+ * Please do not edit this file.
+ * All edits to be made through template source file
+ * <TOP-DIR/scripts/SMCodeGen/templates/stateMachineTmpls/state.cpp.tt>
+ **************************************/
+
+#include "smEnumTypes.h"
+#include "actionTable.h"
+#include "actionHandlers/actionHandlers.h"
+
+#include "mmeStates/pagingStart.h"
+#include "mmeStates/pagingWfServiceReq.h"
+
+using namespace mme;
+using namespace SM;
+
+/******************************************************************************
+* Constructor
+******************************************************************************/
+PagingStart::PagingStart():State(State_e::paging_start)
+{
+}
+
+/******************************************************************************
+* Destructor
+******************************************************************************/
+PagingStart::~PagingStart()
+{
+}
+
+/******************************************************************************
+* creates and returns static instance
+******************************************************************************/
+PagingStart* PagingStart::Instance()
+{
+ static PagingStart state;
+ return &state;
+}
+
+/******************************************************************************
+* initializes eventToActionsMap
+******************************************************************************/
+void PagingStart::initialize()
+{
+ {
+ ActionTable actionTable;
+ actionTable.addAction(&ActionHandlers::send_paging_req_to_ue);
+ actionTable.setNextState(PagingWfServiceReq::Instance());
+ eventToActionsMap.insert(pair<Event_e, ActionTable>(Event_e::DDN_FROM_SGW, actionTable));
+ }
+}
diff --git a/src/mme-app/mmeStates/pagingWfServiceReq.cpp b/src/mme-app/mmeStates/pagingWfServiceReq.cpp
new file mode 100644
index 0000000..fcc77e4
--- /dev/null
+++ b/src/mme-app/mmeStates/pagingWfServiceReq.cpp
@@ -0,0 +1,62 @@
+
+/*
+ * Copyright 2019-present Infosys Limited
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/**************************************
+ * pagingWfServiceReq.cpp
+ * This is an auto generated file.
+ * Please do not edit this file.
+ * All edits to be made through template source file
+ * <TOP-DIR/scripts/SMCodeGen/templates/stateMachineTmpls/state.cpp.tt>
+ **************************************/
+
+#include "smEnumTypes.h"
+#include "actionTable.h"
+#include "actionHandlers/actionHandlers.h"
+
+#include "mmeStates/pagingWfServiceReq.h"
+#include "mmeStates/serviceRequestWfAuthAndSecCheckCmp.h"
+
+using namespace mme;
+using namespace SM;
+
+/******************************************************************************
+* Constructor
+******************************************************************************/
+PagingWfServiceReq::PagingWfServiceReq():State(State_e::paging_wf_service_req)
+{
+}
+
+/******************************************************************************
+* Destructor
+******************************************************************************/
+PagingWfServiceReq::~PagingWfServiceReq()
+{
+}
+
+/******************************************************************************
+* creates and returns static instance
+******************************************************************************/
+PagingWfServiceReq* PagingWfServiceReq::Instance()
+{
+ static PagingWfServiceReq state;
+ return &state;
+}
+
+/******************************************************************************
+* initializes eventToActionsMap
+******************************************************************************/
+void PagingWfServiceReq::initialize()
+{
+ {
+ ActionTable actionTable;
+ actionTable.addAction(&ActionHandlers::process_service_request);
+ actionTable.addAction(&ActionHandlers::send_ddn_ack_to_sgw);
+ actionTable.addAction(&ActionHandlers::perform_auth_and_sec_check);
+ actionTable.setNextState(ServiceRequestWfAuthAndSecCheckCmp::Instance());
+ eventToActionsMap.insert(pair<Event_e, ActionTable>(Event_e::SERVICE_REQUEST_FROM_UE, actionTable));
+ }
+}
diff --git a/src/mme-app/mmeStates/s1ReleaseStart.cpp b/src/mme-app/mmeStates/s1ReleaseStart.cpp
new file mode 100644
index 0000000..41fd266
--- /dev/null
+++ b/src/mme-app/mmeStates/s1ReleaseStart.cpp
@@ -0,0 +1,60 @@
+
+/*
+ * Copyright 2019-present Infosys Limited
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/**************************************
+ * s1ReleaseStart.cpp
+ * This is an auto generated file.
+ * Please do not edit this file.
+ * All edits to be made through template source file
+ * <TOP-DIR/scripts/SMCodeGen/templates/stateMachineTmpls/state.cpp.tt>
+ **************************************/
+
+#include "smEnumTypes.h"
+#include "actionTable.h"
+#include "actionHandlers/actionHandlers.h"
+
+#include "mmeStates/s1ReleaseStart.h"
+#include "mmeStates/s1ReleaseWfReleaseAccessBearerResp.h"
+
+using namespace mme;
+using namespace SM;
+
+/******************************************************************************
+* Constructor
+******************************************************************************/
+S1ReleaseStart::S1ReleaseStart():State(State_e::s1_release_start)
+{
+}
+
+/******************************************************************************
+* Destructor
+******************************************************************************/
+S1ReleaseStart::~S1ReleaseStart()
+{
+}
+
+/******************************************************************************
+* creates and returns static instance
+******************************************************************************/
+S1ReleaseStart* S1ReleaseStart::Instance()
+{
+ static S1ReleaseStart state;
+ return &state;
+}
+
+/******************************************************************************
+* initializes eventToActionsMap
+******************************************************************************/
+void S1ReleaseStart::initialize()
+{
+ {
+ ActionTable actionTable;
+ actionTable.addAction(&ActionHandlers::send_rel_ab_req_to_sgw);
+ actionTable.setNextState(S1ReleaseWfReleaseAccessBearerResp::Instance());
+ eventToActionsMap.insert(pair<Event_e, ActionTable>(Event_e::S1_REL_REQ_FROM_UE, actionTable));
+ }
+}
diff --git a/src/mme-app/mmeStates/s1ReleaseWfReleaseAccessBearerResp.cpp b/src/mme-app/mmeStates/s1ReleaseWfReleaseAccessBearerResp.cpp
new file mode 100644
index 0000000..917c74d
--- /dev/null
+++ b/src/mme-app/mmeStates/s1ReleaseWfReleaseAccessBearerResp.cpp
@@ -0,0 +1,61 @@
+
+/*
+ * Copyright 2019-present Infosys Limited
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/**************************************
+ * s1ReleaseWfReleaseAccessBearerResp.cpp
+ * This is an auto generated file.
+ * Please do not edit this file.
+ * All edits to be made through template source file
+ * <TOP-DIR/scripts/SMCodeGen/templates/stateMachineTmpls/state.cpp.tt>
+ **************************************/
+
+#include "smEnumTypes.h"
+#include "actionTable.h"
+#include "actionHandlers/actionHandlers.h"
+
+#include "mmeStates/s1ReleaseWfReleaseAccessBearerResp.h"
+#include "mmeStates/s1ReleaseWfUeCtxtReleaseComp.h"
+
+using namespace mme;
+using namespace SM;
+
+/******************************************************************************
+* Constructor
+******************************************************************************/
+S1ReleaseWfReleaseAccessBearerResp::S1ReleaseWfReleaseAccessBearerResp():State(State_e::s1_release_wf_release_access_bearer_resp)
+{
+}
+
+/******************************************************************************
+* Destructor
+******************************************************************************/
+S1ReleaseWfReleaseAccessBearerResp::~S1ReleaseWfReleaseAccessBearerResp()
+{
+}
+
+/******************************************************************************
+* creates and returns static instance
+******************************************************************************/
+S1ReleaseWfReleaseAccessBearerResp* S1ReleaseWfReleaseAccessBearerResp::Instance()
+{
+ static S1ReleaseWfReleaseAccessBearerResp state;
+ return &state;
+}
+
+/******************************************************************************
+* initializes eventToActionsMap
+******************************************************************************/
+void S1ReleaseWfReleaseAccessBearerResp::initialize()
+{
+ {
+ ActionTable actionTable;
+ actionTable.addAction(&ActionHandlers::process_rel_ab_resp_from_sgw);
+ actionTable.addAction(&ActionHandlers::send_s1_rel_cmd_to_ue);
+ actionTable.setNextState(S1ReleaseWfUeCtxtReleaseComp::Instance());
+ eventToActionsMap.insert(pair<Event_e, ActionTable>(Event_e::REL_AB_RESP_FROM_SGW, actionTable));
+ }
+}
diff --git a/src/mme-app/mmeStates/s1ReleaseWfUeCtxtReleaseComp.cpp b/src/mme-app/mmeStates/s1ReleaseWfUeCtxtReleaseComp.cpp
new file mode 100644
index 0000000..a354290
--- /dev/null
+++ b/src/mme-app/mmeStates/s1ReleaseWfUeCtxtReleaseComp.cpp
@@ -0,0 +1,58 @@
+
+/*
+ * Copyright 2019-present Infosys Limited
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/**************************************
+ * s1ReleaseWfUeCtxtReleaseComp.cpp
+ * This is an auto generated file.
+ * Please do not edit this file.
+ * All edits to be made through template source file
+ * <TOP-DIR/scripts/SMCodeGen/templates/stateMachineTmpls/state.cpp.tt>
+ **************************************/
+
+#include "smEnumTypes.h"
+#include "actionTable.h"
+#include "actionHandlers/actionHandlers.h"
+
+#include "mmeStates/s1ReleaseWfUeCtxtReleaseComp.h"
+
+using namespace mme;
+using namespace SM;
+
+/******************************************************************************
+* Constructor
+******************************************************************************/
+S1ReleaseWfUeCtxtReleaseComp::S1ReleaseWfUeCtxtReleaseComp():State(State_e::s1_release_wf_ue_ctxt_release_comp)
+{
+}
+
+/******************************************************************************
+* Destructor
+******************************************************************************/
+S1ReleaseWfUeCtxtReleaseComp::~S1ReleaseWfUeCtxtReleaseComp()
+{
+}
+
+/******************************************************************************
+* creates and returns static instance
+******************************************************************************/
+S1ReleaseWfUeCtxtReleaseComp* S1ReleaseWfUeCtxtReleaseComp::Instance()
+{
+ static S1ReleaseWfUeCtxtReleaseComp state;
+ return &state;
+}
+
+/******************************************************************************
+* initializes eventToActionsMap
+******************************************************************************/
+void S1ReleaseWfUeCtxtReleaseComp::initialize()
+{
+ {
+ ActionTable actionTable;
+ actionTable.addAction(&ActionHandlers::process_ue_ctxt_rel_comp);
+ eventToActionsMap.insert(pair<Event_e, ActionTable>(Event_e::UE_CTXT_REL_COMP_FROM_ENB, actionTable));
+ }
+}
diff --git a/src/mme-app/mmeStates/serviceRequestStart.cpp b/src/mme-app/mmeStates/serviceRequestStart.cpp
new file mode 100644
index 0000000..795a067
--- /dev/null
+++ b/src/mme-app/mmeStates/serviceRequestStart.cpp
@@ -0,0 +1,61 @@
+
+/*
+ * Copyright 2019-present Infosys Limited
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/**************************************
+ * serviceRequestStart.cpp
+ * This is an auto generated file.
+ * Please do not edit this file.
+ * All edits to be made through template source file
+ * <TOP-DIR/scripts/SMCodeGen/templates/stateMachineTmpls/state.cpp.tt>
+ **************************************/
+
+#include "smEnumTypes.h"
+#include "actionTable.h"
+#include "actionHandlers/actionHandlers.h"
+
+#include "mmeStates/serviceRequestStart.h"
+#include "mmeStates/serviceRequestWfAuthAndSecCheckCmp.h"
+
+using namespace mme;
+using namespace SM;
+
+/******************************************************************************
+* Constructor
+******************************************************************************/
+ServiceRequestStart::ServiceRequestStart():State(State_e::service_request_start)
+{
+}
+
+/******************************************************************************
+* Destructor
+******************************************************************************/
+ServiceRequestStart::~ServiceRequestStart()
+{
+}
+
+/******************************************************************************
+* creates and returns static instance
+******************************************************************************/
+ServiceRequestStart* ServiceRequestStart::Instance()
+{
+ static ServiceRequestStart state;
+ return &state;
+}
+
+/******************************************************************************
+* initializes eventToActionsMap
+******************************************************************************/
+void ServiceRequestStart::initialize()
+{
+ {
+ ActionTable actionTable;
+ actionTable.addAction(&ActionHandlers::process_service_request);
+ actionTable.addAction(&ActionHandlers::perform_auth_and_sec_check);
+ actionTable.setNextState(ServiceRequestWfAuthAndSecCheckCmp::Instance());
+ eventToActionsMap.insert(pair<Event_e, ActionTable>(Event_e::SERVICE_REQUEST_FROM_UE, actionTable));
+ }
+}
diff --git a/src/mme-app/mmeStates/serviceRequestWfAuthAndSecCheckCmp.cpp b/src/mme-app/mmeStates/serviceRequestWfAuthAndSecCheckCmp.cpp
new file mode 100644
index 0000000..3b63005
--- /dev/null
+++ b/src/mme-app/mmeStates/serviceRequestWfAuthAndSecCheckCmp.cpp
@@ -0,0 +1,60 @@
+
+/*
+ * Copyright 2019-present Infosys Limited
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/**************************************
+ * serviceRequestWfAuthAndSecCheckCmp.cpp
+ * This is an auto generated file.
+ * Please do not edit this file.
+ * All edits to be made through template source file
+ * <TOP-DIR/scripts/SMCodeGen/templates/stateMachineTmpls/state.cpp.tt>
+ **************************************/
+
+#include "smEnumTypes.h"
+#include "actionTable.h"
+#include "actionHandlers/actionHandlers.h"
+
+#include "mmeStates/serviceRequestWfAuthAndSecCheckCmp.h"
+#include "mmeStates/serviceRequestWfInitCtxtResp.h"
+
+using namespace mme;
+using namespace SM;
+
+/******************************************************************************
+* Constructor
+******************************************************************************/
+ServiceRequestWfAuthAndSecCheckCmp::ServiceRequestWfAuthAndSecCheckCmp():State(State_e::service_request_wf_auth_and_sec_check_cmp)
+{
+}
+
+/******************************************************************************
+* Destructor
+******************************************************************************/
+ServiceRequestWfAuthAndSecCheckCmp::~ServiceRequestWfAuthAndSecCheckCmp()
+{
+}
+
+/******************************************************************************
+* creates and returns static instance
+******************************************************************************/
+ServiceRequestWfAuthAndSecCheckCmp* ServiceRequestWfAuthAndSecCheckCmp::Instance()
+{
+ static ServiceRequestWfAuthAndSecCheckCmp state;
+ return &state;
+}
+
+/******************************************************************************
+* initializes eventToActionsMap
+******************************************************************************/
+void ServiceRequestWfAuthAndSecCheckCmp::initialize()
+{
+ {
+ ActionTable actionTable;
+ actionTable.addAction(&ActionHandlers::send_init_ctxt_req_to_ue_svc_req);
+ actionTable.setNextState(ServiceRequestWfInitCtxtResp::Instance());
+ eventToActionsMap.insert(pair<Event_e, ActionTable>(Event_e::AUTH_AND_SEC_CHECK_COMPLETE, actionTable));
+ }
+}
diff --git a/src/mme-app/mmeStates/serviceRequestWfInitCtxtResp.cpp b/src/mme-app/mmeStates/serviceRequestWfInitCtxtResp.cpp
new file mode 100644
index 0000000..7fb820f
--- /dev/null
+++ b/src/mme-app/mmeStates/serviceRequestWfInitCtxtResp.cpp
@@ -0,0 +1,61 @@
+
+/*
+ * Copyright 2019-present Infosys Limited
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/**************************************
+ * serviceRequestWfInitCtxtResp.cpp
+ * This is an auto generated file.
+ * Please do not edit this file.
+ * All edits to be made through template source file
+ * <TOP-DIR/scripts/SMCodeGen/templates/stateMachineTmpls/state.cpp.tt>
+ **************************************/
+
+#include "smEnumTypes.h"
+#include "actionTable.h"
+#include "actionHandlers/actionHandlers.h"
+
+#include "mmeStates/serviceRequestWfInitCtxtResp.h"
+#include "mmeStates/serviceRequestWfMbResp.h"
+
+using namespace mme;
+using namespace SM;
+
+/******************************************************************************
+* Constructor
+******************************************************************************/
+ServiceRequestWfInitCtxtResp::ServiceRequestWfInitCtxtResp():State(State_e::service_request_wf_init_ctxt_resp)
+{
+}
+
+/******************************************************************************
+* Destructor
+******************************************************************************/
+ServiceRequestWfInitCtxtResp::~ServiceRequestWfInitCtxtResp()
+{
+}
+
+/******************************************************************************
+* creates and returns static instance
+******************************************************************************/
+ServiceRequestWfInitCtxtResp* ServiceRequestWfInitCtxtResp::Instance()
+{
+ static ServiceRequestWfInitCtxtResp state;
+ return &state;
+}
+
+/******************************************************************************
+* initializes eventToActionsMap
+******************************************************************************/
+void ServiceRequestWfInitCtxtResp::initialize()
+{
+ {
+ ActionTable actionTable;
+ actionTable.addAction(&ActionHandlers::process_init_ctxt_resp_svc_req);
+ actionTable.addAction(&ActionHandlers::send_mb_req_to_sgw_svc_req);
+ actionTable.setNextState(ServiceRequestWfMbResp::Instance());
+ eventToActionsMap.insert(pair<Event_e, ActionTable>(Event_e::INIT_CTXT_RESP_FROM_UE, actionTable));
+ }
+}
diff --git a/src/mme-app/mmeStates/serviceRequestWfMbResp.cpp b/src/mme-app/mmeStates/serviceRequestWfMbResp.cpp
new file mode 100644
index 0000000..2fc89aa
--- /dev/null
+++ b/src/mme-app/mmeStates/serviceRequestWfMbResp.cpp
@@ -0,0 +1,58 @@
+
+/*
+ * Copyright 2019-present Infosys Limited
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/**************************************
+ * serviceRequestWfMbResp.cpp
+ * This is an auto generated file.
+ * Please do not edit this file.
+ * All edits to be made through template source file
+ * <TOP-DIR/scripts/SMCodeGen/templates/stateMachineTmpls/state.cpp.tt>
+ **************************************/
+
+#include "smEnumTypes.h"
+#include "actionTable.h"
+#include "actionHandlers/actionHandlers.h"
+
+#include "mmeStates/serviceRequestWfMbResp.h"
+
+using namespace mme;
+using namespace SM;
+
+/******************************************************************************
+* Constructor
+******************************************************************************/
+ServiceRequestWfMbResp::ServiceRequestWfMbResp():State(State_e::service_request_wf_mb_resp)
+{
+}
+
+/******************************************************************************
+* Destructor
+******************************************************************************/
+ServiceRequestWfMbResp::~ServiceRequestWfMbResp()
+{
+}
+
+/******************************************************************************
+* creates and returns static instance
+******************************************************************************/
+ServiceRequestWfMbResp* ServiceRequestWfMbResp::Instance()
+{
+ static ServiceRequestWfMbResp state;
+ return &state;
+}
+
+/******************************************************************************
+* initializes eventToActionsMap
+******************************************************************************/
+void ServiceRequestWfMbResp::initialize()
+{
+ {
+ ActionTable actionTable;
+ actionTable.addAction(&ActionHandlers::process_mb_resp_svc_req);
+ eventToActionsMap.insert(pair<Event_e, ActionTable>(Event_e::MB_RESP_FROM_SGW, actionTable));
+ }
+}
diff --git a/src/mme-app/mmeStates/stateFactory.cpp b/src/mme-app/mmeStates/stateFactory.cpp
new file mode 100644
index 0000000..8648a53
--- /dev/null
+++ b/src/mme-app/mmeStates/stateFactory.cpp
@@ -0,0 +1,112 @@
+
+/*
+ * Copyright 2019-present Infosys Limited
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/**************************************
+ * tauStart.cpp
+ * This is an auto generated file.
+ * Please do not edit this file.
+ * All edits to be made through template source file
+ * <TOP-DIR/scripts/SMCodeGen/templates/stateMachineTmpls/stateFactory.cpp.tt>
+ **************************************/
+
+#include "mmeStates/stateFactory.h"
+#include "mmeStates/attachStart.h"
+#include "mmeStates/attachWfAia.h"
+#include "mmeStates/attachWfAttCmp.h"
+#include "mmeStates/attachWfAuthResp.h"
+#include "mmeStates/attachWfAuthRespValidate.h"
+#include "mmeStates/attachWfCsResp.h"
+#include "mmeStates/attachWfEsmInfoCheck.h"
+#include "mmeStates/attachWfEsmInfoResp.h"
+#include "mmeStates/attachWfIdentityResponse.h"
+#include "mmeStates/attachWfImsiValidateAction.h"
+#include "mmeStates/attachWfInitCtxtResp.h"
+#include "mmeStates/attachWfInitCtxtRespAttCmp.h"
+#include "mmeStates/attachWfMbResp.h"
+#include "mmeStates/attachWfSecCmp.h"
+#include "mmeStates/attachWfUla.h"
+#include "mmeStates/defaultMmeState.h"
+#include "mmeStates/detachStart.h"
+#include "mmeStates/detachWfDelSessionResp.h"
+#include "mmeStates/niDetachStart.h"
+#include "mmeStates/niDetachWfDelSessResp.h"
+#include "mmeStates/niDetachWfDetAccptDelSessResp.h"
+#include "mmeStates/niDetachWfDetachAccept.h"
+#include "mmeStates/niDetachWfS1RelComp.h"
+#include "mmeStates/pagingStart.h"
+#include "mmeStates/pagingWfServiceReq.h"
+#include "mmeStates/s1ReleaseStart.h"
+#include "mmeStates/s1ReleaseWfReleaseAccessBearerResp.h"
+#include "mmeStates/s1ReleaseWfUeCtxtReleaseComp.h"
+#include "mmeStates/serviceRequestStart.h"
+#include "mmeStates/serviceRequestWfAuthAndSecCheckCmp.h"
+#include "mmeStates/serviceRequestWfInitCtxtResp.h"
+#include "mmeStates/serviceRequestWfMbResp.h"
+#include "mmeStates/tauStart.h"
+
+using namespace mme;
+
+/**********************************************
+* Constructor
+***********************************************/
+StateFactory::StateFactory()
+{
+}
+
+/**********************************************
+* Destructor
+***********************************************/
+StateFactory::~StateFactory()
+{
+}
+
+/**********************************************
+* creates and returns static instance
+***********************************************/
+
+StateFactory* StateFactory::Instance()
+{
+ static StateFactory instance;
+ return &instance;
+}
+
+void StateFactory::initialize()
+{
+ AttachStart::Instance()->initialize();
+ AttachWfAia::Instance()->initialize();
+ AttachWfAttCmp::Instance()->initialize();
+ AttachWfAuthResp::Instance()->initialize();
+ AttachWfAuthRespValidate::Instance()->initialize();
+ AttachWfCsResp::Instance()->initialize();
+ AttachWfEsmInfoCheck::Instance()->initialize();
+ AttachWfEsmInfoResp::Instance()->initialize();
+ AttachWfIdentityResponse::Instance()->initialize();
+ AttachWfImsiValidateAction::Instance()->initialize();
+ AttachWfInitCtxtResp::Instance()->initialize();
+ AttachWfInitCtxtRespAttCmp::Instance()->initialize();
+ AttachWfMbResp::Instance()->initialize();
+ AttachWfSecCmp::Instance()->initialize();
+ AttachWfUla::Instance()->initialize();
+ DefaultMmeState::Instance()->initialize();
+ DetachStart::Instance()->initialize();
+ DetachWfDelSessionResp::Instance()->initialize();
+ NiDetachStart::Instance()->initialize();
+ NiDetachWfDelSessResp::Instance()->initialize();
+ NiDetachWfDetAccptDelSessResp::Instance()->initialize();
+ NiDetachWfDetachAccept::Instance()->initialize();
+ NiDetachWfS1RelComp::Instance()->initialize();
+ PagingStart::Instance()->initialize();
+ PagingWfServiceReq::Instance()->initialize();
+ S1ReleaseStart::Instance()->initialize();
+ S1ReleaseWfReleaseAccessBearerResp::Instance()->initialize();
+ S1ReleaseWfUeCtxtReleaseComp::Instance()->initialize();
+ ServiceRequestStart::Instance()->initialize();
+ ServiceRequestWfAuthAndSecCheckCmp::Instance()->initialize();
+ ServiceRequestWfInitCtxtResp::Instance()->initialize();
+ ServiceRequestWfMbResp::Instance()->initialize();
+ TauStart::Instance()->initialize();
+}
diff --git a/src/mme-app/mmeStates/tauStart.cpp b/src/mme-app/mmeStates/tauStart.cpp
new file mode 100644
index 0000000..d62c3a5
--- /dev/null
+++ b/src/mme-app/mmeStates/tauStart.cpp
@@ -0,0 +1,58 @@
+
+/*
+ * Copyright 2019-present Infosys Limited
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/**************************************
+ * tauStart.cpp
+ * This is an auto generated file.
+ * Please do not edit this file.
+ * All edits to be made through template source file
+ * <TOP-DIR/scripts/SMCodeGen/templates/stateMachineTmpls/state.cpp.tt>
+ **************************************/
+
+#include "smEnumTypes.h"
+#include "actionTable.h"
+#include "actionHandlers/actionHandlers.h"
+
+#include "mmeStates/tauStart.h"
+
+using namespace mme;
+using namespace SM;
+
+/******************************************************************************
+* Constructor
+******************************************************************************/
+TauStart::TauStart():State(State_e::tau_start)
+{
+}
+
+/******************************************************************************
+* Destructor
+******************************************************************************/
+TauStart::~TauStart()
+{
+}
+
+/******************************************************************************
+* creates and returns static instance
+******************************************************************************/
+TauStart* TauStart::Instance()
+{
+ static TauStart state;
+ return &state;
+}
+
+/******************************************************************************
+* initializes eventToActionsMap
+******************************************************************************/
+void TauStart::initialize()
+{
+ {
+ ActionTable actionTable;
+ actionTable.addAction(&ActionHandlers::send_tau_response_to_ue);
+ eventToActionsMap.insert(pair<Event_e, ActionTable>(Event_e::TAU_REQUEST_FROM_UE, actionTable));
+ }
+}
diff --git a/src/mme-app/mmeThreads.h b/src/mme-app/mmeThreads.h
new file mode 100644
index 0000000..d6e6c91
--- /dev/null
+++ b/src/mme-app/mmeThreads.h
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2019, Infosys Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SRC_MME_APP_MMETHREADS_H_
+#define SRC_MME_APP_MMETHREADS_H_
+
+#include <blockingCircularFifo.h>
+#include <ipcTypes.h>
+#include <msgBuffer.h>
+#include <interfaces/mmeIpcInterface.h>
+#include <mme_app.h>
+
+#define DATA_BUF_SIZE 255
+
+using namespace cmn::ipc;
+using namespace cmn::utils;
+
+extern MmeIpcInterface* mmeIpcIf_g;
+
+extern cmn::utils::BlockingCircularFifo<MsgBuffer, fifoQSize_c> mmeIpcIngressFifo_g;
+extern cmn::utils::BlockingCircularFifo<MsgBuffer, fifoQSize_c> mmeIpcEgressFifo_g;
+
+class MmeIngressIpcProducerThread
+{
+public:
+ void operator()()
+ {
+ uint16_t bytesRead = 0;
+ cmn::ipc::IpcAddress srcAddr;
+ unsigned char buf[DATA_BUF_SIZE] = {0};
+
+ while(1)
+ {
+ if ((bytesRead = mmeIpcIf_g->reader()->recvMsgFrom(buf, DATA_BUF_SIZE, srcAddr)) > 0 )
+ {
+ MsgBuffer *msgBuf = new MsgBuffer(bytesRead);
+ msgBuf->writeBytes(buf, bytesRead);
+ msgBuf->rewind();
+ if (!mmeIpcIngressFifo_g.push(msgBuf))
+ {
+ delete msgBuf;
+ }
+ }
+
+ memset(buf, 0 , 255);
+ }
+ }
+};
+
+class MmeIngressIpcConsumerThread
+{
+public:
+ void operator()()
+ {
+ while(1)
+ {
+ MsgBuffer* msgBuf = NULL;
+ while(mmeIpcIngressFifo_g.pop(msgBuf) == true)
+ {
+ mmeIpcIf_g->handleIpcMsg(msgBuf);
+ }
+ }
+ }
+};
+
+class MmeEgressIpcConsumerThread
+{
+public:
+ void operator()()
+ {
+ while(1)
+ {
+ MsgBuffer* msgBuf = NULL;
+ while(mmeIpcEgressFifo_g.pop(msgBuf) == true)
+ {
+ if (msgBuf != NULL)
+ {
+ cmn::ipc::IpcMsgHeader ipcHdr;
+ msgBuf->rewind();
+ msgBuf->readUint32(ipcHdr.destAddr.u32);
+ msgBuf->readUint32(ipcHdr.srcAddr.u32);
+ mmeIpcIf_g->sender()->sendMsgTo(msgBuf->getDataPointer(), msgBuf->getLength(), ipcHdr.destAddr);
+
+ delete msgBuf;
+ }
+ }
+ }
+ }
+};
+
+#endif /* SRC_MME_APP_MMETHREADS_H_ */
diff --git a/src/mme-app/msgHandlers/gtpMsgHandler.cpp b/src/mme-app/msgHandlers/gtpMsgHandler.cpp
new file mode 100644
index 0000000..3888803
--- /dev/null
+++ b/src/mme-app/msgHandlers/gtpMsgHandler.cpp
@@ -0,0 +1,167 @@
+/*
+ * Copyright (c) 2019, Infosys Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <msgHandlers/gtpMsgHandler.h>
+
+#include <contextManager/subsDataGroupManager.h>
+#include <event.h>
+#include <ipcTypes.h>
+#include <log.h>
+
+using namespace SM;
+using namespace mme;
+
+GtpMsgHandler::~GtpMsgHandler() {
+
+}
+
+GtpMsgHandler::GtpMsgHandler() {
+
+
+}
+
+GtpMsgHandler* GtpMsgHandler::Instance()
+{
+ static GtpMsgHandler msgHandler;
+ return &msgHandler;
+}
+
+void GtpMsgHandler::handleGtpMessage_v(cmn::utils::MsgBuffer* msgBuf)
+{
+ if (msgBuf == NULL)
+ return;
+
+ const gtp_incoming_msg_data_t* msgData_p = (gtp_incoming_msg_data_t*)(msgBuf->getDataPointer());
+
+ switch (msgData_p->msg_type)
+ {
+ case msg_type_t::create_session_response:
+ log_msg(LOG_DEBUG,"Create Session Response msg rxed\n");
+ handleCreateSessionResponseMsg_v(msgBuf, msgData_p->ue_idx);
+ break;
+
+ case msg_type_t::modify_bearer_response:
+ handleModifyBearerResponseMsg_v(msgBuf, msgData_p->ue_idx);
+ break;
+
+ case msg_type_t::delete_session_response:
+ handleDeleteSessionResponseMsg_v(msgBuf, msgData_p->ue_idx);
+ break;
+
+ case msg_type_t::release_bearer_response:
+ handleReleaseBearerResponseMsg_v(msgBuf, msgData_p->ue_idx);
+ break;
+
+ case msg_type_t::downlink_data_notification:
+ handleDdnMsg_v(msgBuf, msgData_p->ue_idx);
+ break;
+
+ default:
+ log_msg(LOG_INFO, "Unhandled Gtp Message %d \n", msgData_p->msg_type);
+ delete msgBuf;
+ }
+
+}
+
+void GtpMsgHandler::handleCreateSessionResponseMsg_v(const cmn::utils::MsgBuffer* msgData_p, uint32_t ueIdx)
+{
+ log_msg(LOG_INFO, "handleCreateSessionResponseMsg_v");
+
+ SM::ControlBlock* controlBlk_p = SubsDataGroupManager::Instance()->findControlBlock(ueIdx);
+ if(controlBlk_p == NULL)
+ {
+ log_msg(LOG_ERROR, "handleCreateSessionResponseMsg_v: "
+ "Failed to find UE context using idx %d\n",
+ ueIdx);
+ return;
+ }
+
+ // Fire CS resp from SGW event, insert cb to procedure queue
+ SM::Event evt(Event_e::CS_RESP_FROM_SGW, (void *)msgData_p);
+ controlBlk_p->addEventToProcQ(evt);
+}
+
+void GtpMsgHandler::handleModifyBearerResponseMsg_v(const cmn::utils::MsgBuffer* msgData_p, uint32_t ueIdx)
+{
+ log_msg(LOG_INFO, "handleModifyBearerResponseMsg_v");
+
+ SM::ControlBlock* controlBlk_p = SubsDataGroupManager::Instance()->findControlBlock(ueIdx);
+ if(controlBlk_p == NULL)
+ {
+ log_msg(LOG_ERROR, "handleModifyBearerResponseMsg_v: "
+ "Failed to find UE context using idx %d\n",
+ ueIdx);
+ return;
+ }
+
+ // Fire MB rep from SGW event, insert cb to procedure queue
+ SM::Event evt(Event_e::MB_RESP_FROM_SGW, (void *)msgData_p);
+ controlBlk_p->addEventToProcQ(evt);
+}
+
+void GtpMsgHandler::handleDeleteSessionResponseMsg_v(const cmn::utils::MsgBuffer* msgData_p, uint32_t ueIdx)
+{
+ log_msg(LOG_INFO, "handleDeleteSessionResponseMsg_v");
+
+ SM::ControlBlock* controlBlk_p = SubsDataGroupManager::Instance()->findControlBlock(ueIdx);
+ if(controlBlk_p == NULL)
+ {
+ log_msg(LOG_ERROR, "handleDeleteSessionResponse_v: "
+ "Failed to find UE context using idx %d\n",
+ ueIdx);
+ return;
+ }
+
+ SM::Event evt(Event_e::DEL_SESSION_RESP_FROM_SGW, (void *)msgData_p);
+ controlBlk_p->addEventToProcQ(evt);
+}
+
+void GtpMsgHandler::handleReleaseBearerResponseMsg_v(const cmn::utils::MsgBuffer* msgData_p, uint32_t ueIdx)
+{
+ log_msg(LOG_INFO, "handleReleaseBearerResponseMsg_v");
+
+ SM::ControlBlock* controlBlk_p = SubsDataGroupManager::Instance()->findControlBlock(ueIdx);
+ if(controlBlk_p == NULL)
+ {
+ log_msg(LOG_ERROR, "handleReleaseBearerResponse_v: "
+ "Failed to find UE context using idx %d\n",
+ ueIdx);
+ return;
+ }
+
+ // Fire rel bearer response from sgw event, insert cb to procedure queue
+ SM::Event evt(Event_e::REL_AB_RESP_FROM_SGW, (void *)msgData_p);
+ controlBlk_p->addEventToProcQ(evt);
+}
+
+void GtpMsgHandler::handleDdnMsg_v(const cmn::utils::MsgBuffer* msgData_p, uint32_t ueIdx)
+{
+ log_msg(LOG_INFO,"Inside handle DDN\n");
+
+ SM::ControlBlock* controlBlk_p = SubsDataGroupManager::Instance()->findControlBlock(ueIdx);
+ if(controlBlk_p == NULL)
+ {
+ log_msg(LOG_ERROR, "handleReleaseBearerResponse_v: "
+ "Failed to find UE context using idx %d\n",
+ ueIdx);
+ return;
+ }
+
+ // Fire ddn from sgw event, insert cb to procedure queue
+ SM::Event evt(Event_e::DDN_FROM_SGW, (void *)msgData_p);
+ controlBlk_p->addEventToProcQ(evt);
+}
+
diff --git a/src/mme-app/msgHandlers/s1MsgHandler.cpp b/src/mme-app/msgHandlers/s1MsgHandler.cpp
new file mode 100644
index 0000000..b13a528
--- /dev/null
+++ b/src/mme-app/msgHandlers/s1MsgHandler.cpp
@@ -0,0 +1,349 @@
+/*
+ * Copyright (c) 2019, Infosys Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <msgHandlers/s1MsgHandler.h>
+
+#include <event.h>
+#include <ipcTypes.h>
+#include <log.h>
+#include <utils/mmeCommonUtils.h>
+#include <contextManager/subsDataGroupManager.h>
+
+using namespace SM;
+using namespace mme;
+
+S1MsgHandler::S1MsgHandler()
+{
+
+}
+
+S1MsgHandler::~S1MsgHandler()
+{
+
+}
+
+S1MsgHandler* S1MsgHandler::Instance()
+{
+ static S1MsgHandler msgHandler;
+ return &msgHandler;
+}
+
+void S1MsgHandler::handleS1Message_v(const cmn::utils::MsgBuffer* buf)
+{
+ log_msg(LOG_INFO, "S1 - handleS1Message_v\n");
+
+ if (buf == NULL)
+ return;
+
+ cmn::utils::MsgBuffer* msgBuf = const_cast<cmn::utils::MsgBuffer *>(buf);
+
+ const s1_incoming_msg_data_t* msgData_p = (s1_incoming_msg_data_t*)(msgBuf->getDataPointer());
+
+ switch (msgData_p->msg_type)
+ {
+ case msg_type_t::attach_request:
+ handleInitUeAttachRequestMsg_v(msgBuf);
+ break;
+
+ case msg_type_t::id_response:
+ handleIdentityResponseMsg_v(msgBuf, msgData_p->ue_idx);
+ break;
+
+ case msg_type_t::auth_response:
+ handleAuthResponseMsg_v(msgBuf, msgData_p->ue_idx);
+ break;
+
+ case msg_type_t::sec_mode_complete:
+ handleSecurityModeResponse_v(msgBuf, msgData_p->ue_idx);
+ break;
+
+ case msg_type_t::esm_info_response:
+ handleEsmInfoResponse_v(msgBuf, msgData_p->ue_idx);
+ break;
+
+ case msg_type_t::init_ctxt_response:
+ handleInitCtxtResponse_v(msgBuf, msgData_p->ue_idx);
+ break;
+
+ case msg_type_t::attach_complete:
+ handleAttachComplete_v(msgBuf, msgData_p->ue_idx);
+ break;
+
+ case msg_type_t::detach_request:
+ handleDetachRequest_v(msgBuf, msgData_p->ue_idx);
+ break;
+
+ case msg_type_t::s1_release_request:
+ handleS1ReleaseRequestMsg_v(msgBuf, msgData_p->ue_idx);
+ break;
+
+ case msg_type_t::s1_release_complete:
+ handleS1ReleaseComplete_v(msgBuf, msgData_p->ue_idx);
+ break;
+
+ case msg_type_t::detach_accept_from_ue:
+ handleDetachAcceptFromUE_v(msgBuf, msgData_p->ue_idx);
+ break;
+
+ case msg_type_t::service_request:
+ handleServiceRequest_v(msgBuf, msgData_p->ue_idx);
+ break;
+
+ case msg_type_t::tau_request:
+ handleTauRequestMsg_v(msgBuf, msgData_p->ue_idx);
+ break;
+
+ default:
+ log_msg(LOG_INFO, "Unhandled S1 Message %d \n", msgData_p->msg_type);
+ delete msgBuf;
+ }
+}
+
+void S1MsgHandler::handleInitUeAttachRequestMsg_v(const cmn::utils::MsgBuffer* msgData_p)
+{
+ log_msg(LOG_INFO, "S1 - handleInitUeAttachRequestMsg_v\n");
+
+ SM::ControlBlock* controlBlk_p = MmeCommonUtils::findControlBlock(
+ const_cast<cmn::utils::MsgBuffer*>(msgData_p));
+ if (controlBlk_p == NULL)
+ {
+ log_msg(LOG_ERROR, "Failed to allocate ControlBlock \n");
+
+ return;
+ }
+
+ // Fire attach-start event, insert cb to procedure queue
+ SM::Event evt(Event_e::ATTACH_REQ_FROM_UE, (void *)msgData_p);
+ controlBlk_p->addEventToProcQ(evt);
+}
+
+void S1MsgHandler::handleIdentityResponseMsg_v(const cmn::utils::MsgBuffer* msgData_p, uint32_t ueIdx)
+{
+ log_msg(LOG_INFO, "S1 - handleIdentityResponseMsg_v\n");
+
+ SM::ControlBlock* controlBlk_p = SubsDataGroupManager::Instance()->findControlBlock(ueIdx);
+ if(controlBlk_p == NULL)
+ {
+ log_msg(LOG_ERROR, "handleIdentityResponseMsg_v: "
+ "Failed to find UE context using idx %d\n",
+ ueIdx);
+ return;
+ }
+
+ // Fire attach-start event, insert cb to procedure queue
+ SM::Event evt(Event_e::IDENTITY_RESPONSE_FROM_UE, (void *)msgData_p);
+ controlBlk_p->addEventToProcQ(evt);
+}
+
+void S1MsgHandler::handleAuthResponseMsg_v(const cmn::utils::MsgBuffer* msgData_p, uint32_t ueIdx)
+{
+ log_msg(LOG_INFO, "S1 - handleAuthResponseMsg_v\n");
+
+ SM::ControlBlock* controlBlk_p = SubsDataGroupManager::Instance()->findControlBlock(ueIdx);
+ if(controlBlk_p == NULL)
+ {
+ log_msg(LOG_ERROR, "handleAuthResponseMsg_v: "
+ "Failed to find UE context using idx %d\n",
+ ueIdx);
+ return;
+ }
+
+ // Fire attach-start event, insert cb to procedure queue
+ SM::Event evt(Event_e::AUTH_RESP_FROM_UE, (void *)msgData_p);
+ controlBlk_p->addEventToProcQ(evt);
+}
+
+void S1MsgHandler::handleSecurityModeResponse_v(const cmn::utils::MsgBuffer* msgData_p, uint32_t ueIdx)
+{
+ log_msg(LOG_INFO, "S1 - handleSecurityModeResponse_v\n");
+
+ SM::ControlBlock* controlBlk_p = SubsDataGroupManager::Instance()->findControlBlock(ueIdx);
+ if(controlBlk_p == NULL)
+ {
+ log_msg(LOG_ERROR, "handleSecurityModeResponse_v: "
+ "Failed to find UE context using idx %d\n",
+ ueIdx);
+ return;
+ }
+
+ // Fire attach-start event, insert cb to procedure queue
+ SM::Event evt(Event_e::SEC_MODE_RESP_FROM_UE, (void *)msgData_p);
+ controlBlk_p->addEventToProcQ(evt);
+}
+
+void S1MsgHandler::handleEsmInfoResponse_v(const cmn::utils::MsgBuffer* msgData_p, uint32_t ueIdx)
+{
+ log_msg(LOG_INFO, "S1 - handleEsmInfoResponse_v\n");
+
+ SM::ControlBlock* controlBlk_p = SubsDataGroupManager::Instance()->findControlBlock(ueIdx);
+ if(controlBlk_p == NULL)
+ {
+ log_msg(LOG_ERROR, "handleEsmInfoResponse_v: "
+ "Failed to find UE context using idx %d\n",
+ ueIdx);
+ return;
+ }
+
+ // Fire attach-start event, insert cb to procedure queue
+ SM::Event evt(Event_e::ESM_INFO_RESP_FROM_UE, (void *)msgData_p);
+ controlBlk_p->addEventToProcQ(evt);
+}
+
+void S1MsgHandler::handleInitCtxtResponse_v(const cmn::utils::MsgBuffer* msgData_p, uint32_t ueIdx)
+{
+ log_msg(LOG_INFO, "S1 - handleInitCtxtResponse_v\n");
+
+ SM::ControlBlock* controlBlk_p = SubsDataGroupManager::Instance()->findControlBlock(ueIdx);
+ if(controlBlk_p == NULL)
+ {
+ log_msg(LOG_ERROR, "handleInitCtxtResponse_v: "
+ "Failed to find UE context using idx %d\n",
+ ueIdx);
+ return;
+ }
+
+ // Fire attach-start event, insert cb to procedure queue
+ SM::Event evt(Event_e::INIT_CTXT_RESP_FROM_UE, (void *)msgData_p);
+ controlBlk_p->addEventToProcQ(evt);
+}
+
+void S1MsgHandler::handleAttachComplete_v(const cmn::utils::MsgBuffer* msgData_p, uint32_t ueIdx)
+{
+ log_msg(LOG_INFO, "S1 - handleAttachComplete_v\n");
+
+ SM::ControlBlock* controlBlk_p = SubsDataGroupManager::Instance()->findControlBlock(ueIdx);
+ if(controlBlk_p == NULL)
+ {
+ log_msg(LOG_ERROR, "handleAttachComplete_v: "
+ "Failed to find UE context using idx %d\n",
+ ueIdx);
+ return;
+ }
+
+ // Fire attach-start event, insert cb to procedure queue
+ SM::Event evt(Event_e::ATT_CMP_FROM_UE, (void *)msgData_p);
+ controlBlk_p->addEventToProcQ(evt);
+}
+
+void S1MsgHandler::handleDetachRequest_v(const cmn::utils::MsgBuffer* msgData_p, uint32_t ueIdx)
+{
+ log_msg(LOG_INFO, "S1 - handleDetachRequest_v\n");
+
+ SM::ControlBlock* controlBlk_p = MmeCommonUtils::findControlBlock(
+ const_cast<cmn::utils::MsgBuffer*>(msgData_p));
+ if(controlBlk_p == NULL)
+ {
+ log_msg(LOG_ERROR, "handleDetachRequest_v: "
+ "Failed to find UE context using idx %d\n", ueIdx);
+ return;
+ }
+
+ // Fire detach request event, insert cb to procedure queue
+ SM::Event evt(Event_e::DETACH_REQ_FROM_UE, (void *)msgData_p);
+ controlBlk_p->addEventToProcQ(evt);
+}
+
+void S1MsgHandler::handleS1ReleaseRequestMsg_v(const cmn::utils::MsgBuffer* msgData_p, uint32_t ueIdx)
+{
+ log_msg(LOG_INFO, "S1 - handleS1ReleaseRequestMsg_v\n");
+
+ SM::ControlBlock* controlBlk_p = SubsDataGroupManager::Instance()->findControlBlock(ueIdx);
+ if(controlBlk_p == NULL)
+ {
+ log_msg(LOG_ERROR, ":handleS1ReleaseRequestMsg_v: "
+ "Failed to find UE context using idx %d\n",
+ ueIdx);
+ return;
+ }
+
+ // Fire s1 release event, insert cb to procedure queue
+ SM::Event evt(Event_e::S1_REL_REQ_FROM_UE, (void *)msgData_p);
+ controlBlk_p->addEventToProcQ(evt);
+}
+
+void S1MsgHandler::handleS1ReleaseComplete_v(const cmn::utils::MsgBuffer* msgData_p, uint32_t ueIdx)
+{
+ log_msg(LOG_INFO, "S1 - handleS1ReleaseComplete_v\n");
+
+ SM::ControlBlock* controlBlk_p = SubsDataGroupManager::Instance()->findControlBlock(ueIdx);
+ if(controlBlk_p == NULL)
+ {
+ log_msg(LOG_ERROR, ":handleS1ReleaseComplete_v: "
+ "Failed to find UE context using idx %d\n",
+ ueIdx);
+ return;
+ }
+
+ // Fire s1 release complete event, insert cb to procedure queue
+ SM::Event evt(Event_e::UE_CTXT_REL_COMP_FROM_ENB, (void *)msgData_p);
+ controlBlk_p->addEventToProcQ(evt);
+}
+
+void S1MsgHandler::handleDetachAcceptFromUE_v(const cmn::utils::MsgBuffer* msgData_p, uint32_t ueIdx)
+{
+ log_msg(LOG_INFO, "S1 - handleDetachAcceptFromUE_v\n");
+
+ SM::ControlBlock* controlBlk_p = SubsDataGroupManager::Instance()->findControlBlock(ueIdx);
+ if(controlBlk_p == NULL)
+ {
+ log_msg(LOG_ERROR, "handleDetachAcceptFromUE_v: "
+ "Failed to find UE Context using idx %d\n",
+ ueIdx);
+ return;
+ }
+
+ //Fire NI_Detach Event, insert CB to procedure queue
+ SM::Event evt(Event_e::DETACH_ACCEPT_FROM_UE, (void *)msgData_p);
+ controlBlk_p->addEventToProcQ(evt);
+}
+
+void S1MsgHandler::handleServiceRequest_v(const cmn::utils::MsgBuffer* msgData_p, uint32_t ueIdx)
+{
+ log_msg(LOG_INFO, "S1 - handleServiceRequest_v\n");
+
+ SM::ControlBlock* controlBlk_p = MmeCommonUtils::findControlBlock(
+ const_cast<cmn::utils::MsgBuffer*>(msgData_p));
+ if(controlBlk_p == NULL)
+ {
+ log_msg(LOG_ERROR, "handleServiceRequest_v: "
+ "Failed to find UE Context using idx %d\n",
+ ueIdx);
+ return;
+ }
+
+ //Fire NI_Detach Event, insert CB to procedure queue
+ SM::Event evt(Event_e::SERVICE_REQUEST_FROM_UE, (void *)msgData_p);
+ controlBlk_p->addEventToProcQ(evt);
+}
+
+void S1MsgHandler::handleTauRequestMsg_v(const cmn::utils::MsgBuffer* msgData_p, uint32_t ueIdx)
+{
+ log_msg(LOG_INFO, "S1 - handleTauRequestMsg_v\n");
+
+ SM::ControlBlock* controlBlk_p = MmeCommonUtils::findControlBlock(
+ const_cast<cmn::utils::MsgBuffer*>(msgData_p));
+ if(controlBlk_p == NULL)
+ {
+ log_msg(LOG_ERROR, "handleTauRequestMsg_v: "
+ "Failed to find UE Context using idx %d\n",
+ ueIdx);
+ return;
+ }
+
+ // Fire tau-start event, insert cb to procedure queue
+ SM::Event evt(Event_e::TAU_REQUEST_FROM_UE, (void *)msgData_p);
+ controlBlk_p->addEventToProcQ(evt);
+}
diff --git a/src/mme-app/msgHandlers/s6MsgHandler.cpp b/src/mme-app/msgHandlers/s6MsgHandler.cpp
new file mode 100644
index 0000000..6880229
--- /dev/null
+++ b/src/mme-app/msgHandlers/s6MsgHandler.cpp
@@ -0,0 +1,153 @@
+/*
+ * Copyright (c) 2019, Infosys Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <msgHandlers/s6MsgHandler.h>
+
+#include <contextManager/subsDataGroupManager.h>
+#include <event.h>
+#include <ipcTypes.h>
+#include <log.h>
+
+using namespace SM;
+using namespace mme;
+
+
+S6MsgHandler::~S6MsgHandler() {
+
+}
+S6MsgHandler::S6MsgHandler() {
+
+}
+
+S6MsgHandler* S6MsgHandler::Instance()
+{
+ static S6MsgHandler msgHandler;
+ return &msgHandler;
+}
+
+void S6MsgHandler::handleS6Message_v(cmn::utils::MsgBuffer* msgBuf)
+{
+ if (msgBuf == NULL)
+ return;
+
+ const s6_incoming_msg_data_t* msgData_p = (s6_incoming_msg_data_t*)(msgBuf->getDataPointer());
+ switch (msgData_p->msg_type)
+ {
+ case msg_type_t::auth_info_answer:
+ handleAuthInfoAnswer_v(msgBuf, msgData_p->ue_idx);
+ break;
+
+ case msg_type_t::update_loc_answer:
+ handleUpdateLocationAnswer_v(msgBuf, msgData_p->ue_idx);
+ break;
+
+ case msg_type_t::purge_answser:
+ handlePurgeAnswer_v(msgBuf, msgData_p->ue_idx);
+ break;
+
+ case msg_type_t::cancel_location_request:
+ handleCancelLocationRequest_v(msgBuf);
+ break;
+
+ default:
+ log_msg(LOG_INFO, "Unhandled S6 Message %d \n", msgData_p->msg_type);
+ }
+
+}
+
+void S6MsgHandler::handleAuthInfoAnswer_v(cmn::utils::MsgBuffer* msgData_p, uint32_t ueIdx)
+{
+ log_msg(LOG_INFO, "Inside handleAuthInfoAnswer_v \n");
+
+ SM::ControlBlock* controlBlk_p = SubsDataGroupManager::Instance()->findControlBlock(ueIdx);
+ if(controlBlk_p == NULL)
+ {
+ log_msg(LOG_ERROR, "handleAuthInfoAnswer_v: "
+ "Failed to find UE context using idx %d\n",
+ ueIdx);
+ return;
+ }
+
+ // Fire Auth Info Answer event, insert cb to procedure queue
+ SM::Event evt(Event_e::AIA_FROM_HSS, (void *)msgData_p);
+ controlBlk_p->addEventToProcQ(evt);
+}
+
+void S6MsgHandler::handleUpdateLocationAnswer_v(cmn::utils::MsgBuffer* msgData_p, uint32_t ueIdx)
+{
+ log_msg(LOG_INFO, "Inside handleUpdateLocationAnswer_v \n");
+
+ SM::ControlBlock* controlBlk_p = SubsDataGroupManager::Instance()->findControlBlock(ueIdx);
+ if(controlBlk_p == NULL)
+ {
+ log_msg(LOG_ERROR, "handleUpdateLocationAnswer_v: "
+ "Failed to find UE context using idx %d\n",
+ ueIdx);
+ return;
+ }
+ // Fire Update Loc Answer event, insert cb to procedure queue
+ SM::Event evt(Event_e::ULA_FROM_HSS, (void *)msgData_p);
+ controlBlk_p->addEventToProcQ(evt);
+}
+
+void S6MsgHandler::handlePurgeAnswer_v(cmn::utils::MsgBuffer* msgData_p, uint32_t ueIdx)
+{
+ log_msg(LOG_INFO, "Inside handlePurgeAnswer_v \n");
+
+ SM::ControlBlock* controlBlk_p = SubsDataGroupManager::Instance()->findControlBlock(ueIdx);
+ if(controlBlk_p == NULL)
+ {
+ log_msg(LOG_ERROR, "handlePurgeAnswer_v: "
+ "Failed to find UE context using idx %d\n",
+ ueIdx);
+ return;
+ }
+ // Fire attach-start event, insert cb to procedure queue
+ //SM::Event evt(Event_e::DETACH_PUR_RESP_FROM_HSS);
+ //controlBlk_p->addEventToProcQ(evt);
+ //
+}
+
+void S6MsgHandler::handleCancelLocationRequest_v(cmn::utils::MsgBuffer* msgData_p)
+{
+ log_msg(LOG_INFO, "Inside handleCancelLocationRequest \n");
+
+ const char *buf = static_cast<const char*>(msgData_p->getDataPointer());
+ const s6_incoming_msg_data_t* msgInfo_p = (s6_incoming_msg_data_t*)(buf);
+
+ DigitRegister15 IMSI;
+ IMSI.setImsiDigits(const_cast<uint8_t*> (msgInfo_p->msg_data.clr_Q_msg_m.imsi));
+
+ int ue_idx = SubsDataGroupManager::Instance()->findCBWithimsi(IMSI);
+ log_msg(LOG_INFO, "UE_IDX found from map : %d \n", ue_idx);
+
+ if (ue_idx < 1)
+ {
+ log_msg(LOG_ERROR, "Failed to find ue index using IMSI : %d\n", ue_idx);
+ return;
+ }
+
+ SM::ControlBlock* controlBlk_p = SubsDataGroupManager::Instance()->findControlBlock(ue_idx);
+ if(controlBlk_p == NULL)
+ {
+ log_msg(LOG_ERROR, "handleCancelLocationRequest_v: "
+ "Failed to find UE Context using IMSI in CLR\n");
+ return;
+ }
+ //Fire CLR event, insert CB to Procedure Queue
+ SM::Event evt(Event_e::CLR_FROM_HSS, (void *)msgData_p);
+ controlBlk_p->addEventToProcQ(evt);
+}
+
diff --git a/src/mme-app/procedureStats.cpp b/src/mme-app/procedureStats.cpp
new file mode 100644
index 0000000..d3e538c
--- /dev/null
+++ b/src/mme-app/procedureStats.cpp
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2019, Infosys Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "procedureStats.h"
+
+using namespace mme;
+
+int ProcedureStats::num_of_air_sent = 0;
+int ProcedureStats::num_of_ulr_sent = 0;
+int ProcedureStats::num_of_processed_aia = 0;
+int ProcedureStats::num_of_processed_ula = 0;
+int ProcedureStats::num_of_auth_req_to_ue_sent = 0;
+int ProcedureStats::num_of_processed_auth_response = 0;
+int ProcedureStats::num_of_sec_mode_cmd_to_ue_sent = 0;
+int ProcedureStats::num_of_processed_sec_mode_resp = 0;
+int ProcedureStats::num_of_esm_info_req_to_ue_sent = 0;
+int ProcedureStats::num_of_handled_esm_info_resp = 0;
+int ProcedureStats::num_of_cs_req_to_sgw_sent = 0;
+int ProcedureStats::num_of_processed_cs_resp = 0;
+int ProcedureStats::num_of_init_ctxt_req_to_ue_sent = 0;
+int ProcedureStats::num_of_processed_init_ctxt_resp = 0;
+int ProcedureStats::num_of_mb_req_to_sgw_sent = 0;
+int ProcedureStats::num_of_processed_attach_cmp_from_ue = 0;
+int ProcedureStats::num_of_processed_mb_resp = 0;
+int ProcedureStats::num_of_attach_done = 0;
+int ProcedureStats::num_of_del_session_req_sent = 0;
+int ProcedureStats::num_of_purge_req_sent = 0;
+int ProcedureStats::num_of_processed_del_session_resp = 0;
+int ProcedureStats::num_of_processed_pur_resp = 0;
+int ProcedureStats::num_of_detach_accept_to_ue_sent = 0;
+int ProcedureStats::num_of_processed_detach_accept = 0;
+int ProcedureStats::num_of_ue_ctxt_release = 0;
+int ProcedureStats::num_of_processed_ctxt_rel_resp = 0;
+int ProcedureStats::num_of_subscribers_attached = 0;
+int ProcedureStats::num_of_rel_access_bearer_req_sent = 0;
+int ProcedureStats::num_of_rel_access_bearer_resp_received = 0;
+int ProcedureStats::num_of_s1_rel_req_received = 0;
+int ProcedureStats::num_of_s1_rel_cmd_sent = 0;
+int ProcedureStats::num_of_s1_rel_comp_received = 0;
+int ProcedureStats::num_of_clr_received = 0;
+int ProcedureStats::num_of_cla_sent = 0;
+int ProcedureStats::num_of_detach_req_to_ue_sent = 0;
+int ProcedureStats::num_of_detach_accept_from_ue = 0;
+int ProcedureStats::total_num_of_subscribers = 0;
+int ProcedureStats::num_of_subscribers_detached = 0;
+int ProcedureStats::num_of_ddn_received = 0;
+int ProcedureStats::num_of_service_request_received = 0;
+int ProcedureStats::num_of_ddn_ack_sent = 0;
+int ProcedureStats::num_of_tau_response_to_ue_sent = 0;
diff --git a/src/mme-app/run.sh b/src/mme-app/run.sh
new file mode 100644
index 0000000..575a70e
--- /dev/null
+++ b/src/mme-app/run.sh
@@ -0,0 +1,28 @@
+#! /bin/bash
+#
+# Copyright (c) 2003-2018, Great Software Laboratory Pvt. Ltd.
+# Copyright (c) 2017 Intel Corporation
+# Copyright (c) 2019, Infosys Ltd.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+export LD_LIBRARY_PATH=./lib:/usr/local/lib
+echo "Start MME application"
+./bin/mme-app &
+sleep 1
+./bin/s1ap-app &
+sleep 1
+./bin/s6a-app > /dev/null &
+sleep 1
+./bin/s11-app > /dev/null &
diff --git a/src/mme-app/sec/secUtils.cpp b/src/mme-app/sec/secUtils.cpp
new file mode 100644
index 0000000..b6a971b
--- /dev/null
+++ b/src/mme-app/sec/secUtils.cpp
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2003-2018, Great Software Laboratory Pvt. Ltd.
+ * Copyright (c) 2017 Intel Corporation
+ * Copyright (c) 2019, Infosys Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <string.h>
+#include <stdint.h>
+
+#include <openssl/x509.h>
+#include <openssl/hmac.h>
+
+#include "sec.h"
+#include "secUtils.h"
+
+/**
+ * @brief Create integrity key
+ * @param[in] kasme key
+ * @param[out] int_key generated integrity key
+ * @return void
+ */
+void SecUtils::create_integrity_key(unsigned char *kasme, unsigned char *int_key)
+{
+ /*TODO : Handle appropriate security values in salt. Remove
+ * hardcoding*/
+ uint8_t salt[HASH_SALT_LEN] = {
+ 0x15,
+ 0x02, /*sec algo code*/
+ 0,
+ 1,
+ 1,
+ 0,
+ 1
+ };
+
+ unsigned char out_key[HMAC_SIZE] = {0};
+ unsigned int out_len = 0;
+ calculate_hmac_sha256(salt, HASH_SALT_LEN, kasme, AIA_KASME_SIZE, out_key, &out_len);
+
+ memcpy(int_key, &out_key[AIA_KASME_SIZE - NAS_INT_KEY_SIZE],
+ NAS_INT_KEY_SIZE);
+}
+
+/**
+ * @brief Create eNodeB key to exchange in init ctx message
+ * @param [in]kasme key
+ * @param [out]kenb_key output the generated key
+ * @return void
+ */
+void SecUtils::create_kenb_key(unsigned char *kasme, unsigned char *kenb_key,
+ unsigned int seq_no)
+{
+ uint8_t salt[HASH_SALT_LEN] = {
+ 0x11, /*TODO : Sec algo. handle properly instead of harcoding here*/
+ (seq_no >> 24) & 0xFF, /*Byte 1 of seq no*/
+ (seq_no >> 16) & 0xFF, /*Byte 2 of seq no*/
+ (seq_no >> 8 ) & 0xFF, /*Byte 3 of seq no*/
+ (seq_no ) & 0xFF, /*Byte 4 of seq no*/
+ 0x00,
+ 0x04
+ };
+
+ uint8_t out_key[HMAC_SIZE];
+ unsigned int out_len = 0;
+ calculate_hmac_sha256(salt, HASH_SALT_LEN, kasme, AIA_KASME_SIZE, out_key, &out_len);
+ memcpy(kenb_key, out_key, KENB_SIZE);
+
+}
+
+
+/**
+* @brief Create MAC(message authentication code)
+* @param [in]input data and key
+* @param [out]output MAC, out_len size of MAC
+* @return void
+*/
+
+
+void SecUtils::calculate_hmac_sha256(const unsigned char *input_data,
+ int input_data_len, const unsigned char *key,
+ int key_length, void *output, unsigned int *out_len)
+{
+
+ unsigned int mac_length = 0;
+ unsigned char mac_buffer[EVP_MAX_MD_SIZE] = {0};
+ HMAC(EVP_sha256(), key, key_length, input_data, input_data_len, mac_buffer, &mac_length);
+ memcpy(output, mac_buffer, mac_length);
+ *out_len = mac_length;
+
+}
diff --git a/src/mme-app/stop.sh b/src/mme-app/stop.sh
new file mode 100644
index 0000000..977e139
--- /dev/null
+++ b/src/mme-app/stop.sh
@@ -0,0 +1,21 @@
+#! /bin/bash
+#
+# Copyright (c) 2003-2018, Great Software Laboratory Pvt. Ltd.
+# Copyright (c) 2017 Intel Corporation
+# Copyright (c) 2019, Infosys Ltd.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+echo "Killing MME application"
+killall -9 mme-app s1ap-app s11-app s6a-app
diff --git a/src/mme-app/structs.cpp b/src/mme-app/structs.cpp
new file mode 100644
index 0000000..63f25c5
--- /dev/null
+++ b/src/mme-app/structs.cpp
@@ -0,0 +1,477 @@
+/*
+ * Copyright (c) 2019, Infosys Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <string>
+#include <sstream>
+#include <cstring>
+#include <iomanip>
+#include "structs.h"
+#include "log.h"
+
+using namespace std;
+
+uint8_t ASCII_TO_BCD(uint8_t left, uint8_t right)
+{
+ uint8_t bcd_value;
+
+ if(left >= '0' && left <= '9') // 0-9 range
+ {
+ bcd_value = ( left - 0x30) << 4 ; // 48 for '0' ASCII offset
+ }
+ else
+ {
+ bcd_value = 0x0f << 4; // filler 1111
+ }
+
+ if(right >= '0' && right <= '9') // 0-9 range
+ {
+ bcd_value |= ( right - 0x30); // 48 for '0' ASCII offset
+ }
+ else
+ {
+ bcd_value |= 0x0f; // filler 1111
+ }
+
+ return bcd_value;
+}
+
+/*******************************************************
+ *TAI
+********************************************************/
+Tai::Tai()
+{
+ memset( &tai_m, 0, sizeof( tai_m ));
+}
+
+Tai::Tai( const TAI& tai_i )
+{
+ memset( &tai_m, 0, sizeof( tai_m ));
+ memcpy( &tai_m, &tai_i, sizeof( tai_i ));
+}
+
+Tai::~Tai()
+{
+}
+
+void Tai::operator = ( const Tai& tai_i )
+{
+ memcpy( &tai_m, &(tai_i.tai_m), sizeof( tai_i.tai_m ));
+}
+
+/*******************************************************
+ *CGI
+********************************************************/
+Cgi::Cgi()
+{
+ memset( &cgi_m, 0, sizeof( cgi_m ));
+}
+
+Cgi::Cgi( const CGI& cgi_i )
+{
+ memset( &cgi_m, 0, sizeof( cgi_m ));
+ memcpy( &cgi_m, &cgi_i, sizeof(cgi_i));
+}
+
+Cgi::~Cgi()
+{
+}
+
+void Cgi::operator = ( const Cgi& cgi_i )
+{
+ memcpy( &cgi_m, &(cgi_i.cgi_m), sizeof(cgi_i.cgi_m));
+}
+
+/*******************************************************
+ *STMSI
+********************************************************/
+Stmsi::Stmsi()
+{
+ memset( &stmsi_m, 0, sizeof( stmsi_m ));
+}
+
+Stmsi::Stmsi( const STMSI& stmsi_i )
+{
+ memset( &stmsi_m, 0, sizeof( stmsi_m ));
+ memcpy( &stmsi_m, &stmsi_i, sizeof( stmsi_i ));
+}
+
+Stmsi::~Stmsi()
+{
+}
+
+void Stmsi::operator = ( const Stmsi& stmsi_i )
+{
+ memcpy( &stmsi_m, &(stmsi_i.stmsi_m), sizeof( stmsi_i.stmsi_m ));
+}
+
+/*******************************************************
+ *ARP
+********************************************************/
+Arp::Arp()
+{
+ memset( &arp_m, 0, sizeof( arp_m ));
+}
+
+Arp::Arp( const ARP& arp_i )
+{
+ memset( &arp_m, 0, sizeof( arp_m ));
+ memcpy( &arp_m, &arp_i, sizeof( arp_i ));
+}
+
+Arp::~Arp()
+{
+}
+
+void Arp::operator = ( const Arp& arp_i )
+{
+ memcpy( &arp_m, &(arp_i.arp_m), sizeof( arp_i.arp_m ));
+}
+
+
+/*******************************************************
+ *Ms_net_capab
+********************************************************/
+Ms_net_capab::Ms_net_capab()
+{
+ memset( &ms_net_capab_m, 0, sizeof( ms_net_capab_m ));
+}
+
+Ms_net_capab::Ms_net_capab( const MS_net_capab& net_cap_i )
+{
+ memset( &ms_net_capab_m, 0, sizeof( ms_net_capab_m ));
+ memcpy( &ms_net_capab_m, &net_cap_i, sizeof( net_cap_i ));
+}
+
+Ms_net_capab::~Ms_net_capab()
+{
+}
+
+void Ms_net_capab::operator = ( const Ms_net_capab& net_cap_i )
+{
+ memcpy( &ms_net_capab_m, &(net_cap_i.ms_net_capab_m), sizeof( net_cap_i.ms_net_capab_m ));
+}
+
+/*******************************************************
+*Ue_net_capab
+********************************************************/
+Ue_net_capab::Ue_net_capab()
+{
+ memset( &ue_net_capab_m, 0, sizeof( ue_net_capab_m ));
+}
+
+Ue_net_capab::Ue_net_capab( const UE_net_capab& net_cap_i )
+{
+ memset( &ue_net_capab_m, 0, sizeof( ue_net_capab_m ));
+ memcpy( &ue_net_capab_m, &net_cap_i, sizeof( net_cap_i ));
+}
+
+Ue_net_capab::~Ue_net_capab()
+{
+}
+
+void Ue_net_capab::operator = ( const Ue_net_capab& net_cap_i )
+{
+ memcpy( &ue_net_capab_m, &(net_cap_i.ue_net_capab_m), sizeof( net_cap_i.ue_net_capab_m ));
+}
+
+/*******************************************************
+*Secinfo
+********************************************************/
+Secinfo::Secinfo()
+{
+ memset( &secinfo_m, 0, sizeof( secinfo_m ));
+}
+
+Secinfo::Secinfo( const secinfo& sec_i )
+{
+ memset( &secinfo_m, 0, sizeof( secinfo_m ));
+ memcpy( &secinfo_m, &sec_i, sizeof( sec_i ));
+}
+
+Secinfo::~Secinfo()
+{
+}
+
+void Secinfo::operator = ( const Secinfo& sec_i )
+{
+ memcpy( &secinfo_m, &(sec_i.secinfo_m), sizeof( sec_i.secinfo_m ));
+}
+
+/*******************************************************
+*Ambr
+********************************************************/
+Ambr::Ambr()
+{
+ memset( &ambr_m, 0, sizeof( ambr_m ));
+}
+
+Ambr::Ambr( const AMBR& ambr_i )
+{
+ memset( &ambr_m, 0, sizeof( ambr_m ));
+ memcpy( &ambr_m, &ambr_i, sizeof( ambr_i ));
+}
+
+Ambr::~Ambr()
+{
+}
+
+void Ambr::operator = ( const Ambr& ambr_i )
+{
+ memcpy( &ambr_m, &(ambr_i.ambr_m), sizeof( ambr_i.ambr_m ));
+}
+
+/*******************************************************
+*E_utran_sec_vector
+********************************************************/
+E_utran_sec_vector::E_utran_sec_vector():AiaSecInfo_mp( NULL )
+{
+ AiaSecInfo_mp = (struct E_UTRAN_sec_vector*)calloc(sizeof(struct E_UTRAN_sec_vector), 1);
+}
+
+E_utran_sec_vector::E_utran_sec_vector( const E_UTRAN_sec_vector& secinfo_i )
+{
+ AiaSecInfo_mp = (struct E_UTRAN_sec_vector*)calloc(sizeof(struct E_UTRAN_sec_vector), 1);
+ memcpy( AiaSecInfo_mp, &secinfo_i, sizeof( E_UTRAN_sec_vector ));
+}
+
+E_utran_sec_vector::~E_utran_sec_vector()
+{
+ free(AiaSecInfo_mp);
+}
+
+void E_utran_sec_vector::operator = ( const E_utran_sec_vector& secinfo_i )
+{
+ if( NULL != secinfo_i.AiaSecInfo_mp )
+ {
+ memcpy( AiaSecInfo_mp, secinfo_i.AiaSecInfo_mp, sizeof( E_UTRAN_sec_vector ));
+ }
+}
+
+std::ostream& operator << ( std::ostream& os, const E_utran_sec_vector& data_i )
+{
+ os << "RAND ";
+ for ( uint32_t i = 0; i < data_i.AiaSecInfo_mp->rand.len; i++)
+ {
+ os << setfill('0') << setw(2) << std::hex <<
+ static_cast<uint32_t>(data_i.AiaSecInfo_mp->rand.val[i]);
+ }
+ os << std::endl;
+
+ os << "RES ";
+ for ( uint32_t i = 0; i < data_i.AiaSecInfo_mp->xres.len; i++)
+ {
+ os << setfill('0') << setw(2) << std::hex <<
+ static_cast<uint32_t>(data_i.AiaSecInfo_mp->xres.val[i]);
+ }
+ os << std::endl;
+
+ os << "AUTN ";
+ for ( uint32_t i = 0; i < data_i.AiaSecInfo_mp->autn.len; i++)
+ {
+ os << setfill('0') << setw(2) << std::hex <<
+ static_cast<uint32_t>(data_i.AiaSecInfo_mp->autn.val[i]);
+ }
+ os << std::endl;
+
+ os << "KASME ";
+ for ( uint32_t i = 0; i < data_i.AiaSecInfo_mp->kasme.len; i++)
+ {
+ os << setfill('0') << setw(2) << std::hex <<
+ static_cast<uint32_t>(data_i.AiaSecInfo_mp->kasme.val[i]);
+ }
+ os << std::endl;
+
+ return os;
+}
+
+/*******************************************************
+*Fteid
+********************************************************/
+Fteid::Fteid()
+{
+ memset( &fteid_m, 0, sizeof( fteid_m ));
+}
+
+Fteid::Fteid( const fteid& fteid_i )
+{
+ memset( &fteid_m, 0, sizeof( fteid_m ));
+ memcpy( &fteid_m, &fteid_i, sizeof( fteid_i ));
+}
+
+Fteid::~Fteid()
+{
+}
+
+void Fteid::operator = ( const Fteid& fteid_i )
+{
+ memcpy( &fteid_m, &(fteid_i.fteid_m), sizeof( fteid_i.fteid_m ));
+}
+
+/*******************************************************
+*Paa
+********************************************************/
+Paa::Paa()
+{
+ memset( &paa_m, 0, sizeof( paa_m ));
+}
+
+Paa::Paa( const PAA& paa_i )
+{
+ memset( &paa_m, 0, sizeof( paa_m ));
+ memcpy( &paa_m, &paa_i, sizeof( paa_i ));
+}
+
+Paa::~Paa()
+{
+}
+
+void Paa::operator = ( const Paa& paa_i )
+{
+ memcpy( &paa_m, &(paa_i.paa_m), sizeof( paa_i.paa_m ));
+}
+
+/*******************************************************
+*Apn_name
+********************************************************/
+Apn_name::Apn_name()
+{
+ memset( &apnname_m, 0, sizeof( apnname_m ));
+}
+
+Apn_name::Apn_name( const apn_name& apn_name_i )
+{
+ memset( &apnname_m, 0, sizeof( apnname_m ));
+ memcpy( &apnname_m, &apn_name_i, sizeof( apn_name_i ));
+}
+
+Apn_name::~Apn_name()
+{
+}
+
+void Apn_name::operator = ( const Apn_name& apn_name_i )
+{
+ memcpy( &apnname_m, &(apn_name_i.apnname_m), sizeof( apn_name_i.apnname_m ));
+}
+
+/*******************************************************
+*DigitRegister15
+********************************************************/
+DigitRegister15::DigitRegister15()
+{
+ memset(&digitsArray,0,15);
+}
+
+void DigitRegister15::convertToBcdArray( uint8_t * arrayOut ) const
+{
+ for( int i=0; i < 7; i++ )
+ {
+ arrayOut[i] = ASCII_TO_BCD(digitsArray[2*i+1],digitsArray[2*i]);
+ }
+ arrayOut[7] = ASCII_TO_BCD(0x0f,digitsArray[14]);
+}
+
+void DigitRegister15::convertFromBcdArray( const uint8_t* bcdArrayIn )
+{
+ // For the imsi value upper nibble of first octect should only be considered
+ if(( bcdArrayIn[0] & 0x0f ) == 0x0f )
+ {
+ digitsArray[0] = (uint8_t)(((bcdArrayIn[0] >> 4) & 0x0f ) + 0x30);
+ for( int i = 1; i < 8; i++ )
+ {
+ digitsArray[2*i] = (uint8_t)(((bcdArrayIn[i] >> 4) & 0x0f) + 0x30);
+ digitsArray[2*i-1] = (uint8_t)((bcdArrayIn[i] & 0x0f) + 0x30);
+ }
+ }
+ else
+ {
+ for( int i = 0; i < 7; i++ )
+ {
+ digitsArray[2*i+1] = (uint8_t)(((bcdArrayIn[i] >> 4) & 0x0f) + 0x30);
+ digitsArray[2*i] = (uint8_t)((bcdArrayIn[i] & 0x0f) + 0x30);
+ }
+ digitsArray[7] = (uint8_t)(((bcdArrayIn[7] >> 4) & 0x0f) + 0x30);
+ }
+ return;
+}
+
+
+void DigitRegister15::setImsiDigits( uint8_t* digitsArrayIn )
+{
+ memcpy( digitsArray, digitsArrayIn, 15);
+}
+
+void DigitRegister15::getImsiDigits( uint8_t* digitsArrayIn ) const
+{
+ memcpy( digitsArrayIn, digitsArray, 15);
+}
+
+bool DigitRegister15::isValid() const
+{
+ bool rc = false;
+ for (uint32_t i = 0; i < 15; i++)
+ {
+ if (digitsArray[i] != 0)
+ {
+ rc = true;
+ break;
+ }
+ }
+ return rc;
+}
+
+void DigitRegister15::operator = ( const DigitRegister15& data_i )
+{
+ memcpy( digitsArray, data_i.digitsArray, sizeof( data_i.digitsArray ));
+}
+
+bool DigitRegister15::operator == ( const DigitRegister15& data_i )const
+{
+ int data_cmp = memcmp(digitsArray, data_i.digitsArray, sizeof( data_i.digitsArray));
+ bool rc = false;
+ if(data_cmp == 0)
+ rc = true;
+ return rc;
+}
+
+bool DigitRegister15::operator < ( const DigitRegister15& data_i )const
+{
+ bool rc = true;
+ if(*this == data_i)
+ rc = false;
+ else
+ {
+ for(int i=0; i<15; i++)
+ {
+ if(digitsArray[i] > data_i.digitsArray[i])
+ {
+ rc = false;
+ break;
+ }
+ }
+ }
+ return rc;
+}
+
+std::ostream& operator << ( std::ostream& os, const DigitRegister15& data_i )
+{
+ for( auto x : data_i.digitsArray )
+ {
+ if( x != 0x0f )
+ os << x - 0x30;
+ }
+ os << "\0";
+ return os;
+}
+
diff --git a/src/mme-app/utils/defaultMmeProcedureCtxt.cpp b/src/mme-app/utils/defaultMmeProcedureCtxt.cpp
new file mode 100644
index 0000000..590ce10
--- /dev/null
+++ b/src/mme-app/utils/defaultMmeProcedureCtxt.cpp
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2019, Infosys Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <utils/defaultMmeProcedureCtxt.h>
+#include <mmeStates/defaultMmeState.h>
+
+using namespace mme;
+
+DefaultMmeProcedureCtxt::DefaultMmeProcedureCtxt()
+{
+ setNextState(DefaultMmeState::Instance());
+ setCtxtType(defaultMmeProcedure_c);
+}
+
+DefaultMmeProcedureCtxt::~DefaultMmeProcedureCtxt()
+{
+
+}
+
+DefaultMmeProcedureCtxt* DefaultMmeProcedureCtxt::Instance()
+{
+ static DefaultMmeProcedureCtxt defaultMmeProcedureCtxt;
+ return &defaultMmeProcedureCtxt;
+}
+
+
+
+
diff --git a/src/mme-app/utils/mmeCommonUtils.cpp b/src/mme-app/utils/mmeCommonUtils.cpp
new file mode 100644
index 0000000..9fc6c68
--- /dev/null
+++ b/src/mme-app/utils/mmeCommonUtils.cpp
@@ -0,0 +1,217 @@
+/*
+ * Copyright (c) 2019, Infosys Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <utils/mmeCommonUtils.h>
+#include <controlBlock.h>
+#include <contextManager/dataBlocks.h>
+#include <contextManager/subsDataGroupManager.h>
+#include <log.h>
+#include <mme_app.h>
+#include <msgBuffer.h>
+#include <s1ap_structs.h>
+#include <utils/defaultMmeProcedureCtxt.h>
+
+using namespace mme;
+
+extern mme_config g_mme_cfg;
+
+bool MmeCommonUtils::isLocalGuti(const guti &guti_r)
+{
+ bool rc = false;
+
+ if (guti_r.mme_grp_id == g_mme_cfg.mme_group_id &&
+ guti_r.mme_code == g_mme_cfg.mme_code)
+ {
+ rc = true;
+ }
+
+ return rc;
+}
+
+uint32_t MmeCommonUtils::allocateMtmsi()
+{
+ uint32_t tmsi = 0;
+
+ while(1)
+ {
+ tmsi = rand() % 10000;
+
+ if (SubsDataGroupManager::Instance()->findCBWithmTmsi(tmsi) == -1)
+ break;
+ }
+
+ log_msg(LOG_INFO, "MTMSI allocated is %u\n", tmsi);
+
+ return tmsi;
+}
+
+AttachType MmeCommonUtils::getAttachType(UEContext* ueContext_p,
+ const struct ue_attach_info& ue_info)
+{
+ log_msg(LOG_INFO, "deriveAttachType\n");
+
+ AttachType attachType = maxAttachType_c;
+
+ if(UE_ID_IMSI(ue_info.flags))
+ {
+ log_msg(LOG_INFO, "IMSI attach received.\n");
+
+ attachType = imsiAttach_c;
+ }
+ else if (UE_ID_GUTI(ue_info.flags))
+ {
+ log_msg(LOG_INFO, "GUTI attach received. mTMSI is %u \n",
+ ue_info.mi_guti.m_TMSI);
+
+ attachType = unknownGutiAttach_c;
+
+ if (isLocalGuti(ue_info.mi_guti))
+ {
+ // The guti is allocated by this MME, check if a context exists.
+ // If the context does not exist, treat as unknown GUTI attach?
+ log_msg(LOG_INFO, "GUTI is local..");
+
+ if (ueContext_p != NULL)
+ {
+ if (ueContext_p->getMtmsi() == ue_info.mi_guti.m_TMSI)
+ {
+ log_msg(LOG_INFO, "and known\n");
+
+ attachType = knownGutiAttach_c;
+ }
+ else
+ {
+ log_msg(LOG_INFO, "mTMSI mismatches with UE context. "
+ "Treat as unknown GUTI attach\n");
+ }
+ }
+ else
+ {
+ log_msg(LOG_INFO, "UE context is null. Unknown GUTI attach triggered\n");
+ }
+
+ }
+ else
+ {
+ log_msg(LOG_INFO, "GUTI is not local..");
+ }
+ }
+ return attachType;
+}
+
+SM::ControlBlock* MmeCommonUtils::findControlBlock(cmn::utils::MsgBuffer* buf)
+{
+ SM::ControlBlock *cb = NULL;
+
+ const s1_incoming_msg_data_t* msgData_p = (s1_incoming_msg_data_t*)(buf->getDataPointer());
+ if(msgData_p == NULL)
+ {
+ log_msg(LOG_INFO, "MsgData is NULL .\n");
+ return cb;
+ }
+
+ switch (msgData_p->msg_type)
+ {
+ case attach_request:
+ {
+ const struct ue_attach_info &ue_info = (msgData_p->msg_data.ue_attach_info_m);
+ if(UE_ID_IMSI(ue_info.flags))
+ {
+ log_msg(LOG_INFO, "IMSI attach received.\n");
+
+ cb = SubsDataGroupManager::Instance()->allocateCB();
+ cb->setTempDataBlock(DefaultMmeProcedureCtxt::Instance());
+ }
+ else if (UE_ID_GUTI(ue_info.flags))
+ {
+ log_msg(LOG_INFO, "GUTI attach received.\n");
+
+ if (isLocalGuti(ue_info.mi_guti))
+ {
+ log_msg(LOG_INFO, "GUTI is local.\n");
+
+ int cbIndex = SubsDataGroupManager::Instance()->findCBWithmTmsi(ue_info.mi_guti.m_TMSI);
+ if (cbIndex > 0)
+ {
+ cb = SubsDataGroupManager::Instance()->findControlBlock(cbIndex);
+ }
+ else
+ {
+ log_msg(LOG_ERROR, "Failed to find control block with mTmsi.\n");
+
+ // allocate new cb and proceed?
+ cb = SubsDataGroupManager::Instance()->allocateCB();
+ cb->setTempDataBlock(DefaultMmeProcedureCtxt::Instance());
+ }
+ }
+ else
+ {
+ cb = SubsDataGroupManager::Instance()->allocateCB();
+ cb->setTempDataBlock(DefaultMmeProcedureCtxt::Instance());
+ }
+ }
+ break;
+ }
+ case service_request:
+ {
+ const struct service_req_Q_msg &service_req = (msgData_p->msg_data.service_req_Q_msg_m);
+ int cbIndex = SubsDataGroupManager::Instance()->findCBWithmTmsi(service_req.s_tmsi.m_TMSI);
+ if (cbIndex > 0)
+ {
+ cb = SubsDataGroupManager::Instance()->findControlBlock(cbIndex);
+ }
+ else
+ {
+ log_msg(LOG_INFO, "Failed to find control block with mTmsi.\n");
+ }
+
+ break;
+ }
+ case detach_request:
+ {
+ const struct detach_req_Q_msg &detach_Req = (msgData_p->msg_data.detachReq_Q_msg_m);
+ int cbIndex = SubsDataGroupManager::Instance()->findCBWithmTmsi(detach_Req.ue_m_tmsi);
+ if (cbIndex > 0)
+ {
+ cb = SubsDataGroupManager::Instance()->findControlBlock(cbIndex);
+ }
+ else
+ {
+ log_msg(LOG_INFO, "Failed to find control block with mTmsi. %d\n", detach_Req.ue_m_tmsi);
+ }
+ break;
+ }
+ case tau_request:
+ {
+ cb = SubsDataGroupManager::Instance()->findControlBlock(msgData_p->ue_idx);
+
+ if (cb == NULL)
+ log_msg(LOG_INFO, "Failed to retrieve CB using idx %d.\n", msgData_p->ue_idx);
+
+ break;
+ }
+ default:
+ {
+ log_msg(LOG_INFO, "Unhandled message is NULL .\n");
+ }
+ }
+
+ return cb;
+}
+
+
+
+
diff --git a/src/mme-app/utils/mmeContextManagerUtils.cpp b/src/mme-app/utils/mmeContextManagerUtils.cpp
new file mode 100644
index 0000000..933600a
--- /dev/null
+++ b/src/mme-app/utils/mmeContextManagerUtils.cpp
@@ -0,0 +1,248 @@
+/*
+ * Copyright (c) 2019, Infosys Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <controlBlock.h>
+#include <contextManager/subsDataGroupManager.h>
+#include <log.h>
+#include <utils/mmeContextManagerUtils.h>
+
+using namespace mme;
+
+bool MmeContextManagerUtils::deleteProcedureCtxt(MmeProcedureCtxt* procedure_p)
+{
+ log_msg(LOG_DEBUG, "deleteProcedureCtxt: Entry");
+
+ if (procedure_p == NULL)
+ {
+ log_msg(LOG_INFO, "Procedure Context is NULL");
+
+ return false;
+ }
+
+ SubsDataGroupManager* subsDgMgr_p = SubsDataGroupManager::Instance();
+
+ log_msg(LOG_INFO, "Procedure Type is %d", procedure_p->getCtxtType());
+
+ bool rc = true;
+ switch (procedure_p->getCtxtType())
+ {
+ case attach_c:
+ case s1Release_c:
+ {
+ subsDgMgr_p->deleteMmeProcedureCtxt(procedure_p);
+ break;
+ }
+ case detach_c:
+ {
+ MmeDetachProcedureCtxt* detachProc_p =
+ static_cast<MmeDetachProcedureCtxt *>(procedure_p);
+
+ subsDgMgr_p->deleteMmeDetachProcedureCtxt(detachProc_p);
+
+ break;
+ }
+ case serviceRequest_c:
+ {
+ MmeSvcReqProcedureCtxt* svcReqProc_p =
+ static_cast<MmeSvcReqProcedureCtxt*>(procedure_p);
+
+ subsDgMgr_p->deleteMmeSvcReqProcedureCtxt(svcReqProc_p);
+
+ break;
+ }
+ case tau_c:
+ {
+ MmeTauProcedureCtxt* tauProc_p =
+ static_cast<MmeTauProcedureCtxt*>(procedure_p);
+
+ subsDgMgr_p->deleteMmeTauProcedureCtxt(tauProc_p);
+
+ break;
+ }
+ default:
+ {
+ log_msg(LOG_INFO, "Unsupported procedure type %d\n", procedure_p->getCtxtType());
+ rc = false;
+ }
+ }
+ return rc;
+}
+
+bool MmeContextManagerUtils::deallocateProcedureCtxt(SM::ControlBlock& cb_r, ProcedureType procType)
+{
+ bool rc = false;
+
+ MmeProcedureCtxt* procedure_p =
+ static_cast<MmeProcedureCtxt*>(cb_r.getTempDataBlock());
+
+ MmeProcedureCtxt* prevProcedure_p = NULL;
+ MmeProcedureCtxt* nextProcedure_p = NULL;
+
+ while (procedure_p != NULL)
+ {
+ nextProcedure_p =
+ static_cast<MmeProcedureCtxt*>(procedure_p->getNextTempDataBlock());
+
+ ProcedureType procedureType = procedure_p->getCtxtType();
+ if (procType == procedureType)
+ {
+ log_msg(LOG_INFO, "Procedure type %d\n", procedureType);
+
+ rc = deleteProcedureCtxt(procedure_p);
+
+ if (rc == true)
+ {
+ if (prevProcedure_p != NULL)
+ {
+ if (nextProcedure_p != NULL)
+ {
+ prevProcedure_p->setNextTempDataBlock(nextProcedure_p);
+ }
+ }
+ else
+ {
+ cb_r.setTempDataBlock(nextProcedure_p);
+ }
+ }
+ // break out of while loop
+ break;
+ }
+ prevProcedure_p = procedure_p;
+ procedure_p = nextProcedure_p;
+ }
+
+ return rc;
+}
+
+bool MmeContextManagerUtils::deallocateAllProcedureCtxts(SM::ControlBlock& cb_r)
+{
+ bool rc = false;
+
+ MmeProcedureCtxt* procedure_p =
+ static_cast<MmeProcedureCtxt*>(cb_r.getTempDataBlock());
+
+ MmeProcedureCtxt* nextProcedure_p = NULL;
+
+ while (procedure_p != NULL)
+ {
+ nextProcedure_p =
+ static_cast<MmeProcedureCtxt*>(procedure_p->getNextTempDataBlock());
+
+ if (procedure_p->getCtxtType() != defaultMmeProcedure_c)
+ {
+ rc = deleteProcedureCtxt(procedure_p);
+ }
+
+ procedure_p = nextProcedure_p;
+ }
+ return rc;
+}
+
+MmeProcedureCtxt* MmeContextManagerUtils::findProcedureCtxt(SM::ControlBlock& cb_r, ProcedureType procType)
+{
+ MmeProcedureCtxt* mmeProcCtxt_p = NULL;
+
+ MmeProcedureCtxt* currentProcedure_p =
+ static_cast<MmeProcedureCtxt*>(cb_r.getTempDataBlock());
+
+ MmeProcedureCtxt* nextProcedure_p = NULL;
+
+ while (currentProcedure_p != NULL)
+ {
+ nextProcedure_p = static_cast<MmeProcedureCtxt*>(
+ currentProcedure_p->getNextTempDataBlock());
+
+ if (currentProcedure_p->getCtxtType() == procType)
+ {
+ mmeProcCtxt_p = currentProcedure_p;
+ break;
+ }
+ currentProcedure_p = nextProcedure_p;
+ }
+
+ return mmeProcCtxt_p;
+}
+
+void MmeContextManagerUtils::deleteSessionContext(SM::ControlBlock& cb_r)
+{
+ UEContext* ueCtxt_p = static_cast<UEContext *>(cb_r.getPermDataBlock());
+ if (ueCtxt_p == NULL)
+ {
+ log_msg(LOG_DEBUG, "Failed to retrieve UEContext from control block %u", cb_r.getCBIndex());
+ return;
+ }
+
+ SessionContext* sessCtxt_p = ueCtxt_p->getSessionContext();
+ if (sessCtxt_p == NULL)
+ {
+ log_msg(LOG_DEBUG, "Failed to retrieve SessionContext from UEContext %u", cb_r.getCBIndex());
+ return;
+ }
+
+ BearerContext* bearerCtxt_p = sessCtxt_p->getBearerContext();
+ if(bearerCtxt_p != NULL)
+ {
+ log_msg(LOG_INFO, "Deallocating bearer context for UE block %u", cb_r.getCBIndex());
+
+ SubsDataGroupManager::Instance()->deleteBearerContext(bearerCtxt_p);
+ sessCtxt_p->setBearerContext(NULL);
+ }
+
+ log_msg(LOG_INFO, "Deallocating session context for UE block %u", cb_r.getCBIndex());
+
+ SubsDataGroupManager::Instance()->deleteSessionContext(sessCtxt_p);
+ ueCtxt_p->setSessionContext(NULL);
+}
+
+void MmeContextManagerUtils::deleteUEContext(uint32_t cbIndex)
+{
+ SM::ControlBlock* cb_p = SubsDataGroupManager::Instance()->findControlBlock(cbIndex);
+ if (cb_p == NULL)
+ {
+ log_msg(LOG_DEBUG, "Failed to find control block for index %u", cbIndex);
+ return;
+ }
+
+ deallocateAllProcedureCtxts(*cb_p);
+
+ deleteSessionContext(*cb_p);
+
+ UEContext* ueCtxt_p = static_cast<UEContext *>(cb_p->getPermDataBlock());
+ if (ueCtxt_p == NULL)
+ {
+ log_msg(LOG_DEBUG, "Failed to retrieve UEContext from control block %u", cbIndex);
+ }
+ else
+ {
+ MmContext* mmContext_p = ueCtxt_p->getMmContext();
+ if (mmContext_p != NULL)
+ {
+ SubsDataGroupManager::Instance()->deleteMmContext(mmContext_p);
+ ueCtxt_p->setMmContext(NULL);
+ }
+
+ // Remove IMSI -> CBIndex key mapping
+ const DigitRegister15& ue_imsi = ueCtxt_p->getImsi();
+ SubsDataGroupManager::Instance()->deleteimsikey(ue_imsi);
+
+ // Remove mTMSI -> CBIndex mapping
+ SubsDataGroupManager::Instance()->deletemTmsikey(ueCtxt_p->getMtmsi());
+
+ SubsDataGroupManager::Instance()->deleteUEContext(ueCtxt_p);
+ }
+
+ SubsDataGroupManager::Instance()->deAllocateCB(cb_p->getCBIndex());
+}