Commit ff24746c authored by Stephen Hemminger's avatar Stephen Hemminger

Convert to use rta_getattr_ functions

User new functions (inspired by libmnl) to do type safe access
of routeing attributes
parent 49b730d7
......@@ -104,7 +104,7 @@ int genl_ctrl_resolve_family(const char *family)
goto errout;
}
ret = *(__u16 *) RTA_DATA(tb[CTRL_ATTR_FAMILY_ID]);
ret = rta_getattr_u16(tb[CTRL_ATTR_FAMILY_ID]);
}
errout:
......
......@@ -47,7 +47,7 @@ static inline int rtm_get_table(struct rtmsg *r, struct rtattr **tb)
{
__u32 table = r->rtm_table;
if (tb[RTA_TABLE])
table = *(__u32*) RTA_DATA(tb[RTA_TABLE]);
table = rta_getattr_u32(tb[RTA_TABLE]);
return table;
}
......
......@@ -155,7 +155,7 @@ static void print_queuelen(FILE *f, struct rtattr *tb[IFLA_MAX + 1])
return;
memset(&ifr, 0, sizeof(ifr));
strcpy(ifr.ifr_name, (char *)RTA_DATA(tb[IFLA_IFNAME]));
strcpy(ifr.ifr_name, rta_getattr_str(tb[IFLA_IFNAME]));
if (ioctl(s, SIOCGIFTXQLEN, &ifr) < 0) {
fprintf(f, "ioctl(SIOCGIFXQLEN) failed: %s\n", strerror(errno));
close(s);
......@@ -397,7 +397,7 @@ int print_linkinfo(const struct sockaddr_nl *who,
fprintf(fp, "Deleted ");
fprintf(fp, "%d: %s", ifi->ifi_index,
tb[IFLA_IFNAME] ? (char*)RTA_DATA(tb[IFLA_IFNAME]) : "<nil>");
tb[IFLA_IFNAME] ? rta_getattr_str(tb[IFLA_IFNAME]) : "<nil>");
if (tb[IFLA_LINK]) {
SPRINT_BUF(b1);
......@@ -417,14 +417,14 @@ int print_linkinfo(const struct sockaddr_nl *who,
if (tb[IFLA_MTU])
fprintf(fp, "mtu %u ", *(int*)RTA_DATA(tb[IFLA_MTU]));
if (tb[IFLA_QDISC])
fprintf(fp, "qdisc %s ", (char*)RTA_DATA(tb[IFLA_QDISC]));
fprintf(fp, "qdisc %s ", rta_getattr_str(tb[IFLA_QDISC]));
if (tb[IFLA_MASTER]) {
SPRINT_BUF(b1);
fprintf(fp, "master %s ", ll_idx_n2a(*(int*)RTA_DATA(tb[IFLA_MASTER]), b1));
}
if (tb[IFLA_OPERSTATE])
print_operstate(fp, *(__u8 *)RTA_DATA(tb[IFLA_OPERSTATE]));
print_operstate(fp, rta_getattr_u8(tb[IFLA_OPERSTATE]));
if (do_link && tb[IFLA_LINKMODE])
print_linkmode(fp, tb[IFLA_LINKMODE]);
......@@ -460,7 +460,7 @@ int print_linkinfo(const struct sockaddr_nl *who,
if (do_link && tb[IFLA_IFALIAS])
fprintf(fp,"\n alias %s",
(const char *) RTA_DATA(tb[IFLA_IFALIAS]));
rta_getattr_str(tb[IFLA_IFALIAS]));
if (do_link && show_stats) {
if (tb[IFLA_STATS64])
......@@ -665,7 +665,7 @@ int print_addrinfo(const struct sockaddr_nl *who, struct nlmsghdr *n,
if (ifa_flags)
fprintf(fp, "flags %02x ", ifa_flags);
if (rta_tb[IFA_LABEL])
fprintf(fp, "%s", (char*)RTA_DATA(rta_tb[IFA_LABEL]));
fprintf(fp, "%s", rta_getattr_str(rta_tb[IFA_LABEL]));
if (rta_tb[IFA_CACHEINFO]) {
struct ifa_cacheinfo *ci = RTA_DATA(rta_tb[IFA_CACHEINFO]);
fprintf(fp, "%s", _SL_);
......
......@@ -79,7 +79,7 @@ static void macvlan_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[]
RTA_PAYLOAD(tb[IFLA_MACVLAN_MODE]) < sizeof(__u32))
return;
mode = *(__u32 *)RTA_DATA(tb[IFLA_VLAN_ID]);
mode = rta_getattr_u32(tb[IFLA_VLAN_ID]);
fprintf(f, " mode %s ",
mode == MACVLAN_MODE_PRIVATE ? "private"
: mode == MACVLAN_MODE_VEPA ? "vepa"
......
......@@ -76,7 +76,7 @@ static void macvtap_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[]
RTA_PAYLOAD(tb[IFLA_MACVLAN_MODE]) < sizeof(__u32))
return;
mode = *(__u32 *)RTA_DATA(tb[IFLA_VLAN_ID]);
mode = rta_getattr_u32(tb[IFLA_VLAN_ID]);
fprintf(f, " mode %s ",
mode == MACVLAN_MODE_PRIVATE ? "private"
: mode == MACVLAN_MODE_VEPA ? "vepa"
......
......@@ -183,7 +183,7 @@ static void vlan_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
RTA_PAYLOAD(tb[IFLA_VLAN_ID]) < sizeof(__u16))
return;
fprintf(f, "id %u ", *(__u16 *)RTA_DATA(tb[IFLA_VLAN_ID]));
fprintf(f, "id %u ", rta_getattr_u16(tb[IFLA_VLAN_ID]));
if (tb[IFLA_VLAN_FLAGS]) {
if (RTA_PAYLOAD(tb[IFLA_VLAN_FLAGS]) < sizeof(*flags))
......
......@@ -282,7 +282,7 @@ int print_neigh(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
}
if (tb[NDA_PROBES] && show_stats) {
__u32 p = *(__u32 *) RTA_DATA(tb[NDA_PROBES]);
__u32 p = rta_getattr_u32(tb[NDA_PROBES]);
fprintf(fp, " probes %u", p);
}
......
......@@ -376,7 +376,7 @@ int print_ntable(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
n->nlmsg_len - NLMSG_LENGTH(sizeof(*ndtm)));
if (tb[NDTA_NAME]) {
char *name = RTA_DATA(tb[NDTA_NAME]);
const char *name = rta_getattr_str(tb[NDTA_NAME]);
if (strlen(filter.name) > 0 && strcmp(filter.name, name))
return 0;
......@@ -386,7 +386,7 @@ int print_ntable(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
RTA_PAYLOAD(tb[NDTA_PARMS]));
if (tpb[NDTPA_IFINDEX]) {
__u32 ifindex = *(__u32 *)RTA_DATA(tpb[NDTPA_IFINDEX]);
__u32 ifindex = rta_getattr_u32(tpb[NDTPA_IFINDEX]);
if (filter.index && filter.index != ifindex)
return 0;
......@@ -406,7 +406,7 @@ int print_ntable(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
fprintf(fp, "(%d) ", ndtm->ndtm_family);
if (tb[NDTA_NAME]) {
char *name = RTA_DATA(tb[NDTA_NAME]);
const char *name = rta_getattr_str(tb[NDTA_NAME]);
fprintf(fp, "%s ", name);
}
......@@ -418,19 +418,19 @@ int print_ntable(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
fprintf(fp, " ");
if (tb[NDTA_THRESH1]) {
__u32 thresh1 = *(__u32 *)RTA_DATA(tb[NDTA_THRESH1]);
__u32 thresh1 = rta_getattr_u32(tb[NDTA_THRESH1]);
fprintf(fp, "thresh1 %u ", thresh1);
}
if (tb[NDTA_THRESH2]) {
__u32 thresh2 = *(__u32 *)RTA_DATA(tb[NDTA_THRESH2]);
__u32 thresh2 = rta_getattr_u32(tb[NDTA_THRESH2]);
fprintf(fp, "thresh2 %u ", thresh2);
}
if (tb[NDTA_THRESH3]) {
__u32 thresh3 = *(__u32 *)RTA_DATA(tb[NDTA_THRESH3]);
__u32 thresh3 = rta_getattr_u32(tb[NDTA_THRESH3]);
fprintf(fp, "thresh3 %u ", thresh3);
}
if (tb[NDTA_GC_INTERVAL]) {
__u64 gc_int = *(__u64 *)RTA_DATA(tb[NDTA_GC_INTERVAL]);
__u64 gc_int = rta_getattr_u64(tb[NDTA_GC_INTERVAL]);
fprintf(fp, "gc_int %llu ", gc_int);
}
......@@ -469,7 +469,7 @@ int print_ntable(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
if (tb[NDTA_PARMS]) {
if (tpb[NDTPA_IFINDEX]) {
__u32 ifindex = *(__u32 *)RTA_DATA(tpb[NDTPA_IFINDEX]);
__u32 ifindex = rta_getattr_u32(tpb[NDTPA_IFINDEX]);
fprintf(fp, " ");
fprintf(fp, "dev %s ", ll_index_to_name(ifindex));
......@@ -479,19 +479,19 @@ int print_ntable(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
fprintf(fp, " ");
if (tpb[NDTPA_REFCNT]) {
__u32 refcnt = *(__u32 *)RTA_DATA(tpb[NDTPA_REFCNT]);
__u32 refcnt = rta_getattr_u32(tpb[NDTPA_REFCNT]);
fprintf(fp, "refcnt %u ", refcnt);
}
if (tpb[NDTPA_REACHABLE_TIME]) {
__u64 reachable = *(__u64 *)RTA_DATA(tpb[NDTPA_REACHABLE_TIME]);
__u64 reachable = rta_getattr_u64(tpb[NDTPA_REACHABLE_TIME]);
fprintf(fp, "reachable %llu ", reachable);
}
if (tpb[NDTPA_BASE_REACHABLE_TIME]) {
__u64 breachable = *(__u64 *)RTA_DATA(tpb[NDTPA_BASE_REACHABLE_TIME]);
__u64 breachable = rta_getattr_u64(tpb[NDTPA_BASE_REACHABLE_TIME]);
fprintf(fp, "base_reachable %llu ", breachable);
}
if (tpb[NDTPA_RETRANS_TIME]) {
__u64 retrans = *(__u64 *)RTA_DATA(tpb[NDTPA_RETRANS_TIME]);
__u64 retrans = rta_getattr_u64(tpb[NDTPA_RETRANS_TIME]);
fprintf(fp, "retrans %llu ", retrans);
}
......@@ -500,15 +500,15 @@ int print_ntable(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
fprintf(fp, " ");
if (tpb[NDTPA_GC_STALETIME]) {
__u64 gc_stale = *(__u64 *)RTA_DATA(tpb[NDTPA_GC_STALETIME]);
__u64 gc_stale = rta_getattr_u64(tpb[NDTPA_GC_STALETIME]);
fprintf(fp, "gc_stale %llu ", gc_stale);
}
if (tpb[NDTPA_DELAY_PROBE_TIME]) {
__u64 delay_probe = *(__u64 *)RTA_DATA(tpb[NDTPA_DELAY_PROBE_TIME]);
__u64 delay_probe = rta_getattr_u64(tpb[NDTPA_DELAY_PROBE_TIME]);
fprintf(fp, "delay_probe %llu ", delay_probe);
}
if (tpb[NDTPA_QUEUE_LEN]) {
__u32 queue = *(__u32 *)RTA_DATA(tpb[NDTPA_QUEUE_LEN]);
__u32 queue = rta_getattr_u32(tpb[NDTPA_QUEUE_LEN]);
fprintf(fp, "queue %u ", queue);
}
......@@ -517,15 +517,15 @@ int print_ntable(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
fprintf(fp, " ");
if (tpb[NDTPA_APP_PROBES]) {
__u32 aprobe = *(__u32 *)RTA_DATA(tpb[NDTPA_APP_PROBES]);
__u32 aprobe = rta_getattr_u32(tpb[NDTPA_APP_PROBES]);
fprintf(fp, "app_probes %u ", aprobe);
}
if (tpb[NDTPA_UCAST_PROBES]) {
__u32 uprobe = *(__u32 *)RTA_DATA(tpb[NDTPA_UCAST_PROBES]);
__u32 uprobe = rta_getattr_u32(tpb[NDTPA_UCAST_PROBES]);
fprintf(fp, "ucast_probes %u ", uprobe);
}
if (tpb[NDTPA_MCAST_PROBES]) {
__u32 mprobe = *(__u32 *)RTA_DATA(tpb[NDTPA_MCAST_PROBES]);
__u32 mprobe = rta_getattr_u32(tpb[NDTPA_MCAST_PROBES]);
fprintf(fp, "mcast_probes %u ", mprobe);
}
......@@ -534,19 +534,19 @@ int print_ntable(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
fprintf(fp, " ");
if (tpb[NDTPA_ANYCAST_DELAY]) {
__u64 anycast_delay = *(__u64 *)RTA_DATA(tpb[NDTPA_ANYCAST_DELAY]);
__u64 anycast_delay = rta_getattr_u64(tpb[NDTPA_ANYCAST_DELAY]);
fprintf(fp, "anycast_delay %llu ", anycast_delay);
}
if (tpb[NDTPA_PROXY_DELAY]) {
__u64 proxy_delay = *(__u64 *)RTA_DATA(tpb[NDTPA_PROXY_DELAY]);
__u64 proxy_delay = rta_getattr_u64(tpb[NDTPA_PROXY_DELAY]);
fprintf(fp, "proxy_delay %llu ", proxy_delay);
}
if (tpb[NDTPA_PROXY_QLEN]) {
__u32 pqueue = *(__u32 *)RTA_DATA(tpb[NDTPA_PROXY_QLEN]);
__u32 pqueue = rta_getattr_u32(tpb[NDTPA_PROXY_QLEN]);
fprintf(fp, "proxy_queue %u ", pqueue);
}
if (tpb[NDTPA_LOCKTIME]) {
__u64 locktime = *(__u64 *)RTA_DATA(tpb[NDTPA_LOCKTIME]);
__u64 locktime = rta_getattr_u64(tpb[NDTPA_LOCKTIME]);
fprintf(fp, "locktime %llu ", locktime);
}
......
......@@ -227,7 +227,7 @@ int filter_nlmsg(struct nlmsghdr *n, struct rtattr **tb, int host_len)
if (filter.realmmask) {
__u32 realms = 0;
if (tb[RTA_FLOW])
realms = *(__u32*)RTA_DATA(tb[RTA_FLOW]);
realms = rta_getattr_u32(tb[RTA_FLOW]);
if ((realms^filter.realm)&filter.realmmask)
return 0;
}
......@@ -404,7 +404,7 @@ int print_route(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
abuf, sizeof(abuf)));
}
if (tb[RTA_PRIORITY])
fprintf(fp, " metric %u ", *(__u32*)RTA_DATA(tb[RTA_PRIORITY]));
fprintf(fp, " metric %u ", rta_getattr_u32(tb[RTA_PRIORITY]));
if (r->rtm_flags & RTNH_F_DEAD)
fprintf(fp, "dead ");
if (r->rtm_flags & RTNH_F_ONLINK)
......@@ -424,7 +424,7 @@ int print_route(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
}
if (tb[RTA_FLOW] && filter.realmmask != ~0U) {
__u32 to = *(__u32*)RTA_DATA(tb[RTA_FLOW]);
__u32 to = rta_getattr_u32(tb[RTA_FLOW]);
__u32 from = to>>16;
to &= 0xFFFF;
fprintf(fp, "realm%s ", from ? "s" : "");
......@@ -589,7 +589,7 @@ int print_route(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
abuf, sizeof(abuf)));
}
if (tb[RTA_FLOW]) {
__u32 to = *(__u32*)RTA_DATA(tb[RTA_FLOW]);
__u32 to = rta_getattr_u32(tb[RTA_FLOW]);
__u32 from = to>>16;
to &= 0xFFFF;
fprintf(fp, " realm%s ", from ? "s" : "");
......
......@@ -131,23 +131,23 @@ int print_rule(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
__u32 mark = 0, mask = 0;
if (tb[FRA_FWMARK])
mark = *(__u32*)RTA_DATA(tb[FRA_FWMARK]);
mark = rta_getattr_u32(tb[FRA_FWMARK]);
if (tb[FRA_FWMASK] &&
(mask = *(__u32*)RTA_DATA(tb[FRA_FWMASK])) != 0xFFFFFFFF)
(mask = rta_getattr_u32(tb[FRA_FWMASK])) != 0xFFFFFFFF)
fprintf(fp, "fwmark 0x%x/0x%x ", mark, mask);
else
fprintf(fp, "fwmark 0x%x ", mark);
}
if (tb[FRA_IFNAME]) {
fprintf(fp, "iif %s ", (char*)RTA_DATA(tb[FRA_IFNAME]));
fprintf(fp, "iif %s ", rta_getattr_str(tb[FRA_IFNAME]));
if (r->rtm_flags & FIB_RULE_IIF_DETACHED)
fprintf(fp, "[detached] ");
}
if (tb[FRA_OIFNAME]) {
fprintf(fp, "oif %s ", (char*)RTA_DATA(tb[FRA_OIFNAME]));
fprintf(fp, "oif %s ", rta_getattr_str(tb[FRA_OIFNAME]));
if (r->rtm_flags & FIB_RULE_OIF_DETACHED)
fprintf(fp, "[detached] ");
}
......@@ -157,7 +157,7 @@ int print_rule(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
fprintf(fp, "lookup %s ", rtnl_rttable_n2a(table, b1, sizeof(b1)));
if (tb[FRA_FLOW]) {
__u32 to = *(__u32*)RTA_DATA(tb[FRA_FLOW]);
__u32 to = rta_getattr_u32(tb[FRA_FLOW]);
__u32 from = to>>16;
to &= 0xFFFF;
if (from) {
......@@ -180,7 +180,7 @@ int print_rule(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
} else if (r->rtm_type == FR_ACT_GOTO) {
fprintf(fp, "goto ");
if (tb[FRA_GOTO])
fprintf(fp, "%u", *(__u32 *) RTA_DATA(tb[FRA_GOTO]));
fprintf(fp, "%u", rta_getattr_u32(tb[FRA_GOTO]));
else
fprintf(fp, "none");
if (r->rtm_flags & FIB_RULE_UNRESOLVED)
......
......@@ -806,7 +806,7 @@ void xfrm_xfrma_print(struct rtattr *tb[], __u16 family,
return;
}
lastused = *(__u64 *)RTA_DATA(tb[XFRMA_LASTUSED]);
lastused = rta_getattr_u64(tb[XFRMA_LASTUSED]);
fprintf(fp, "%s", strxf_time(lastused));
fprintf(fp, "%s", _SL_);
......
......@@ -98,35 +98,35 @@ get_failed:
linkinfo[IFLA_INFO_DATA]);
if (greinfo[IFLA_GRE_IKEY])
ikey = *(__u32 *)RTA_DATA(greinfo[IFLA_GRE_IKEY]);
ikey = rta_getattr_u32(greinfo[IFLA_GRE_IKEY]);
if (greinfo[IFLA_GRE_OKEY])
okey = *(__u32 *)RTA_DATA(greinfo[IFLA_GRE_OKEY]);
okey = rta_getattr_u32(greinfo[IFLA_GRE_OKEY]);
if (greinfo[IFLA_GRE_IFLAGS])
iflags = *(__u16 *)RTA_DATA(greinfo[IFLA_GRE_IFLAGS]);
iflags = rta_getattr_u16(greinfo[IFLA_GRE_IFLAGS]);
if (greinfo[IFLA_GRE_OFLAGS])
oflags = *(__u16 *)RTA_DATA(greinfo[IFLA_GRE_OFLAGS]);
oflags = rta_getattr_u16(greinfo[IFLA_GRE_OFLAGS]);
if (greinfo[IFLA_GRE_LOCAL])
saddr = *(__u32 *)RTA_DATA(greinfo[IFLA_GRE_LOCAL]);
saddr = rta_getattr_u32(greinfo[IFLA_GRE_LOCAL]);
if (greinfo[IFLA_GRE_REMOTE])
daddr = *(__u32 *)RTA_DATA(greinfo[IFLA_GRE_REMOTE]);
daddr = rta_getattr_u32(greinfo[IFLA_GRE_REMOTE]);
if (greinfo[IFLA_GRE_PMTUDISC])
pmtudisc = *(__u8 *)RTA_DATA(
pmtudisc = rta_getattr_u8(
greinfo[IFLA_GRE_PMTUDISC]);
if (greinfo[IFLA_GRE_TTL])
ttl = *(__u8 *)RTA_DATA(greinfo[IFLA_GRE_TTL]);
ttl = rta_getattr_u8(greinfo[IFLA_GRE_TTL]);
if (greinfo[IFLA_GRE_TOS])
tos = *(__u8 *)RTA_DATA(greinfo[IFLA_GRE_TOS]);
tos = rta_getattr_u8(greinfo[IFLA_GRE_TOS]);
if (greinfo[IFLA_GRE_LINK])
link = *(__u8 *)RTA_DATA(greinfo[IFLA_GRE_LINK]);
link = rta_getattr_u8(greinfo[IFLA_GRE_LINK]);
}
while (argc > 0) {
......@@ -279,7 +279,7 @@ static void gre_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
return;
if (tb[IFLA_GRE_REMOTE]) {
unsigned addr = *(__u32 *)RTA_DATA(tb[IFLA_GRE_REMOTE]);
unsigned addr = rta_getattr_u32(tb[IFLA_GRE_REMOTE]);
if (addr)
remote = format_host(AF_INET, 4, &addr, s1, sizeof(s1));
......@@ -288,7 +288,7 @@ static void gre_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
fprintf(f, "remote %s ", remote);
if (tb[IFLA_GRE_LOCAL]) {
unsigned addr = *(__u32 *)RTA_DATA(tb[IFLA_GRE_LOCAL]);
unsigned addr = rta_getattr_u32(tb[IFLA_GRE_LOCAL]);
if (addr)
local = format_host(AF_INET, 4, &addr, s1, sizeof(s1));
......@@ -296,8 +296,8 @@ static void gre_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
fprintf(f, "local %s ", local);
if (tb[IFLA_GRE_LINK] && *(__u32 *)RTA_DATA(tb[IFLA_GRE_LINK])) {
unsigned link = *(__u32 *)RTA_DATA(tb[IFLA_GRE_LINK]);
if (tb[IFLA_GRE_LINK] && rta_getattr_u32(tb[IFLA_GRE_LINK])) {
unsigned link = rta_getattr_u32(tb[IFLA_GRE_LINK]);
const char *n = if_indextoname(link, s2);
if (n)
......@@ -306,13 +306,13 @@ static void gre_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
fprintf(f, "dev %u ", link);
}
if (tb[IFLA_GRE_TTL] && *(__u8 *)RTA_DATA(tb[IFLA_GRE_TTL]))
fprintf(f, "ttl %d ", *(__u8 *)RTA_DATA(tb[IFLA_GRE_TTL]));
if (tb[IFLA_GRE_TTL] && rta_getattr_u8(tb[IFLA_GRE_TTL]))
fprintf(f, "ttl %d ", rta_getattr_u8(tb[IFLA_GRE_TTL]));
else
fprintf(f, "ttl inherit ");
if (tb[IFLA_GRE_TOS] && *(__u8 *)RTA_DATA(tb[IFLA_GRE_TOS])) {
int tos = *(__u8 *)RTA_DATA(tb[IFLA_GRE_TOS]);
if (tb[IFLA_GRE_TOS] && rta_getattr_u8(tb[IFLA_GRE_TOS])) {
int tos = rta_getattr_u8(tb[IFLA_GRE_TOS]);
fputs("tos ", f);
if (tos == 1)
......@@ -322,14 +322,14 @@ static void gre_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
}
if (tb[IFLA_GRE_PMTUDISC] &&
!*(__u8 *)RTA_DATA(tb[IFLA_GRE_PMTUDISC]))
!rta_getattr_u8(tb[IFLA_GRE_PMTUDISC]))
fputs("nopmtudisc ", f);
if (tb[IFLA_GRE_IFLAGS])
iflags = *(__u16 *)RTA_DATA(tb[IFLA_GRE_IFLAGS]);
iflags = rta_getattr_u16(tb[IFLA_GRE_IFLAGS]);
if (tb[IFLA_GRE_OFLAGS])
oflags = *(__u16 *)RTA_DATA(tb[IFLA_GRE_OFLAGS]);
oflags = rta_getattr_u16(tb[IFLA_GRE_OFLAGS]);
if ((iflags & GRE_KEY) && tb[IFLA_GRE_IKEY]) {
inet_ntop(AF_INET, RTA_DATA(tb[IFLA_GRE_IKEY]), s2, sizeof(s2));
......
......@@ -1370,7 +1370,7 @@ static void tcp_show_info(const struct nlmsghdr *nlh, struct inet_diag_msg *r)
}
if (tb[INET_DIAG_CONG])
printf(" %s", (char *) RTA_DATA(tb[INET_DIAG_CONG]));
printf(" %s", rta_getattr_str(tb[INET_DIAG_CONG]));
if (info->tcpi_options & TCPI_OPT_WSCALE)
printf(" wscale:%d,%d", info->tcpi_snd_wscale,
......
......@@ -448,7 +448,7 @@ static inline int print_value(FILE *fd, int type, struct rtattr *rta)
"size mismatch.\n");
return -1;
}
fprintf(fd, "%d", *(__u32 *) RTA_DATA(rta));
fprintf(fd, "%d", rta_getattr_u32(rta));
break;
case TCF_META_TYPE_VAR:
......@@ -485,7 +485,7 @@ static int print_object(FILE *fd, struct tcf_meta_val *obj, struct rtattr *rta)
goto size_mismatch;
fprintf(fd, " mask 0x%08x",
*(__u32*) RTA_DATA(rta));
rta_getattr_u32(rta));
}
break;
}
......
......@@ -122,7 +122,7 @@ static int basic_print_opt(struct filter_util *qu, FILE *f,
if (tb[TCA_BASIC_CLASSID]) {
SPRINT_BUF(b1);
fprintf(f, "flowid %s ",
sprint_tc_classid(*(__u32*)RTA_DATA(tb[TCA_BASIC_CLASSID]), b1));
sprint_tc_classid(rta_getattr_u32(tb[TCA_BASIC_CLASSID]), b1));
}
if (tb[TCA_BASIC_EMATCHES])
......
......@@ -282,7 +282,7 @@ static int flow_print_opt(struct filter_util *fu, FILE *f, struct rtattr *opt,
fprintf(f, "handle 0x%x ", handle);
if (tb[TCA_FLOW_MODE]) {
__u32 mode = *(__u32 *)RTA_DATA(tb[TCA_FLOW_MODE]);
__u32 mode = rta_getattr_u32(tb[TCA_FLOW_MODE]);
switch (mode) {
case FLOW_MODE_MAP:
......@@ -295,7 +295,7 @@ static int flow_print_opt(struct filter_util *fu, FILE *f, struct rtattr *opt,
}
if (tb[TCA_FLOW_KEYS]) {
__u32 keymask = *(__u32 *)RTA_DATA(tb[TCA_FLOW_KEYS]);
__u32 keymask = rta_getattr_u32(tb[TCA_FLOW_KEYS]);
char *sep = "";
fprintf(f, "keys ");
......@@ -309,9 +309,9 @@ static int flow_print_opt(struct filter_util *fu, FILE *f, struct rtattr *opt,
}
if (tb[TCA_FLOW_MASK])
mask = *(__u32 *)RTA_DATA(tb[TCA_FLOW_MASK]);
mask = rta_getattr_u32(tb[TCA_FLOW_MASK]);
if (tb[TCA_FLOW_XOR])
val = *(__u32 *)RTA_DATA(tb[TCA_FLOW_XOR]);
val = rta_getattr_u32(tb[TCA_FLOW_XOR]);
if (mask != ~0 || val != 0) {
__u32 or = (mask & val) ^ val;
......@@ -327,21 +327,21 @@ static int flow_print_opt(struct filter_util *fu, FILE *f, struct rtattr *opt,
if (tb[TCA_FLOW_RSHIFT])
fprintf(f, "rshift %u ",
*(__u32 *)RTA_DATA(tb[TCA_FLOW_RSHIFT]));
rta_getattr_u32(tb[TCA_FLOW_RSHIFT]));
if (tb[TCA_FLOW_ADDEND])
fprintf(f, "addend 0x%x ",
*(__u32 *)RTA_DATA(tb[TCA_FLOW_ADDEND]));
rta_getattr_u32(tb[TCA_FLOW_ADDEND]));
if (tb[TCA_FLOW_DIVISOR])
fprintf(f, "divisor %u ",
*(__u32 *)RTA_DATA(tb[TCA_FLOW_DIVISOR]));
rta_getattr_u32(tb[TCA_FLOW_DIVISOR]));
if (tb[TCA_FLOW_BASECLASS])
fprintf(f, "baseclass %s ",
sprint_tc_classid(*(__u32 *)RTA_DATA(tb[TCA_FLOW_BASECLASS]), b1));
sprint_tc_classid(rta_getattr_u32(tb[TCA_FLOW_BASECLASS]), b1));
if (tb[TCA_FLOW_PERTURB])
fprintf(f, "perturb %usec ",
*(__u32 *)RTA_DATA(tb[TCA_FLOW_PERTURB]));
rta_getattr_u32(tb[TCA_FLOW_PERTURB]));
if (tb[TCA_FLOW_EMATCHES])
print_ematch(f, tb[TCA_FLOW_EMATCHES]);
......
......@@ -130,7 +130,7 @@ static int fw_print_opt(struct filter_util *qu, FILE *f, struct rtattr *opt, __u
if(handle)
mark = handle;
if(tb[TCA_FW_MASK] &&
(mask = *(__u32*)RTA_DATA(tb[TCA_FW_MASK])) != 0xFFFFFFFF)
(mask = rta_getattr_u32(tb[TCA_FW_MASK])) != 0xFFFFFFFF)
fprintf(f, "handle 0x%x/0x%x ", mark, mask);
else
fprintf(f, "handle 0x%x ", handle);
......@@ -138,14 +138,14 @@ static int fw_print_opt(struct filter_util *qu, FILE *f, struct rtattr *opt, __u
if (tb[TCA_FW_CLASSID]) {
SPRINT_BUF(b1);
fprintf(f, "classid %s ", sprint_tc_classid(*(__u32*)RTA_DATA(tb[TCA_FW_CLASSID]), b1));
fprintf(f, "classid %s ", sprint_tc_classid(rta_getattr_u32(tb[TCA_FW_CLASSID]), b1));
}
if (tb[TCA_FW_POLICE])
tc_print_police(f, tb[TCA_FW_POLICE]);
if (tb[TCA_FW_INDEV]) {
struct rtattr *idev = tb[TCA_FW_INDEV];
fprintf(f, "input dev %s ",(char *)RTA_DATA(idev));
fprintf(f, "input dev %s ",rta_getattr_str(idev));
}
if (tb[TCA_FW_ACT]) {
......
......@@ -148,12 +148,12 @@ static int route_print_opt(struct filter_util *qu, FILE *f, struct rtattr *opt,
if (tb[TCA_ROUTE4_CLASSID]) {
SPRINT_BUF(b1);
fprintf(f, "flowid %s ", sprint_tc_classid(*(__u32*)RTA_DATA(tb[TCA_ROUTE4_CLASSID]), b1));
fprintf(f, "flowid %s ", sprint_tc_classid(rta_getattr_u32(tb[TCA_ROUTE4_CLASSID]), b1));
}
if (tb[TCA_ROUTE4_TO])
fprintf(f, "to %s ", rtnl_rtrealm_n2a(*(__u32*)RTA_DATA(tb[TCA_ROUTE4_TO]), b1, sizeof(b1)));
fprintf(f, "to %s ", rtnl_rtrealm_n2a(rta_getattr_u32(tb[TCA_ROUTE4_TO]), b1, sizeof(b1)));
if (tb[TCA_ROUTE4_FROM])
fprintf(f, "from %s ", rtnl_rtrealm_n2a(*(__u32*)RTA_DATA(tb[TCA_ROUTE4_FROM]), b1, sizeof(b1)));
fprintf(f, "from %s ", rtnl_rtrealm_n2a(rta_getattr_u32(tb[TCA_ROUTE4_FROM]), b1, sizeof(b1)));
if (tb[TCA_ROUTE4_IIF])
fprintf(f, "fromif %s", ll_index_to_name(*(int*)RTA_DATA(tb[TCA_ROUTE4_IIF])));
if (tb[TCA_ROUTE4_POLICE])
......
......@@ -336,9 +336,9 @@ static int rsvp_print_opt(struct filter_util *qu, FILE *f, struct rtattr *opt, _
if (tb[TCA_RSVP_CLASSID]) {
SPRINT_BUF(b1);
if (!pinfo || pinfo->tunnelhdr == 0)
fprintf(f, "flowid %s ", sprint_tc_classid(*(__u32*)RTA_DATA(tb[TCA_RSVP_CLASSID]), b1));
fprintf(f, "flowid %s ", sprint_tc_classid(rta_getattr_u32(tb[TCA_RSVP_CLASSID]), b1));
else
fprintf(f, "tunnel %d skip %d ", *(__u32*)RTA_DATA(tb[TCA_RSVP_CLASSID]), pinfo->tunnelhdr);
fprintf(f, "tunnel %d skip %d ", rta_getattr_u32(tb[TCA_RSVP_CLASSID]), pinfo->tunnelhdr);
} else if (pinfo && pinfo->tunnelhdr)
fprintf(f, "tunnel [BAD] skip %d ", pinfo->tunnelhdr);
......
......@@ -134,7 +134,7 @@ static int tcindex_print_opt(struct filter_util *qu, FILE *f,
if (RTA_PAYLOAD(tb[TCA_TCINDEX_HASH]) < sizeof(hash))
return -1;
hash = *(__u16 *) RTA_DATA(tb[TCA_TCINDEX_HASH]);
hash = rta_getattr_u16(tb[TCA_TCINDEX_HASH]);
fprintf(f,"hash %d ",hash);
}
if (tb[TCA_TCINDEX_MASK]) {
......@@ -142,7 +142,7 @@ static int tcindex_print_opt(struct filter_util *qu, FILE *f,
if (RTA_PAYLOAD(tb[TCA_TCINDEX_MASK]) < sizeof(mask))
return -1;
mask = *(__u16 *) RTA_DATA(tb[TCA_TCINDEX_MASK]);
mask = rta_getattr_u16(tb[TCA_TCINDEX_MASK]);
fprintf(f,"mask 0x%04x ",mask);
}
if (tb[TCA_TCINDEX_SHIFT]) {
......
......@@ -1198,9 +1198,9 @@ static int u32_print_opt(struct filter_util *qu, FILE *f, struct rtattr *opt,
}
if (tb[TCA_U32_DIVISOR]) {
fprintf(f, "ht divisor %d ", *(__u32*)RTA_DATA(tb[TCA_U32_DIVISOR]));
fprintf(f, "ht divisor %d ", rta_getattr_u32(tb[TCA_U32_DIVISOR]));
} else if (tb[TCA_U32_HASH]) {
__u32 htid = *(__u32*)RTA_DATA(tb[TCA_U32_HASH]);
__u32 htid = rta_getattr_u32(tb[TCA_U32_HASH]);
fprintf(f, "key ht %x bkt %x ", TC_U32_USERHTID(htid),
TC_U32_HASH(htid));
} else {
......@@ -1210,14 +1210,14 @@ static int u32_print_opt(struct filter_util *qu, FILE *f, struct rtattr *opt,
SPRINT_BUF(b1);
fprintf(f, "%sflowid %s ",
!sel || !(sel->flags&TC_U32_TERMINAL) ? "*" : "",
sprint_tc_classid(*(__u32*)RTA_DATA(tb[TCA_U32_CLASSID]), b1));
sprint_tc_classid(rta_getattr_u32(tb[TCA_U32_CLASSID]), b1));
} else if (sel && sel->flags&TC_U32_TERMINAL) {
fprintf(f, "terminal flowid ??? ");
}
if (tb[TCA_U32_LINK]) {
SPRINT_BUF(b1);
fprintf(f, "link %s ",
sprint_u32_handle(*(__u32*)RTA_DATA(tb[TCA_U32_LINK]), b1));
sprint_u32_handle(rta_getattr_u32(tb[TCA_U32_LINK]), b1));
}
if (tb[TCA_U32_PCNT]) {
......@@ -1278,7 +1278,7 @@ static int u32_print_opt(struct filter_util *qu, FILE *f, struct rtattr *opt,
}
if (tb[TCA_U32_INDEV]) {
struct rtattr *idev = tb[TCA_U32_INDEV];
fprintf(f, "\n input dev %s\n", (char *) RTA_DATA(idev));
fprintf(f, "\n input dev %s\n", rta_getattr_str(idev));
}
if (tb[TCA_U32_ACT]) {
tc_print_action(f, tb[TCA_U32_ACT]);
......
......@@ -552,7 +552,7 @@ print_ipt(struct action_util *au,FILE * f, struct rtattr *arg)
fprintf(f, "[NULL ipt table name ] assuming mangle ");
} else {
fprintf(f, "tablename: %s ",
(char *) RTA_DATA(tb[TCA_IPT_TABLE]));
rta_getattr_str(tb[TCA_IPT_TABLE]));
}
if (tb[TCA_IPT_HOOK] == NULL) {
......@@ -560,7 +560,7 @@ print_ipt(struct action_util *au,FILE * f, struct rtattr *arg)
return -1;
} else {
__u32 hook;
hook = *(__u32 *) RTA_DATA(tb[TCA_IPT_HOOK]);
hook = rta_getattr_u32(tb[TCA_IPT_HOOK]);
fprintf(f, " hook: %s \n", ipthooks[hook]);
}
......@@ -591,7 +591,7 @@ print_ipt(struct action_util *au,FILE * f, struct rtattr *arg)
fprintf(f, " [NULL ipt target index ]\n");
} else {
__u32 index;
index = *(__u32 *) RTA_DATA(tb[TCA_IPT_INDEX]);
index = rta_getattr_u32(tb[TCA_IPT_INDEX]);
fprintf(f, " \n\tindex %d", index);
}
......
......@@ -353,7 +353,7 @@ print_police(struct action_util *a, FILE *f, struct rtattr *arg)
if (p->peakrate.rate)
fprintf(f, "peakrate %s ", sprint_rate(p->peakrate.rate, b1));
if (tb[TCA_POLICE_AVRATE])
fprintf(f, "avrate %s ", sprint_rate(*(__u32*)RTA_DATA(tb[TCA_POLICE_AVRATE]), b1));
fprintf(f, "avrate %s ", sprint_rate(rta_getattr_u32(tb[TCA_POLICE_AVRATE]), b1));
fprintf(f, "action %s", police_action_n2a(p->action, b1, sizeof(b1)));
if (tb[TCA_POLICE_RESULT]) {
fprintf(f, "/%s ", police_action_n2a(*(int*)RTA_DATA(tb[TCA_POLICE_RESULT]), b1, sizeof(b1)));
......
......@@ -284,7 +284,7 @@ print_ipt(struct action_util *au,FILE * f, struct rtattr *arg)
fprintf(f, "[NULL ipt table name ] assuming mangle ");
} else {
fprintf(f, "tablename: %s ",
(char *) RTA_DATA(tb[TCA_IPT_TABLE]));
rta_getattr_str(tb[TCA_IPT_TABLE]));
}
if (tb[TCA_IPT_HOOK] == NULL) {
......@@ -292,7 +292,7 @@ print_ipt(struct action_util *au,FILE * f, struct rtattr *arg)
return -1;
} else {
__u32 hook;
hook = *(__u32 *) RTA_DATA(tb[TCA_IPT_HOOK]);
hook = rta_getattr_u32(tb[TCA_IPT_HOOK]);
fprintf(f, " hook: %s \n", ipthooks[hook]);
}
......@@ -328,7 +328,7 @@ print_ipt(struct action_util *au,FILE * f, struct rtattr *arg)
fprintf(f, " [NULL ipt target index ]\n");
} else {
__u32 index;
index = *(__u32 *) RTA_DATA(tb[TCA_IPT_INDEX]);
index = rta_getattr_u32(tb[TCA_IPT_INDEX]);
fprintf(f, " \n\tindex %d", index);
}
......
......@@ -367,7 +367,7 @@ print_ipt(struct action_util *au,FILE * f, struct rtattr *arg)
fprintf(f, "[NULL ipt table name ] assuming mangle ");
} else {
fprintf(f, "tablename: %s ",
(char *) RTA_DATA(tb[TCA_IPT_TABLE]));
rta_getattr_str(tb[TCA_IPT_TABLE]));
}
if (tb[TCA_IPT_HOOK] == NULL) {
......@@ -375,7 +375,7 @@ print_ipt(struct action_util *au,FILE * f, struct rtattr *arg)
return -1;
} else {
__u32 hook;
hook = *(__u32 *) RTA_DATA(tb[TCA_IPT_HOOK]);
hook = rta_getattr_u32(tb[TCA_IPT_HOOK]);
fprintf(f, " hook: %s \n", ipthooks[hook]);
}
......@@ -406,7 +406,7 @@ print_ipt(struct action_util *au,FILE * f, struct rtattr *arg)
fprintf(f, " [NULL ipt target index ]\n");
} else {
__u32 index;
index = *(__u32 *) RTA_DATA(tb[TCA_IPT_INDEX]);
index = rta_getattr_u32(tb[TCA_IPT_INDEX]);
fprintf(f, " \n\tindex %d", index);
}
......
......@@ -210,11 +210,11 @@ static int atm_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
}
if (tb[TCA_ATM_HDR]) {
int i;
const __u8 *hdr = RTA_DATA(tb[TCA_ATM_HDR]);
fprintf(f,"hdr");
for (i = 0; i < RTA_PAYLOAD(tb[TCA_ATM_HDR]); i++)
fprintf(f,"%c%02x",i ? '.' : ' ',
((unsigned char *) RTA_DATA(tb[TCA_ATM_HDR]))[i]);
fprintf(f,"%c%02x", i ? '.' : ' ', hdr[i]);
if (!i) fprintf(f," .");
fprintf(f," ");
}
......@@ -224,7 +224,7 @@ static int atm_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
if (RTA_PAYLOAD(tb[TCA_ATM_EXCESS]) < sizeof(excess))
fprintf(stderr,"ATM: excess class ID too short\n");
else {
excess = *(__u32 *) RTA_DATA(tb[TCA_ATM_EXCESS]);
excess = rta_getattr_u32(tb[TCA_ATM_EXCESS]);
if (!excess) fprintf(f,"excess clp ");
else {
char buf[64];
......
......@@ -182,7 +182,7 @@ static int choke_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
return -1;
if (tb[TCA_CHOKE_MAX_P] &&
RTA_PAYLOAD(tb[TCA_CHOKE_MAX_P]) >= sizeof(__u32))
max_P = *(__u32 *)RTA_DATA(tb[TCA_CHOKE_MAX_P]);
max_P = rta_getattr_u32(tb[TCA_CHOKE_MAX_P]);
fprintf(f, "limit %up min %up max %up ",
qopt->limit, qopt->qth_min, qopt->qth_max);
......
......@@ -93,7 +93,7 @@ static int drr_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
if (tb[TCA_DRR_QUANTUM])
fprintf(f, "quantum %s ",
sprint_size(*(__u32 *)RTA_DATA(tb[TCA_DRR_QUANTUM]), b1));
sprint_size(rta_getattr_u32(tb[TCA_DRR_QUANTUM]), b1));
return 0;
}
......
......@@ -140,25 +140,25 @@ static int dsmark_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
if (!RTA_PAYLOAD(tb[TCA_DSMARK_MASK]))
fprintf(stderr,"dsmark: empty mask\n");
else fprintf(f,"mask 0x%02x ",
*(__u8 *) RTA_DATA(tb[TCA_DSMARK_MASK]));
rta_getattr_u8(tb[TCA_DSMARK_MASK]));
}
if (tb[TCA_DSMARK_VALUE]) {
if (!RTA_PAYLOAD(tb[TCA_DSMARK_VALUE]))
fprintf(stderr,"dsmark: empty value\n");
else fprintf(f,"value 0x%02x ",
*(__u8 *) RTA_DATA(tb[TCA_DSMARK_VALUE]));
rta_getattr_u8(tb[TCA_DSMARK_VALUE]));
}
if (tb[TCA_DSMARK_INDICES]) {
if (RTA_PAYLOAD(tb[TCA_DSMARK_INDICES]) < sizeof(__u16))
fprintf(stderr,"dsmark: indices too short\n");
else fprintf(f,"indices 0x%04x ",
*(__u16 *) RTA_DATA(tb[TCA_DSMARK_INDICES]));
rta_getattr_u16(tb[TCA_DSMARK_INDICES]));
}
if (tb[TCA_DSMARK_DEFAULT_INDEX]) {
if (RTA_PAYLOAD(tb[TCA_DSMARK_DEFAULT_INDEX]) < sizeof(__u16))
fprintf(stderr,"dsmark: default_index too short\n");
else fprintf(f,"default_index 0x%04x ",
*(__u16 *) RTA_DATA(tb[TCA_DSMARK_DEFAULT_INDEX]));
rta_getattr_u16(tb[TCA_DSMARK_DEFAULT_INDEX]));
}
if (tb[TCA_DSMARK_SET_TC_INDEX]) fprintf(f,"set_tc_index ");
return 0;
......
......@@ -112,7 +112,7 @@ int prio_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
if (tb[TCA_PRIO_MQ])
fprintf(f, " multiqueue: %s ",
*(unsigned char *)RTA_DATA(tb[TCA_PRIO_MQ]) ? "on" : "off");
rta_getattr_u8(tb[TCA_PRIO_MQ]) ? "on" : "off");
return 0;
}
......
......@@ -102,12 +102,12 @@ static int qfq_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
if (tb[TCA_QFQ_WEIGHT]) {
fprintf(f, "weight %u ",
*(__u32 *)RTA_DATA(tb[TCA_QFQ_WEIGHT]));
rta_getattr_u32(tb[TCA_QFQ_WEIGHT]));
}
if (tb[TCA_QFQ_LMAX]) {
fprintf(f, "maxpkt %u ",
*(__u32 *)RTA_DATA(tb[TCA_QFQ_LMAX]));
rta_getattr_u32(tb[TCA_QFQ_LMAX]));
}
return 0;
......
......@@ -176,7 +176,7 @@ static int red_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
if (tb[TCA_RED_MAX_P] &&
RTA_PAYLOAD(tb[TCA_RED_MAX_P]) >= sizeof(__u32))
max_P = *(__u32 *)RTA_DATA(tb[TCA_RED_MAX_P]);
max_P = rta_getattr_u32(tb[TCA_RED_MAX_P]);
fprintf(f, "limit %s min %s max %s ",
sprint_size(qopt->limit, b1),
......
......@@ -107,7 +107,7 @@ int rr_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
if (tb[TCA_PRIO_MQ])
fprintf(f, " multiqueue: %s ",
*(unsigned char *)RTA_DATA(tb[TCA_PRIO_MQ]) ? "on" : "off");
rta_getattr_u8(tb[TCA_PRIO_MQ]) ? "on" : "off");
return 0;
}
......
......@@ -191,7 +191,7 @@ int print_class(const struct sockaddr_nl *who,
else
print_tc_classid(abuf, sizeof(abuf), t->tcm_handle);
}
fprintf(fp, "class %s %s ", (char*)RTA_DATA(tb[TCA_KIND]), abuf);
fprintf(fp, "class %s %s ", rta_getattr_str(tb[TCA_KIND]), abuf);
if (filter_ifindex == 0)
fprintf(fp, "dev %s ", ll_index_to_name(t->tcm_ifindex));
......
......@@ -240,7 +240,7 @@ int print_filter(const struct sockaddr_nl *who,
fprintf(fp, "pref %u ", prio);
}
}
fprintf(fp, "%s ", (char*)RTA_DATA(tb[TCA_KIND]));
fprintf(fp, "%s ", rta_getattr_str(tb[TCA_KIND]));
q = get_filter_kind(RTA_DATA(tb[TCA_KIND]));
if (tb[TCA_OPTIONS]) {
if (q)
......
......@@ -229,7 +229,7 @@ int print_qdisc(const struct sockaddr_nl *who,
if (n->nlmsg_type == RTM_DELQDISC)
fprintf(fp, "deleted ");
fprintf(fp, "qdisc %s %x: ", (char*)RTA_DATA(tb[TCA_KIND]), t->tcm_handle>>16);
fprintf(fp, "qdisc %s %x: ", rta_getattr_str(tb[TCA_KIND]), t->tcm_handle>>16);
if (filter_ifindex == 0)
fprintf(fp, "dev %s ", ll_index_to_name(t->tcm_ifindex));
if (t->tcm_parent == TC_H_ROOT)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment