addattr_l(nlh, 128, CTRL_ATTR_FAMILY_NAME, family, strlen(family) + 1);
- if (rtnl_talk(&rth, nlh, 0, 0, nlh, NULL, NULL) < 0) {
+ if (rtnl_talk(&rth, nlh, 0, 0, nlh) < 0) {
fprintf(stderr, "Error talking to the kernel\n");
goto errout;
}
goto ctrl_done;
}
- if (rtnl_talk(&rth, nlh, 0, 0, nlh, NULL, NULL) < 0) {
+ if (rtnl_talk(&rth, nlh, 0, 0, nlh) < 0) {
fprintf(stderr, "Error talking to the kernel\n");
goto ctrl_done;
}
goto ctrl_done;
}
- rtnl_dump_filter(&rth, print_ctrl, stdout, NULL, NULL);
+ rtnl_dump_filter(&rth, print_ctrl, stdout);
}
{
rtnl_filter_t filter;
void *arg1;
- rtnl_filter_t junk;
- void *arg2;
};
extern int rtnl_dump_filter_l(struct rtnl_handle *rth,
const struct rtnl_dump_filter_arg *arg);
extern int rtnl_dump_filter(struct rtnl_handle *rth, rtnl_filter_t filter,
- void *arg1,
- rtnl_filter_t junk,
- void *arg2);
-
+ void *arg);
extern int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer,
- unsigned groups, struct nlmsghdr *answer,
- rtnl_filter_t junk,
- void *jarg);
+ unsigned groups, struct nlmsghdr *answer);
extern int rtnl_send(struct rtnl_handle *rth, const void *buf, int);
extern int rtnl_send_check(struct rtnl_handle *rth, const void *buf, int);
(parse_rtattr((tb), (max), RTA_DATA(rta), RTA_PAYLOAD(rta)))
#define parse_rtattr_nested_compat(tb, max, rta, data, len) \
-({ data = RTA_PAYLOAD(rta) >= len ? RTA_DATA(rta) : NULL; \
- __parse_rtattr_nested_compat(tb, max, rta, len); })
+ ({ data = RTA_PAYLOAD(rta) >= len ? RTA_DATA(rta) : NULL; \
+ __parse_rtattr_nested_compat(tb, max, rta, len); })
extern int rtnl_listen(struct rtnl_handle *, rtnl_filter_t handler,
void *jarg);
exit(1);
}
- if (rtnl_dump_filter(&rth, store_nlmsg, &linfo, NULL, NULL) < 0) {
+ if (rtnl_dump_filter(&rth, store_nlmsg, &linfo) < 0) {
fprintf(stderr, "Dump terminated\n");
exit(1);
}
{
.filter = print_addrinfo_secondary,
.arg1 = stdout,
- .junk = NULL,
- .arg2 = NULL
},
{
.filter = print_addrinfo_primary,
.arg1 = stdout,
- .junk = NULL,
- .arg2 = NULL
},
{
.filter = NULL,
.arg1 = NULL,
- .junk = NULL,
- .arg2 = NULL
},
};
if (rtnl_wilddump_request(&rth, filter.family, RTM_GETADDR) < 0) {
exit(1);
}
- if (rtnl_dump_filter(&rth, store_nlmsg, &ainfo, NULL, NULL) < 0) {
+ if (rtnl_dump_filter(&rth, store_nlmsg, &ainfo) < 0) {
fprintf(stderr, "Dump terminated\n");
exit(1);
}
sizeof(cinfo));
}
- if (rtnl_talk(&rth, &req.n, 0, 0, NULL, NULL, NULL) < 0)
+ if (rtnl_talk(&rth, &req.n, 0, 0, NULL) < 0)
return -2;
return 0;
return 1;
}
- if (rtnl_dump_filter(&rth, print_addrlabel, stdout, NULL, NULL) < 0) {
+ if (rtnl_dump_filter(&rth, print_addrlabel, stdout) < 0) {
fprintf(stderr, "Dump terminated\n");
return 1;
}
if (req.ifal.ifal_family == AF_UNSPEC)
req.ifal.ifal_family = AF_INET6;
- if (rtnl_talk(&rth, &req.n, 0, 0, NULL, NULL, NULL) < 0)
+ if (rtnl_talk(&rth, &req.n, 0, 0, NULL) < 0)
return 2;
return 0;
if (rtnl_open(&rth2, 0) < 0)
return -1;
- if (rtnl_talk(&rth2, n, 0, 0, NULL, NULL, NULL) < 0)
+ if (rtnl_talk(&rth2, n, 0, 0, NULL) < 0)
return -2;
rtnl_close(&rth2);
return 1;
}
- if (rtnl_dump_filter(&rth, flush_addrlabel, NULL, NULL, NULL) < 0) {
+ if (rtnl_dump_filter(&rth, flush_addrlabel, NULL) < 0) {
fprintf(stderr, "Flush terminated\n");
return 1;
}
req.i.ifi_index = 0;
addattr32(&req.n, sizeof(req), IFLA_GROUP, group);
- if (rtnl_talk(&rth, &req.n, 0, 0, NULL, NULL, NULL) < 0)
+ if (rtnl_talk(&rth, &req.n, 0, 0, NULL) < 0)
exit(2);
return 0;
}
addattr_l(&req.n, sizeof(req), IFLA_IFNAME, name, len);
}
- if (rtnl_talk(&rth, &req.n, 0, 0, NULL, NULL, NULL) < 0)
+ if (rtnl_talk(&rth, &req.n, 0, 0, NULL) < 0)
exit(2);
return 0;
return -1;
}
- if (rtnl_talk(&rth, &req.n, 0, 0, NULL, NULL, NULL) < 0)
+ if (rtnl_talk(&rth, &req.n, 0, 0, NULL) < 0)
exit(2);
return 0;
exit(1);
}
filter.flushed = 0;
- if (rtnl_dump_filter(&rth, print_neigh, stdout, NULL, NULL) < 0) {
+ if (rtnl_dump_filter(&rth, print_neigh, stdout) < 0) {
fprintf(stderr, "Flush terminated\n");
exit(1);
}
exit(1);
}
- if (rtnl_dump_filter(&rth, print_neigh, stdout, NULL, NULL) < 0) {
+ if (rtnl_dump_filter(&rth, print_neigh, stdout) < 0) {
fprintf(stderr, "Dump terminated\n");
exit(1);
}
RTA_PAYLOAD(parms_rta));
}
- if (rtnl_talk(&rth, &req.n, 0, 0, NULL, NULL, NULL) < 0)
+ if (rtnl_talk(&rth, &req.n, 0, 0, NULL) < 0)
exit(2);
return 0;
exit(1);
}
- if (rtnl_dump_filter(&rth, print_ntable, stdout, NULL, NULL) < 0) {
+ if (rtnl_dump_filter(&rth, print_ntable, stdout) < 0) {
fprintf(stderr, "Dump terminated\n");
exit(1);
}
if (req.r.rtm_family == AF_UNSPEC)
req.r.rtm_family = AF_INET;
- if (rtnl_talk(&rth, &req.n, 0, 0, NULL, NULL, NULL) < 0)
+ if (rtnl_talk(&rth, &req.n, 0, 0, NULL) < 0)
exit(2);
return 0;
exit(1);
}
filter.flushed = 0;
- if (rtnl_dump_filter(&rth, filter_fn, stdout, NULL, NULL) < 0) {
+ if (rtnl_dump_filter(&rth, filter_fn, stdout) < 0) {
fprintf(stderr, "Flush terminated\n");
exit(1);
}
}
}
- if (rtnl_dump_filter(&rth, filter_fn, stdout, NULL, NULL) < 0) {
+ if (rtnl_dump_filter(&rth, filter_fn, stdout) < 0) {
fprintf(stderr, "Dump terminated\n");
exit(1);
}
if (req.r.rtm_family == AF_UNSPEC)
req.r.rtm_family = AF_INET;
- if (rtnl_talk(&rth, &req.n, 0, 0, &req.n, NULL, NULL) < 0)
+ if (rtnl_talk(&rth, &req.n, 0, 0, &req.n) < 0)
exit(2);
if (connected && !from_ok) {
req.n.nlmsg_flags = NLM_F_REQUEST;
req.n.nlmsg_type = RTM_GETROUTE;
- if (rtnl_talk(&rth, &req.n, 0, 0, &req.n, NULL, NULL) < 0)
+ if (rtnl_talk(&rth, &req.n, 0, 0, &req.n) < 0)
exit(2);
}
ll_init_map(&rth);
- ret = rtnl_talk(&rth, n, 0, 0, n, NULL, NULL);
+ ret = rtnl_talk(&rth, n, 0, 0, n);
if ((ret < 0) && (errno == EEXIST))
ret = 0;
return 1;
}
- if (rtnl_dump_filter(&rth, print_rule, stdout, NULL, NULL) < 0) {
+ if (rtnl_dump_filter(&rth, print_rule, stdout) < 0) {
fprintf(stderr, "Dump terminated\n");
return 1;
}
if (!table_ok && cmd == RTM_NEWRULE)
req.r.rtm_table = RT_TABLE_MAIN;
- if (rtnl_talk(&rth, &req.n, 0, 0, NULL, NULL, NULL) < 0)
+ if (rtnl_talk(&rth, &req.n, 0, 0, NULL) < 0)
return 2;
return 0;
if (rtnl_open(&rth2, 0) < 0)
return -1;
- if (rtnl_talk(&rth2, n, 0, 0, NULL, NULL, NULL) < 0)
+ if (rtnl_talk(&rth2, n, 0, 0, NULL) < 0)
return -2;
rtnl_close(&rth2);
return 1;
}
- if (rtnl_dump_filter(&rth, flush_rule, NULL, NULL, NULL) < 0) {
+ if (rtnl_dump_filter(&rth, flush_rule, NULL) < 0) {
fprintf(stderr, "Flush terminated\n");
return 1;
}
req.i.ifi_family = preferred_family;
req.i.ifi_index = ifi->ifi_index;
- if (rtnl_talk(&rth, &req.n, 0, 0, &req.n, NULL, NULL) < 0) {
+ if (rtnl_talk(&rth, &req.n, 0, 0, &req.n) < 0) {
get_failed:
fprintf(stderr,
"Failed to get existing tunnel info.\n");
write_stamp(fp);
- if (rtnl_dump_filter(&rth, dump_msg, fp, NULL, NULL) < 0) {
+ if (rtnl_dump_filter(&rth, dump_msg, fp) < 0) {
fprintf(stderr, "Dump terminated\n");
return 1;
}
if (req.xpinfo.sel.family == AF_UNSPEC)
req.xpinfo.sel.family = AF_INET;
- if (rtnl_talk(&rth, &req.n, 0, 0, NULL, NULL, NULL) < 0)
+ if (rtnl_talk(&rth, &req.n, 0, 0, NULL) < 0)
exit(2);
rtnl_close(&rth);
(void *)&ctx, ctx.sctx.len);
}
- if (rtnl_talk(&rth, &req.n, 0, 0, res_nlbuf, NULL, NULL) < 0)
+ if (rtnl_talk(&rth, &req.n, 0, 0, res_nlbuf) < 0)
exit(2);
rtnl_close(&rth);
exit(1);
}
- if (rtnl_dump_filter(&rth, xfrm_policy_keep, &xb, NULL, NULL) < 0) {
+ if (rtnl_dump_filter(&rth, xfrm_policy_keep, &xb) < 0) {
fprintf(stderr, "Delete-all terminated\n");
exit(1);
}
exit(1);
}
- if (rtnl_dump_filter(&rth, xfrm_policy_print, stdout, NULL, NULL) < 0) {
+ if (rtnl_dump_filter(&rth, xfrm_policy_print, stdout) < 0) {
fprintf(stderr, "Dump terminated\n");
exit(1);
}
if (rtnl_open_byproto(&rth, 0, NETLINK_XFRM) < 0)
exit(1);
- if (rtnl_talk(&rth, &req.n, 0, 0, &req.n, NULL, NULL) < 0)
+ if (rtnl_talk(&rth, &req.n, 0, 0, &req.n) < 0)
exit(2);
print_spdinfo(&req.n, (void*)stdout);
if (show_stats > 1)
fprintf(stderr, "Flush policy\n");
- if (rtnl_talk(&rth, &req.n, 0, 0, NULL, NULL, NULL) < 0)
+ if (rtnl_talk(&rth, &req.n, 0, 0, NULL) < 0)
exit(2);
rtnl_close(&rth);
if (req.xsinfo.family == AF_UNSPEC)
req.xsinfo.family = AF_INET;
- if (rtnl_talk(&rth, &req.n, 0, 0, NULL, NULL, NULL) < 0)
+ if (rtnl_talk(&rth, &req.n, 0, 0, NULL) < 0)
exit(2);
rtnl_close(&rth);
req.xspi.info.family = AF_INET;
- if (rtnl_talk(&rth, &req.n, 0, 0, res_n, NULL, NULL) < 0)
+ if (rtnl_talk(&rth, &req.n, 0, 0, res_n) < 0)
exit(2);
if (xfrm_state_print(NULL, res_n, (void*)stdout) < 0) {
req.xsid.family = AF_INET;
if (delete) {
- if (rtnl_talk(&rth, &req.n, 0, 0, NULL, NULL, NULL) < 0)
+ if (rtnl_talk(&rth, &req.n, 0, 0, NULL) < 0)
exit(2);
} else {
char buf[NLMSG_BUF_SIZE];
memset(buf, 0, sizeof(buf));
- if (rtnl_talk(&rth, &req.n, 0, 0, res_n, NULL, NULL) < 0)
+ if (rtnl_talk(&rth, &req.n, 0, 0, res_n) < 0)
exit(2);
if (xfrm_state_print(NULL, res_n, (void*)stdout) < 0) {
exit(1);
}
- if (rtnl_dump_filter(&rth, xfrm_state_keep, &xb, NULL, NULL) < 0) {
+ if (rtnl_dump_filter(&rth, xfrm_state_keep, &xb) < 0) {
fprintf(stderr, "Delete-all terminated\n");
exit(1);
}
exit(1);
}
- if (rtnl_dump_filter(&rth, xfrm_state_print, stdout, NULL, NULL) < 0) {
+ if (rtnl_dump_filter(&rth, xfrm_state_print, stdout) < 0) {
fprintf(stderr, "Dump terminated\n");
exit(1);
}
if (rtnl_open_byproto(&rth, 0, NETLINK_XFRM) < 0)
exit(1);
- if (rtnl_talk(&rth, &req.n, 0, 0, &req.n, NULL, NULL) < 0)
+ if (rtnl_talk(&rth, &req.n, 0, 0, &req.n) < 0)
exit(2);
print_sadinfo(&req.n, (void*)stdout);
fprintf(stderr, "Flush state proto=%s\n",
strxf_xfrmproto(req.xsf.proto));
- if (rtnl_talk(&rth, &req.n, 0, 0, NULL, NULL, NULL) < 0)
+ if (rtnl_talk(&rth, &req.n, 0, 0, NULL) < 0)
exit(2);
rtnl_close(&rth);
if (nladdr.nl_pid != 0 ||
h->nlmsg_pid != rth->local.nl_pid ||
- h->nlmsg_seq != rth->dump) {
- if (a->junk) {
- err = a->junk(&nladdr, h,
- a->arg2);
- if (err < 0)
- return err;
- }
+ h->nlmsg_seq != rth->dump)
goto skip_it;
- }
if (h->nlmsg_type == NLMSG_DONE) {
found_done = 1;
int rtnl_dump_filter(struct rtnl_handle *rth,
rtnl_filter_t filter,
- void *arg1,
- rtnl_filter_t junk,
- void *arg2)
+ void *arg1)
{
const struct rtnl_dump_filter_arg a[2] = {
- { .filter = filter, .arg1 = arg1, .junk = junk, .arg2 = arg2 },
- { .filter = NULL, .arg1 = NULL, .junk = NULL, .arg2 = NULL }
+ { .filter = filter, .arg1 = arg1, },
+ { .filter = NULL, .arg1 = NULL, },
};
return rtnl_dump_filter_l(rth, a);
}
int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer,
- unsigned groups, struct nlmsghdr *answer,
- rtnl_filter_t junk,
- void *jarg)
+ unsigned groups, struct nlmsghdr *answer)
{
int status;
unsigned seq;
exit(1);
}
for (h = (struct nlmsghdr*)buf; status >= sizeof(*h); ) {
- int err;
int len = h->nlmsg_len;
int l = len - sizeof(*h);
- if (l<0 || len>status) {
+ if (l < 0 || len>status) {
if (msg.msg_flags & MSG_TRUNC) {
fprintf(stderr, "Truncated message\n");
return -1;
if (nladdr.nl_pid != peer ||
h->nlmsg_pid != rtnl->local.nl_pid ||
h->nlmsg_seq != seq) {
- if (junk) {
- err = junk(&nladdr, h, jarg);
- if (err < 0)
- return err;
- }
/* Don't forget to skip that message. */
status -= NLMSG_ALIGN(len);
h = (struct nlmsghdr*)((char*)h + NLMSG_ALIGN(len));
exit(1);
}
- if (rtnl_dump_filter(rth, ll_remember_index, NULL, NULL, NULL) < 0) {
+ if (rtnl_dump_filter(rth, ll_remember_index, NULL) < 0) {
fprintf(stderr, "Dump terminated\n");
exit(1);
}
exit(1);
}
- if (rtnl_dump_filter(&rth, get_nlmsg, NULL, NULL, NULL) < 0) {
+ if (rtnl_dump_filter(&rth, get_nlmsg, NULL) < 0) {
fprintf(stderr, "Dump terminated\n");
exit(1);
}
if (cmd == RTM_GETACTION)
ans = &req.n;
- if (rtnl_talk(&rth, &req.n, 0, 0, ans, NULL, NULL) < 0) {
+ if (rtnl_talk(&rth, &req.n, 0, 0, ans) < 0) {
fprintf(stderr, "We have an error talking to the kernel\n");
return 1;
}
}
tail->rta_len = (void *) NLMSG_TAIL(&req.n) - (void *) tail;
- if (rtnl_talk(&rth, &req.n, 0, 0, NULL, NULL, NULL) < 0) {
+ if (rtnl_talk(&rth, &req.n, 0, 0, NULL) < 0) {
fprintf(stderr, "We have an error talking to the kernel\n");
ret = -1;
}
perror("Cannot send dump request");
return 1;
}
- ret = rtnl_dump_filter(&rth, print_action, stdout, NULL, NULL);
+ ret = rtnl_dump_filter(&rth, print_action, stdout);
}
if (event == RTM_DELACTION) {
req.n.nlmsg_type = RTM_DELACTION;
req.n.nlmsg_flags |= NLM_F_ROOT;
req.n.nlmsg_flags |= NLM_F_REQUEST;
- if (rtnl_talk(&rth, &req.n, 0, 0, NULL, NULL, NULL) < 0) {
+ if (rtnl_talk(&rth, &req.n, 0, 0, NULL) < 0) {
fprintf(stderr, "We have an error flushing\n");
return 1;
}
}
}
- if (rtnl_talk(&rth, &req.n, 0, 0, NULL, NULL, NULL) < 0)
+ if (rtnl_talk(&rth, &req.n, 0, 0, NULL) < 0)
return 2;
return 0;
return 1;
}
- if (rtnl_dump_filter(&rth, print_class, stdout, NULL, NULL) < 0) {
+ if (rtnl_dump_filter(&rth, print_class, stdout) < 0) {
fprintf(stderr, "Dump terminated\n");
return 1;
}
}
}
- if (rtnl_talk(&rth, &req.n, 0, 0, NULL, NULL, NULL) < 0) {
+ if (rtnl_talk(&rth, &req.n, 0, 0, NULL) < 0) {
fprintf(stderr, "We have an error talking to the kernel\n");
return 2;
}
return 1;
}
- if (rtnl_dump_filter(&rth, print_filter, stdout, NULL, NULL) < 0) {
+ if (rtnl_dump_filter(&rth, print_filter, stdout) < 0) {
fprintf(stderr, "Dump terminated\n");
return 1;
}
req.t.tcm_ifindex = idx;
}
- if (rtnl_talk(&rth, &req.n, 0, 0, NULL, NULL, NULL) < 0)
+ if (rtnl_talk(&rth, &req.n, 0, 0, NULL) < 0)
return 2;
return 0;
return 1;
}
- if (rtnl_dump_filter(&rth, print_qdisc, stdout, NULL, NULL) < 0) {
+ if (rtnl_dump_filter(&rth, print_qdisc, stdout) < 0) {
fprintf(stderr, "Dump terminated\n");
return 1;
}