struct rtattr *tb[TCA_ACT_BPF_MAX + 1];
struct tc_act_bpf *parm;
- SPRINT_BUF(action_buf);
-
if (arg == NULL)
return -1;
fprintf(f, " ");
}
- fprintf(f, "default-action %s\n", action_n2a(parm->action, action_buf,
- sizeof(action_buf)));
+ fprintf(f, "default-action %s\n", action_n2a(parm->action));
fprintf(f, "\tindex %d ref %d bind %d", parm->index, parm->refcnt,
parm->bindcnt);
char *uflag_5 = "";
char *uflag_6 = "";
- SPRINT_BUF(action_buf);
-
int uflag_count = 0;
if (arg == NULL)
fprintf(f, "csum (%s%s%s%s%s%s) action %s\n",
uflag_1, uflag_2, uflag_3,
uflag_4, uflag_5, uflag_6,
- action_n2a(sel->action, action_buf, sizeof(action_buf)));
+ action_n2a(sel->action));
fprintf(f, "\tindex %d ref %d bind %d", sel->index, sel->refcnt, sel->bindcnt);
if (show_stats) {
static int
print_gact(struct action_util *au, FILE * f, struct rtattr *arg)
{
- SPRINT_BUF(b1);
#ifdef CONFIG_GACT_PROB
- SPRINT_BUF(b2);
struct tc_gact_p *pp = NULL;
struct tc_gact_p pp_dummy;
#endif
}
p = RTA_DATA(tb[TCA_GACT_PARMS]);
- fprintf(f, "gact action %s", action_n2a(p->action, b1, sizeof(b1)));
+ fprintf(f, "gact action %s", action_n2a(p->action));
#ifdef CONFIG_GACT_PROB
if (tb[TCA_GACT_PROB] != NULL) {
pp = RTA_DATA(tb[TCA_GACT_PROB]);
memset(&pp_dummy, 0, sizeof(pp_dummy));
pp = &pp_dummy;
}
- fprintf(f, "\n\t random type %s %s val %d", prob_n2a(pp->ptype), action_n2a(pp->paction, b2, sizeof (b2)), pp->pval);
+ fprintf(f, "\n\t random type %s %s val %d",
+ prob_n2a(pp->ptype), action_n2a(pp->paction), pp->pval);
#endif
fprintf(f, "\n\t index %d ref %d bind %d", p->index, p->refcnt, p->bindcnt);
if (show_stats) {
__u32 mhash = 0;
__u32 mprio = 0;
int has_optional = 0;
- SPRINT_BUF(b1);
SPRINT_BUF(b2);
if (arg == NULL)
fprintf(f, "ife %s action %s ",
(p->flags & IFE_ENCODE) ? "encode" : "decode",
- action_n2a(p->action, b1, sizeof(b1)));
+ action_n2a(p->action));
if (tb[TCA_IFE_TYPE]) {
ife_type = rta_getattr_u16(tb[TCA_IFE_TYPE]);
struct rtattr *tb[TCA_MIRRED_MAX + 1];
const char *dev;
- SPRINT_BUF(b1);
-
if (arg == NULL)
return -1;
return -1;
}
- fprintf(f, "mirred (%s to device %s) %s", mirred_n2a(p->eaction), dev, action_n2a(p->action, b1, sizeof (b1)));
+ fprintf(f, "mirred (%s to device %s) %s",
+ mirred_n2a(p->eaction), dev, action_n2a(p->action));
fprintf(f, "\n ");
fprintf(f, "\tindex %d ref %d bind %d", p->index, p->refcnt, p->bindcnt);
char buf1[256];
char buf2[256];
- SPRINT_BUF(buf3);
int len;
if (arg == NULL)
format_host_r(AF_INET, 4, &sel->old_addr, buf1, sizeof(buf1)),
len,
format_host_r(AF_INET, 4, &sel->new_addr, buf2, sizeof(buf2)),
- action_n2a(sel->action, buf3, sizeof(buf3)));
+ action_n2a(sel->action));
if (show_stats) {
if (tb[TCA_NAT_TM]) {
struct tc_pedit_sel *sel;
struct rtattr *tb[TCA_PEDIT_MAX + 1];
- SPRINT_BUF(b1);
-
if (arg == NULL)
return -1;
sel = RTA_DATA(tb[TCA_PEDIT_PARMS]);
fprintf(f, " pedit action %s keys %d\n ",
- action_n2a(sel->action, b1, sizeof(b1)), sel->nkeys);
+ action_n2a(sel->action), sel->nkeys);
fprintf(f, "\t index %d ref %d bind %d", sel->index, sel->refcnt,
sel->bindcnt);
fprintf(stderr, "Illegal \"%s\"\n", arg);
}
-static const char *police_action_n2a(int action, char *buf, int len)
-{
- switch (action) {
- case -1:
- return "continue";
- break;
- case TC_POLICE_OK:
- return "pass";
- break;
- case TC_POLICE_SHOT:
- return "drop";
- break;
- case TC_POLICE_RECLASSIFY:
- return "reclassify";
- case TC_POLICE_PIPE:
- return "pipe";
- default:
- snprintf(buf, len, "%d", action);
- return buf;
- }
-}
-
static int get_police_result(int *action, int *result, char *arg)
{
char *p = strchr(arg, '/');
fprintf(f, "avrate %s ",
sprint_rate(rta_getattr_u32(tb[TCA_POLICE_AVRATE]),
b1));
- fprintf(f, "action %s",
- police_action_n2a(p->action, b1, sizeof(b1)));
+ fprintf(f, "action %s", action_n2a(p->action));
if (tb[TCA_POLICE_RESULT]) {
__u32 action = rta_getattr_u32(tb[TCA_POLICE_RESULT]);
- fprintf(f, "/%s",
- police_action_n2a(action, b1, sizeof(b1)));
+ fprintf(f, "/%s", action_n2a(action));
} else
fprintf(f, " ");
}
break;
}
- fprintf(f, " %s", action_n2a(parm->action, b1, sizeof(b1)));
+ fprintf(f, " %s", action_n2a(parm->action));
fprintf(f, "\n\t index %d ref %d bind %d", parm->index, parm->refcnt,
parm->bindcnt);
return buf;
}
-char *action_n2a(int action, char *buf, int len)
+const char *action_n2a(int action)
{
+ static char buf[64];
+
switch (action) {
- case -1:
+ case TC_ACT_UNSPEC:
return "continue";
- break;
case TC_ACT_OK:
return "pass";
- break;
case TC_ACT_SHOT:
return "drop";
- break;
case TC_ACT_RECLASSIFY:
return "reclassify";
case TC_ACT_PIPE:
case TC_ACT_STOLEN:
return "stolen";
default:
- snprintf(buf, len, "%d", action);
+ snprintf(buf, 64, "%d", action);
+ buf[63] = '\0';
return buf;
}
}
int tc_print_police(FILE *f, struct rtattr *tb);
int parse_police(int *argc_p, char ***argv_p, int tca_id, struct nlmsghdr *n);
-char *action_n2a(int action, char *buf, int len);
+const char *action_n2a(int action);
int action_a2n(char *arg, int *result, bool allow_num);
int act_parse_police(struct action_util *a, int *argc_p,
char ***argv_p, int tca_id, struct nlmsghdr *n);