blob: 6880229a4308598137240116bbb348906d0ac73f [file] [log] [blame]
anjana_sreekumar@infosys.com991c2062020-01-08 11:42:57 +05301/*
2 * Copyright (c) 2019, Infosys Ltd.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#include <msgHandlers/s6MsgHandler.h>
17
18#include <contextManager/subsDataGroupManager.h>
19#include <event.h>
20#include <ipcTypes.h>
21#include <log.h>
22
23using namespace SM;
24using namespace mme;
25
26
27S6MsgHandler::~S6MsgHandler() {
28
29}
30S6MsgHandler::S6MsgHandler() {
31
32}
33
34S6MsgHandler* S6MsgHandler::Instance()
35{
36 static S6MsgHandler msgHandler;
37 return &msgHandler;
38}
39
40void S6MsgHandler::handleS6Message_v(cmn::utils::MsgBuffer* msgBuf)
41{
42 if (msgBuf == NULL)
43 return;
44
45 const s6_incoming_msg_data_t* msgData_p = (s6_incoming_msg_data_t*)(msgBuf->getDataPointer());
46 switch (msgData_p->msg_type)
47 {
48 case msg_type_t::auth_info_answer:
49 handleAuthInfoAnswer_v(msgBuf, msgData_p->ue_idx);
50 break;
51
52 case msg_type_t::update_loc_answer:
53 handleUpdateLocationAnswer_v(msgBuf, msgData_p->ue_idx);
54 break;
55
56 case msg_type_t::purge_answser:
57 handlePurgeAnswer_v(msgBuf, msgData_p->ue_idx);
58 break;
59
60 case msg_type_t::cancel_location_request:
61 handleCancelLocationRequest_v(msgBuf);
62 break;
63
64 default:
65 log_msg(LOG_INFO, "Unhandled S6 Message %d \n", msgData_p->msg_type);
66 }
67
68}
69
70void S6MsgHandler::handleAuthInfoAnswer_v(cmn::utils::MsgBuffer* msgData_p, uint32_t ueIdx)
71{
72 log_msg(LOG_INFO, "Inside handleAuthInfoAnswer_v \n");
73
74 SM::ControlBlock* controlBlk_p = SubsDataGroupManager::Instance()->findControlBlock(ueIdx);
75 if(controlBlk_p == NULL)
76 {
77 log_msg(LOG_ERROR, "handleAuthInfoAnswer_v: "
78 "Failed to find UE context using idx %d\n",
79 ueIdx);
80 return;
81 }
82
83 // Fire Auth Info Answer event, insert cb to procedure queue
84 SM::Event evt(Event_e::AIA_FROM_HSS, (void *)msgData_p);
85 controlBlk_p->addEventToProcQ(evt);
86}
87
88void S6MsgHandler::handleUpdateLocationAnswer_v(cmn::utils::MsgBuffer* msgData_p, uint32_t ueIdx)
89{
90 log_msg(LOG_INFO, "Inside handleUpdateLocationAnswer_v \n");
91
92 SM::ControlBlock* controlBlk_p = SubsDataGroupManager::Instance()->findControlBlock(ueIdx);
93 if(controlBlk_p == NULL)
94 {
95 log_msg(LOG_ERROR, "handleUpdateLocationAnswer_v: "
96 "Failed to find UE context using idx %d\n",
97 ueIdx);
98 return;
99 }
100 // Fire Update Loc Answer event, insert cb to procedure queue
101 SM::Event evt(Event_e::ULA_FROM_HSS, (void *)msgData_p);
102 controlBlk_p->addEventToProcQ(evt);
103}
104
105void S6MsgHandler::handlePurgeAnswer_v(cmn::utils::MsgBuffer* msgData_p, uint32_t ueIdx)
106{
107 log_msg(LOG_INFO, "Inside handlePurgeAnswer_v \n");
108
109 SM::ControlBlock* controlBlk_p = SubsDataGroupManager::Instance()->findControlBlock(ueIdx);
110 if(controlBlk_p == NULL)
111 {
112 log_msg(LOG_ERROR, "handlePurgeAnswer_v: "
113 "Failed to find UE context using idx %d\n",
114 ueIdx);
115 return;
116 }
117 // Fire attach-start event, insert cb to procedure queue
118 //SM::Event evt(Event_e::DETACH_PUR_RESP_FROM_HSS);
119 //controlBlk_p->addEventToProcQ(evt);
120 //
121}
122
123void S6MsgHandler::handleCancelLocationRequest_v(cmn::utils::MsgBuffer* msgData_p)
124{
125 log_msg(LOG_INFO, "Inside handleCancelLocationRequest \n");
126
127 const char *buf = static_cast<const char*>(msgData_p->getDataPointer());
128 const s6_incoming_msg_data_t* msgInfo_p = (s6_incoming_msg_data_t*)(buf);
129
130 DigitRegister15 IMSI;
131 IMSI.setImsiDigits(const_cast<uint8_t*> (msgInfo_p->msg_data.clr_Q_msg_m.imsi));
132
133 int ue_idx = SubsDataGroupManager::Instance()->findCBWithimsi(IMSI);
134 log_msg(LOG_INFO, "UE_IDX found from map : %d \n", ue_idx);
135
136 if (ue_idx < 1)
137 {
138 log_msg(LOG_ERROR, "Failed to find ue index using IMSI : %d\n", ue_idx);
139 return;
140 }
141
142 SM::ControlBlock* controlBlk_p = SubsDataGroupManager::Instance()->findControlBlock(ue_idx);
143 if(controlBlk_p == NULL)
144 {
145 log_msg(LOG_ERROR, "handleCancelLocationRequest_v: "
146 "Failed to find UE Context using IMSI in CLR\n");
147 return;
148 }
149 //Fire CLR event, insert CB to Procedure Queue
150 SM::Event evt(Event_e::CLR_FROM_HSS, (void *)msgData_p);
151 controlBlk_p->addEventToProcQ(evt);
152}
153