NEXT_ARG_FWD();
}
- if (argc) {
- if (matches(*argv, "reclassify") == 0) {
- parm.action = TC_ACT_RECLASSIFY;
- NEXT_ARG_FWD();
- } else if (matches(*argv, "pipe") == 0) {
- parm.action = TC_ACT_PIPE;
- NEXT_ARG_FWD();
- } else if (matches(*argv, "drop") == 0 ||
- matches(*argv, "shot") == 0) {
- parm.action = TC_ACT_SHOT;
- NEXT_ARG_FWD();
- } else if (matches(*argv, "continue") == 0) {
- parm.action = TC_ACT_UNSPEC;
- NEXT_ARG_FWD();
- } else if (matches(*argv, "pass") == 0 ||
- matches(*argv, "ok") == 0) {
- parm.action = TC_ACT_OK;
- NEXT_ARG_FWD();
- }
- }
+ if (argc && !action_a2n(*argv, &parm.action, false))
+ NEXT_ARG_FWD();
if (argc) {
if (matches(*argv, "index") == 0) {
}
sel.action = TC_ACT_PIPE;
- if (argc) {
- if (matches(*argv, "reclassify") == 0) {
- sel.action = TC_ACT_RECLASSIFY;
- argc--;
- argv++;
- } else if (matches(*argv, "pipe") == 0) {
- sel.action = TC_ACT_PIPE;
- argc--;
- argv++;
- } else if (matches(*argv, "drop") == 0 ||
- matches(*argv, "shot") == 0) {
- sel.action = TC_ACT_SHOT;
- argc--;
- argv++;
- } else if (matches(*argv, "continue") == 0) {
- sel.action = TC_ACT_UNSPEC;
- argc--;
- argv++;
- } else if (matches(*argv, "pass") == 0 ||
- matches(*argv, "ok") == 0) {
- sel.action = TC_ACT_OK;
- argc--;
- argv++;
- }
- }
+ if (argc && !action_a2n(*argv, &sel.action, false))
+ NEXT_ARG_FWD();
if (argc) {
if (matches(*argv, "index") == 0) {
return -1;
}
- if (argc) {
- if (matches(*argv, "reclassify") == 0) {
- sel.action = TC_ACT_RECLASSIFY;
- argc--;
- argv++;
- } else if (matches(*argv, "pipe") == 0) {
- sel.action = TC_ACT_PIPE;
- argc--;
- argv++;
- } else if (matches(*argv, "drop") == 0 ||
- matches(*argv, "shot") == 0) {
- sel.action = TC_ACT_SHOT;
- argc--;
- argv++;
- } else if (matches(*argv, "continue") == 0) {
- sel.action = TC_ACT_UNSPEC;
- argc--;
- argv++;
- } else if (matches(*argv, "pass") == 0 ||
- matches(*argv, "ok") == 0) {
- sel.action = TC_ACT_OK;
- argc--;
- argv++;
- }
- }
+ if (argc && !action_a2n(*argv, &sel.action, false))
+ NEXT_ARG_FWD();
if (argc) {
if (matches(*argv, "index") == 0) {
static int
get_act(char ***argv_p)
{
- char **argv = *argv_p;
+ int n;
- if (matches(*argv, "reclassify") == 0) {
- return TC_ACT_RECLASSIFY;
- } else if (matches(*argv, "drop") == 0 || matches(*argv, "shot") == 0) {
- return TC_ACT_SHOT;
- } else if (matches(*argv, "continue") == 0) {
- return TC_ACT_UNSPEC;
- } else if (matches(*argv, "pipe") == 0) {
- return TC_ACT_PIPE;
- } else if (matches(*argv, "pass") == 0 || matches(*argv, "ok") == 0) {
- return TC_ACT_OK;
- } else {
- fprintf(stderr, "bad action type %s\n", *argv);
+ if (!action_a2n(**argv_p, &n, false)) {
+ fprintf(stderr, "bad action type %s\n", **argv_p);
return -10;
}
+ return n;
}
static int
argv++;
}
- if (argc) {
- if (matches(*argv, "reclassify") == 0) {
- p.action = TC_ACT_RECLASSIFY;
- argc--;
- argv++;
- } else if (matches(*argv, "pipe") == 0) {
- p.action = TC_ACT_PIPE;
- argc--;
- argv++;
- } else if (matches(*argv, "drop") == 0 ||
- matches(*argv, "shot") == 0) {
- p.action = TC_ACT_SHOT;
- argc--;
- argv++;
- } else if (matches(*argv, "continue") == 0) {
- p.action = TC_ACT_UNSPEC;
- argc--;
- argv++;
- } else if (matches(*argv, "pass") == 0 ||
- matches(*argv, "ok") == 0) {
- p.action = TC_ACT_OK;
- argc--;
- argv++;
- }
- }
+ if (argc && !action_a2n(*argv, &p.action, false))
+ NEXT_ARG_FWD();
if (argc) {
if (matches(*argv, "index") == 0) {
}
- if (argc && p.eaction == TCA_EGRESS_MIRROR) {
-
- if (matches(*argv, "reclassify") == 0) {
- p.action = TC_POLICE_RECLASSIFY;
- NEXT_ARG();
- } else if (matches(*argv, "pipe") == 0) {
- p.action = TC_POLICE_PIPE;
- NEXT_ARG();
- } else if (matches(*argv, "drop") == 0 ||
- matches(*argv, "shot") == 0) {
- p.action = TC_POLICE_SHOT;
- NEXT_ARG();
- } else if (matches(*argv, "continue") == 0) {
- p.action = TC_POLICE_UNSPEC;
- NEXT_ARG();
- } else if (matches(*argv, "pass") == 0 ||
- matches(*argv, "ok") == 0) {
- p.action = TC_POLICE_OK;
- NEXT_ARG();
- }
-
- }
+ if (argc && p.eaction == TCA_EGRESS_MIRROR
+ && !action_a2n(*argv, &p.action, false))
+ NEXT_ARG();
if (argc) {
if (iok && matches(*argv, "index") == 0) {
return -1;
}
- if (argc) {
- if (matches(*argv, "reclassify") == 0) {
- sel.action = TC_ACT_RECLASSIFY;
- argc--;
- argv++;
- } else if (matches(*argv, "pipe") == 0) {
- sel.action = TC_ACT_PIPE;
- argc--;
- argv++;
- } else if (matches(*argv, "drop") == 0 ||
- matches(*argv, "shot") == 0) {
- sel.action = TC_ACT_SHOT;
- argc--;
- argv++;
- } else if (matches(*argv, "continue") == 0) {
- sel.action = TC_ACT_UNSPEC;
- argc--;
- argv++;
- } else if (matches(*argv, "pass") == 0 ||
- matches(*argv, "ok") == 0) {
- sel.action = TC_ACT_OK;
- argc--;
- argv++;
- }
- }
+ if (argc && !action_a2n(*argv, &sel.action, false))
+ NEXT_ARG_FWD();
if (argc) {
if (matches(*argv, "index") == 0) {
return -1;
}
- if (argc) {
- if (matches(*argv, "reclassify") == 0) {
- sel.sel.action = TC_ACT_RECLASSIFY;
- NEXT_ARG();
- } else if (matches(*argv, "pipe") == 0) {
- sel.sel.action = TC_ACT_PIPE;
- NEXT_ARG();
- } else if (matches(*argv, "drop") == 0 ||
- matches(*argv, "shot") == 0) {
- sel.sel.action = TC_ACT_SHOT;
- NEXT_ARG();
- } else if (matches(*argv, "continue") == 0) {
- sel.sel.action = TC_ACT_UNSPEC;
- NEXT_ARG();
- } else if (matches(*argv, "pass") == 0 ||
- matches(*argv, "ok") == 0) {
- sel.sel.action = TC_ACT_OK;
- NEXT_ARG();
- }
- }
+ if (argc && !action_a2n(*argv, &sel.sel.action, false))
+ NEXT_ARG();
if (argc) {
if (matches(*argv, "index") == 0) {
}
}
-static int police_action_a2n(const char *arg, int *result)
-{
- int res;
-
- if (matches(arg, "continue") == 0)
- res = -1;
- else if (matches(arg, "drop") == 0)
- res = TC_POLICE_SHOT;
- else if (matches(arg, "shot") == 0)
- res = TC_POLICE_SHOT;
- else if (matches(arg, "pass") == 0)
- res = TC_POLICE_OK;
- else if (strcmp(arg, "ok") == 0)
- res = TC_POLICE_OK;
- else if (matches(arg, "reclassify") == 0)
- res = TC_POLICE_RECLASSIFY;
- else if (matches(arg, "pipe") == 0)
- res = TC_POLICE_PIPE;
- else {
- char dummy;
-
- if (sscanf(arg, "%d%c", &res, &dummy) != 1)
- return -1;
- }
- *result = res;
- return 0;
-}
-
static int get_police_result(int *action, int *result, char *arg)
{
char *p = strchr(arg, '/');
if (p)
*p = 0;
- if (police_action_a2n(arg, action)) {
+ if (action_a2n(arg, action, true)) {
if (p)
*p = '/';
return -1;
if (p) {
*p = '/';
- if (police_action_a2n(p+1, result))
+ if (action_a2n(p+1, result, true))
return -1;
}
return 0;
}
}
- if (argc) {
- if (matches(*argv, "reclassify") == 0) {
- sel.action = TC_ACT_RECLASSIFY;
- argc--;
- argv++;
- } else if (matches(*argv, "pipe") == 0) {
- sel.action = TC_ACT_PIPE;
- argc--;
- argv++;
- } else if (matches(*argv, "drop") == 0 ||
- matches(*argv, "shot") == 0) {
- sel.action = TC_ACT_SHOT;
- argc--;
- argv++;
- } else if (matches(*argv, "continue") == 0) {
- sel.action = TC_ACT_UNSPEC;
- argc--;
- argv++;
- } else if (matches(*argv, "pass") == 0 ||
- matches(*argv, "ok") == 0) {
- sel.action = TC_ACT_OK;
- argc--;
- argv++;
- }
- }
+ if (argc && !action_a2n(*argv, &sel.action, false))
+ NEXT_ARG_FWD();
if (argc) {
if (matches(*argv, "index") == 0) {
}
sel.action = TC_ACT_PIPE;
- if (argc) {
- if (matches(*argv, "reclassify") == 0) {
- sel.action = TC_ACT_RECLASSIFY;
- NEXT_ARG();
- } else if (matches(*argv, "pipe") == 0) {
- sel.action = TC_ACT_PIPE;
- NEXT_ARG();
- } else if (matches(*argv, "drop") == 0 ||
- matches(*argv, "shot") == 0) {
- sel.action = TC_ACT_SHOT;
- NEXT_ARG();
- } else if (matches(*argv, "continue") == 0) {
- sel.action = TC_ACT_UNSPEC;
- NEXT_ARG();
- } else if (matches(*argv, "pass") == 0 ||
- matches(*argv, "ok") == 0) {
- sel.action = TC_ACT_OK;
- NEXT_ARG();
- }
- }
+ if (argc && !action_a2n(*argv, &sel.action, false))
+ NEXT_ARG();
if (argc) {
if (matches(*argv, "index") == 0) {
}
parm.action = TC_ACT_PIPE;
- if (argc) {
- if (matches(*argv, "reclassify") == 0) {
- parm.action = TC_ACT_RECLASSIFY;
- argc--;
- argv++;
- } else if (matches(*argv, "pipe") == 0) {
- parm.action = TC_ACT_PIPE;
- argc--;
- argv++;
- } else if (matches(*argv, "drop") == 0 ||
- matches(*argv, "shot") == 0) {
- parm.action = TC_ACT_SHOT;
- argc--;
- argv++;
- } else if (matches(*argv, "continue") == 0) {
- parm.action = TC_ACT_UNSPEC;
- argc--;
- argv++;
- } else if (matches(*argv, "pass") == 0 ||
- matches(*argv, "ok") == 0) {
- parm.action = TC_ACT_OK;
- argc--;
- argv++;
- }
- }
+ if (argc && !action_a2n(*argv, &parm.action, false))
+ NEXT_ARG_FWD();
if (argc) {
if (matches(*argv, "index") == 0) {