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 | * |
| 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 | |
| 35 | extern int g_enb_fd; |
| 36 | extern ipc_handle ipc_S1ap_Hndl; |
| 37 | |
| 38 | int |
| 39 | s1_esm_resp_handler(struct proto_IE *s1_esm_resp_ies) |
| 40 | { |
| 41 | struct s1_incoming_msg_data_t esm_resp= {0}; |
| 42 | esm_resp.msg_type = esm_info_response; |
| 43 | |
| 44 | /*****Message structure*** |
| 45 | */ |
| 46 | log_msg(LOG_INFO, "Parse s1ap ESM response message:--\n"); |
| 47 | |
| 48 | /*Validate all eNB info*/ |
| 49 | |
| 50 | /*Add eNB info to hash*/ |
| 51 | |
| 52 | /*Create Q structure for stage 1 to MME. |
| 53 | contains init UE information.*/ |
| 54 | for(int i = 0; i < s1_esm_resp_ies->no_of_IEs; i++) |
| 55 | { |
| 56 | switch(s1_esm_resp_ies->data[i].IE_type) |
| 57 | { |
| 58 | case S1AP_IE_MME_UE_ID: |
| 59 | { |
| 60 | esm_resp.ue_idx = s1_esm_resp_ies->data[i].val.mme_ue_s1ap_id; |
| 61 | }break; |
| 62 | case S1AP_IE_NAS_PDU: |
| 63 | { |
| 64 | if(s1_esm_resp_ies->data[i].val.nas.header.message_type != NAS_ESM_RESP) |
| 65 | { |
| 66 | esm_resp.msg_data.esm_resp_Q_msg_m.status = S1AP_SECMODE_FAILED;//Error in authentication |
| 67 | } |
| 68 | else |
| 69 | { |
| 70 | esm_resp.msg_data.esm_resp_Q_msg_m.status = SUCCESS; |
| 71 | memcpy(&(esm_resp.msg_data.esm_resp_Q_msg_m.apn), &(s1_esm_resp_ies->data[i].val.nas.elements[0].pduElement.apn), |
| 72 | sizeof(struct apn_name)); |
| 73 | } |
| 74 | |
| 75 | }break; |
| 76 | default: |
| 77 | log_msg(LOG_WARNING,"Unhandled IE"); |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | |
| 82 | esm_resp.destInstAddr = htonl(mmeAppInstanceNum_c); |
| 83 | esm_resp.srcInstAddr = htonl(s1apAppInstanceNum_c); |
| 84 | |
| 85 | //STIMER_GET_CURRENT_TP(g_attach_stats[s1_auth_resp_ies->data[1].enb_ue_s1ap_id].auth_to_mme); |
| 86 | send_tipc_message(ipc_S1ap_Hndl, mmeAppInstanceNum_c, (char *)&esm_resp, S1_READ_MSG_BUF_SIZE); |
| 87 | |
| 88 | /*Send S1Setup response*/ |
| 89 | log_msg(LOG_INFO, "ESM Info resp send to mme-app\n"); |
| 90 | |
| 91 | //TODO: free IEs |
| 92 | return SUCCESS; |
| 93 | } |
| 94 | |