Commit ebf32083 authored by Jamal Hadi Salim's avatar Jamal Hadi Salim Committed by Stephen Hemminger

First part of cleaning up the help output of actions.

Signed-off-by: default avatarStephen Hemminger <shemminger@osdl.org>
parent da7aea79
...@@ -58,6 +58,7 @@ void act_usage(void) ...@@ -58,6 +58,7 @@ void act_usage(void)
"\t\tExample ACTNAME is gact, mirred etc\n" "\t\tExample ACTNAME is gact, mirred etc\n"
"\t\tEach action has its own parameters (ACTPARAMS)\n" "\t\tEach action has its own parameters (ACTPARAMS)\n"
"\n"); "\n");
exit(-1);
} }
static int print_noaopt(struct action_util *au, FILE *f, struct rtattr *opt) static int print_noaopt(struct action_util *au, FILE *f, struct rtattr *opt)
......
...@@ -45,22 +45,28 @@ explain(void) ...@@ -45,22 +45,28 @@ explain(void)
#ifdef CONFIG_GACT_PROB #ifdef CONFIG_GACT_PROB
fprintf(stderr, "Usage: ... gact <ACTION> [RAND] [INDEX]\n"); fprintf(stderr, "Usage: ... gact <ACTION> [RAND] [INDEX]\n");
fprintf(stderr, fprintf(stderr,
"Where: ACTION := reclassify | drop | continue | pass " "Where: \tACTION := reclassify | drop | continue | pass \n"
"RAND := random <RANDTYPE> <ACTION> <VAL>" "\tRAND := random <RANDTYPE> <ACTION> <VAL>\n"
"RANDTYPE := netrand | determ" "\tRANDTYPE := netrand | determ\n"
"VAL : = value not exceeding 10000" "\tVAL : = value not exceeding 10000\n"
"INDEX := index value used" "\tINDEX := index value used\n"
"\n"); "\n");
#else #else
fprintf(stderr, "Usage: ... gact <ACTION> [INDEX]\n"); fprintf(stderr, "Usage: ... gact <ACTION> [INDEX]\n");
fprintf(stderr, fprintf(stderr,
"Where: ACTION := reclassify | drop | continue | pass " "Where: \tACTION := reclassify | drop | continue | pass \n"
"INDEX := index value used" "\tINDEX := index value used\n"
"\n"); "\n");
#endif #endif
} }
#define usage() return(-1) static void
usage(void)
{
explain();
exit(-1);
}
int int
get_act(char ***argv_p) get_act(char ***argv_p)
...@@ -157,6 +163,8 @@ parse_gact(struct action_util *a, int *argc_p, char ***argv_p, int tca_id, struc ...@@ -157,6 +163,8 @@ parse_gact(struct action_util *a, int *argc_p, char ***argv_p, int tca_id, struc
} }
argc--; argc--;
argv++; argv++;
} else if (matches(*argv, "help") == 0) {
usage();
} }
} }
#endif #endif
......
...@@ -33,13 +33,19 @@ explain(void) ...@@ -33,13 +33,19 @@ explain(void)
{ {
fprintf(stderr, "Usage: mirred <DIRECTION> <ACTION> [index INDEX] <dev DEVICENAME> \n"); fprintf(stderr, "Usage: mirred <DIRECTION> <ACTION> [index INDEX] <dev DEVICENAME> \n");
fprintf(stderr, "where: \n"); fprintf(stderr, "where: \n");
fprintf(stderr, "DIRECTION := <ingress | egress>\n"); fprintf(stderr, "\tDIRECTION := <ingress | egress>\n");
fprintf(stderr, "aCTION := <mirror | redirect>\n"); fprintf(stderr, "\tACTION := <mirror | redirect>\n");
fprintf(stderr, " : INDEX is the specific policy instance id\n"); fprintf(stderr, "\tINDEX is the specific policy instance id\n");
fprintf(stderr, " : DEVICENAME is the devicename \n"); fprintf(stderr, "\tDEVICENAME is the devicename \n");
} }
#define usage() return(-1) static void
usage(void)
{
explain();
exit(-1);
}
char *mirred_n2a(int action) char *mirred_n2a(int action)
{ {
...@@ -133,7 +139,6 @@ parse_egress(struct action_util *a, int *argc_p, char ***argv_p, int tca_id, str ...@@ -133,7 +139,6 @@ parse_egress(struct action_util *a, int *argc_p, char ***argv_p, int tca_id, str
} }
if (!ok && !iok) { if (!ok && !iok) {
explain();
return -1; return -1;
} }
...@@ -235,9 +240,10 @@ parse_mirred(struct action_util *a, int *argc_p, char ***argv_p, int tca_id, str ...@@ -235,9 +240,10 @@ parse_mirred(struct action_util *a, int *argc_p, char ***argv_p, int tca_id, str
} else if (matches(*argv, "ingress") == 0) { } else if (matches(*argv, "ingress") == 0) {
fprintf(stderr,"mirred ingress not supported at the moment\n"); fprintf(stderr,"mirred ingress not supported at the moment\n");
} else if (matches(*argv, "help") == 0) {
usage();
} else { } else {
fprintf(stderr,"mirred not supported %s\n", *argv); fprintf(stderr,"mirred option not supported %s\n", *argv);
} }
return -1; return -1;
......
...@@ -33,25 +33,30 @@ static struct m_pedit_util *pedit_list; ...@@ -33,25 +33,30 @@ static struct m_pedit_util *pedit_list;
int pedit_debug = 1; int pedit_debug = 1;
static void static void
p_explain(void) explain(void)
{ {
fprintf(stderr, "Usage: ... pedit <MUNGE>\n"); fprintf(stderr, "Usage: ... pedit munge <MUNGE>\n");
fprintf(stderr, fprintf(stderr,
"Where: MUNGE := <RAW>|<LAYERED>\n" "Where: MUNGE := <RAW>|<LAYERED>\n"
"<RAW>:= <OFFSETC>[ATC]<CMD>\n " "\t<RAW>:= <OFFSETC>[ATC]<CMD>\n "
"OFFSETC:= offset <offval> <u8|u16|u32>\n " "\t\tOFFSETC:= offset <offval> <u8|u16|u32>\n "
"ATC:= at <atval> offmask <maskval> shift <shiftval>\n " "\t\tATC:= at <atval> offmask <maskval> shift <shiftval>\n "
"NOTE: offval is byte offset, must be multiple of 4\n " "\t\tNOTE: offval is byte offset, must be multiple of 4\n "
"NOTE: maskval is a 32 bit hex number\n " "\t\tNOTE: maskval is a 32 bit hex number\n "
"NOTE: shiftval is a is a shift value\n " "\t\tNOTE: shiftval is a is a shift value\n "
"CMD:= clear | invert | set <setval>| retain\n " "\t\tCMD:= clear | invert | set <setval>| retain\n "
"<LAYERED>:= ip <ipdata> | ip6 <ip6data> \n " "\t<LAYERED>:= ip <ipdata> | ip6 <ip6data> \n "
" | udp <udpdata> | tcp <tcpdata> | icmp <icmpdata> \n" " \t\t| udp <udpdata> | tcp <tcpdata> | icmp <icmpdata> \n"
"For Example usage look at the examples directory"); "For Example usage look at the examples directory\n");
} }
#define usage() return(-1) static void
usage(void)
{
explain();
exit(-1);
}
static int static int
pedit_parse_nopopt (int *argc_p, char ***argv_p,struct tc_pedit_sel *sel,struct tc_pedit_key *tkey) pedit_parse_nopopt (int *argc_p, char ***argv_p,struct tc_pedit_sel *sel,struct tc_pedit_key *tkey)
...@@ -423,11 +428,6 @@ parse_munge(int *argc_p, char ***argv_p,struct tc_pedit_sel *sel) ...@@ -423,11 +428,6 @@ parse_munge(int *argc_p, char ***argv_p,struct tc_pedit_sel *sel)
NEXT_ARG(); NEXT_ARG();
res = parse_offset(&argc, &argv,sel,&tkey); res = parse_offset(&argc, &argv,sel,&tkey);
goto done; goto done;
#if jamal
} else if (strcmp(*argv, "help") == 0) {
p_explain();
return -1;
#endif
} else { } else {
char k[16]; char k[16];
struct m_pedit_util *p = NULL; struct m_pedit_util *p = NULL;
...@@ -479,16 +479,18 @@ parse_pedit(struct action_util *a, int *argc_p, char ***argv_p, int tca_id, stru ...@@ -479,16 +479,18 @@ parse_pedit(struct action_util *a, int *argc_p, char ***argv_p, int tca_id, stru
NEXT_ARG(); NEXT_ARG();
ok++; ok++;
continue; continue;
} else if (matches(*argv, "help") == 0) {
usage();
} else if (matches(*argv, "munge") == 0) { } else if (matches(*argv, "munge") == 0) {
if (!ok) { if (!ok) {
fprintf(stderr, "Illegal pedit construct (%s) \n", *argv); fprintf(stderr, "Illegal pedit construct (%s) \n", *argv);
p_explain(); explain();
return -1; return -1;
} }
NEXT_ARG(); NEXT_ARG();
if (parse_munge(&argc, &argv,&sel.sel)) { if (parse_munge(&argc, &argv,&sel.sel)) {
fprintf(stderr, "Illegal pedit construct (%s) \n", *argv); fprintf(stderr, "Illegal pedit construct (%s) \n", *argv);
p_explain(); explain();
return -1; return -1;
} }
ok++; ok++;
...@@ -499,7 +501,7 @@ parse_pedit(struct action_util *a, int *argc_p, char ***argv_p, int tca_id, stru ...@@ -499,7 +501,7 @@ parse_pedit(struct action_util *a, int *argc_p, char ***argv_p, int tca_id, stru
} }
if (!ok) { if (!ok) {
p_explain(); explain();
return -1; return -1;
} }
......
...@@ -32,7 +32,7 @@ struct action_util police_action_util = { ...@@ -32,7 +32,7 @@ struct action_util police_action_util = {
.print_aopt = print_police, .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, "Usage: ... police rate BPS burst BYTES[/BYTES] [ mtu BYTES[/BYTES] ]\n");
fprintf(stderr, " [ peakrate BPS ] [ avrate BPS ]\n"); fprintf(stderr, " [ peakrate BPS ] [ avrate BPS ]\n");
...@@ -41,6 +41,7 @@ static void explain(void) ...@@ -41,6 +41,7 @@ static void explain(void)
fprintf(stderr, "New Syntax ACTIONTERM := conform-exceed <EXCEEDACT>[/NOTEXCEEDACT] \n"); fprintf(stderr, "New Syntax ACTIONTERM := conform-exceed <EXCEEDACT>[/NOTEXCEEDACT] \n");
fprintf(stderr, "Where: *EXCEEDACT := pipe | ok | reclassify | drop | continue \n"); fprintf(stderr, "Where: *EXCEEDACT := pipe | ok | reclassify | drop | continue \n");
fprintf(stderr, "Where: pipe is only valid for new syntax \n"); fprintf(stderr, "Where: pipe is only valid for new syntax \n");
exit(-1);
} }
static void explain1(char *arg) static void explain1(char *arg)
...@@ -48,9 +49,6 @@ static void explain1(char *arg) ...@@ -48,9 +49,6 @@ static void explain1(char *arg)
fprintf(stderr, "Illegal \"%s\"\n", arg); fprintf(stderr, "Illegal \"%s\"\n", arg);
} }
#define usage() return(-1)
char *police_action_n2a(int action, char *buf, int len) char *police_action_n2a(int action, char *buf, int len)
{ {
switch (action) { switch (action) {
...@@ -236,8 +234,7 @@ int act_parse_police(struct action_util *a,int *argc_p, char ***argv_p, int tca_ ...@@ -236,8 +234,7 @@ int act_parse_police(struct action_util *a,int *argc_p, char ***argv_p, int tca_
return -1; return -1;
} }
} else if (strcmp(*argv, "help") == 0) { } else if (strcmp(*argv, "help") == 0) {
explain(); usage();
return -1;
} else { } else {
break; break;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment