anjana_sreekumar@infosys.com | 991c206 | 2020-01-08 11:42:57 +0530 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (c) 2003-2018, Great Software Laboratory Pvt. Ltd. |
| 3 | * Copyright (c) 2017 Intel Corporation |
| 4 | * Copyright (c) 2019, Infosys Ltd. |
| 5 | * |
| 6 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | * you may not use this file except in compliance with the License. |
| 8 | * You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, software |
| 13 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | * See the License for the specific language governing permissions and |
| 16 | * limitations under the License. |
| 17 | */ |
| 18 | |
| 19 | #include <stdio.h> |
| 20 | #include <stdlib.h> |
| 21 | #include <arpa/inet.h> |
| 22 | #include <unistd.h> |
| 23 | #include <string.h> |
| 24 | #include <pthread.h> |
| 25 | |
| 26 | #include "log.h" |
| 27 | #include "err_codes.h" |
| 28 | #include "message_queues.h" |
| 29 | #include "ipc_api.h" |
| 30 | #include "gtpv2c.h" |
| 31 | #include "gtpv2c_ie.h" |
| 32 | #include "msgType.h" |
| 33 | #include "../../gtpV2Codec/gtpV2StackWrappers.h" |
| 34 | /************************************************************************ |
| 35 | Current file : Stage 1 handler. |
| 36 | ATTACH stages : |
| 37 | Stage 1 : detach request -->delete session |
| 38 | **************************************************************************/ |
| 39 | |
| 40 | /****Globals and externs ***/ |
| 41 | |
| 42 | /*S11 CP communication parameters*/ |
| 43 | extern int g_s11_fd; |
| 44 | extern struct sockaddr_in g_s11_cp_addr; |
| 45 | extern socklen_t g_s11_serv_size; |
| 46 | extern volatile uint32_t g_s11_sequence; |
| 47 | static char buf[S11_DTCHREQ_STAGE1_BUF_SIZE]; |
| 48 | |
| 49 | struct thread_pool *g_tpool; |
| 50 | |
| 51 | extern struct GtpV2Stack* gtpStack_gp; |
| 52 | extern volatile uint32_t g_s11_sequence; |
| 53 | |
| 54 | struct MsgBuffer* dsReqMsgBuf_p = NULL; |
| 55 | /****Global and externs end***/ |
| 56 | |
| 57 | /** |
| 58 | * Stage specific message processing. |
| 59 | */ |
| 60 | static int |
| 61 | delete_session_processing(struct DS_Q_msg *ds_msg) |
| 62 | { |
| 63 | GtpV2MessageHeader gtpHeader; |
| 64 | gtpHeader.msgType = GTP_DELETE_SESSION_REQ; |
| 65 | gtpHeader.sequenceNumber = g_s11_sequence; |
| 66 | gtpHeader.teidPresent = true; |
| 67 | gtpHeader.teid = ds_msg->s11_sgw_c_fteid.header.teid_gre; |
| 68 | |
| 69 | DeleteSessionRequestMsgData msgData; |
| 70 | memset(&msgData, 0, sizeof(DeleteSessionRequestMsgData)); |
| 71 | |
| 72 | msgData.indicationFlagsIePresent = true; |
| 73 | msgData.indicationFlags.iOI = true; |
| 74 | |
| 75 | msgData.linkedEpsBearerIdIePresent = true; |
| 76 | msgData.linkedEpsBearerId.epsBearerId = ds_msg->bearer_id; |
| 77 | |
| 78 | GtpV2Stack_buildGtpV2Message(gtpStack_gp, dsReqMsgBuf_p, >pHeader, &msgData); |
| 79 | g_s11_sequence++; |
| 80 | |
| 81 | sendto(g_s11_fd, |
| 82 | MsgBuffer_getDataPointer(dsReqMsgBuf_p), |
| 83 | MsgBuffer_getBufLen(dsReqMsgBuf_p), 0, |
| 84 | (struct sockaddr*)&g_s11_cp_addr, g_s11_serv_size); |
| 85 | log_msg(LOG_INFO, "Send delete session request\n"); |
| 86 | |
| 87 | MsgBuffer_reset(dsReqMsgBuf_p); |
| 88 | |
| 89 | return SUCCESS; |
| 90 | } |
| 91 | |
| 92 | |
| 93 | /** |
| 94 | * Thread function for stage. |
| 95 | */ |
| 96 | void* |
| 97 | delete_session_handler(void *data) |
| 98 | { |
| 99 | log_msg(LOG_INFO, "Delete session handler initialized\n"); |
| 100 | |
| 101 | delete_session_processing((struct DS_Q_msg *)data); |
| 102 | return NULL; |
| 103 | } |
| 104 | |