00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00027 #ifndef _CONFIG_H_
00028 #define _CONFIG_H_
00029
00033 #define NUM_EXT_INTERFACE_DETECT_RETRY 120
00034
00036 #define EXT_INTERFACE_DETECT_RETRY_INTERVAL 1
00037
00039 #ifndef SYSCONFDIR
00040 #define DEFAULT_CONFIGFILE "/etc/wifidog.conf"
00041 #else
00042 #define DEFAULT_CONFIGFILE SYSCONFDIR"/wifidog.conf"
00043 #endif
00044 #define DEFAULT_DAEMON 1
00045 #define DEFAULT_DEBUGLEVEL LOG_INFO
00046 #define DEFAULT_HTTPDMAXCONN 10
00047 #define DEFAULT_GATEWAYID NULL
00048 #define DEFAULT_GATEWAYPORT 2060
00049 #define DEFAULT_HTTPDNAME "WiFiDog"
00050 #define DEFAULT_CLIENTTIMEOUT 5
00051 #define DEFAULT_CHECKINTERVAL 5
00052 #define DEFAULT_LOG_SYSLOG 0
00053 #define DEFAULT_SYSLOG_FACILITY LOG_DAEMON
00054 #define DEFAULT_WDCTL_SOCK "/tmp/wdctl.sock"
00055 #define DEFAULT_INTERNAL_SOCK "/tmp/wifidog.sock"
00056 #define DEFAULT_AUTHSERVPORT 80
00057 #define DEFAULT_AUTHSERVSSLPORT 443
00058
00059 #define DEFAULT_AUTHSERVSSLAVAILABLE 0
00060
00061 #define DEFAULT_AUTHSERVPATH "/wifidog/"
00062
00067 typedef struct _auth_serv_t {
00068 char *authserv_hostname;
00069 char *authserv_path;
00070 int authserv_http_port;
00072 int authserv_ssl_port;
00074 int authserv_use_ssl;
00075 char *last_ip;
00076 struct _auth_serv_t *next;
00077 } t_auth_serv;
00078
00082 typedef struct _firewall_rule_t {
00083 int block_allow;
00084 char *protocol;
00085 char *port;
00086 char *mask;
00087 struct _firewall_rule_t *next;
00088 } t_firewall_rule;
00089
00093 typedef struct _firewall_ruleset_t {
00094 char *name;
00095 t_firewall_rule *rules;
00096 struct _firewall_ruleset_t *next;
00097 } t_firewall_ruleset;
00098
00102 typedef struct _trusted_mac_t {
00103 char *mac;
00104 struct _trusted_mac_t *next;
00105 } t_trusted_mac;
00106
00110 typedef struct {
00111 char configfile[255];
00112 char *wdctl_sock;
00113 char *internal_sock;
00114 int daemon;
00115 int debuglevel;
00116 char *external_interface;
00118 char *gw_id;
00120 char *gw_interface;
00121 char *gw_address;
00123 int gw_port;
00125 t_auth_serv *auth_servers;
00126 char *httpdname;
00128 int httpdmaxconn;
00130 int clienttimeout;
00132 int checkinterval;
00134 int log_syslog;
00135 int syslog_facility;
00137 t_firewall_ruleset *rulesets;
00138 t_trusted_mac *trustedmaclist;
00139 } s_config;
00140
00142 s_config *config_get_config(void);
00143
00145 void config_init(void);
00146
00148 void config_init_override(void);
00149
00151 void config_read(char *filename);
00152
00154 void config_validate(void);
00155
00157 t_auth_serv *get_auth_server(void);
00158
00160 void mark_auth_server_bad(t_auth_serv *);
00161
00163 t_firewall_rule *get_ruleset(char *);
00164
00165 static void config_notnull(void *parm, char *parmname);
00166 static int parse_boolean_value(char *);
00167 static void parse_auth_server(FILE *, char *, int *);
00168 static int _parse_firewall_rule(char *ruleset, char *leftover);
00169 static void parse_firewall_ruleset(char *, FILE *, char *, int *);
00170 void parse_trusted_mac_list(char *);
00171
00172 #define LOCK_CONFIG() do { \
00173 debug(LOG_DEBUG, "Locking config"); \
00174 pthread_mutex_lock(&config_mutex); \
00175 debug(LOG_DEBUG, "Config locked"); \
00176 } while (0)
00177
00178 #define UNLOCK_CONFIG() do { \
00179 debug(LOG_DEBUG, "Unlocking config"); \
00180 pthread_mutex_unlock(&config_mutex); \
00181 debug(LOG_DEBUG, "Config unlocked"); \
00182 } while (0)
00183
00184 #endif