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 | #include "json_data.h" |
| 19 | #include "s1ap_config.h" |
| 20 | #include "err_codes.h" |
| 21 | |
| 22 | s1ap_config g_s1ap_cfg; |
| 23 | |
| 24 | void |
| 25 | init_parser(char *path) |
| 26 | { |
| 27 | load_json(path); |
| 28 | } |
| 29 | |
| 30 | int |
| 31 | parse_s1ap_conf() |
| 32 | { |
| 33 | char mcc_dig1; |
| 34 | char mcc_dig2; |
| 35 | char mcc_dig3; |
| 36 | char mnc_dig1; |
| 37 | char mnc_dig2; |
| 38 | char mnc_dig3; |
| 39 | |
| 40 | /*s1ap information*/ |
| 41 | g_s1ap_cfg.mme_name = get_string_scalar("mme.name"); |
| 42 | if(NULL == g_s1ap_cfg.mme_name) return -1; |
| 43 | |
| 44 | g_s1ap_cfg.s1ap_local_ip = get_ip_scalar("s1ap.s1ap_local_addr"); |
| 45 | if(-1 == g_s1ap_cfg.s1ap_local_ip) return -1; |
| 46 | g_s1ap_cfg.sctp_port = get_int_scalar("s1ap.sctp_port"); |
| 47 | if(-1 == g_s1ap_cfg.sctp_port) return -1; |
| 48 | |
| 49 | g_s1ap_cfg.enb_ip = get_ip_scalar("s1ap.enb_addr"); |
| 50 | if(-1 == g_s1ap_cfg.enb_ip) return -1; |
| 51 | g_s1ap_cfg.enb_port = get_int_scalar("s1ap.enb_port"); |
| 52 | if(-1 == g_s1ap_cfg.enb_port) return -1; |
| 53 | |
| 54 | g_s1ap_cfg.mme_group_id = get_int_scalar("mme.group_id"); |
| 55 | if(-1 == g_s1ap_cfg.mme_group_id) return -1; |
| 56 | |
| 57 | g_s1ap_cfg.mme_code = get_int_scalar("mme.code"); |
| 58 | if(-1 == g_s1ap_cfg.mme_code) return -1; |
| 59 | |
| 60 | mcc_dig1 = get_int_scalar("mme.mcc.dig1"); |
| 61 | if(E_PARSING_FAILED == mcc_dig1) return E_PARSING_FAILED; |
| 62 | mcc_dig2 = get_int_scalar("mme.mcc.dig2"); |
| 63 | if(E_PARSING_FAILED == mcc_dig1) return E_PARSING_FAILED; |
| 64 | mcc_dig3 = get_int_scalar("mme.mcc.dig3"); |
| 65 | if(E_PARSING_FAILED == mcc_dig1) return E_PARSING_FAILED; |
| 66 | mnc_dig1 = get_int_scalar("mme.mnc.dig1"); |
| 67 | if(E_PARSING_FAILED == mcc_dig1) return E_PARSING_FAILED; |
| 68 | mnc_dig2 = get_int_scalar("mme.mnc.dig2"); |
| 69 | if(E_PARSING_FAILED == mcc_dig1) return E_PARSING_FAILED; |
| 70 | mnc_dig3 = get_int_scalar("mme.mnc.dig3"); |
| 71 | if(E_PARSING_FAILED == mcc_dig1) return E_PARSING_FAILED; |
| 72 | |
| 73 | g_s1ap_cfg.mme_plmn_id.idx[0] = mcc_dig2 << 4 | mcc_dig1; |
| 74 | g_s1ap_cfg.mme_plmn_id.idx[1] = mnc_dig3 << 4 | mcc_dig3; |
| 75 | g_s1ap_cfg.mme_plmn_id.idx[2] = mnc_dig2 << 4 | mnc_dig1; |
| 76 | |
| 77 | return SUCCESS; |
| 78 | } |