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