blob: 1489af54faea1f86549009b11db151c6d3c2a206 [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//#include "detach_stage1_info.h"
35
36extern int g_enb_fd;
37extern ipc_handle ipc_S1ap_Hndl;
38
39int
40detach_accept_from_ue_handler(struct proto_IE *detach_ies, bool retransmit)
41{
42 struct s1_incoming_msg_data_t acpt= {0};
43
44 /*****Message structure***
45 */
46 log_msg(LOG_INFO, "Parse s1ap ni detach accept message\n");
47
48
49 /*Validate all eNB info*/
50
51 /*Add eNB info to hash*/
52
53 /*Create Q structure for detach stage 1 to MME.
54 contains init UE information.*/
55 /* TODO : Revisit, in InitialContextSetup Request we are sending
56 * MME UE S1AP Id as M-TMSI.
57 */
58 acpt.msg_type = detach_accept_from_ue;
59 for(int i = 0; i < detach_ies->no_of_IEs; i++)
60 {
61 switch(detach_ies->data[i].IE_type)
62 {
63 case S1AP_IE_MME_UE_ID:
64 {
65 if (!retransmit)
66 {
67 acpt.ue_idx = detach_ies->data[i].val.mme_ue_s1ap_id;
68 }
69 }
70 break;
71 case S1AP_IE_ENB_UE_ID:
72 {
73 acpt.s1ap_enb_ue_id = detach_ies->data[i].val.enb_ue_s1ap_id;
74 }
75 break;
76 default:
77 log_msg(LOG_WARNING,"Unhandled IE");
78 }
79 }
80
81 acpt.destInstAddr = htonl(mmeAppInstanceNum_c);
82 acpt.srcInstAddr = htonl(s1apAppInstanceNum_c);
83 send_tipc_message(ipc_S1ap_Hndl, mmeAppInstanceNum_c, (char *)&acpt, S1_READ_MSG_BUF_SIZE);
84
85 /*Send S1Setup response*/
86 log_msg(LOG_INFO, "Send to mme-app stage1.\n");
87
88 return SUCCESS;
89}
90
91