blob: 3c8c4c86ab4376841a7e51929e122c99ad5e858c [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 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#include <stdio.h>
19#include <stdlib.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 "main.h"
28#include "s1ap.h"
29#include "s1ap_config.h"
30#include "sctp_conn.h"
31#include "s1ap_structs.h"
32#include "s1ap_msg_codes.h"
33#include "msgType.h"
34
35
36extern int g_enb_fd;
37extern ipc_handle ipc_S1ap_Hndl;
38extern struct time_stat g_attach_stats[];
39
40int
41s1_identity_resp_handler(struct proto_IE *s1_id_resp_ies)
42{
43 struct s1_incoming_msg_data_t id_resp= {0};
44
45 /*****Message structure***
46 */
47 log_msg(LOG_INFO, "Parse s1ap identity resp message:--\n");
48
49 /*Validate all eNB info*/
50
51 /*Add eNB info to hash*/
52
53 /*Create Q structure for stage 1 to MME.
54 contains init UE information.*/
55 id_resp.msg_type = id_response;
56 for(int i = 0; i < s1_id_resp_ies->no_of_IEs; i++)
57 {
58 switch(s1_id_resp_ies->data[i].IE_type)
59 {
60 case S1AP_IE_MME_UE_ID:
61 {
62 id_resp.ue_idx = s1_id_resp_ies->data[i].val.mme_ue_s1ap_id;
63 }break;
64 case S1AP_IE_NAS_PDU:
65 {
66 if(s1_id_resp_ies->data[i].val.nas.header.message_type != NAS_IDENTITY_RESPONSE)
67 {
68 id_resp.msg_data.identityResp_Q_msg_m.status = S1AP_IDENTITY_FAILED;
69 }
70 else
71 {
72 id_resp.msg_data.identityResp_Q_msg_m.status = SUCCESS;
73 }
74
75 memcpy(&(id_resp.msg_data.identityResp_Q_msg_m.IMSI),
76 &(s1_id_resp_ies->data[i].val.nas.elements[0].pduElement.IMSI),
77 BINARY_IMSI_LEN);
78 }break;
79 default:
80 log_msg(LOG_WARNING,"Unhandled IE In identification Response %d",s1_id_resp_ies->data[i].IE_type);
81 }
82 }
83 id_resp.destInstAddr = htonl(mmeAppInstanceNum_c);
84 id_resp.srcInstAddr = htonl(s1apAppInstanceNum_c);
85
86 //STIMER_GET_CURRENT_TP(g_attach_stats[s1_id_resp_ies->data[1].enb_ue_s1ap_id].auth_to_mme);
87 send_tipc_message(ipc_S1ap_Hndl, mmeAppInstanceNum_c, (char *)&id_resp, S1_READ_MSG_BUF_SIZE);
88
89 /*Send S1Setup response*/
90 log_msg(LOG_INFO, "Id resp send to mme-app stage3.\n");
91
92 //TODO: free IEs
93 return SUCCESS;
94}
95
96