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
00034 #define NUM_EXT_INTERFACE_DETECT_RETRY 120
00035
00037 #define EXT_INTERFACE_DETECT_RETRY_INTERVAL 1
00038
00040 #ifndef SYSCONFDIR
00041 #define DEFAULT_CONFIGFILE "/etc/wifidog.conf"
00042 #else
00043 #define DEFAULT_CONFIGFILE SYSCONFDIR"/wifidog.conf"
00044 #endif
00045 #define DEFAULT_DAEMON 1
00046 #define DEFAULT_DEBUGLEVEL LOG_INFO
00047 #define DEFAULT_HTTPDMAXCONN 10
00048 #define DEFAULT_GATEWAYID NULL
00049 #define DEFAULT_GATEWAYPORT 2060
00050 #define DEFAULT_HTTPDNAME "WiFiDog"
00051 #define DEFAULT_CLIENTTIMEOUT 5
00052 #define DEFAULT_CHECKINTERVAL 60
00053 #define DEFAULT_LOG_SYSLOG 0
00054 #define DEFAULT_SYSLOG_FACILITY LOG_DAEMON
00055 #define DEFAULT_WDCTL_SOCK "/tmp/wdctl.sock"
00056 #define DEFAULT_INTERNAL_SOCK "/tmp/wifidog.sock"
00057 #define DEFAULT_AUTHSERVPORT 80
00058 #define DEFAULT_AUTHSERVSSLPORT 443
00059
00060 #define DEFAULT_AUTHSERVSSLAVAILABLE 0
00061
00062 #define DEFAULT_AUTHSERVPATH "/wifidog/"
00063
00068 typedef struct _auth_serv_t {
00069 char *authserv_hostname;
00070 char *authserv_path;
00071 int authserv_http_port;
00073 int authserv_ssl_port;
00075 int authserv_use_ssl;
00076 char *last_ip;
00077 struct _auth_serv_t *next;
00078 } t_auth_serv;
00079
00083 typedef struct _firewall_rule_t {
00084 int block_allow;
00085 char *protocol;
00086 char *port;
00087 char *mask;
00088 struct _firewall_rule_t *next;
00089 } t_firewall_rule;
00090
00094 typedef struct _firewall_ruleset_t {
00095 char *name;
00096 t_firewall_rule *rules;
00097 struct _firewall_ruleset_t *next;
00098 } t_firewall_ruleset;
00099
00103 typedef struct _trusted_mac_t {
00104 char *mac;
00105 struct _trusted_mac_t *next;
00106 } t_trusted_mac;
00107
00111 typedef struct {
00112 char configfile[255];
00113 char *wdctl_sock;
00114 char *internal_sock;
00115 int daemon;
00116 int debuglevel;
00117 char *external_interface;
00119 char *gw_id;
00121 char *gw_interface;
00122 char *gw_address;
00124 int gw_port;
00126 t_auth_serv *auth_servers;
00127 char *httpdname;
00129 int httpdmaxconn;
00131 int clienttimeout;
00133 int checkinterval;
00135 int log_syslog;
00136 int syslog_facility;
00138 t_firewall_ruleset *rulesets;
00139 t_trusted_mac *trustedmaclist;
00140 } s_config;
00141
00143 s_config *config_get_config(void);
00144
00146 void config_init(void);
00147
00149 void config_init_override(void);
00150
00152 void config_read(char *filename);
00153
00155 void config_validate(void);
00156
00158 t_auth_serv *get_auth_server(void);
00159
00161 void mark_auth_server_bad(t_auth_serv *);
00162
00164 t_firewall_rule *get_ruleset(char *);
00165
00166 static void config_notnull(void *parm, char *parmname);
00167 static int parse_boolean_value(char *);
00168 static void parse_auth_server(FILE *, char *, int *);
00169 static int _parse_firewall_rule(char *ruleset, char *leftover);
00170 static void parse_firewall_ruleset(char *, FILE *, char *, int *);
00171 void parse_trusted_mac_list(char *);
00172
00173 #define LOCK_CONFIG() do { \
00174 debug(LOG_DEBUG, "Locking config"); \
00175 pthread_mutex_lock(&config_mutex); \
00176 debug(LOG_DEBUG, "Config locked"); \
00177 } while (0)
00178
00179 #define UNLOCK_CONFIG() do { \
00180 debug(LOG_DEBUG, "Unlocking config"); \
00181 pthread_mutex_unlock(&config_mutex); \
00182 debug(LOG_DEBUG, "Config unlocked"); \
00183 } while (0)
00184
00185 #endif