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 "err_codes.h" |
| 27 | #include "options.h" |
| 28 | #include "ipc_api.h" |
| 29 | #include "message_queues.h" |
| 30 | #include "s11.h" |
| 31 | #include "s11_config.h" |
| 32 | #include "msgType.h" |
| 33 | //#include "stage6_info.h" |
| 34 | #include "../../gtpV2Codec/gtpV2StackWrappers.h" |
| 35 | |
| 36 | /*Globals and externs*/ |
| 37 | extern int g_resp_fd; |
| 38 | extern struct GtpV2Stack* gtpStack_gp; |
| 39 | /*End : globals and externs*/ |
| 40 | |
| 41 | |
| 42 | int |
| 43 | s11_CS_resp_handler(MsgBuffer* message, GtpV2MessageHeader* hdr) |
| 44 | { |
| 45 | |
| 46 | struct gtp_incoming_msg_data_t csr_info; |
| 47 | /*****Message structure*** |
| 48 | */ |
| 49 | |
| 50 | /*Check whether has teid flag is set. Also check whether this check is needed for CSR.*/ |
| 51 | csr_info.ue_idx = hdr->teid; |
| 52 | csr_info.msg_type = create_session_response; |
| 53 | |
| 54 | CreateSessionResponseMsgData msgData; |
| 55 | memset(&msgData, 0, sizeof(CreateSessionResponseMsgData)); |
| 56 | |
| 57 | bool rc = GtpV2Stack_decodeMessage(gtpStack_gp, hdr, message, &msgData); |
| 58 | if(rc == false) |
| 59 | { |
| 60 | log_msg(LOG_ERROR, "s11_CS_resp_handler: " |
| 61 | "Failed to decode Create Session Response Msg %d\n", |
| 62 | hdr->teid); |
| 63 | return E_PARSING_FAILED; |
| 64 | } |
| 65 | |
| 66 | csr_info.msg_data.csr_Q_msg_m.s11_sgw_fteid.header.iface_type = 11; |
| 67 | csr_info.msg_data.csr_Q_msg_m.s11_sgw_fteid.header.teid_gre = msgData.senderFTeidForControlPlane.teidGreKey; |
| 68 | csr_info.msg_data.csr_Q_msg_m.s11_sgw_fteid.header.v4 = 1; |
| 69 | csr_info.msg_data.csr_Q_msg_m.s11_sgw_fteid.ip.ipv4.s_addr = msgData.senderFTeidForControlPlane.ipV4Address.ipValue; |
| 70 | |
| 71 | csr_info.msg_data.csr_Q_msg_m.s5s8_pgwc_fteid.header.iface_type = 7; |
| 72 | csr_info.msg_data.csr_Q_msg_m.s5s8_pgwc_fteid.header.teid_gre = msgData.pgwS5S8S2bFTeid.teidGreKey; |
| 73 | csr_info.msg_data.csr_Q_msg_m.s5s8_pgwc_fteid.header.v4 = 1; |
| 74 | csr_info.msg_data.csr_Q_msg_m.s5s8_pgwc_fteid.ip.ipv4.s_addr = msgData.pgwS5S8S2bFTeid.ipV4Address.ipValue; |
| 75 | |
| 76 | csr_info.msg_data.csr_Q_msg_m.s1u_sgw_fteid.header.iface_type = 1; |
| 77 | csr_info.msg_data.csr_Q_msg_m.s1u_sgw_fteid.header.teid_gre = msgData.bearerContextsCreated[0].s1USgwFTeid.teidGreKey; |
| 78 | csr_info.msg_data.csr_Q_msg_m.s1u_sgw_fteid.header.v4 = 1; |
| 79 | csr_info.msg_data.csr_Q_msg_m.s1u_sgw_fteid.ip.ipv4.s_addr = msgData.bearerContextsCreated[0].s1USgwFTeid.ipV4Address.ipValue; |
| 80 | |
| 81 | csr_info.msg_data.csr_Q_msg_m.s5s8_pgwu_fteid.header.iface_type = 5; |
| 82 | csr_info.msg_data.csr_Q_msg_m.s5s8_pgwu_fteid.header.teid_gre = msgData.bearerContextsCreated[0].s5S8UPgwFTeid.teidGreKey; |
| 83 | csr_info.msg_data.csr_Q_msg_m.s5s8_pgwu_fteid.header.v4 = 1; |
| 84 | csr_info.msg_data.csr_Q_msg_m.s5s8_pgwu_fteid.ip.ipv4.s_addr = msgData.bearerContextsCreated[0].s5S8UPgwFTeid.ipV4Address.ipValue; |
| 85 | |
| 86 | csr_info.msg_data.csr_Q_msg_m.pdn_addr.pdn_type = 1; |
| 87 | csr_info.msg_data.csr_Q_msg_m.pdn_addr.ip_type.ipv4.s_addr = msgData.pdnAddressAllocation.ipV4Address.ipValue; |
| 88 | |
| 89 | |
| 90 | csr_info.destInstAddr = htonl(mmeAppInstanceNum_c); |
| 91 | csr_info.srcInstAddr = htonl(s11AppInstanceNum_c); |
| 92 | |
| 93 | /*Send CS response msg*/ |
| 94 | send_tipc_message(g_resp_fd, mmeAppInstanceNum_c, (char *)&csr_info, GTP_READ_MSG_BUF_SIZE); |
| 95 | log_msg(LOG_INFO, "Send CS resp to mme-app stage6.\n"); |
| 96 | |
| 97 | return SUCCESS; |
| 98 | } |