#define SITNL_ADDATTR(_msg, _max_size, _attr, _data, _size) \
{ \
- if (sitnl_addattr(_msg, _max_size, _attr, _data, _size) < 0)\
+ if (sitnl_addattr(_msg, _max_size, _attr, _data, _size) < 0) \
{ \
goto err; \
} \
}
/* if (((int)nladdr.nl_pid != peer) || (h->nlmsg_pid != nladdr.nl_pid)
- || (h->nlmsg_seq != seq))
- {
- rcv_len -= NLMSG_ALIGN(len);
- h = (struct nlmsghdr *)((char *)h + NLMSG_ALIGN(len));
- msg(M_DEBUG, "%s: skipping unrelated message. nl_pid:%d (peer:%d) nl_msg_pid:%d nl_seq:%d seq:%d",
- __func__, (int)nladdr.nl_pid, peer, h->nlmsg_pid,
- h->nlmsg_seq, seq);
- continue;
- }
-*/
+ * || (h->nlmsg_seq != seq))
+ * {
+ * rcv_len -= NLMSG_ALIGN(len);
+ * h = (struct nlmsghdr *)((char *)h + NLMSG_ALIGN(len));
+ * msg(M_DEBUG, "%s: skipping unrelated message. nl_pid:%d (peer:%d) nl_msg_pid:%d nl_seq:%d seq:%d",
+ * __func__, (int)nladdr.nl_pid, peer, h->nlmsg_pid,
+ * h->nlmsg_seq, seq);
+ * continue;
+ * }
+ */
if (h->nlmsg_type == NLMSG_ERROR)
{
err = (struct nlmsgerr *)NLMSG_DATA(h);
{
ret = 0;
if (cb)
+ {
ret = cb(h, arg_cb);
+ }
}
else
{
case RTA_OIF:
ifindex = *(unsigned int *)RTA_DATA(rta);
break;
+
/* route prefix */
case RTA_DST:
break;
+
/* GW for the route */
case RTA_GATEWAY:
memcpy(&res->gw, RTA_DATA(rta), res->addr_size);
res.addr_size = sizeof(in_addr_t);
req.n.nlmsg_flags |= NLM_F_DUMP;
break;
+
case AF_INET6:
res.addr_size = sizeof(struct in6_addr);
break;
+
default:
/* unsupported */
return -EINVAL;
}
ifindex = if_nametoindex(iface);
- if (ifindex == 0) {
+ if (ifindex == 0)
+ {
msg(M_WARN, "%s: rtnl: cannot get ifindex for %s: %s", __func__, iface,
strerror(errno));
return -ENOENT;
req.i.ifi_index = ifindex;
req.i.ifi_change |= IFF_UP;
if (up)
+ {
req.i.ifi_flags |= IFF_UP;
+ }
else
+ {
req.i.ifi_flags &= ~IFF_UP;
+ }
msg(M_INFO, "%s: set %s %s", __func__, iface, up ? "up" : "down");
CLEAR(req);
ifindex = if_nametoindex(iface);
- if (ifindex == 0) {
+ if (ifindex == 0)
+ {
msg(M_WARN | M_ERRNO, "%s: rtnl: cannot get ifindex for %s", __func__,
iface);
return -1;
case AF_INET:
size = sizeof(struct in_addr);
break;
+
case AF_INET6:
size = sizeof(struct in6_addr);
break;
+
default:
msg(M_WARN, "%s: rtnl: unknown address family %d", __func__,
af_family);
{
int ifindex;
- switch (af_family) {
+ switch (af_family)
+ {
case AF_INET:
case AF_INET6:
break;
+
default:
return -EINVAL;
}
{
int ifindex;
- switch (af_family) {
+ switch (af_family)
+ {
case AF_INET:
case AF_INET6:
break;
+
default:
return -EINVAL;
}
case AF_INET:
size = sizeof(in_addr_t);
break;
+
case AF_INET6:
size = sizeof(struct in6_addr);
break;
+
default:
return -EINVAL;
}
{
int ifindex;
- switch (af_family) {
+ switch (af_family)
+ {
case AF_INET:
case AF_INET6:
break;
+
default:
- return -EINVAL;;
+ return -EINVAL;
}
if (!iface)
{
int ifindex;
- switch (af_family) {
+ switch (af_family)
+ {
case AF_INET:
case AF_INET6:
break;
+
default:
- return -EINVAL;;
+ return -EINVAL;
}
if (!iface)