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, oHTTPDRealm, oHTTPDUsername, oHTTPDPassword,
  oClientTimeout, oCheckInterval, oWdctlSocket, oSyslogFacility,
  oFirewallRule, oFirewallRuleSet, oTrustedMACList, oHtmlMessageFile
}

Functions

static void config_notnull (const void *parm, const char *parmname)
static int parse_boolean_value (char *)
static void parse_auth_server (FILE *, const char *, int *)
static int _parse_firewall_rule (const char *ruleset, char *leftover)
static void parse_firewall_ruleset (const char *, FILE *, const 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 (const char *ruleset)
 Fetch a firewall rule set.
void config_read (const 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
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 384 of file conf.c.

Referenced by _parse_firewall_rule().


Function Documentation

static int _parse_firewall_rule ( const 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 479 of file conf.c.

References debug, _firewall_ruleset_t::name, _firewall_rule_t::next, _firewall_ruleset_t::next, _firewall_ruleset_t::rules, s_config::rulesets, safe_malloc(), and TO_NEXT_WORD.

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 152 of file conf.c.

Referenced by _connect_auth_server(), auth_server_request(), authenticate_client(), fw_sync_with_authserver(), http_callback_404(), http_callback_auth(), http_callback_status(), iptables_fw_init(), iptables_fw_set_authservers(), parse_commandline(), ping(), send_http_page(), thread_client_timeout_check(), and thread_ping().

void config_init ( void   ) 

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 191 of file conf.c.

References s_config::daemon, and DEFAULT_DAEMON.

void config_read ( const char *  filename  ) 

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 828 of file conf.c.

References s_config::auth_servers, debug, and s_config::gw_interface.

t_auth_serv* get_auth_server ( void   ) 

Get the active auth server.

This function returns the current (first auth_server)

Definition at line 855 of file conf.c.

References s_config::auth_servers.

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 ( const char *  ruleset  ) 

Fetch a firewall rule set.

Definition at line 615 of file conf.c.

References _firewall_ruleset_t::name, _firewall_ruleset_t::next, _firewall_ruleset_t::rules, and s_config::rulesets.

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 867 of file conf.c.

References s_config::auth_servers, and _auth_serv_t::next.

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 Fri Sep 25 15:28:43 2009 for WifiDog by  doxygen 1.5.5