diff --git a/package/gluon-neighbour-info/src/gluon-neighbour-info.c b/package/gluon-neighbour-info/src/gluon-neighbour-info.c index c1dd162a..b7206f6f 100644 --- a/package/gluon-neighbour-info/src/gluon-neighbour-info.c +++ b/package/gluon-neighbour-info/src/gluon-neighbour-info.c @@ -38,7 +38,7 @@ void usage() { puts("Usage: gluon-neighbour-info [-h] [-s] [-l] [-c ] [-t ] -d -p -i -r "); puts(" -p UDP port"); - puts(" -d multicast group, e.g. ff02:0:0:0:0:0:2:1001"); + puts(" -d destination address (unicast ip6 or multicast group, e.g. ff02:0:0:0:0:0:2:1001)"); puts(" -i interface, e.g. eth0 "); puts(" -r request, e.g. nodeinfo"); puts(" -t timeout in seconds (default: 3)"); @@ -145,7 +145,6 @@ int main(int argc, char **argv) { } client_addr.sin6_family = AF_INET6; - client_addr.sin6_addr = in6addr_any; opterr = 0; @@ -154,6 +153,7 @@ int main(int argc, char **argv) { char *sse = NULL; bool loop = false; int ret = false; + bool destination_set = false; int c; while ((c = getopt(argc, argv, "p:d:r:i:t:s:c:lh")) != -1) @@ -165,6 +165,8 @@ int main(int argc, char **argv) { if (!inet_pton(AF_INET6, optarg, &client_addr.sin6_addr)) { perror("Invalid IPv6 address. This message will probably confuse you"); exit(EXIT_FAILURE); + } else { + destination_set = true; } break; case 'i': @@ -206,10 +208,20 @@ int main(int argc, char **argv) { } if (request_string == NULL) { - fprintf(stderr, "No request string supplied"); + fprintf(stderr, "No request string supplied\n"); exit(EXIT_FAILURE); } + if (client_addr.sin6_port == htons(0)) { + fprintf(stderr, "No port supplied\n"); + exit(EXIT_FAILURE); + } + + if (!destination_set) { + fprintf(stderr, "No destination address supplied\n"); + exit(EXIT_FAILURE); + } + if (sse) { fputs("Content-Type: text/event-stream\n\n", stdout); fflush(stdout);