summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
author/C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org </C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org>2008-01-05 14:13:11 +0000
committer/C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org </C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org>2008-01-05 14:13:11 +0000
commit7763eff37cd8ab4b1af0021c18f1ff86e1f19acd (patch)
tree2f9e7d0c22933a3eec15723c24c19da9cc3099e5 /src
parent70d1f229a46565c48cfaa6412e865ddd4bc5c585 (diff)
downloadconntrack-tools-7763eff37cd8ab4b1af0021c18f1ff86e1f19acd.tar.gz
conntrack-tools-7763eff37cd8ab4b1af0021c18f1ff86e1f19acd.zip
obsolete `-S' option: Use information provided by the config file
Diffstat (limited to 'src')
-rw-r--r--src/main.c12
-rw-r--r--src/read_config_yy.y24
-rw-r--r--src/run.c22
-rw-r--r--src/sync-mode.c10
4 files changed, 42 insertions, 26 deletions
diff --git a/src/main.c b/src/main.c
index ee6abf3..c8b1074 100644
--- a/src/main.c
+++ b/src/main.c
@@ -33,8 +33,7 @@ union ct_state state;
static const char usage_daemon_commands[] =
"Daemon mode commands:\n"
- " -d [options]\t\tRun in daemon mode\n"
- " -S [options]\t\tRun in statistics mode\n";
+ " -d [options]\t\tRun in daemon mode\n";
static const char usage_client_commands[] =
"Client mode commands:\n"
@@ -63,7 +62,7 @@ void show_usage(char *progname)
}
/* These live in run.c */
-int init(int);
+int init(void);
void run(void);
void set_operation_mode(int *current, int want, char *argv[])
@@ -116,7 +115,7 @@ int main(int argc, char *argv[])
{
int ret, i, config_set = 0, action;
char config_file[PATH_MAX];
- int type = 0, mode = 0;
+ int type = 0;
struct utsname u;
int version, major, minor;
@@ -209,7 +208,8 @@ int main(int argc, char *argv[])
action = STATS;
break;
case 'S':
- set_operation_mode(&mode, STATS_MODE, argv);
+ fprintf(stderr, "WARNING: -S option is obsolete. "
+ "Ignoring.\n");
break;
case 'n':
set_operation_mode(&type, REQUEST, argv);
@@ -295,7 +295,7 @@ int main(int argc, char *argv[])
* initialization process
*/
- if (init(mode) == -1) {
+ if (init() == -1) {
close_log();
fprintf(stderr, "ERROR: conntrackd cannot start, please "
"check the logfile for more info\n");
diff --git a/src/read_config_yy.y b/src/read_config_yy.y
index ebb1c73..e2bb4c8 100644
--- a/src/read_config_yy.y
+++ b/src/read_config_yy.y
@@ -356,7 +356,15 @@ ignore_proto: T_IGMP
conf.ignore_protocol[IPPROTO_IGMP] = 1;
};
-sync: T_SYNC '{' sync_list '}';
+sync: T_SYNC '{' sync_list '}'
+{
+ if (conf.flags & CTD_STATS_MODE) {
+ fprintf(stderr, "ERROR: Cannot use both Stats and Sync "
+ "clauses in conntrackd.conf.\n");
+ exit(EXIT_FAILURE);
+ }
+ conf.flags |= CTD_SYNC_MODE;
+};
sync_list:
| sync_list sync_line;
@@ -377,12 +385,12 @@ sync_line: refreshtime
sync_mode_alarm: T_SYNC_MODE T_ALARM '{' sync_mode_alarm_list '}'
{
- conf.flags |= SYNC_MODE_ALARM;
+ conf.flags |= CTD_SYNC_ALARM;
};
sync_mode_ftfw: T_SYNC_MODE T_FTFW '{' sync_mode_ftfw_list '}'
{
- conf.flags |= SYNC_MODE_FTFW;
+ conf.flags |= CTD_SYNC_FTFW;
};
sync_mode_alarm_list:
@@ -554,7 +562,15 @@ family : T_FAMILY T_STRING
conf.family = AF_INET;
};
-stats: T_STATS '{' stats_list '}';
+stats: T_STATS '{' stats_list '}'
+{
+ if (conf.flags & CTD_SYNC_MODE) {
+ fprintf(stderr, "ERROR: Cannot use both Stats and Sync "
+ "clauses in conntrackd.conf.\n");
+ exit(EXIT_FAILURE);
+ }
+ conf.flags |= CTD_STATS_MODE;
+};
stats_list:
| stats_list stat_line
diff --git a/src/run.c b/src/run.c
index 0411fcb..ebf4b3c 100644
--- a/src/run.c
+++ b/src/run.c
@@ -85,20 +85,16 @@ void local_handler(int fd, void *data)
dlog(STATE(log), LOG_WARNING, "unknown local request %d", type);
}
-int init(int mode)
+int init(void)
{
- switch(mode) {
- case STATS_MODE:
- STATE(mode) = &stats_mode;
- break;
- case SYNC_MODE:
- STATE(mode) = &sync_mode;
- break;
- default:
- fprintf(stderr, "Unknown running mode! default "
- "to synchronization mode\n");
- STATE(mode) = &sync_mode;
- break;
+ if (CONFIG(flags) & CTD_STATS_MODE)
+ STATE(mode) = &stats_mode;
+ else if (CONFIG(flags) & CTD_SYNC_MODE)
+ STATE(mode) = &sync_mode;
+ else {
+ fprintf(stderr, "WARNING: No running mode specified. "
+ "Defaulting to statistics mode.\n");
+ STATE(mode) = &stats_mode;
}
/* Initialization */
diff --git a/src/sync-mode.c b/src/sync-mode.c
index 7c42c78..d54e169 100644
--- a/src/sync-mode.c
+++ b/src/sync-mode.c
@@ -126,11 +126,15 @@ static int init_sync(void)
}
memset(state.sync, 0, sizeof(struct ct_sync_state));
- if (CONFIG(flags) & SYNC_MODE_FTFW)
+ if (CONFIG(flags) & CTD_SYNC_FTFW)
STATE_SYNC(sync) = &ftfw;
- else
- /* default to ftfw mode */
+ else if (CONFIG(flags) & CTD_SYNC_ALARM)
+ STATE_SYNC(sync) = &alarm;
+ else {
+ fprintf(stderr, "WARNING: No synchronization mode specified. "
+ "Defaulting to FT-FW mode.\n");
STATE_SYNC(sync) = &ftfw;
+ }
if (STATE_SYNC(sync)->init)
STATE_SYNC(sync)->init();