blob: 021507507b34ce0082b49616e28043dd88e81f58 [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_secmode_resp_handler(struct proto_IE *s1_sec_resp_ies)
42{
43 //TODO: use static instead of synamic for perf.
44 struct s1_incoming_msg_data_t secmode_resp= {0};
45
46 /*****Message structure***
47 */
48 log_msg(LOG_INFO, "Parse s1ap sec mode complete message:--\n");
49
50 /*Validate all eNB info*/
51
52 /*Add eNB info to hash*/
53
54 /*Create Q structure for stage 1 to MME.
55 contains init UE information.*/
56 secmode_resp.msg_type = sec_mode_complete;
57
58 for(int i = 0; i < s1_sec_resp_ies->no_of_IEs; i++)
59 {
60 switch(s1_sec_resp_ies->data[i].IE_type)
61 {
62 case S1AP_IE_MME_UE_ID:
63 {
64 secmode_resp.ue_idx = s1_sec_resp_ies->data[i].val.mme_ue_s1ap_id;
65 }break;
66 case S1AP_IE_NAS_PDU:
67 {
68 if(s1_sec_resp_ies->data[i].val.nas.header.message_type != NAS_SEC_MODE_COMPLETE)
69 {
70 secmode_resp.msg_data.secmode_resp_Q_msg_m.status = S1AP_SECMODE_FAILED;//Error in authentication
71 }
72 else
73 {
74 secmode_resp.msg_data.secmode_resp_Q_msg_m.status = SUCCESS;
75 }
76
77 }break;
78 default:
79 log_msg(LOG_WARNING,"Unhandled IE");
80 }
81 }
82
83 /*Copy xres from response, send to mme for verification*/
84 //...
85 //auth_res.res.len = a1_secmode_resp_ies[2].data.nas.authresp_len;
86 //memcpy(&(auth_res.res.val, s1_sec_resp_ies[2].data.nas.RES, authres.res.len);
87
88 secmode_resp.destInstAddr = htonl(mmeAppInstanceNum_c);
89 secmode_resp.srcInstAddr = htonl(s1apAppInstanceNum_c);
90 send_tipc_message(ipc_S1ap_Hndl, mmeAppInstanceNum_c, (char *)&secmode_resp, S1_READ_MSG_BUF_SIZE);
91
92 /*Send S1Setup response*/
93 log_msg(LOG_INFO, "Auth resp send to mme-app stage4.\n");
94
95 //TODO: free IEs
96 return SUCCESS;
97}
98