Skip to contentSkip to conversation

: Fix help for actions

IPROUTE2 jamal 1 participant 1 message Jul 17, 2006

Subsystems (2)
lore
Share & tools
lore

jamal

author
#0 lore raw

Stephen,
Here's one of 2-3 patches over a period of time that i will send your way to clean up the help for actions. Please apply.

cheers,
jamal

First part of cleaning up the help output of actions.

---
commit a31787bf2939fd9eb11396e3765c78c4d1e744a1
tree 884f90d157adf219559481ae5a1d70cb6cda90e7
parent 9cd6ca6d2a2b1b27fc3c98ecb8e081b19aa64019
author Jamal Hadi Salim <[email protected]> Mon, 17 Jul 2006 07:24:23 -0400 committer Jamal Hadi Salim <hadi@jzny2.(none)> Mon, 17 Jul 2006 07:24:23 -0400

 tc/m_action.c |    1 +
 tc/m_gact.c   |   24 ++++++++++++++++--------
 tc/m_mirred.c |   22 ++++++++++++++--------
 tc/m_pedit.c  |   44 +++++++++++++++++++++++---------------------
 tc/m_police.c |    9 +++------
 5 files changed, 57 insertions(+), 43 deletions(-)
tc/m_action.c +1 -0
index a7efe72..c612069 100644
@@ -38,6 +38,7 @@ int tab_flush = 0;
 void act_usage(void)
 {
 	fprintf (stderr, "action usage improper\n");
+	exit(-1);
 }
 
 static int print_noaopt(struct action_util *au, FILE *f, struct rtattr *opt)
tc/m_gact.c +16 -8
index 4bb5041..4e3f3c7 100644
@@ -45,22 +45,28 @@ explain(void)
 #ifdef CONFIG_GACT_PROB
 	fprintf(stderr, "Usage: ... gact <ACTION> [RAND] [INDEX]\n");
 	fprintf(stderr,
-		"Where: ACTION := reclassify | drop | continue | pass "
-		        "RAND := random <RANDTYPE> <ACTION> <VAL>"
-		        "RANDTYPE := netrand | determ"
-			"VAL : = value not exceeding 10000"
-			"INDEX := index value used"
+		"Where: \tACTION := reclassify | drop | continue | pass \n"
+		        "\tRAND := random <RANDTYPE> <ACTION> <VAL>\n"
+		        "\tRANDTYPE := netrand | determ\n"
+			"\tVAL : = value not exceeding 10000\n"
+			"\tINDEX := index value used\n"
 			"\n");
 #else
 	fprintf(stderr, "Usage: ... gact <ACTION> [INDEX]\n");
 	fprintf(stderr,
-		"Where: ACTION := reclassify | drop | continue | pass "
-		"INDEX := index value used"
+		"Where: \tACTION := reclassify | drop | continue | pass \n"
+		"\tINDEX := index value used\n"
 			"\n");
 #endif
 }
 
-#define usage() return(-1)
+
+static void
+usage(void)
+{
+	explain();
+	exit(-1);
+}
 
 int
 get_act(char ***argv_p)
@@ -157,6 +163,8 @@ #ifdef CONFIG_GACT_PROB
 			}
 			argc--;
 			argv++;
+		} else if (matches(*argv, "help") == 0) {
+				usage();
 		}
 	}
 #endif
tc/m_mirred.c +14 -8
index cbfea84..ed87c81 100644
@@ -33,13 +33,19 @@ explain(void)
 {
 	fprintf(stderr, "Usage: mirred <DIRECTION> <ACTION> [index INDEX] <dev DEVICENAME> \n");
 	fprintf(stderr, "where: \n");
-	fprintf(stderr, "DIRECTION := <ingress | egress>\n");
-	fprintf(stderr, "aCTION := <mirror | redirect>\n");
-	fprintf(stderr, "     : INDEX  is the specific policy instance id\n");
-	fprintf(stderr, "     : DEVICENAME is the devicename \n");
+	fprintf(stderr, "\tDIRECTION := <ingress | egress>\n");
+	fprintf(stderr, "\tACTION := <mirror | redirect>\n");
+	fprintf(stderr, "\tINDEX  is the specific policy instance id\n");
+	fprintf(stderr, "\tDEVICENAME is the devicename \n");
+
 }
 
-#define usage() return(-1)
+static void
+usage(void)
+{
+	explain();
+	exit(-1);
+}
 
 char *mirred_n2a(int action)
 {
@@ -133,7 +139,6 @@ parse_egress(struct action_util *a, int 
 	}
 
 	if (!ok && !iok) {
-		explain();
 		return -1;
 	}
 
@@ -235,9 +240,10 @@ parse_mirred(struct action_util *a, int 
 
 	} else if (matches(*argv, "ingress") == 0) {
 		fprintf(stderr,"mirred ingress not supported at the moment\n");
-
+	} else if (matches(*argv, "help") == 0) {
+		usage();
 	} else {
-		fprintf(stderr,"mirred not supported %s\n", *argv);
+		fprintf(stderr,"mirred option not supported %s\n", *argv);
 	}
 
 	return -1;
tc/m_pedit.c +23 -21

82 lines not on this page · raw message

tc/m_police.c +3 -6
index 71adb59..7b80367 100644
@@ -32,7 +32,7 @@ struct action_util police_action_util = 
 	.print_aopt = print_police,
 };
 
-static void explain(void)
+static void usage(void)
 {
 	fprintf(stderr, "Usage: ... police rate BPS burst BYTES[/BYTES] [ mtu BYTES[/BYTES] ]\n");
 	fprintf(stderr, "                [ peakrate BPS ] [ avrate BPS ]\n");
@@ -41,6 +41,7 @@ static void explain(void)
 	fprintf(stderr, "New Syntax ACTIONTERM := conform-exceed <EXCEEDACT>[/NOTEXCEEDACT] \n"); 
 	fprintf(stderr, "Where: *EXCEEDACT := pipe | ok | reclassify | drop | continue \n");
 	fprintf(stderr, "Where:  pipe is only valid for new syntax \n");
+	exit(-1);
 }
 
 static void explain1(char *arg)
@@ -48,9 +49,6 @@ static void explain1(char *arg)
 	fprintf(stderr, "Illegal \"%s\"\n", arg);
 }
 
-#define usage() return(-1)
-
-
 char *police_action_n2a(int action, char *buf, int len)
 {
 	switch (action) {
@@ -236,8 +234,7 @@ int act_parse_police(struct action_util 
 				return -1;
 			}
 		} else if (strcmp(*argv, "help") == 0) {
-			explain();
-			return -1;
+			usage();
 		} else {
 			break;
 		}