Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/ndp Don't forget to set sin_scope. From Ryota Ozaki



details:   https://anonhg.NetBSD.org/src/rev/5ef37abef49f
branches:  trunk
changeset: 812422:5ef37abef49f
user:      christos <christos%NetBSD.org@localhost>
date:      Mon Dec 14 18:24:06 2015 +0000

description:
Don't forget to set sin_scope. From Ryota Ozaki

diffstat:

 usr.sbin/ndp/ndp.c |  20 +++++++++++++-------
 1 files changed, 13 insertions(+), 7 deletions(-)

diffs (55 lines):

diff -r 0724d9d6c53b -r 5ef37abef49f usr.sbin/ndp/ndp.c
--- a/usr.sbin/ndp/ndp.c        Mon Dec 14 15:29:45 2015 +0000
+++ b/usr.sbin/ndp/ndp.c        Mon Dec 14 18:24:06 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ndp.c,v 1.45 2015/08/03 09:51:40 ozaki-r Exp $ */
+/*     $NetBSD: ndp.c,v 1.46 2015/12/14 18:24:06 christos Exp $        */
 /*     $KAME: ndp.c,v 1.121 2005/07/13 11:30:13 keiichi Exp $  */
 
 /*
@@ -304,6 +304,15 @@
 }
 
 static void
+makeaddr(struct sockaddr_in6 *mysin, const void *resp)
+{
+       const struct sockaddr_in6 *res = resp;
+       mysin->sin6_addr = res->sin6_addr;
+       mysin->sin6_scope_id = res->sin6_scope_id;
+       inet6_putscopeid(mysin, INET6_IS_ADDR_LINKLOCAL);
+}
+
+static void
 getsocket(void)
 {
        if (my_s < 0) {
@@ -362,8 +371,7 @@
                warnx("%s: %s", host, gai_strerror(gai_error));
                return 1;
        }
-       mysin->sin6_addr = ((struct sockaddr_in6 *)(void *)res->ai_addr)->sin6_addr;
-       inet6_putscopeid(mysin, INET6_IS_ADDR_LINKLOCAL);
+       makeaddr(mysin, res->ai_addr);
        ea = (u_char *)LLADDR(&sdl_m);
        if (ndp_ether_aton(eaddr, ea) == 0)
                sdl_m.sdl_alen = 6;
@@ -429,8 +437,7 @@
                warnx("%s: %s", host, gai_strerror(gai_error));
                return;
        }
-       mysin->sin6_addr = ((struct sockaddr_in6 *)(void *)res->ai_addr)->sin6_addr;
-       inet6_putscopeid(mysin, INET6_IS_ADDR_LINKLOCAL);
+       makeaddr(mysin, res->ai_addr);
        dump(&mysin->sin6_addr, 0);
        if (found_entry == 0) {
                (void)getnameinfo((struct sockaddr *)(void *)mysin,
@@ -463,8 +470,7 @@
                warnx("%s: %s", host, gai_strerror(gai_error));
                return 1;
        }
-       mysin->sin6_addr = ((struct sockaddr_in6 *)(void *)res->ai_addr)->sin6_addr;
-       inet6_putscopeid(mysin, INET6_IS_ADDR_LINKLOCAL);
+       makeaddr(mysin, res->ai_addr);
        if (rtmsg(RTM_GET) < 0)
                errx(1, "RTM_GET(%s) failed", host);
        mysin = (struct sockaddr_in6 *)(void *)(rtm + 1);



Home | Main Index | Thread Index | Old Index