Skip to content
Browse files

added the -z option to specify the zone of the destination, particularly

for the default destination, ff02::1.
  • Loading branch information...
1 parent d2a5b8d commit 396a4821d6ca35f7b258b2e336defbf709a464ca jinmei committed
Showing with 41 additions and 6 deletions.
  1. +15 −1 kame/kame/wru/wru.8
  2. +26 −5 kame/kame/wru/wru.c
View
16 kame/kame/wru/wru.8
@@ -1,4 +1,4 @@
-.\" $KAME: wru.8,v 1.5 2002/01/21 08:25:54 jinmei Exp $
+.\" $KAME: wru.8,v 1.6 2002/03/03 12:25:03 jinmei Exp $
.\"
.\" Copyright (C) 2002 WIDE Project.
.\" All rights reserved.
@@ -49,6 +49,9 @@ client
.Op Fl i Ar interval
.Ek
.Bk -words
+.Op Fl z Ar zone
+.Ek
+.Bk -words
.Op Ar host
.Ek
.Sh DESCRIPTION
@@ -65,6 +68,9 @@ is omitted,
.Nm
sends the query packets to the all-nodes link-local address (ff02::1).
In this case the link zone is determined as follows:
+If the zone is specified by the
+.Fl z
+option, the zone is used.
If the default interface is set via the
.Xr ndp 8
command, the interface is used.
@@ -126,6 +132,14 @@ This option is exclusive with the
option.
.It Fl v
requires verbose output.
+.It Fl z Ar zone
+specifies the zone of the destination.
+This option is typically used when the target
+.Ar host
+is omitted and the default interface is unknown or undesirable.
+When the outgoing
+.Ar host
+is specified, this option assumes it is a numeric address.
.El
.Sh RETURN VALUES
.Nm
View
31 kame/kame/wru/wru.c
@@ -1,4 +1,4 @@
- /* $KAME: wru.c,v 1.8 2002/01/28 06:57:01 itojun Exp $ */
+ /* $KAME: wru.c,v 1.9 2002/03/03 12:25:04 jinmei Exp $ */
/*
* Copyright (C) 2002 WIDE Project.
@@ -105,7 +105,7 @@ main(argc, argv)
int qdatalen = sizeof(struct in6_addr), qbuflen;
int count = 1;
int rsbsize = 81920; /* about 40 clusters */
- char *host, *qbuf, *qdata, rbuf[2048];
+ char *host, *zone = NULL, *qbuf, *qdata, rbuf[2048];
u_int16_t qflags = 0;
u_int8_t nonce[8];
struct addrinfo hints, *res, *res0;
@@ -120,7 +120,7 @@ main(argc, argv)
struct timeval tv;
#endif
- while ((ch = getopt(argc, argv, "1Ama:c:i:v")) != -1) {
+ while ((ch = getopt(argc, argv, "1Ama:c:i:vz:")) != -1) {
switch (ch) {
case '1':
opt_flags |= F_SINGLEWAIT;
@@ -187,6 +187,10 @@ main(argc, argv)
opt_flags |= F_VERBOSE;
break;
+ case 'z':
+ zone = optarg;
+ break;
+
default:
usage();
}
@@ -202,6 +206,23 @@ main(argc, argv)
else
host = argv[0];
+ if (zone) {
+ int newhostlen;
+ char *newhost, *cp;
+
+ /* construct host%zone */
+ newhostlen = strlen(host) + strlen(zone) + 1;
+ if ((newhost = malloc(newhostlen)) == NULL)
+ err(1, "malloc(%d)", newhostlen);
+ cp = newhost;
+ strcpy(cp, host);
+ cp += strlen(host);
+ *cp++ = '%';
+ strcpy(cp, zone);
+
+ host = newhost;
+ }
+
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_INET6;
hints.ai_socktype = SOCK_RAW;
@@ -209,7 +230,7 @@ main(argc, argv)
ret_ga = getaddrinfo(host, NULL, &hints, &res0);
if (ret_ga)
errx(1, "%s", gai_strerror(ret_ga));
- if (argc < 1) {
+ if (argc < 1 && !zone) {
/* try to set the default link ID */
if (res0->ai_next) {
errx(1,
@@ -778,6 +799,6 @@ static void
usage()
{
fprintf(stderr, "usage: wru [-(1|m)] [-Av] [-a [aAclsg]] "
- "[-c count] [-i interval] [host]\n");
+ "[-c count] [-i interval] [-z zone] [host]\n");
exit(1);
}

0 comments on commit 396a482

Please sign in to comment.
Something went wrong with that request. Please try again.