summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiri Pirko <jiri@resnulli.us>2013-06-13 16:10:50 +0200
committerJiri Pirko <jiri@resnulli.us>2013-06-13 16:12:09 +0200
commit69d1c977b4770e651db6bc498fdca9c3061cef8c (patch)
tree6e6fe8ddb46b9a0e76e7aedef6e1a460ff7c69d5
parent39e1f53dd4efc00b84ff097b15558747c92593f2 (diff)
downloadlibndp-69d1c977b4770e651db6bc498fdca9c3061cef8c.tar.gz
add flag getters for prefix option
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
-rw-r--r--include/ndp.h3
-rw-r--r--libndp/libndp.c60
-rw-r--r--utils/ndptool.c6
3 files changed, 69 insertions, 0 deletions
diff --git a/include/ndp.h b/include/ndp.h
index 423181d..08d6ad4 100644
--- a/include/ndp.h
+++ b/include/ndp.h
@@ -127,6 +127,9 @@ struct in6_addr *ndp_msg_opt_prefix(struct ndp_msg *msg, int offset);
uint8_t ndp_msg_opt_prefix_len(struct ndp_msg *msg, int offset);
uint32_t ndp_msg_opt_prefix_valid_time(struct ndp_msg *msg, int offset);
uint32_t ndp_msg_opt_prefix_preferred_time(struct ndp_msg *msg, int offset);
+bool ndp_msg_opt_prefix_flag_on_link(struct ndp_msg *msg, int offset);
+bool ndp_msg_opt_prefix_flag_auto_addr_conf(struct ndp_msg *msg, int offset);
+bool ndp_msg_opt_prefix_flag_router_addr(struct ndp_msg *msg, int offset);
uint32_t ndp_msg_opt_mtu(struct ndp_msg *msg, int offset);
diff --git a/libndp/libndp.c b/libndp/libndp.c
index 20efe90..0600e59 100644
--- a/libndp/libndp.c
+++ b/libndp/libndp.c
@@ -1266,6 +1266,66 @@ uint32_t ndp_msg_opt_prefix_preferred_time(struct ndp_msg *msg, int offset)
}
/**
+ * ndp_msg_opt_prefix_flag_on_link:
+ * @msg: message structure
+ * @offset: in-message offset
+ *
+ * Get on-link flag.
+ * User should use this function only inside ndp_msg_opt_for_each_offset()
+ * macro loop.
+ *
+ * Returns: on-link flag.
+ **/
+NDP_EXPORT
+bool ndp_msg_opt_prefix_flag_on_link(struct ndp_msg *msg, int offset)
+{
+ struct nd_opt_prefix_info *pi =
+ ndp_msg_payload_opts_offset(msg, offset);
+
+ return pi->nd_opt_pi_flags_reserved & ND_OPT_PI_FLAG_ONLINK;
+}
+
+/**
+ * ndp_msg_opt_prefix_flag_auto_addr_conf:
+ * @msg: message structure
+ * @offset: in-message offset
+ *
+ * Get autonomous address-configuration flag.
+ * User should use this function only inside ndp_msg_opt_for_each_offset()
+ * macro loop.
+ *
+ * Returns: autonomous address-configuration flag.
+ **/
+NDP_EXPORT
+bool ndp_msg_opt_prefix_flag_auto_addr_conf(struct ndp_msg *msg, int offset)
+{
+ struct nd_opt_prefix_info *pi =
+ ndp_msg_payload_opts_offset(msg, offset);
+
+ return pi->nd_opt_pi_flags_reserved & ND_OPT_PI_FLAG_AUTO;
+}
+
+/**
+ * ndp_msg_opt_prefix_flag_router_addr:
+ * @msg: message structure
+ * @offset: in-message offset
+ *
+ * Get router address flag.
+ * User should use this function only inside ndp_msg_opt_for_each_offset()
+ * macro loop.
+ *
+ * Returns: router address flag.
+ **/
+NDP_EXPORT
+bool ndp_msg_opt_prefix_flag_router_addr(struct ndp_msg *msg, int offset)
+{
+ struct nd_opt_prefix_info *pi =
+ ndp_msg_payload_opts_offset(msg, offset);
+
+ return pi->nd_opt_pi_flags_reserved & ND_OPT_PI_FLAG_RADDR;
+}
+
+/**
* ndp_msg_opt_mtu:
* @msg: message structure
* @offset: in-message offset
diff --git a/utils/ndptool.c b/utils/ndptool.c
index 32b641f..d0764ce 100644
--- a/utils/ndptool.c
+++ b/utils/ndptool.c
@@ -257,6 +257,12 @@ static int msgrcv_handler_func(struct ndp *ndp, struct ndp_msg *msg, void *priv)
pr_out("infinity");
else
pr_out("%us", preferred_time);
+ pr_out(", on_link: %s",
+ ndp_msg_opt_prefix_flag_on_link(msg, offset) ? "yes" : "no");
+ pr_out(", autonomous_addr_conf: %s",
+ ndp_msg_opt_prefix_flag_auto_addr_conf(msg, offset) ? "yes" : "no");
+ pr_out(", router_addr: %s",
+ ndp_msg_opt_prefix_flag_router_addr(msg, offset) ? "yes" : "no");
pr_out("\n");
}
ndp_msg_opt_for_each_offset(offset, msg, NDP_MSG_OPT_MTU)