blob: ac10f67c0eac1a2a1d9a74b20068ecf72c67d5b6 [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 <stdio.h>
18#include <stdlib.h>
19#include <arpa/inet.h>
20#include <unistd.h>
21#include <string.h>
22#include <pthread.h>
23
24#include "err_codes.h"
25#include "options.h"
26#include "ipc_api.h"
27#include "message_queues.h"
28#include "s11.h"
29#include "s11_config.h"
30#include "msgType.h"
31//#include "detach_stage2_info.h"
32#include "../../gtpV2Codec/gtpV2StackWrappers.h"
33/*Globals and externs*/
34extern int g_resp_fd;
35extern struct GtpV2Stack* gtpStack_gp;
36/*End : globals and externs*/
37
38
39int
40s11_DDN_handler(MsgBuffer* message, GtpV2MessageHeader* hdr)
41{
42
43
44 struct gtp_incoming_msg_data_t ddn_info;
45 ddn_info.msg_type = downlink_data_notification;
46 ddn_info.ue_idx = hdr->teid;
47 ddn_info.msg_data.ddn_Q_msg_m.seq_no = hdr->sequenceNumber;
48
49
50 DownlinkDataNotificationMsgData msgData;
51 memset(&msgData, 0, sizeof(DownlinkDataNotificationMsgData));
52
53 bool rc = GtpV2Stack_decodeMessage(gtpStack_gp, hdr, message, &msgData);
54 if(rc == false)
55 {
56
57 log_msg(LOG_ERROR, "s11_Ddn_handler: "
58 "Failed to decode ddn Msg %d\n",
59 hdr->teid);
60 return E_PARSING_FAILED;
61 }
62 /*****Message structure****/
63 log_msg(LOG_INFO, "Parse S11 Ddn message\n");
64
65 //TODO : check cause for the result verification
66
67 ddn_info.msg_data.ddn_Q_msg_m.arp.prioLevel = msgData.allocationRetentionPriority.pl;
68 ddn_info.msg_data.ddn_Q_msg_m.arp.preEmptionCapab = msgData.allocationRetentionPriority.pci;
69 ddn_info.msg_data.ddn_Q_msg_m.arp.preEmptionVulnebility = msgData.allocationRetentionPriority.pvi;
70 ddn_info.msg_data.ddn_Q_msg_m.cause = msgData.cause.causeValue;
71 ddn_info.msg_data.ddn_Q_msg_m.eps_bearer_id = msgData.epsBearerId.epsBearerId;
72
73 ddn_info.destInstAddr = htonl(mmeAppInstanceNum_c);
74 ddn_info.srcInstAddr = htonl(s11AppInstanceNum_c);
75
76 /*Send DDN msg*/
77 send_tipc_message(g_resp_fd, mmeAppInstanceNum_c, (char *)&ddn_info, GTP_READ_MSG_BUF_SIZE);
78
79 log_msg(LOG_INFO, "Send ddn to mme-app\n");
80
81
82 return SUCCESS;
83}