Allow daemon mode

This commit is contained in:
vemax78
2013-06-16 12:09:57 +02:00
parent 7b6bd52f48
commit 99b6373cd7
11 changed files with 106 additions and 8 deletions

View File

@ -16,6 +16,9 @@ static char g_configurationfile[260] = AC_DEFAULT_CONFIGURATION_FILE;
/* Alloc AC */
static int ac_init(void) {
/* */
g_ac.standalone = 1;
/* Network */
capwap_network_init(&g_ac.net);
g_ac.mtu = CAPWAP_MTU_DEFAULT;
@ -137,7 +140,7 @@ static int ac_parsing_configuration_1_0(config_t* config) {
if (configSetting != NULL) {
int count = config_setting_length(configSetting);
/* Disable output interface */
/* Disable output interface */
capwap_logging_disable_allinterface();
/* Enable selected interface */
@ -158,6 +161,11 @@ static int ac_parsing_configuration_1_0(config_t* config) {
}
}
/* Set running mode */
if (config_lookup_bool(config, "application.standalone", &configInt) == CONFIG_TRUE) {
g_ac.standalone = ((configInt != 0) ? 1 : 0);
}
/* Set name of AC */
if (config_lookup_string(config, "application.name", &configString) == CONFIG_TRUE) {
if (strlen(configString) > CAPWAP_ACNAME_MAXLENGTH) {
@ -690,6 +698,14 @@ int main(int argc, char** argv) {
if (value < 0) {
result = AC_ERROR_LOAD_CONFIGURATION;
} else if (value > 0) {
if (!g_ac.standalone) {
capwap_daemon();
/* Console logging is disabled in daemon mode */
capwap_logging_disable_console();
capwap_logging_info("Running AC in daemon mode");
}
/* Complete configuration AC */
result = ac_configure();
if (result == CAPWAP_SUCCESSFUL) {

View File

@ -83,8 +83,9 @@ struct ac_data_session_handshake {
/* AC */
struct ac_t {
int standalone;
int running;
/* */
struct ac_state dfa;
struct capwap_network net;