struct ifaddrs_ctx *ctx = pctx;
if (h->nlmsg_type == RTM_NEWLINK) {
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wcast-align"
+
for (rta = __NLMSG_RTA(h, sizeof(*ifi)); __NLMSG_RTAOK(rta, h);
rta = __RTA_NEXT(rta)) {
if (rta->rta_type != IFLA_STATS)
stats_len = __RTA_DATALEN(rta);
break;
}
+
+#pragma GCC diagnostic pop
} else {
for (ifs0 = ctx->hash[ifa->ifa_index % IFADDRS_HASH_SIZE]; ifs0;
ifs0 = ifs0->hash_next)
return -1;
}
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wcast-align"
+
if (h->nlmsg_type == RTM_NEWLINK) {
ifs->index = ifi->ifi_index;
ifs->ifa.ifa_flags = ifi->ifi_flags;
&ifs->netmask, ifa->ifa_prefixlen);
}
+#pragma GCC diagnostic pop
+
if (ifs->ifa.ifa_name) {
if (!ctx->first)
ctx->first = ifs;
if (r <= 0)
return -1;
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wcast-align"
for (h = &u.reply; __NLMSG_OK(h, (void *)&u.buf[r]);
h = __NLMSG_NEXT(h)) {
if (h->nlmsg_type == NLMSG_DONE)
if (ret)
return ret;
}
+#pragma GCC diagnostic pop
}
}
if (tempIfAddr->ifa_addr == NULL)
continue;
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wcast-align"
+
if (tempIfAddr->ifa_addr->sa_family == AF_INET) {
if (family && strcmp(family, "inet"))
continue;
tempAddrPtr = &((struct sockaddr_in6 *)tempIfAddr->ifa_addr)->sin6_addr;
}
+#pragma GCC diagnostic pop
+
if (interface && strcmp(interface, tempIfAddr->ifa_name))
continue;
else if (!interface && strcmp("lo", tempIfAddr->ifa_name) == 0)
if (err < 0)
goto out;
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wcast-align"
+
do {
/* Restore the answer buffer length, it might have been
* overwritten by a previous receive.
}
} while (readmore);
+#pragma GCC diagnostic pop
+
/* If we end up here, we didn't find any result, so signal an error. */
err = -1;
* the given RTM_NEWADDR message. Allocates memory for the address and stores
* that pointer in *res (so res should be an in_addr** or in6_addr**).
*/
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wcast-align"
+
static int ifa_get_local_ip(int family, struct nlmsghdr *msg, void **res)
{
int addrlen;
return 0;
}
+#pragma GCC diagnostic pop
+
static int ip_addr_get(int family, int ifindex, void **res)
{
int answer_len, err;
if (err < 0)
goto out;
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wcast-align"
+
do {
/* Restore the answer buffer length, it might have been
* overwritten by a previous receive.
}
} while (readmore);
+#pragma GCC diagnostic pop
+
/* If we end up here, we didn't find any result, so signal an
* error.
*/
return -1;
memset(buf, 0, sizeof(buf));
+
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wcast-align"
hdr = (struct nlmsghdr *)buf;
msg = (struct rtgenmsg *)NLMSG_DATA(hdr);
+#pragma GCC diagnostic pop
hdr->nlmsg_len = NLMSG_LENGTH(sizeof(*msg));
hdr->nlmsg_type = RTM_NEWNSID;
if ((type <= max) && (!tb[type]))
tb[type] = rta;
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wcast-align"
rta = RTA_NEXT(rta, len);
+#pragma GCC diagnostic pop
}
return 0;
return -1;
memset(buf, 0, sizeof(buf));
+
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wcast-align"
hdr = (struct nlmsghdr *)buf;
msg = (struct rtgenmsg *)NLMSG_DATA(hdr);
+#pragma GCC diagnostic pop
hdr->nlmsg_len = NLMSG_LENGTH(sizeof(*msg));
hdr->nlmsg_type = RTM_GETNSID;
if (len < 0)
return -1;
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wcast-align"
parse_rtattr(tb, __LXC_NETNSA_MAX, NETNS_RTA(msg), len);
if (tb[__LXC_NETNSA_NSID])
return rta_getattr_s32(tb[__LXC_NETNSA_NSID]);
+#pragma GCC diagnostic pop
return -1;
}