blob: 73a459ad325ce810e7c0d79ada47ff6bd269f497 [file] [log] [blame]
anjana_sreekumar@infosys.com991c2062020-01-08 11:42:57 +05301/*
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*/
39extern int g_s11_fd;
40extern struct sockaddr_in g_s11_cp_addr;
41extern socklen_t g_s11_serv_size;
42extern volatile uint32_t g_s11_sequence;
43static char buf[S11_DDN_ACK_BUF_SIZE];
44
45struct thread_pool *g_tpool;
46
47extern struct GtpV2Stack* gtpStack_gp;
48extern volatile uint32_t g_s11_sequence;
49
50struct MsgBuffer* ddnAckMsgBuf_p = NULL;
51/****Global and externs end***/
52
53/**
54* Stage specific message processing.
55*/
56static int
57ddn_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, &gtpHeader, &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*/
88void*
89ddn_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