summaryrefslogtreecommitdiff
path: root/ip/iprule.c
diff options
context:
space:
mode:
authorPhil Sutter <phil@nwl.cc>2016-03-22 19:35:17 +0100
committerStephen Hemminger <stephen@networkplumber.org>2016-03-27 10:37:35 -0700
commitd49f934c1019cf92a500b951e21ae7cbc46ca7c7 (patch)
tree15066a248c80d10cfb063065442ae52d770fcf9e /ip/iprule.c
parent2e96d2ccd03a29896fc8a2c6ee6b769c512501df (diff)
lib/utils: introduce format_host_rta()
This simple macro eases calling format_host() with data from an rt_attr pointer. Signed-off-by: Phil Sutter <phil@nwl.cc>
Diffstat (limited to 'ip/iprule.c')
-rw-r--r--ip/iprule.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/ip/iprule.c b/ip/iprule.c
index 3fd510ef..ac570440 100644
--- a/ip/iprule.c
+++ b/ip/iprule.c
@@ -89,10 +89,8 @@ int print_rule(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
r->rtm_src_len
);
} else {
- fprintf(fp, "from %s ", format_host(r->rtm_family,
- RTA_PAYLOAD(tb[FRA_SRC]),
- RTA_DATA(tb[FRA_SRC]))
- );
+ fprintf(fp, "from %s ",
+ format_host_rta(r->rtm_family, tb[FRA_SRC]));
}
} else if (r->rtm_src_len) {
fprintf(fp, "from 0/%d ", r->rtm_src_len);
@@ -108,9 +106,8 @@ int print_rule(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
r->rtm_dst_len
);
} else {
- fprintf(fp, "to %s ", format_host(r->rtm_family,
- RTA_PAYLOAD(tb[FRA_DST]),
- RTA_DATA(tb[FRA_DST])));
+ fprintf(fp, "to %s ",
+ format_host_rta(r->rtm_family, tb[FRA_DST]));
}
} else if (r->rtm_dst_len) {
fprintf(fp, "to 0/%d ", r->rtm_dst_len);
@@ -183,9 +180,8 @@ int print_rule(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
if (r->rtm_type == RTN_NAT) {
if (tb[RTA_GATEWAY]) {
fprintf(fp, "map-to %s ",
- format_host(r->rtm_family,
- RTA_PAYLOAD(tb[RTA_GATEWAY]),
- RTA_DATA(tb[RTA_GATEWAY])));
+ format_host_rta(r->rtm_family,
+ tb[RTA_GATEWAY]));
} else
fprintf(fp, "masquerade");
} else if (r->rtm_type == FR_ACT_GOTO) {