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 | |
| 36 | /****Globals and externs ***/ |
| 37 | |
| 38 | /*S11 CP communication parameters*/ |
| 39 | extern int g_s11_fd; |
| 40 | extern struct sockaddr_in g_s11_cp_addr; |
| 41 | extern socklen_t g_s11_serv_size; |
| 42 | extern volatile uint32_t g_s11_sequence; |
| 43 | static char buf[S11_DDN_ACK_BUF_SIZE]; |
| 44 | |
| 45 | struct thread_pool *g_tpool; |
| 46 | |
| 47 | extern struct GtpV2Stack* gtpStack_gp; |
| 48 | extern volatile uint32_t g_s11_sequence; |
| 49 | |
| 50 | struct MsgBuffer* ddnAckMsgBuf_p = NULL; |
| 51 | /****Global and externs end***/ |
| 52 | |
| 53 | /** |
| 54 | * Stage specific message processing. |
| 55 | */ |
| 56 | static int |
| 57 | ddn_ack_processing(struct DDN_ACK_Q_msg *ddn_ack_msg) |
| 58 | { |
| 59 | GtpV2MessageHeader gtpHeader; |
| 60 | gtpHeader.msgType = 177; |
| 61 | gtpHeader.sequenceNumber = ddn_ack_msg->seq_no; |
| 62 | gtpHeader.teidPresent = true; |
| 63 | gtpHeader.teid = ddn_ack_msg->ue_idx; |
| 64 | |
| 65 | DownlinkDataNotificationAcknowledgeMsgData msgData; |
| 66 | memset(&msgData, 0, sizeof(DownlinkDataNotificationAcknowledgeMsgData)); |
| 67 | |
| 68 | msgData.cause.causeValue = ddn_ack_msg->cause; |
| 69 | |
| 70 | |
| 71 | GtpV2Stack_buildGtpV2Message(gtpStack_gp, ddnAckMsgBuf_p, >pHeader, &msgData); |
| 72 | g_s11_sequence++; |
| 73 | |
| 74 | sendto(g_s11_fd, |
| 75 | MsgBuffer_getDataPointer(ddnAckMsgBuf_p), |
| 76 | MsgBuffer_getBufLen(ddnAckMsgBuf_p), 0, |
| 77 | (struct sockaddr*)&g_s11_cp_addr, g_s11_serv_size); |
| 78 | |
| 79 | log_msg(LOG_INFO, "DDN Ack Sent, len - %d bytes.\n", MsgBuffer_getBufLen(ddnAckMsgBuf_p)); |
| 80 | MsgBuffer_reset(ddnAckMsgBuf_p); |
| 81 | return SUCCESS; |
| 82 | } |
| 83 | |
| 84 | |
| 85 | /** |
| 86 | * Thread function for stage. |
| 87 | */ |
| 88 | void* |
| 89 | ddn_ack_handler(void *data) |
| 90 | { |
| 91 | log_msg(LOG_INFO, "DDN Ack handler initialized\n"); |
| 92 | ddn_ack_processing((struct DDN_ACK_Q_msg *)data); |
| 93 | return NULL; |
| 94 | } |
| 95 | |