blob: a26db1ab192c4c70899f5183463ef2f9c3a9984d [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
18#include <stdio.h>
19#include <stdlib.h>
20#include <pthread.h>
21#include <string.h>
22#include <unistd.h>
23#include <stdint.h>
24#include "common_proc_info.h"
25#include "log.h"
26#include "err_codes.h"
27#include "message_queues.h"
28#include "ipc_api.h"
29#include "s1ap.h"
30#include "s1ap_config.h"
31#include "main.h"
32#include "msgType.h"
33
34
35/*static int
36get_uectxtrelcmd_protoie_value(struct proto_IE *value, struct s1relcmd_info *g_uectxtrelcmd)
37{
38 //uint8_t ieCnt = 0;
39
40 value->no_of_IEs = UE_CTX_RELEASE_NO_OF_IES;
41
42 value->data = (proto_IEs *) malloc(UE_CTX_RELEASE_NO_OF_IES *
43 sizeof(proto_IEs));
44
45 value->data[0].mme_ue_s1ap_id = g_uectxtrelcmd->ue_idx;
46
47 value->data[1].enb_ue_s1ap_id = g_uectxtrelcmd->enb_s1ap_ue_id;
48
49 log_msg(LOG_INFO, "mme_ue_s1ap_id %d and enb_ue_s1ap_id %d\n",
50 g_uectxtrelcmd->ue_idx,g_uectxtrelcmd->enb_s1ap_ue_id);
51 return SUCCESS;
52}*/
53
54/**
55* Stage specific message processing.
56*/
57static int
58ics_req_paging_processing(struct ics_req_paging_Q_msg *g_icsreq)
59{
60 log_msg(LOG_DEBUG,"Process Init Ctxt Req for service Request.");
61 uint32_t length = 0;
62 uint8_t *buffer = NULL;
63
64 Buffer g_ics_req_buffer;
65 struct s1ap_common_req_Q_msg req= {0};
66
67 log_msg(LOG_DEBUG,"Inside ics_req_paging processing\n");
68
69 req.IE_type = S1AP_INIT_CTXT_SETUP_REQ;
70 req.ue_idx = g_icsreq->ue_idx;
71 req.enb_fd = g_icsreq->enb_fd;
72 req.enb_s1ap_ue_id = g_icsreq->enb_s1ap_ue_id;
73 req.mme_s1ap_ue_id = g_icsreq->ue_idx;
74 req.ueag_max_dl_bitrate = g_icsreq->ueag_max_dl_bitrate;
75 req.ueag_max_ul_bitrate = g_icsreq->ueag_max_ul_bitrate;
76 req.bearer_id = g_icsreq->bearer_id;
77 memcpy(&(req.gtp_teid), &(g_icsreq->gtp_teid), sizeof(struct fteid));
78 memcpy(&(req.sec_key), &(g_icsreq->sec_key), KENB_SIZE);
79
80 log_msg(LOG_DEBUG,"Before s1ap_encoder\n");
81
82 int ret = s1ap_mme_encode_initiating(&req, &buffer, &length);
83 log_msg(LOG_DEBUG,"Invoked s1ap_encoder\n");
84 if(ret == -1)
85 {
86 log_msg(LOG_ERROR, "Encoding ics_req_paging failed.\n");
87 return E_FAIL;
88 }
89
90 buffer_copy(&g_ics_req_buffer, buffer, length);
91 send_sctp_msg(g_icsreq->enb_fd, g_ics_req_buffer.buf, g_ics_req_buffer.pos,1);
92 log_msg(LOG_INFO, "\n----ICS Req for paging sent to UE.---\n");
93 return SUCCESS;
94
95}
96
97
98/**
99* Thread function for stage.
100*/
101void*
102ics_req_paging_handler(void *data)
103{
104
105 log_msg(LOG_INFO,"ICS Req for paging handler ready.\n");
106
107 ics_req_paging_processing((struct ics_req_paging_Q_msg *)data);
108
109 return NULL;
110}
111
112