]>
git.proxmox.com Git - mirror_iproute2.git/blob - tc/tc_exec.c
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
9 * Authors: Daniel Borkmann <daniel@iogearbox.net>
19 #include "tc_common.h"
21 static struct exec_util
*exec_list
;
24 static void usage(void)
26 fprintf(stderr
, "Usage: tc exec [ EXEC_TYPE ] [ help | OPTIONS ]\n");
27 fprintf(stderr
, "Where:\n");
28 fprintf(stderr
, "EXEC_TYPE := { bpf | etc. }\n");
29 fprintf(stderr
, "OPTIONS := ... try tc exec <desired EXEC_KIND> help\n");
32 static int parse_noeopt(struct exec_util
*eu
, int argc
, char **argv
)
35 fprintf(stderr
, "Unknown exec \"%s\", hence option \"%s\" is unparsable\n",
43 static struct exec_util
*get_exec_kind(const char *name
)
49 for (eu
= exec_list
; eu
; eu
= eu
->next
)
50 if (strcmp(eu
->id
, name
) == 0)
53 snprintf(buf
, sizeof(buf
), "%s/e_%s.so", get_tc_lib(), name
);
54 dlh
= dlopen(buf
, RTLD_LAZY
);
58 dlh
= BODY
= dlopen(NULL
, RTLD_LAZY
);
64 snprintf(buf
, sizeof(buf
), "%s_exec_util", name
);
74 eu
= calloc(1, sizeof(*eu
));
76 strncpy(eu
->id
, name
, sizeof(eu
->id
) - 1);
77 eu
->parse_eopt
= parse_noeopt
;
84 int do_exec(int argc
, char **argv
)
87 char kind
[FILTER_NAMESZ
] = {};
90 fprintf(stderr
, "No command given, try \"tc exec help\".\n");
94 if (matches(*argv
, "help") == 0) {
99 strncpy(kind
, *argv
, sizeof(kind
) - 1);
101 eu
= get_exec_kind(kind
);
106 return eu
->parse_eopt(eu
, argc
, argv
);