conf.c File Reference

Config file parsing. More...

Go to the source code of this file.

Defines

#define _GNU_SOURCE
#define TO_NEXT_WORD(s, e)

Enumerations

enum  OpCodes {
  oBadOption, oDaemon, oDebugLevel, oExternalInterface,
  oGatewayID, oGatewayInterface, oGatewayAddress, oGatewayPort,
  oAuthServer, oAuthServHostname, oAuthServSSLAvailable, oAuthServSSLPort,
  oAuthServHTTPPort, oAuthServPath, oAuthServLoginScriptPathFragment, oAuthServPortalScriptPathFragment,
  oAuthServMsgScriptPathFragment, oAuthServPingScriptPathFragment, oAuthServAuthScriptPathFragment, oHTTPDMaxConn,
  oHTTPDName, oClientTimeout, oCheckInterval, oWdctlSocket,
  oSyslogFacility, oFirewallRule, oFirewallRuleSet, oTrustedMACList
}

Functions

static void config_notnull (void *parm, char *parmname)
static int parse_boolean_value (char *)
static void parse_auth_server (FILE *, char *, int *)
static int _parse_firewall_rule (char *ruleset, char *leftover)
static void parse_firewall_ruleset (char *, FILE *, char *, int *)
static OpCodes config_parse_token (const char *cp, const char *filename, int linenum)
s_configconfig_get_config (void)
 Get the current gateway configuration.
void config_init (void)
 Initialise the conf system.
void config_init_override (void)
 Initialize the variables we override with the command line.
t_firewall_ruleget_ruleset (char *ruleset)
 Fetch a firewall rule set.
void config_read (char *filename)
 Reads the configuration file.
void parse_trusted_mac_list (char *ptr)
void config_validate (void)
 Check that the configuration is valid.
t_auth_servget_auth_server (void)
 Get the active auth server.
void mark_auth_server_bad (t_auth_serv *bad_server)
 Bump server to bottom of the list.

Variables

static s_config config
pthread_mutex_t config_mutex = PTHREAD_MUTEX_INITIALIZER
static int missing_parms
struct {
   const char *   name
   OpCodes   opcode
   int   required
keywords []


Detailed Description

Config file parsing.

Author:
Copyright (C) 2004 Philippe April <papril777@yahoo.com>

Copyright (C) 2007 Benoit Grégoire, Technologies Coeus inc.

Definition in file conf.c.


Define Documentation

#define TO_NEXT_WORD ( s,
 ) 

Value:

do { \
        while (*s != '\0' && !isblank(*s)) { \
                s++; \
        } \
        if (*s != '\0') { \
                *s = '\0'; \
                s++; \
                while (isblank(*s)) \
                        s++; \
        } else { \
                e = 1; \
        } \
} while (0)
Advance to the next word
Parameters:
s string to parse, this is the next_word pointer, the value of s when the macro is called is the current word, after the macro completes, s contains the beginning of the NEXT word, so you need to save s to something else before doing TO_NEXT_WORD
e should be 0 when calling TO_NEXT_WORD(), it'll be changed to 1 if the end of the string is reached.

Definition at line 373 of file conf.c.

Referenced by _parse_firewall_rule().


Enumeration Type Documentation

enum OpCodes

Enumerator:
oBadOption 
oDaemon 
oDebugLevel 
oExternalInterface 
oGatewayID 
oGatewayInterface 
oGatewayAddress 
oGatewayPort 
oAuthServer 
oAuthServHostname 
oAuthServSSLAvailable 
oAuthServSSLPort 
oAuthServHTTPPort 
oAuthServPath 
oAuthServLoginScriptPathFragment 
oAuthServPortalScriptPathFragment 
oAuthServMsgScriptPathFragment 
oAuthServPingScriptPathFragment 
oAuthServAuthScriptPathFragment 
oHTTPDMaxConn 
oHTTPDName 
oClientTimeout 
oCheckInterval 
oWdctlSocket 
oSyslogFacility 
oFirewallRule 
oFirewallRuleSet 
oTrustedMACList 

Definition at line 65 of file conf.c.


Function Documentation

static int _parse_firewall_rule ( char *  ruleset,
char *  leftover 
) [static]

< 0 == block, 1 == allow

< If 0, port contained non-numerics

< reached end of line

< First word

< port to open/block

< protocol to block, tcp/udp/icmp

< Netmask

< other key word

Definition at line 468 of file conf.c.

References debug, t_firewall_ruleset::name, t_firewall_rule::next, t_firewall_ruleset::next, t_firewall_ruleset::rules, s_config::rulesets, safe_malloc(), safe_strdup(), and TO_NEXT_WORD.

Referenced by parse_firewall_ruleset().

s_config* config_get_config ( void   ) 

Get the current gateway configuration.

Accessor for the current gateway configuration

Returns:
: A pointer to the current config. The pointer isn't opaque, but should be treated as READ-ONLY

Definition at line 145 of file conf.c.

Referenced by _connect_auth_server(), _debug(), authenticate_client(), fw_sync_with_authserver(), get_status_text(), http_callback_404(), http_callback_auth(), http_wifidog_header(), iptables_fw_init(), iptables_fw_set_authservers(), is_auth_online(), is_online(), parse_commandline(), ping(), thread_client_timeout_check(), thread_ping(), and wdctl_restart().

void config_init ( void   ) 

Initialise the conf system.

Sets the default config parameters and initialises the configuration system

Definition at line 152 of file conf.c.

void config_init_override ( void   ) 

Initialize the variables we override with the command line.

If the command-line didn't provide a config, use the default.

Definition at line 180 of file conf.c.

void config_read ( char *  filename  ) 

Reads the configuration file.

Parameters:
filename Full path of the configuration file to be read

Definition at line 621 of file conf.c.

void config_validate ( void   ) 

Check that the configuration is valid.

Verifies if the configuration is complete and valid. Terminates the program if it isn't

Definition at line 799 of file conf.c.

t_auth_serv* get_auth_server ( void   ) 

Get the active auth server.

This function returns the current (first auth_server)

Definition at line 826 of file conf.c.

Referenced by auth_server_request(), authenticate_client(), http_callback_404(), http_callback_auth(), http_send_redirect_to_auth(), and ping().

t_firewall_rule* get_ruleset ( char *  ruleset  ) 

Fetch a firewall rule set.

Definition at line 604 of file conf.c.

void mark_auth_server_bad ( t_auth_serv bad_server  ) 

Bump server to bottom of the list.

This function marks the current auth_server, if it matches the argument, as bad. Basically, the "bad" server becomes the last one on the list.

Definition at line 838 of file conf.c.

Referenced by _connect_auth_server().


Variable Documentation

pthread_mutex_t config_mutex = PTHREAD_MUTEX_INITIALIZER

Mutex for the configuration file, used by the auth_servers related functions.

Definition at line 56 of file conf.c.


Generated on Sun Apr 13 21:55:00 2008 for WifiDog by  doxygen 1.5.3