00001 /********************************************************************\ 00002 * This program is free software; you can redistribute it and/or * 00003 * modify it under the terms of the GNU General Public License as * 00004 * published by the Free Software Foundation; either version 2 of * 00005 * the License, or (at your option) any later version. * 00006 * * 00007 * This program is distributed in the hope that it will be useful, * 00008 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00009 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00010 * GNU General Public License for more details. * 00011 * * 00012 * You should have received a copy of the GNU General Public License* 00013 * along with this program; if not, contact: * 00014 * * 00015 * Free Software Foundation Voice: +1-617-542-5942 * 00016 * 59 Temple Place - Suite 330 Fax: +1-617-542-2652 * 00017 * Boston, MA 02111-1307, USA gnu@gnu.org * 00018 * * 00019 \********************************************************************/ 00020 00021 /* $Id: conf.h 1373 2008-09-30 09:27:40Z wichert $ */ 00027 #ifndef _CONFIG_H_ 00028 #define _CONFIG_H_ 00029 00034 #define NUM_EXT_INTERFACE_DETECT_RETRY 0 00035 00037 #define EXT_INTERFACE_DETECT_RETRY_INTERVAL 1 00038 00040 #ifndef SYSCONFDIR 00041 #define DEFAULT_CONFIGFILE "/etc/wifidog.conf" 00042 #define DEFAULT_HTMLMSGFILE "/etc/wifidog-msg.html" 00043 #else 00044 #define DEFAULT_CONFIGFILE SYSCONFDIR"/wifidog.conf" 00045 #define DEFAULT_HTMLMSGFILE SYSCONFDIR"/wifidog-msg.html" 00046 #endif 00047 #define DEFAULT_DAEMON 1 00048 #define DEFAULT_DEBUGLEVEL LOG_INFO 00049 #define DEFAULT_HTTPDMAXCONN 10 00050 #define DEFAULT_GATEWAYID NULL 00051 #define DEFAULT_GATEWAYPORT 2060 00052 #define DEFAULT_HTTPDNAME "WiFiDog" 00053 #define DEFAULT_CLIENTTIMEOUT 5 00054 #define DEFAULT_CHECKINTERVAL 60 00055 #define DEFAULT_LOG_SYSLOG 0 00056 #define DEFAULT_SYSLOG_FACILITY LOG_DAEMON 00057 #define DEFAULT_WDCTL_SOCK "/tmp/wdctl.sock" 00058 #define DEFAULT_INTERNAL_SOCK "/tmp/wifidog.sock" 00059 #define DEFAULT_AUTHSERVPORT 80 00060 #define DEFAULT_AUTHSERVSSLPORT 443 00061 00062 #define DEFAULT_AUTHSERVSSLAVAILABLE 0 00063 00064 #define DEFAULT_AUTHSERVPATH "/wifidog/" 00065 #define DEFAULT_AUTHSERVLOGINPATHFRAGMENT "login/?" 00066 #define DEFAULT_AUTHSERVPORTALPATHFRAGMENT "portal/?" 00067 #define DEFAULT_AUTHSERVMSGPATHFRAGMENT "gw_message.php?" 00068 #define DEFAULT_AUTHSERVPINGPATHFRAGMENT "ping/?" 00069 #define DEFAULT_AUTHSERVAUTHPATHFRAGMENT "auth/?" 00070 00075 typedef struct _auth_serv_t { 00076 char *authserv_hostname; 00077 char *authserv_path; 00078 char *authserv_login_script_path_fragment; 00079 char *authserv_portal_script_path_fragment; 00080 char *authserv_msg_script_path_fragment; 00081 char *authserv_ping_script_path_fragment; 00082 char *authserv_auth_script_path_fragment; 00083 int authserv_http_port; 00085 int authserv_ssl_port; 00087 int authserv_use_ssl; 00088 char *last_ip; 00089 struct _auth_serv_t *next; 00090 } t_auth_serv; 00091 00095 typedef struct _firewall_rule_t { 00096 int block_allow; 00097 char *protocol; 00098 char *port; 00099 char *mask; 00100 struct _firewall_rule_t *next; 00101 } t_firewall_rule; 00102 00106 typedef struct _firewall_ruleset_t { 00107 char *name; 00108 t_firewall_rule *rules; 00109 struct _firewall_ruleset_t *next; 00110 } t_firewall_ruleset; 00111 00115 typedef struct _trusted_mac_t { 00116 char *mac; 00117 struct _trusted_mac_t *next; 00118 } t_trusted_mac; 00119 00123 typedef struct { 00124 char configfile[255]; 00125 char *htmlmsgfile; 00126 char *wdctl_sock; 00127 char *internal_sock; 00128 int daemon; 00129 int debuglevel; 00130 char *external_interface; 00132 char *gw_id; 00134 char *gw_interface; 00135 char *gw_address; 00137 int gw_port; 00139 t_auth_serv *auth_servers; 00140 char *httpdname; 00142 int httpdmaxconn; 00144 char *httpdrealm; 00145 char *httpdusername; 00146 char *httpdpassword; 00147 int clienttimeout; 00149 int checkinterval; 00151 int log_syslog; 00152 int syslog_facility; 00154 t_firewall_ruleset *rulesets; 00155 t_trusted_mac *trustedmaclist; 00156 } s_config; 00157 00159 s_config *config_get_config(void); 00160 00162 void config_init(void); 00163 00165 void config_init_override(void); 00166 00168 void config_read(const char *filename); 00169 00171 void config_validate(void); 00172 00174 t_auth_serv *get_auth_server(void); 00175 00177 void mark_auth_server_bad(t_auth_serv *); 00178 00180 t_firewall_rule *get_ruleset(const char *); 00181 00182 void parse_trusted_mac_list(char *); 00183 00184 #define LOCK_CONFIG() do { \ 00185 debug(LOG_DEBUG, "Locking config"); \ 00186 pthread_mutex_lock(&config_mutex); \ 00187 debug(LOG_DEBUG, "Config locked"); \ 00188 } while (0) 00189 00190 #define UNLOCK_CONFIG() do { \ 00191 debug(LOG_DEBUG, "Unlocking config"); \ 00192 pthread_mutex_unlock(&config_mutex); \ 00193 debug(LOG_DEBUG, "Config unlocked"); \ 00194 } while (0) 00195 00196 #endif /* _CONFIG_H_ */