blob: 009f23d38b3782d3c1fff0391667edef9308266c [file] [log] [blame]
anjana_sreekumar@infosys.com991c2062020-01-08 11:42:57 +05301/*
2 * Copyright (c) 2019, Infosys Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#include <stdio.h>
17#include <stdlib.h>
18#include <unistd.h>
19#include <string.h>
20#include <pthread.h>
21
22#include "err_codes.h"
23#include "options.h"
24#include "ipc_api.h"
25#include "main.h"
26#include "s1ap.h"
27#include "s1ap_config.h"
28#include "sctp_conn.h"
29#include "s1ap_structs.h"
30#include "s1ap_msg_codes.h"
31#include "msgType.h"
32
33
34extern int g_enb_fd;
35extern ipc_handle ipc_S1ap_Hndl;
36
37int
38s1_ctx_release_complete_handler(SuccessfulOutcome_t *msg)
39{
40 struct s1_incoming_msg_data_t release_complete= {0};
41 struct proto_IE s1_ctx_release_ies;
42
43 log_msg(LOG_INFO, "Parse s1ap context release complete message:--\n");
44
45 convertUeCtxRelComplToProtoIe(msg, &s1_ctx_release_ies);
46
47 /*TODO: Validate all eNB info*/
48 for(int i = 0; i < s1_ctx_release_ies.no_of_IEs; i++)
49 {
50 switch(s1_ctx_release_ies.data[i].IE_type)
51 {
52 case S1AP_IE_MME_UE_ID:
53 {
54 release_complete.ue_idx = s1_ctx_release_ies.data[i].val.mme_ue_s1ap_id;
55 }break;
56 default:
57 log_msg(LOG_WARNING,"Unhandled IE");
58 }
59 }
60
61 release_complete.msg_type = s1_release_complete;
62 release_complete.destInstAddr = htonl(mmeAppInstanceNum_c);
63 release_complete.srcInstAddr = htonl(s1apAppInstanceNum_c);
64 int i = 0;
65 i = send_tipc_message(ipc_S1ap_Hndl,mmeAppInstanceNum_c,
66 (char *)&release_complete,
67 S1_READ_MSG_BUF_SIZE);
68 if (i < 0) {
69
70 log_msg(LOG_ERROR,"Error To write in s1_ctx_release_code_handler\n");
71 }
72
73 log_msg(LOG_INFO, "Ctx Release complete sent to mme-app."
74 "Bytes sent %d\n", i);
75
76 //TODO: free IEs
77 return SUCCESS;
78}
79