blob: d2c6bf12bd7fb9dfd32849d2ba16583d2d0e2a27 [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
25#include "ProtocolIE-Container.h"
26#include "ProtocolIE-ID.h"
27#include "ProtocolIE-Field.h"
28#include "log.h"
29#include "err_codes.h"
30#include "message_queues.h"
31#include "ipc_api.h"
32#include "s1ap.h"
33#include "s1ap_config.h"
34#include "main.h"
35#include "msgType.h"
36#include "common_proc_info.h"
37
38
39/*Stage specific message processing.
40*/
41static int
42paging_processing(struct paging_req_Q_msg *g_paging)
43{
44 log_msg(LOG_DEBUG,"Process paging.");
45 uint32_t length = 0;
46 uint8_t *buffer = NULL;
47
48 Buffer g_paging_buffer;
49 struct s1ap_common_req_Q_msg req= {0};
50
51 req.IE_type = S1AP_PAGING_REQ;
52 req.enb_fd = g_paging->enb_fd;
53 req.ue_idx = g_paging->ue_idx;
54 req.enb_s1ap_ue_id = g_paging->enb_s1ap_ue_id;
55 req.cn_domain = g_paging->cn_domain;
56 memcpy(req.imsi, g_paging->IMSI, BINARY_IMSI_LEN);
57 memcpy(&req.tai, &g_paging->tai, sizeof(struct TAI));
58
59
60
61 int ret = s1ap_mme_encode_initiating(&req, &buffer, &length);
62
63 if(ret == -1)
64 {
65 log_msg(LOG_ERROR, "Encoding paging request failed.\n");
66 return E_FAIL;
67 }
68
69
70 buffer_copy(&g_paging_buffer, buffer, length);
71 send_sctp_msg(g_paging->enb_fd, g_paging_buffer.buf, g_paging_buffer.pos,1);
72 log_msg(LOG_INFO, "\n-----Paging sent to UE.---\n");
73 return SUCCESS;
74}
75
76
77/**
78* Thread function for stage.
79*/
80void*
81paging_handler(void *data)
82{
83
84 log_msg(LOG_INFO, "paging handler ready.\n");
85
86 paging_processing((struct paging_req_Q_msg*)data);
87
88 return NULL;
89}
90
91