anjana_sreekumar@infosys.com | 991c206 | 2020-01-08 11:42:57 +0530 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (c) 2003-2018, Great Software Laboratory Pvt. Ltd. |
| 3 | * Copyright (c) 2017 Intel Corporation |
| 4 | * Copyright (c) 2019, Infosys Ltd. |
| 5 | * |
| 6 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | * you may not use this file except in compliance with the License. |
| 8 | * You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, software |
| 13 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | * See the License for the specific language governing permissions and |
| 16 | * limitations under the License. |
| 17 | */ |
| 18 | |
| 19 | #include <stdio.h> |
| 20 | #include <stdlib.h> |
| 21 | #include <unistd.h> |
| 22 | #include <string.h> |
| 23 | #include <pthread.h> |
| 24 | |
| 25 | #include "err_codes.h" |
| 26 | #include "options.h" |
| 27 | #include "ipc_api.h" |
| 28 | #include "main.h" |
| 29 | #include "s1ap.h" |
| 30 | #include "s1ap_config.h" |
| 31 | #include "sctp_conn.h" |
| 32 | #include "s1ap_structs.h" |
| 33 | #include "s1ap_msg_codes.h" |
| 34 | #include "msgType.h" |
| 35 | |
| 36 | |
| 37 | extern int g_enb_fd; |
| 38 | extern int g_sctp_fd; |
| 39 | extern ipc_handle ipc_S1ap_Hndl; |
| 40 | |
| 41 | int |
| 42 | s1_attach_complete_handler(struct proto_IE *s1_esm_resp_ies) |
| 43 | { |
| 44 | struct s1_incoming_msg_data_t attachComplete= {0}; |
| 45 | |
| 46 | /*****Message structure*** |
| 47 | */ |
| 48 | log_msg(LOG_INFO, "Parse s1ap-nas attach complete message:--\n"); |
| 49 | |
| 50 | /*Validate all eNB info*/ |
| 51 | |
| 52 | /*Create Q structure for stage 1 to MME. |
| 53 | contains init UE information.*/ |
| 54 | attachComplete.msg_type = attach_complete; |
| 55 | for(int i = 0; i < s1_esm_resp_ies->no_of_IEs; i++) |
| 56 | { |
| 57 | switch(s1_esm_resp_ies->data[i].IE_type) |
| 58 | { |
| 59 | case S1AP_IE_MME_UE_ID: |
| 60 | { |
| 61 | attachComplete.ue_idx = s1_esm_resp_ies->data[i].val.mme_ue_s1ap_id; |
| 62 | }break; |
| 63 | default: |
| 64 | log_msg(LOG_WARNING,"Unhandled IE"); |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | attachComplete.msg_data.attach_complete_Q_msg_m.status = SUCCESS; |
| 69 | |
| 70 | |
| 71 | attachComplete.destInstAddr = htonl(mmeAppInstanceNum_c); |
| 72 | attachComplete.srcInstAddr = htonl(s1apAppInstanceNum_c); |
| 73 | |
| 74 | int i = send_tipc_message(ipc_S1ap_Hndl, mmeAppInstanceNum_c, (char *)&attachComplete, S1_READ_MSG_BUF_SIZE); |
| 75 | |
| 76 | if (i < 0) { |
| 77 | log_msg(LOG_ERROR, "Error to write in s1_attach_complete_handler\n"); |
| 78 | } else { |
| 79 | /*Send S1Setup response*/ |
| 80 | log_msg(LOG_INFO, "Attach complete send to mme-app stage8. Bytes send %d\n", i); |
| 81 | } |
| 82 | |
| 83 | //Anjana: Socket cleanup |
| 84 | /*close(g_sctp_fd); |
| 85 | if (g_enb_fd != 0) |
| 86 | close(g_enb_fd);*/ |
| 87 | //TODO: free IEs |
| 88 | return SUCCESS; |
| 89 | } |
| 90 | |