blob: 3c3404bbcbfb17da979e3e99dc7f4031c7abfdd8 [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 <unistd.h>
22#include <string.h>
23#include <pthread.h>
24
25#include "err_codes.h"
26#include "options.h"
27#include "ipc_api.h"
28#include "main.h"
29#include "s1ap.h"
30#include "s1ap_config.h"
31#include "sctp_conn.h"
32#include "s1ap_structs.h"
33#include "s1ap_msg_codes.h"
34#include "msgType.h"
35
36
37extern int g_enb_fd;
38extern ipc_handle ipc_S1ap_Hndl;
39
40int
41s1_init_ctx_resp_handler(SuccessfulOutcome_t *msg)
42{
43 struct proto_IE s1_ics_ies;
44 struct s1_incoming_msg_data_t ics_resp= {0};
45
46 /*****Message structure****/
47 log_msg(LOG_INFO, "Parse int ctx s1ap response message:--\n");
48 /*parse_IEs(msg+2, &s1_ics_ies, S1AP_INITIAL_CTX_RESP_CODE);*/
49 convertInitCtxRspToProtoIe(msg, &s1_ics_ies);
50
51 ics_resp.msg_type = init_ctxt_response;
52
53 for(int i = 0; i < s1_ics_ies.no_of_IEs; i++)
54 {
55 switch(s1_ics_ies.data[i].IE_type)
56 {
57 case S1AP_IE_MME_UE_ID:
58 {
59 ics_resp.ue_idx = s1_ics_ies.data[i].val.mme_ue_s1ap_id;
60 }break;
61 case S1AP_ERAB_SETUP_CTX_SUR:
62 {
63 for(int j = 0; j < s1_ics_ies.data[i].val.erab.no_of_elements; j++)
64 {
65 /*TBD: Handle multiple erabs in ics rsp*/
66 ics_resp.msg_data.initctx_resp_Q_msg_m.transp_layer_addr = s1_ics_ies.data[i].val.erab.elements[j].su_res.transp_layer_addr;
67 ics_resp.msg_data.initctx_resp_Q_msg_m.gtp_teid = s1_ics_ies.data[i].val.erab.elements[j].su_res.gtp_teid;
68 break;
69 }
70 }break;
71 default:
72 log_msg(LOG_WARNING,"Unhandled IE");
73 }
74 }
75
76
77
78 ics_resp.destInstAddr = htonl(mmeAppInstanceNum_c);
79 ics_resp.srcInstAddr = htonl(s1apAppInstanceNum_c);
80 int i = send_tipc_message(ipc_S1ap_Hndl, mmeAppInstanceNum_c, (char *)&ics_resp, S1_READ_MSG_BUF_SIZE);
81
82 if (i < 0) {
83 log_msg(LOG_ERROR, "Error to write in s1_init_ctx_resp_handler\n");
84 }
85 /*Send S1Setup response*/
86 log_msg(LOG_INFO, "Init ctx resp send to mme-app stage7. Bytes send %d\n", i);
87
88 //TODO: free IEs
89 return SUCCESS;
90}