int show_stats = 0;
int show_details = 0;
int show_raw = 0;
+int show_pretty = 0;
+
int resolve_hosts = 0;
int use_iec = 0;
int force = 0;
struct rtnl_handle rth;
-static void *BODY; /* cached handle dlopen(NULL) */
+static void *BODY = NULL; /* cached handle dlopen(NULL) */
static struct qdisc_util * qdisc_list;
static struct filter_util * filter_list;
-static int print_noqopt(struct qdisc_util *qu, FILE *f,
+static int print_noqopt(struct qdisc_util *qu, FILE *f,
struct rtattr *opt)
{
if (opt && RTA_PAYLOAD(opt))
- fprintf(f, "[Unknown qdisc, optlen=%u] ",
+ fprintf(f, "[Unknown qdisc, optlen=%u] ",
(unsigned) RTA_PAYLOAD(opt));
return 0;
}
static int print_nofopt(struct filter_util *qu, FILE *f, struct rtattr *opt, __u32 fhandle)
{
if (opt && RTA_PAYLOAD(opt))
- fprintf(f, "fh %08x [Unknown filter, optlen=%u] ",
+ fprintf(f, "fh %08x [Unknown filter, optlen=%u] ",
fhandle, (unsigned) RTA_PAYLOAD(opt));
else if (fhandle)
fprintf(f, "fh %08x ", fhandle);
if (strcmp(q->id, str) == 0)
return q;
- snprintf(buf, sizeof(buf), "/usr/lib/tc/q_%s.so", str);
+ snprintf(buf, sizeof(buf), "%s/q_%s.so", get_tc_lib(), str);
dlh = dlopen(buf, RTLD_LAZY);
if (!dlh) {
/* look in current binary, only open once */
if (strcmp(q->id, str) == 0)
return q;
- snprintf(buf, sizeof(buf), "/usr/lib/tc/f_%s.so", str);
+ snprintf(buf, sizeof(buf), "%s/f_%s.so", get_tc_lib(), str);
dlh = dlopen(buf, RTLD_LAZY);
if (dlh == NULL) {
dlh = BODY;
static void usage(void)
{
fprintf(stderr, "Usage: tc [ OPTIONS ] OBJECT { COMMAND | help }\n"
- "where OBJECT := { qdisc | class | filter | action }\n"
- " OPTIONS := { -s[tatistics] | -d[etails] | -r[aw] | -b[atch] [file] }\n");
+ " tc [-force] -batch filename\n"
+ "where OBJECT := { qdisc | class | filter | action | monitor }\n"
+ " OPTIONS := { -s[tatistics] | -d[etails] | -r[aw] | -p[retty] | -b[atch] [filename] }\n");
}
static int do_cmd(int argc, char **argv)
if (matches(*argv, "actions") == 0)
return do_action(argc-1, argv+1);
+ if (matches(*argv, "monitor") == 0)
+ return do_tcmonitor(argc-1, argv+1);
+
if (matches(*argv, "help") == 0) {
usage();
return 0;
}
-
- fprintf(stderr, "Object \"%s\" is unknown, try \"tc help\".\n",
+
+ fprintf(stderr, "Object \"%s\" is unknown, try \"tc help\".\n",
*argv);
return -1;
}
if (name && strcmp(name, "-") != 0) {
if (freopen(name, "r", stdin) == NULL) {
- fprintf(stderr, "Cannot open file \"%s\" for reading: %s=n",
+ fprintf(stderr, "Cannot open file \"%s\" for reading: %s\n",
name, strerror(errno));
return -1;
}
break;
}
}
+ if (line)
+ free(line);
rtnl_close(&rth);
return ret;
++show_details;
} else if (matches(argv[1], "-raw") == 0) {
++show_raw;
+ } else if (matches(argv[1], "-pretty") == 0) {
+ ++show_pretty;
} else if (matches(argv[1], "-Version") == 0) {
printf("tc utility, iproute2-ss%s\n", SNAPSHOT);
return 0;