From 3f267576ac3caf3c6c69331e86f27c8b139e412e Mon Sep 17 00:00:00 2001 From: "Nicholas J. Kain" Date: Mon, 17 Mar 2014 20:28:26 -0400 Subject: [PATCH] Use RTA_DATA() instead of rtattr_get_data(). --- ndhc/ifset.c | 8 ++++---- ndhc/netlink.c | 5 ++--- ndhc/nl.h | 5 ----- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/ndhc/ifset.c b/ndhc/ifset.c index f5af3af..4838205 100644 --- a/ndhc/ifset.c +++ b/ndhc/ifset.c @@ -385,12 +385,12 @@ static void ipbcpfx_clear_others_do(const struct nlmsghdr *nlh, void *data) goto erase; if (!tb[IFA_ADDRESS]) goto erase; - if (memcmp(rtattr_get_data(tb[IFA_ADDRESS]), &ipx->ipaddr, + if (memcmp(RTA_DATA(tb[IFA_ADDRESS]), &ipx->ipaddr, sizeof ipx->ipaddr)) goto erase; if (!tb[IFA_BROADCAST]) goto erase; - if (memcmp(rtattr_get_data(tb[IFA_BROADCAST]), &ipx->bcast, + if (memcmp(RTA_DATA(tb[IFA_BROADCAST]), &ipx->bcast, sizeof ipx->bcast)) goto erase; break; @@ -404,8 +404,8 @@ static void ipbcpfx_clear_others_do(const struct nlmsghdr *nlh, void *data) erase: r = rtnl_addr_broadcast_send(ipx->fd, RTM_DELADDR, ifm->ifa_flags, ifm->ifa_scope, - tb[IFA_ADDRESS] ? rtattr_get_data(tb[IFA_ADDRESS]) : NULL, - tb[IFA_BROADCAST] ? rtattr_get_data(tb[IFA_BROADCAST]) : NULL, + tb[IFA_ADDRESS] ? RTA_DATA(tb[IFA_ADDRESS]) : NULL, + tb[IFA_BROADCAST] ? RTA_DATA(tb[IFA_BROADCAST]) : NULL, ifm->ifa_prefixlen); if (r < 0 && r != -2) { log_warning("%s: (%s) Failed to delete IP and broadcast addresses.", diff --git a/ndhc/netlink.c b/ndhc/netlink.c index ca98b4f..ab81215 100644 --- a/ndhc/netlink.c +++ b/ndhc/netlink.c @@ -106,7 +106,7 @@ static int get_if_index_and_mac(const struct nlmsghdr *nlh, struct rtattr *tb[IFLA_MAX] = {0}; nl_rtattr_parse(nlh, sizeof *ifm, rtattr_assign, tb); if (tb[IFLA_IFNAME] && !strncmp(client_config.interface, - rtattr_get_data(tb[IFLA_IFNAME]), + RTA_DATA(tb[IFLA_IFNAME]), sizeof client_config.interface)) { client_config.ifindex = ifm->ifi_index; 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.", maclen); - const unsigned char *mac = - (unsigned char *)rtattr_get_data(tb[IFLA_ADDRESS]); + const unsigned char *mac = RTA_DATA(tb[IFLA_ADDRESS]); log_line("%s hardware address %x:%x:%x:%x:%x:%x", client_config.interface, mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); diff --git a/ndhc/nl.h b/ndhc/nl.h index fe1aa74..cf03ea7 100644 --- a/ndhc/nl.h +++ b/ndhc/nl.h @@ -33,11 +33,6 @@ #include #include -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) { const struct nlmsgerr *err = NLMSG_DATA(nlh);