From f133f56f46c5ea52031be986f1a319ead672ef25 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Tue, 31 Mar 2009 15:36:39 +0200 Subject: conntrack: remove broken command checking code This patch removes the broken command checking. This is better handled by the option checkings which comes just after this one. This patch also fixes some inconsistencies in the command parameter checking when long names are used. Signed-off-by: Pablo Neira Ayuso --- src/conntrack.c | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/src/conntrack.c b/src/conntrack.c index 9c5e69b..0305408 100644 --- a/src/conntrack.c +++ b/src/conntrack.c @@ -58,12 +58,6 @@ #include #include -static const char cmdflags[NUMBER_OF_CMD] -= {'L','I','U','D','G','F','E','V','h','L','I','D','G','F','E','C','C','S'}; - -static const char cmd_need_param[NUMBER_OF_CMD] -= { 2, 0, 0, 0, 0, 2, 2, 2, 2, 2, 0, 0, 0, 2, 2, 2, 2, 2}; - static const char *optflags[NUMBER_OF_OPT] = { "src","dst","reply-src","reply-dst","protonum","timeout","status","zero", "event-mask","tuple-src","tuple-dst","mask-src","mask-dst","nat-range","mark", @@ -71,12 +65,12 @@ static const char *optflags[NUMBER_OF_OPT] = { static struct option original_opts[] = { {"dump", 2, 0, 'L'}, - {"create", 1, 0, 'I'}, - {"delete", 1, 0, 'D'}, - {"update", 1, 0, 'U'}, - {"get", 1, 0, 'G'}, - {"flush", 1, 0, 'F'}, - {"event", 1, 0, 'E'}, + {"create", 2, 0, 'I'}, + {"delete", 2, 0, 'D'}, + {"update", 2, 0, 'U'}, + {"get", 2, 0, 'G'}, + {"flush", 2, 0, 'F'}, + {"event", 2, 0, 'E'}, {"counter", 2, 0, 'C'}, {"stats", 0, 0, 'S'}, {"version", 0, 0, 'V'}, @@ -255,15 +249,6 @@ exit_error(enum exittype status, const char *msg, ...) exit(status); } -static void -generic_cmd_check(int command, int local_options) -{ - if (cmd_need_param[command] == 0 && !local_options) - exit_error(PARAMETER_PROBLEM, - "You need to supply parameters to `-%c'", - cmdflags[command]); -} - static int bit2cmd(int command) { int i; @@ -1212,7 +1197,6 @@ int main(int argc, char *argv[]) family = AF_INET; cmd = bit2cmd(command); - generic_cmd_check(cmd, options); generic_opt_check(options, NUMBER_OF_OPT, commands_v_options[cmd], -- cgit v1.2.3