summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog1
-rw-r--r--conntrackd.85
-rw-r--r--include/conntrackd.h6
-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
7 files changed, 48 insertions, 32 deletions
diff --git a/ChangeLog b/ChangeLog
index 78e3034..d9c9411 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -28,6 +28,7 @@ o hash lookup speedups based on comments from netdev's discussions
o add support for connection logging to the statistics mode via Logfile
o minor irrelevant fixes for uncommon error paths and fix several typos
o detach daemon from its terminal (Ben Lenitz <BLentz@channing-bete.com>)
+o obsolete `-S' option: Use information provided by the config file
version 0.9.5 (2007/07/29)
------------------------------
diff --git a/conntrackd.8 b/conntrackd.8
index 8e2f2cc..0520ed7 100644
--- a/conntrackd.8
+++ b/conntrackd.8
@@ -19,10 +19,7 @@ can be divided into several different groups.
These options specify the particular operation mode in which conntrackd runs. Only one of them can be specified at any given time.
.TP
.BI "-d "
-Run conntrackd in daemon mode. This option can be combined with "-S"
-.TP
-.BI "-S "
-Run conntrackd in statistics mode. Default mode is synchronization mode, so if you want to use
+Run conntrackd in daemon mode.
.B conntrackd
in statistics mode, you have to pass this option
.SS CLIENT COMMANDS
diff --git a/include/conntrackd.h b/include/conntrackd.h
index e5b8a4e..116ab9d 100644
--- a/include/conntrackd.h
+++ b/include/conntrackd.h
@@ -51,8 +51,10 @@ enum {
#define REQUEST 2
/* conntrackd modes */
-#define SYNC_MODE 0
-#define STATS_MODE 1
+#define CTD_SYNC_MODE (1UL << 0)
+#define CTD_STATS_MODE (1UL << 1)
+#define CTD_SYNC_FTFW (1UL << 2)
+#define CTD_SYNC_ALARM (1UL << 3)
/* FILENAME_MAX is 4096 on my system, perhaps too much? */
#ifndef FILENAME_MAXLEN
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();