rtnl_filter_t junk,
void *jarg);
extern int rtnl_send(struct rtnl_handle *rth, const char *buf, int);
-
+extern int rtnl_send_check(struct rtnl_handle *rth, const char *buf, int);
extern int addattr32(struct nlmsghdr *n, int maxlen, int type, __u32 data);
extern int addattr_l(struct nlmsghdr *n, int maxlen, int type, const void *data, int alen);
static int flush_update(void)
{
- if (rtnl_send(&rth, filter.flushb, filter.flushp) < 0) {
+ if (rtnl_send_check(&rth, filter.flushb, filter.flushp) < 0) {
perror("Failed to send flush request");
return -1;
}
static int flush_update(void)
{
- if (rtnl_send(&rth, filter.flushb, filter.flushp) < 0) {
+ if (rtnl_send_check(&rth, filter.flushb, filter.flushp) < 0) {
perror("Failed to send flush request");
return -1;
}
static int flush_update(void)
{
- if (rtnl_send(&rth, filter.flushb, filter.flushp) < 0) {
+ if (rtnl_send_check(&rth, filter.flushb, filter.flushp) < 0) {
perror("Failed to send flush request");
return -1;
}
break;
}
- if (rtnl_send(&rth, xb.buf, xb.offset) < 0) {
+ if (rtnl_send_check(&rth, xb.buf, xb.offset) < 0) {
perror("Failed to send delete-all request");
exit(1);
}
break;
}
- if (rtnl_send(&rth, xb.buf, xb.offset) < 0) {
+ if (rtnl_send_check(&rth, xb.buf, xb.offset) < 0) {
perror("Failed to send delete-all request\n");
exit(1);
}
struct nlmsghdr nlh;
struct rtgenmsg g;
} req;
- struct sockaddr_nl nladdr;
-
- memset(&nladdr, 0, sizeof(nladdr));
- nladdr.nl_family = AF_NETLINK;
memset(&req, 0, sizeof(req));
req.nlh.nlmsg_len = sizeof(req);
req.nlh.nlmsg_seq = rth->dump = ++rth->seq;
req.g.rtgen_family = family;
- return sendto(rth->fd, (void*)&req, sizeof(req), 0,
- (struct sockaddr*)&nladdr, sizeof(nladdr));
+ return send(rth->fd, (void*)&req, sizeof(req), 0);
}
int rtnl_send(struct rtnl_handle *rth, const char *buf, int len)
{
- struct sockaddr_nl nladdr;
+ return send(rth->fd, buf, len, 0);
+}
+
+int rtnl_send_check(struct rtnl_handle *rth, const char *buf, int len)
+{
struct nlmsghdr *h;
int status;
char resp[1024];
- memset(&nladdr, 0, sizeof(nladdr));
- nladdr.nl_family = AF_NETLINK;
-
- status = sendto(rth->fd, buf, len, 0,
- (struct sockaddr*)&nladdr, sizeof(nladdr));
+ status = send(rth->fd, buf, len, 0);
if (status < 0)
return status;