Blame SOURCES/0004-ndptool-add-option-to-send-messages-types.patch

2480dc
From 8bd97d7548236a29deeca27c94feb94a1cc71149 Mon Sep 17 00:00:00 2001
2480dc
From: Jamie Bainbridge <jamie.bainbridge@gmail.com>
2480dc
Date: Thu, 10 Mar 2016 16:12:06 +1000
2480dc
Subject: [PATCH 4/6] ndptool: add option to send messages types
2480dc
2480dc
Use the new flags interface of message sending, implement sending
2480dc
Unsolicited NA in ndptool. -U was chosen to mirror established
2480dc
convention of unsolicited ARP in arping.
2480dc
2480dc
Signed-off-by: Jamie Bainbridge <jamie.bainbridge@gmail.com>
2480dc
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
2480dc
---
2480dc
 man/ndptool.8   |  4 ++++
2480dc
 utils/ndptool.c | 12 ++++++++++--
2480dc
 2 files changed, 14 insertions(+), 2 deletions(-)
2480dc
2480dc
diff --git a/man/ndptool.8 b/man/ndptool.8
2480dc
index b742683..ef765dc 100644
2480dc
--- a/man/ndptool.8
2480dc
+++ b/man/ndptool.8
2480dc
@@ -41,6 +41,10 @@ Neighbor Advertisement.
2480dc
 .B "\-i ifname, \-\-ifname ifname"
2480dc
 Specified interface name.
2480dc
 
2480dc
+.TP
2480dc
+.B "\-U, \-\-unsolicited"
2480dc
+Send Unsolicited NA.
2480dc
+
2480dc
 .SH COMMAND
2480dc
 .TP
2480dc
 .B "monitor"
2480dc
diff --git a/utils/ndptool.c b/utils/ndptool.c
2480dc
index 04ec4e1..2639f81 100644
2480dc
--- a/utils/ndptool.c
2480dc
+++ b/utils/ndptool.c
2480dc
@@ -39,6 +39,8 @@ enum verbosity_level {
2480dc
 #define DEFAULT_VERB VERB1
2480dc
 static int g_verbosity = DEFAULT_VERB;
2480dc
 
2480dc
+static uint8_t flags = ND_OPT_NORMAL;
2480dc
+
2480dc
 #define pr_err(args...) fprintf(stderr, ##args)
2480dc
 #define pr_outx(verb_level, args...)			\
2480dc
 	do {						\
2480dc
@@ -133,6 +135,7 @@ static void print_help(const char *argv0) {
2480dc
             "\t-t --msg-type=TYPE       Specify message type\n"
2480dc
 	    "\t                         (\"rs\", \"ra\", \"ns\", \"na\")\n"
2480dc
             "\t-i --ifname=IFNAME       Specify interface name\n"
2480dc
+            "\t-U --unsolicited         Send Unsolicited NA\n"
2480dc
 	    "Available commands:\n"
2480dc
 	    "\tmonitor\n"
2480dc
 	    "\tsend\n",
2480dc
@@ -340,7 +343,8 @@ static int run_cmd_send(struct ndp *ndp, enum ndp_msg_type msg_type,
2480dc
 		return err;
2480dc
 	}
2480dc
 	ndp_msg_ifindex_set(msg, ifindex);
2480dc
-	err = ndp_msg_send(ndp, msg);
2480dc
+
2480dc
+	err = ndp_msg_send(ndp, msg, flags);
2480dc
 	if (err) {
2480dc
 		pr_err("Failed to send message\n");
2480dc
 		goto msg_destroy;
2480dc
@@ -379,6 +383,7 @@ int main(int argc, char **argv)
2480dc
 		{ "verbose",	no_argument,		NULL, 'v' },
2480dc
 		{ "msg-type",	required_argument,	NULL, 't' },
2480dc
 		{ "ifname",	required_argument,	NULL, 'i' },
2480dc
+		{ "unsolicited",no_argument,		NULL, 'U' },
2480dc
 		{ NULL, 0, NULL, 0 }
2480dc
 	};
2480dc
 	int opt;
2480dc
@@ -391,7 +396,7 @@ int main(int argc, char **argv)
2480dc
 	int err;
2480dc
 	int res = EXIT_FAILURE;
2480dc
 
2480dc
-	while ((opt = getopt_long(argc, argv, "hvt:i:",
2480dc
+	while ((opt = getopt_long(argc, argv, "hvt:i:U",
2480dc
 				  long_options, NULL)) >= 0) {
2480dc
 
2480dc
 		switch(opt) {
2480dc
@@ -409,6 +414,9 @@ int main(int argc, char **argv)
2480dc
 			free(ifname);
2480dc
 			ifname = strdup(optarg);
2480dc
 			break;
2480dc
+		case 'U':
2480dc
+			flags |= ND_OPT_NA_UNSOL;
2480dc
+			break;
2480dc
 		case '?':
2480dc
 			pr_err("unknown option.\n");
2480dc
 			print_help(argv0);
2480dc
-- 
2480dc
2.5.5
2480dc