1 /*
2  * Copyright (C) 2015 Red Hat, Inc.
3  *
4  * Author: Nikos Mavrogiannopoulos
5  *
6  * This file is part of ocserv.
7  *
8  * ocserv is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation; either version 2.1 of
11  * the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this program.  If not, see <http://www.gnu.org/licenses/>
20  */
21 #ifndef COMMON_CONFIG_H
22 # define COMMON_CONFIG_H
23 
24 #include <config.h>
25 #include <vpn.h>
26 #include <ipc.pb-c.h>
27 
28 char *sanitize_config_value(void *pool, const char *value);
29 int _add_multi_line_val(void *pool, char ***varname, size_t *num,
30 		        const char *val);
31 int cfg_parse_ports(void *pool, FwPortSt ***fw_ports, size_t *n_fw_ports, const char *str);
32 
33 #define MAX_SUBOPTIONS 5
34 
35 typedef struct subcfg_val_st {
36 	char *name;
37 	char *value;
38 } subcfg_val_st;
39 
40 typedef struct gssapi_cfg_st {
41 	char *keytab;
42 	unsigned no_local_map;
43 	time_t ticket_freshness_secs;
44 	int gid_min;
45 } gssapi_cfg_st;
46 
47 typedef struct radius_cfg_st {
48 	char *config;
49 	char *nas_identifier;
50 } radius_cfg_st;
51 
52 typedef struct plain_cfg_st {
53 	char *passwd;
54 	char *otp_file;
55 } plain_cfg_st;
56 
57 typedef struct pam_cfg_st {
58 	int gid_min;
59 } pam_cfg_st;
60 
61 #define CHECK_TRUE(str) ((str != NULL && (c_strcasecmp(str, "true") == 0 || c_strcasecmp(str, "yes") == 0))?1:0)
62 
63 struct perm_cfg_st;
64 
65 void *get_brackets_string1(void *pool, const char *str);
66 void *gssapi_get_brackets_string(void *pool, struct perm_cfg_st *config, const char *str);
67 void *radius_get_brackets_string(void *pool, struct perm_cfg_st *config, const char *str);
68 void *pam_get_brackets_string(void *pool, struct perm_cfg_st *config, const char *str);
69 void *plain_get_brackets_string(void *pool, struct perm_cfg_st *config, const char *str);
70 void *oidc_get_brackets_string(void * pool, struct perm_cfg_st *config, const char *str);
71 
72 void parse_kkdcp_string(char *str, int *socktype, char **_port, char **_server, char **_path, char **_realm);
73 
74 #endif
75