#include "utils.h"
#include "rt_names.h"
+#include "tc_common.h"
#include "tc_util.h"
static void explain(void)
fh &= 0xFFFF;
fh |= id<<16;
} else if (matches(*argv, "fromif") == 0) {
- struct rtnl_handle rth;
__u32 id;
NEXT_ARG();
- if (rtnl_open(&rth, 0) == 0) {
- ll_init_map(&rth);
- rtnl_close(&rth);
- }
+ ll_init_map(&rth);
if ((id=ll_name_to_index(*argv)) <= 0) {
fprintf(stderr, "Illegal \"fromif\"\n");
return -1;
#include <dlfcn.h>
#include "utils.h"
+#include "tc_common.h"
#include "tc_util.h"
static struct action_util * action_list;
int prio = 0;
int ret = 0;
__u32 i;
- struct rtnl_handle rth;
struct sockaddr_nl nladdr;
struct rtattr *tail;
struct rtattr *tail2;
tail->rta_len = (void *) NLMSG_TAIL(&req.n) - (void *) tail;
- if (rtnl_open(&rth, 0) < 0) {
- fprintf(stderr, "Cannot open rtnetlink\n");
- return 1;
- }
-
req.n.nlmsg_seq = rth.dump = ++rth.seq;
if (cmd == RTM_GETACTION)
ans = &req.n;
+
if (rtnl_talk(&rth, &req.n, 0, 0, ans, NULL, NULL) < 0) {
fprintf(stderr, "We have an error talking to the kernel\n");
- rtnl_close(&rth);
return 1;
}
if (ans && do_print_action(NULL, &req.n, (void*)stdout) < 0) {
fprintf(stderr, "Dump terminated\n");
- rtnl_close(&rth);
return 1;
}
*argc_p = argc;
*argv_p = argv;
- rtnl_close(&rth);
bad_val:
return ret;
}
char **argv = *argv_p;
int ret = 0;
- struct rtnl_handle rth;
struct rtattr *tail;
struct {
struct nlmsghdr n;
}
tail->rta_len = (void *) NLMSG_TAIL(&req.n) - (void *) tail;
- if (rtnl_open(&rth, 0) < 0) {
- fprintf(stderr, "Cannot open rtnetlink\n");
- return 1;
- }
-
-
if (rtnl_talk(&rth, &req.n, 0, 0, NULL, NULL, NULL) < 0) {
fprintf(stderr, "We have an error talking to the kernel\n");
ret = -1;
*argc_p = argc;
*argv_p = argv;
- rtnl_close(&rth);
+
return ret;
}
{
int ret = 0, prio = 0, msg_size = 0;
char k[16];
- struct rtnl_handle rth;
struct rtattr *tail,*tail2;
struct action_util *a = NULL;
struct {
tail2->rta_len = (void *) NLMSG_TAIL(&req.n) - (void *) tail2;
tail->rta_len = (void *) NLMSG_TAIL(&req.n) - (void *) tail;
- if (rtnl_open(&rth, 0) < 0) {
- fprintf(stderr, "Cannot open rtnetlink\n");
- return 1;
- }
-
msg_size = NLMSG_ALIGN(req.n.nlmsg_len) - NLMSG_ALIGN(sizeof(struct nlmsghdr));
if (event == RTM_GETACTION) {
req.n.nlmsg_flags |= NLM_F_REQUEST;
if (rtnl_talk(&rth, &req.n, 0, 0, NULL, NULL, NULL) < 0) {
fprintf(stderr, "We have an error flushing\n");
- rtnl_close(&rth);
return 1;
}
bad_val:
- rtnl_close(&rth);
return ret;
}
#include <string.h>
#include "utils.h"
#include "tc_util.h"
+#include "tc_common.h"
#include <linux/tc_act/tc_mirred.h>
int mirred_d = 1;
struct tc_mirred p;
struct rtattr *tail;
char d[16];
- struct rtnl_handle rth;
memset(d,0,sizeof(d)-1);
memset(&p,0,sizeof(struct tc_mirred));
if (d[0]) {
int idx;
- if (rtnl_open(&rth, 0) < 0) {
- fprintf(stderr, "Cannot open rtnetlink\n");
- return 1;
- }
ll_init_map(&rth);
-
if ((idx = ll_name_to_index(d)) == 0) {
fprintf(stderr, "Cannot find device \"%s\"\n", d);
- rtnl_close(&rth);
return -1;
}
p.ifindex = idx;
- rtnl_close(&rth);
}
{
struct tc_mirred *p;
struct rtattr *tb[TCA_MIRRED_MAX + 1];
- struct rtnl_handle rth;
const char *dev;
SPRINT_BUF(b1);
}
p = RTA_DATA(tb[TCA_MIRRED_PARMS]);
- if (rtnl_open(&rth, 0) < 0) {
- fprintf(stderr, "Cannot open rtnetlink\n");
- return -1;
- }
-
ll_init_map(&rth);
-
if ((dev = ll_index_to_name(p->ifindex)) == 0) {
fprintf(stderr, "Cannot find device %d\n", p->ifindex);
- rtnl_close(&rth);
return -1;
}
}
}
fprintf(f, "\n ");
- rtnl_close(&rth);
return 0;
}
int tc_class_list(int argc, char **argv)
{
struct tcmsg t;
- struct rtnl_handle rth;
char d[16];
memset(&t, 0, sizeof(t));
if (rtnl_dump_request(&rth, RTM_GETTCLASS, &t, sizeof(t)) < 0) {
perror("Cannot send dump request");
- rtnl_close(&rth);
return 1;
}
if (rtnl_dump_filter(&rth, print_class, stdout, NULL, NULL) < 0) {
fprintf(stderr, "Dump terminated\n");
- rtnl_close(&rth);
return 1;
}
extern int do_filter(int argc, char **argv);
extern int do_action(int argc, char **argv);
+struct tc_estimator;
extern int parse_estimator(int *p_argc, char ***p_argv, struct tc_estimator *est);
if ((req.t.tcm_ifindex = ll_name_to_index(d)) == 0) {
fprintf(stderr, "Cannot find device \"%s\"\n", d);
- rtnl_close(&rth);
return 1;
}
}
int tc_filter_list(int argc, char **argv)
{
struct tcmsg t;
- struct rtnl_handle rth;
char d[16];
__u32 prio = 0;
__u32 protocol = 0;
if (d[0]) {
if ((t.tcm_ifindex = ll_name_to_index(d)) == 0) {
fprintf(stderr, "Cannot find device \"%s\"\n", d);
- rtnl_close(&rth);
return 1;
}
filter_ifindex = t.tcm_ifindex;
if ((idx = ll_name_to_index(d)) == 0) {
fprintf(stderr, "Cannot find device \"%s\"\n", d);
- rtnl_close(&rth);
return 1;
}
req.t.tcm_ifindex = idx;
int tc_qdisc_list(int argc, char **argv)
{
struct tcmsg t;
- struct rtnl_handle rth;
char d[16];
memset(&t, 0, sizeof(t));
if (d[0]) {
if ((t.tcm_ifindex = ll_name_to_index(d)) == 0) {
fprintf(stderr, "Cannot find device \"%s\"\n", d);
- rtnl_close(&rth);
return 1;
}
filter_ifindex = t.tcm_ifindex;