summaryrefslogtreecommitdiffstats
path: root/tc/tc_util.c
diff options
context:
space:
mode:
authorosdl.net!shemminger <osdl.net!shemminger>2004-08-13 23:54:55 +0000
committerosdl.net!shemminger <osdl.net!shemminger>2004-08-13 23:54:55 +0000
commit2373fde9b0ba14c1758290a68332f1af9882abc0 (patch)
tree79d714dd5dd74ddfb502dbeaa7984b9b9737f618 /tc/tc_util.c
parent6d3692a94ce4d4c3a4c38eb5065ff89bde910a05 (diff)
new stuff from jamal.
(Logical change 1.66)
Diffstat (limited to 'tc/tc_util.c')
-rw-r--r--tc/tc_util.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/tc/tc_util.c b/tc/tc_util.c
index d87085c2..ad72b63e 100644
--- a/tc/tc_util.c
+++ b/tc/tc_util.c
@@ -369,4 +369,62 @@ char * sprint_qdisc_handle(__u32 h, char *buf)
return buf;
}
+char * action_n2a(int action, char *buf, int len)
+{
+ switch (action) {
+ case -1:
+ 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:
+ return "pipe";
+ case TC_ACT_STOLEN:
+ return "stolen";
+ default:
+ snprintf(buf, len, "%d", action);
+ return buf;
+ }
+}
+int action_a2n(char *arg, int *result)
+{
+ int res;
+
+ if (matches(arg, "continue") == 0)
+ res = -1;
+ else if (matches(arg, "drop") == 0)
+ res = TC_ACT_SHOT;
+ else if (matches(arg, "shot") == 0)
+ res = TC_ACT_SHOT;
+ else if (matches(arg, "pass") == 0)
+ res = TC_ACT_OK;
+ else if (strcmp(arg, "ok") == 0)
+ res = TC_ACT_OK;
+ else if (matches(arg, "reclassify") == 0)
+ res = TC_ACT_RECLASSIFY;
+ else {
+ char dummy;
+ if (sscanf(arg, "%d%c", &res, &dummy) != 1)
+ return -1;
+ }
+ *result = res;
+ return 0;
+}
+
+void print_tm(FILE * f, struct tcf_t *tm)
+{
+ int hz = get_hz();
+ if (tm->install != 0)
+ fprintf(f, " installed %d sec", tm->install/hz);
+ if (tm->lastuse != 0)
+ fprintf(f, " used %d sec", tm->lastuse/hz);
+ if (tm->expires != 0)
+ fprintf(f, " expires %d sec", tm->expires/hz);
+}