blob: 3888803231445f2365fc2bf8c6d9f1f8613cf24a [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
17#include <msgHandlers/gtpMsgHandler.h>
18
19#include <contextManager/subsDataGroupManager.h>
20#include <event.h>
21#include <ipcTypes.h>
22#include <log.h>
23
24using namespace SM;
25using namespace mme;
26
27GtpMsgHandler::~GtpMsgHandler() {
28
29}
30
31GtpMsgHandler::GtpMsgHandler() {
32
33
34}
35
36GtpMsgHandler* GtpMsgHandler::Instance()
37{
38 static GtpMsgHandler msgHandler;
39 return &msgHandler;
40}
41
42void GtpMsgHandler::handleGtpMessage_v(cmn::utils::MsgBuffer* msgBuf)
43{
44 if (msgBuf == NULL)
45 return;
46
47 const gtp_incoming_msg_data_t* msgData_p = (gtp_incoming_msg_data_t*)(msgBuf->getDataPointer());
48
49 switch (msgData_p->msg_type)
50 {
51 case msg_type_t::create_session_response:
52 log_msg(LOG_DEBUG,"Create Session Response msg rxed\n");
53 handleCreateSessionResponseMsg_v(msgBuf, msgData_p->ue_idx);
54 break;
55
56 case msg_type_t::modify_bearer_response:
57 handleModifyBearerResponseMsg_v(msgBuf, msgData_p->ue_idx);
58 break;
59
60 case msg_type_t::delete_session_response:
61 handleDeleteSessionResponseMsg_v(msgBuf, msgData_p->ue_idx);
62 break;
63
64 case msg_type_t::release_bearer_response:
65 handleReleaseBearerResponseMsg_v(msgBuf, msgData_p->ue_idx);
66 break;
67
68 case msg_type_t::downlink_data_notification:
69 handleDdnMsg_v(msgBuf, msgData_p->ue_idx);
70 break;
71
72 default:
73 log_msg(LOG_INFO, "Unhandled Gtp Message %d \n", msgData_p->msg_type);
74 delete msgBuf;
75 }
76
77}
78
79void GtpMsgHandler::handleCreateSessionResponseMsg_v(const cmn::utils::MsgBuffer* msgData_p, uint32_t ueIdx)
80{
81 log_msg(LOG_INFO, "handleCreateSessionResponseMsg_v");
82
83 SM::ControlBlock* controlBlk_p = SubsDataGroupManager::Instance()->findControlBlock(ueIdx);
84 if(controlBlk_p == NULL)
85 {
86 log_msg(LOG_ERROR, "handleCreateSessionResponseMsg_v: "
87 "Failed to find UE context using idx %d\n",
88 ueIdx);
89 return;
90 }
91
92 // Fire CS resp from SGW event, insert cb to procedure queue
93 SM::Event evt(Event_e::CS_RESP_FROM_SGW, (void *)msgData_p);
94 controlBlk_p->addEventToProcQ(evt);
95}
96
97void GtpMsgHandler::handleModifyBearerResponseMsg_v(const cmn::utils::MsgBuffer* msgData_p, uint32_t ueIdx)
98{
99 log_msg(LOG_INFO, "handleModifyBearerResponseMsg_v");
100
101 SM::ControlBlock* controlBlk_p = SubsDataGroupManager::Instance()->findControlBlock(ueIdx);
102 if(controlBlk_p == NULL)
103 {
104 log_msg(LOG_ERROR, "handleModifyBearerResponseMsg_v: "
105 "Failed to find UE context using idx %d\n",
106 ueIdx);
107 return;
108 }
109
110 // Fire MB rep from SGW event, insert cb to procedure queue
111 SM::Event evt(Event_e::MB_RESP_FROM_SGW, (void *)msgData_p);
112 controlBlk_p->addEventToProcQ(evt);
113}
114
115void GtpMsgHandler::handleDeleteSessionResponseMsg_v(const cmn::utils::MsgBuffer* msgData_p, uint32_t ueIdx)
116{
117 log_msg(LOG_INFO, "handleDeleteSessionResponseMsg_v");
118
119 SM::ControlBlock* controlBlk_p = SubsDataGroupManager::Instance()->findControlBlock(ueIdx);
120 if(controlBlk_p == NULL)
121 {
122 log_msg(LOG_ERROR, "handleDeleteSessionResponse_v: "
123 "Failed to find UE context using idx %d\n",
124 ueIdx);
125 return;
126 }
127
128 SM::Event evt(Event_e::DEL_SESSION_RESP_FROM_SGW, (void *)msgData_p);
129 controlBlk_p->addEventToProcQ(evt);
130}
131
132void GtpMsgHandler::handleReleaseBearerResponseMsg_v(const cmn::utils::MsgBuffer* msgData_p, uint32_t ueIdx)
133{
134 log_msg(LOG_INFO, "handleReleaseBearerResponseMsg_v");
135
136 SM::ControlBlock* controlBlk_p = SubsDataGroupManager::Instance()->findControlBlock(ueIdx);
137 if(controlBlk_p == NULL)
138 {
139 log_msg(LOG_ERROR, "handleReleaseBearerResponse_v: "
140 "Failed to find UE context using idx %d\n",
141 ueIdx);
142 return;
143 }
144
145 // Fire rel bearer response from sgw event, insert cb to procedure queue
146 SM::Event evt(Event_e::REL_AB_RESP_FROM_SGW, (void *)msgData_p);
147 controlBlk_p->addEventToProcQ(evt);
148}
149
150void GtpMsgHandler::handleDdnMsg_v(const cmn::utils::MsgBuffer* msgData_p, uint32_t ueIdx)
151{
152 log_msg(LOG_INFO,"Inside handle DDN\n");
153
154 SM::ControlBlock* controlBlk_p = SubsDataGroupManager::Instance()->findControlBlock(ueIdx);
155 if(controlBlk_p == NULL)
156 {
157 log_msg(LOG_ERROR, "handleReleaseBearerResponse_v: "
158 "Failed to find UE context using idx %d\n",
159 ueIdx);
160 return;
161 }
162
163 // Fire ddn from sgw event, insert cb to procedure queue
164 SM::Event evt(Event_e::DDN_FROM_SGW, (void *)msgData_p);
165 controlBlk_p->addEventToProcQ(evt);
166}
167