Use RTA_DATA() instead of rtattr_get_data().

This commit is contained in:
Nicholas J. Kain 2014-03-17 20:28:26 -04:00
parent f7de4a14fd
commit 3f267576ac
3 changed files with 6 additions and 12 deletions

View File

@ -385,12 +385,12 @@ static void ipbcpfx_clear_others_do(const struct nlmsghdr *nlh, void *data)
goto erase; goto erase;
if (!tb[IFA_ADDRESS]) if (!tb[IFA_ADDRESS])
goto erase; goto erase;
if (memcmp(rtattr_get_data(tb[IFA_ADDRESS]), &ipx->ipaddr, if (memcmp(RTA_DATA(tb[IFA_ADDRESS]), &ipx->ipaddr,
sizeof ipx->ipaddr)) sizeof ipx->ipaddr))
goto erase; goto erase;
if (!tb[IFA_BROADCAST]) if (!tb[IFA_BROADCAST])
goto erase; goto erase;
if (memcmp(rtattr_get_data(tb[IFA_BROADCAST]), &ipx->bcast, if (memcmp(RTA_DATA(tb[IFA_BROADCAST]), &ipx->bcast,
sizeof ipx->bcast)) sizeof ipx->bcast))
goto erase; goto erase;
break; break;
@ -404,8 +404,8 @@ static void ipbcpfx_clear_others_do(const struct nlmsghdr *nlh, void *data)
erase: erase:
r = rtnl_addr_broadcast_send(ipx->fd, RTM_DELADDR, ifm->ifa_flags, r = rtnl_addr_broadcast_send(ipx->fd, RTM_DELADDR, ifm->ifa_flags,
ifm->ifa_scope, ifm->ifa_scope,
tb[IFA_ADDRESS] ? rtattr_get_data(tb[IFA_ADDRESS]) : NULL, tb[IFA_ADDRESS] ? RTA_DATA(tb[IFA_ADDRESS]) : NULL,
tb[IFA_BROADCAST] ? rtattr_get_data(tb[IFA_BROADCAST]) : NULL, tb[IFA_BROADCAST] ? RTA_DATA(tb[IFA_BROADCAST]) : NULL,
ifm->ifa_prefixlen); ifm->ifa_prefixlen);
if (r < 0 && r != -2) { if (r < 0 && r != -2) {
log_warning("%s: (%s) Failed to delete IP and broadcast addresses.", log_warning("%s: (%s) Failed to delete IP and broadcast addresses.",

View File

@ -106,7 +106,7 @@ static int get_if_index_and_mac(const struct nlmsghdr *nlh,
struct rtattr *tb[IFLA_MAX] = {0}; struct rtattr *tb[IFLA_MAX] = {0};
nl_rtattr_parse(nlh, sizeof *ifm, rtattr_assign, tb); nl_rtattr_parse(nlh, sizeof *ifm, rtattr_assign, tb);
if (tb[IFLA_IFNAME] && !strncmp(client_config.interface, if (tb[IFLA_IFNAME] && !strncmp(client_config.interface,
rtattr_get_data(tb[IFLA_IFNAME]), RTA_DATA(tb[IFLA_IFNAME]),
sizeof client_config.interface)) { sizeof client_config.interface)) {
client_config.ifindex = ifm->ifi_index; client_config.ifindex = ifm->ifi_index;
if (!tb[IFLA_ADDRESS]) if (!tb[IFLA_ADDRESS])
@ -116,8 +116,7 @@ static int get_if_index_and_mac(const struct nlmsghdr *nlh,
suicide("FATAL: Adapter hardware address length should be 6, but is %u.", suicide("FATAL: Adapter hardware address length should be 6, but is %u.",
maclen); maclen);
const unsigned char *mac = const unsigned char *mac = RTA_DATA(tb[IFLA_ADDRESS]);
(unsigned char *)rtattr_get_data(tb[IFLA_ADDRESS]);
log_line("%s hardware address %x:%x:%x:%x:%x:%x", log_line("%s hardware address %x:%x:%x:%x:%x:%x",
client_config.interface, client_config.interface,
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);

View File

@ -33,11 +33,6 @@
#include <linux/netlink.h> #include <linux/netlink.h>
#include <linux/rtnetlink.h> #include <linux/rtnetlink.h>
static inline void *rtattr_get_data(const struct rtattr *attr)
{
return (char *)RTA_DATA(attr);
}
static inline int nlmsg_get_error(const struct nlmsghdr *nlh) static inline int nlmsg_get_error(const struct nlmsghdr *nlh)
{ {
const struct nlmsgerr *err = NLMSG_DATA(nlh); const struct nlmsgerr *err = NLMSG_DATA(nlh);