From: Ken-ichirou MATSUZAWA <chamaken@gmail.com>
To: netfilter-devel@vger.kernel.org
Cc: Pablo Neira Ayuso <pablo@netfilter.org>
Subject: libmnl [PATCH 6/8] examples: made sub functions the same
Date: Sat, 07 Dec 2013 20:29:23 +0900 [thread overview]
Message-ID: <87fvq4aoh8.wl%chamaken@gmail.com> (raw)
show entry in oneline and RTA_PRIORITY
Signed-off-by: Ken-ichirou MATSUZAWA <chamas@h4.dion.ne.jp>
---
examples/rtnl/rtnl-route-dump.c | 10 +++++++---
examples/rtnl/rtnl-route-event.c | 13 ++++++++++---
2 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/examples/rtnl/rtnl-route-dump.c b/examples/rtnl/rtnl-route-dump.c
index 9829e36..17da80b 100644
--- a/examples/rtnl/rtnl-route-dump.c
+++ b/examples/rtnl/rtnl-route-dump.c
@@ -71,7 +71,6 @@ static void attributes_show_ipv4(struct nlattr *tb[])
}
}
}
- printf("\n");
}
/* like inet_ntoa(), not reentrant */
@@ -109,6 +108,9 @@ static void attributes_show_ipv6(struct nlattr *tb[])
struct in6_addr *addr = mnl_attr_get_payload(tb[RTA_GATEWAY]);
printf("gw=%s ", inet6_ntoa(*addr));
}
+ if (tb[RTA_PRIORITY]) {
+ printf("prio=%u ", mnl_attr_get_u32(tb[RTA_PRIORITY]));
+ }
if (tb[RTA_METRICS]) {
int i;
struct nlattr *tbx[RTAX_MAX+1] = {};
@@ -122,7 +124,6 @@ static void attributes_show_ipv6(struct nlattr *tb[])
}
}
}
- printf("\n");
}
static int data_ipv4_attr_cb(const struct nlattr *attr, void *data)
@@ -142,6 +143,7 @@ static int data_ipv4_attr_cb(const struct nlattr *attr, void *data)
case RTA_FLOW:
case RTA_PREFSRC:
case RTA_GATEWAY:
+ case RTA_PRIORITY:
if (mnl_attr_validate(attr, MNL_TYPE_U32) < 0) {
perror("mnl_attr_validate");
return MNL_CB_ERROR;
@@ -171,6 +173,7 @@ static int data_ipv6_attr_cb(const struct nlattr *attr, void *data)
case RTA_TABLE:
case RTA_OIF:
case RTA_FLOW:
+ case RTA_PRIORITY:
if (mnl_attr_validate(attr, MNL_TYPE_U32) < 0) {
perror("mnl_attr_validate");
return MNL_CB_ERROR;
@@ -276,7 +279,7 @@ static int data_cb(const struct nlmsghdr *nlh, void *data)
* RTM_F_EQUALIZE = 0x400: Multipath equalizer: NI
* RTM_F_PREFIX = 0x800: Prefix addresses
*/
- printf("flags=%x\n", rm->rtm_flags);
+ printf("flags=%x ", rm->rtm_flags);
switch(rm->rtm_family) {
case AF_INET:
@@ -289,6 +292,7 @@ static int data_cb(const struct nlmsghdr *nlh, void *data)
break;
}
+ printf("\n");
return MNL_CB_OK;
}
diff --git a/examples/rtnl/rtnl-route-event.c b/examples/rtnl/rtnl-route-event.c
index 8a836f8..6cad9f0 100644
--- a/examples/rtnl/rtnl-route-event.c
+++ b/examples/rtnl/rtnl-route-event.c
@@ -55,6 +55,9 @@ static void attributes_show_ipv4(struct nlattr *tb[])
struct in_addr *addr = mnl_attr_get_payload(tb[RTA_GATEWAY]);
printf("gw=%s ", inet_ntoa(*addr));
}
+ if (tb[RTA_PRIORITY]) {
+ printf("prio=%u ", mnl_attr_get_u32(tb[RTA_PRIORITY]));
+ }
if (tb[RTA_METRICS]) {
int i;
struct nlattr *tbx[RTAX_MAX+1] = {};
@@ -105,6 +108,9 @@ static void attributes_show_ipv6(struct nlattr *tb[])
struct in6_addr *addr = mnl_attr_get_payload(tb[RTA_GATEWAY]);
printf("gw=%s ", inet6_ntoa(*addr));
}
+ if (tb[RTA_PRIORITY]) {
+ printf("prio=%u ", mnl_attr_get_u32(tb[RTA_PRIORITY]));
+ }
if (tb[RTA_METRICS]) {
int i;
struct nlattr *tbx[RTAX_MAX+1] = {};
@@ -118,7 +124,6 @@ static void attributes_show_ipv6(struct nlattr *tb[])
}
}
}
- printf("\n");
}
static int data_ipv4_attr_cb(const struct nlattr *attr, void *data)
@@ -138,6 +143,7 @@ static int data_ipv4_attr_cb(const struct nlattr *attr, void *data)
case RTA_FLOW:
case RTA_PREFSRC:
case RTA_GATEWAY:
+ case RTA_PRIORITY:
if (mnl_attr_validate(attr, MNL_TYPE_U32) < 0) {
perror("mnl_attr_validate");
return MNL_CB_ERROR;
@@ -167,6 +173,7 @@ static int data_ipv6_attr_cb(const struct nlattr *attr, void *data)
case RTA_TABLE:
case RTA_OIF:
case RTA_FLOW:
+ case RTA_PRIORITY:
if (mnl_attr_validate(attr, MNL_TYPE_U32) < 0) {
perror("mnl_attr_validate");
return MNL_CB_ERROR;
@@ -281,7 +288,7 @@ static int data_cb(const struct nlmsghdr *nlh, void *data)
* RTM_F_EQUALIZE = 0x400: Multipath equalizer: NI
* RTM_F_PREFIX = 0x800: Prefix addresses
*/
- printf("flags=%x", rm->rtm_flags);
+ printf("flags=%x ", rm->rtm_flags);
switch(rm->rtm_family) {
case AF_INET:
@@ -293,8 +300,8 @@ static int data_cb(const struct nlmsghdr *nlh, void *data)
attributes_show_ipv6(tb);
break;
}
- printf("\n");
+ printf("\n");
return MNL_CB_OK;
}
--
1.8.4.rc3
reply other threads:[~2013-12-07 11:29 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87fvq4aoh8.wl%chamaken@gmail.com \
--to=chamaken@gmail.com \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).