anjana_sreekumar@infosys.com | 991c206 | 2020-01-08 11:42:57 +0530 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (c) 2019, Infosys Ltd. |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 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 | |
| 36 | extern int g_enb_fd; |
| 37 | extern ipc_handle ipc_S1ap_Hndl; |
| 38 | |
| 39 | int |
| 40 | s1_ctx_release_request_handler(InitiatingMessage_t *msg) |
| 41 | { |
| 42 | struct s1_incoming_msg_data_t release_request= {0}; |
| 43 | struct proto_IE s1_ctx_rel_req_ies; |
| 44 | |
| 45 | log_msg(LOG_INFO, "Parse s1ap context release request message:--\n"); |
| 46 | |
| 47 | convertUeCtxRelReqToProtoIe(msg, &s1_ctx_rel_req_ies); |
| 48 | |
| 49 | /*TODO: Validate all eNB info*/ |
| 50 | for(int i = 0; i < s1_ctx_rel_req_ies.no_of_IEs; i++) |
| 51 | { |
| 52 | switch(s1_ctx_rel_req_ies.data[i].IE_type) |
| 53 | { |
| 54 | case S1AP_IE_MME_UE_ID: |
| 55 | { |
| 56 | release_request.ue_idx = s1_ctx_rel_req_ies.data[i].val.mme_ue_s1ap_id; |
| 57 | }break; |
| 58 | default: |
| 59 | log_msg(LOG_WARNING,"Unhandled IE.\n"); |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | |
| 64 | release_request.msg_type = s1_release_request; |
| 65 | release_request.destInstAddr = htonl(mmeAppInstanceNum_c); |
| 66 | release_request.srcInstAddr = htonl(s1apAppInstanceNum_c); |
| 67 | int i = 0; |
| 68 | i = send_tipc_message(ipc_S1ap_Hndl,mmeAppInstanceNum_c, |
| 69 | (char *)&release_request, |
| 70 | S1_READ_MSG_BUF_SIZE); |
| 71 | |
| 72 | if (i < 0) { |
| 73 | |
| 74 | log_msg(LOG_ERROR,"Error To write in s1_ctx_release_request_handler\n"); |
| 75 | } |
| 76 | |
| 77 | log_msg(LOG_INFO, "Ctx Release request sent to mme-app." |
| 78 | "Bytes send %d\n", i); |
| 79 | |
| 80 | //TODO: free IEs |
| 81 | return SUCCESS; |
| 82 | } |