blob: 01804fafb439eeb797d64597d348965d05c11ccc [file] [log] [blame]
anjana_sreekumar@infosys.com991c2062020-01-08 11:42:57 +05301/*
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 <string.h>
19
20#include "json_data.h"
21#include "s6a_config.h"
22#include "err_codes.h"
23
24/**Globals and externs**/
25s6a_config g_s6a_cfg;
26/**Globals and externs**/
27
28/**
29 * @brief Initialize json parser and file reading
30 * @param Path to json file
31 * @return void
32 */
33void
34init_parser(char *path)
35{
36 load_json(path);
37}
38
39/**
40 * @brief Read s6a configuration parameters from input json
41 * @param None
42 * @return int - Success or fail
43 */
44int
45parse_s6a_conf()
46{
47 /*Read s11 config information*/
48 char *tmp = get_string_scalar("s6a.hss_type");
49 if(NULL == tmp) return E_FAIL;
50 if(!strcmp(tmp, "freediameter")) g_s6a_cfg.hss_type = HSS_FD;
51 else g_s6a_cfg.hss_type = HSS_PERF;
52 free(tmp);
53
54 g_s6a_cfg.hss_host_name = get_string_scalar("s6a.host_name");
55 if( NULL == g_s6a_cfg.hss_host_name) return E_FAIL;
56
57 g_s6a_cfg.realm = get_string_scalar("s6a.realm");
58 if(NULL == g_s6a_cfg.realm) return E_FAIL;
59
60 return SUCCESS;
61}