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 <pthread.h> |
| 21 | #include <string.h> |
| 22 | #include <unistd.h> |
| 23 | #include <stdint.h> |
| 24 | #include "common_proc_info.h" |
| 25 | #include "log.h" |
| 26 | #include "err_codes.h" |
| 27 | #include "message_queues.h" |
| 28 | #include "ipc_api.h" |
| 29 | #include "s1ap.h" |
| 30 | #include "s1ap_config.h" |
| 31 | #include "main.h" |
| 32 | #include "msgType.h" |
| 33 | |
| 34 | |
| 35 | /*static int |
| 36 | get_uectxtrelcmd_protoie_value(struct proto_IE *value, struct s1relcmd_info *g_uectxtrelcmd) |
| 37 | { |
| 38 | //uint8_t ieCnt = 0; |
| 39 | |
| 40 | value->no_of_IEs = UE_CTX_RELEASE_NO_OF_IES; |
| 41 | |
| 42 | value->data = (proto_IEs *) malloc(UE_CTX_RELEASE_NO_OF_IES * |
| 43 | sizeof(proto_IEs)); |
| 44 | |
| 45 | value->data[0].mme_ue_s1ap_id = g_uectxtrelcmd->ue_idx; |
| 46 | |
| 47 | value->data[1].enb_ue_s1ap_id = g_uectxtrelcmd->enb_s1ap_ue_id; |
| 48 | |
| 49 | log_msg(LOG_INFO, "mme_ue_s1ap_id %d and enb_ue_s1ap_id %d\n", |
| 50 | g_uectxtrelcmd->ue_idx,g_uectxtrelcmd->enb_s1ap_ue_id); |
| 51 | return SUCCESS; |
| 52 | }*/ |
| 53 | |
| 54 | /** |
| 55 | * Stage specific message processing. |
| 56 | */ |
| 57 | static int |
| 58 | relcmd_processing(struct s1relcmd_info *g_uectxtrelcmd) |
| 59 | { |
| 60 | log_msg(LOG_DEBUG,"Process Ctx rel cmd."); |
| 61 | uint32_t length = 0; |
| 62 | uint8_t *buffer = NULL; |
| 63 | |
| 64 | Buffer g_ctxrel_buffer; |
| 65 | struct s1ap_common_req_Q_msg req= {0}; |
| 66 | |
| 67 | log_msg(LOG_DEBUG,"Inside relcmd processing\n"); |
| 68 | |
| 69 | req.IE_type = S1AP_CTX_REL_CMD; |
| 70 | req.enb_fd = g_uectxtrelcmd->enb_fd; |
| 71 | req.mme_s1ap_ue_id = g_uectxtrelcmd->ue_idx; |
| 72 | req.enb_s1ap_ue_id = g_uectxtrelcmd->enb_s1ap_ue_id; |
| 73 | req.cause.present = g_uectxtrelcmd->cause.present; |
| 74 | req.cause.choice.radioNetwork = g_uectxtrelcmd->cause.choice.radioNetwork; |
| 75 | |
| 76 | log_msg(LOG_DEBUG,"Before s1ap_encoder\n"); |
| 77 | |
| 78 | int ret = s1ap_mme_encode_initiating(&req, &buffer, &length); |
| 79 | log_msg(LOG_DEBUG,"Invoked s1ap_encoder\n"); |
| 80 | if(ret == -1) |
| 81 | { |
| 82 | log_msg(LOG_ERROR, "Encoding ctx rel cmd failed.\n"); |
| 83 | return E_FAIL; |
| 84 | } |
| 85 | |
| 86 | buffer_copy(&g_ctxrel_buffer, buffer, length); |
| 87 | send_sctp_msg(g_uectxtrelcmd->enb_fd, g_ctxrel_buffer.buf, g_ctxrel_buffer.pos,1); |
| 88 | log_msg(LOG_INFO, "\n-----S1 Release Command sent to UE.---\n"); |
| 89 | return SUCCESS; |
| 90 | |
| 91 | } |
| 92 | |
| 93 | |
| 94 | /** |
| 95 | * Thread function for stage. |
| 96 | */ |
| 97 | void* |
| 98 | s1_release_command_handler(void *data) |
| 99 | { |
| 100 | |
| 101 | log_msg(LOG_INFO, "s1 release command handler ready.\n"); |
| 102 | |
| 103 | relcmd_processing((struct s1relcmd_info *)data); |
| 104 | |
| 105 | return NULL; |
| 106 | } |
| 107 | |
| 108 | |