diff options
author | hrs <hrs@FreeBSD.org> | 2012-12-05 19:45:24 +0000 |
---|---|---|
committer | hrs <hrs@FreeBSD.org> | 2012-12-05 19:45:24 +0000 |
commit | 377b89c55f75aba70c2c66bfc96fb4c4af7311ae (patch) | |
tree | 54a3401d4d89d95ebe41cab5790300d24c5a6268 /usr.sbin/ndp/ndp.c | |
parent | efc06bd8013ad630fe9083f423265d89b9d717ff (diff) | |
download | FreeBSD-src-377b89c55f75aba70c2c66bfc96fb4c4af7311ae.zip FreeBSD-src-377b89c55f75aba70c2c66bfc96fb4c4af7311ae.tar.gz |
- Move definition of V_deembed_scopeid to scope6_var.h.
- Deembed scope id in L3 address in in6_lltable_dump().
- Simplify scope id recovery in rtsock routines.
- Remove embedded scope id handling in ndp(8) and route(8) completely.
Diffstat (limited to 'usr.sbin/ndp/ndp.c')
-rw-r--r-- | usr.sbin/ndp/ndp.c | 54 |
1 files changed, 6 insertions, 48 deletions
diff --git a/usr.sbin/ndp/ndp.c b/usr.sbin/ndp/ndp.c index be21d0f..b50ddb7 100644 --- a/usr.sbin/ndp/ndp.c +++ b/usr.sbin/ndp/ndp.c @@ -404,12 +404,8 @@ set(argc, argv) return 1; } sin->sin6_addr = ((struct sockaddr_in6 *)res->ai_addr)->sin6_addr; -#ifdef __KAME__ - if (IN6_IS_ADDR_LINKLOCAL(&sin->sin6_addr)) { - *(u_int16_t *)&sin->sin6_addr.s6_addr[2] = - htons(((struct sockaddr_in6 *)res->ai_addr)->sin6_scope_id); - } -#endif + sin->sin6_scope_id = + ((struct sockaddr_in6 *)res->ai_addr)->sin6_scope_id; ea = (u_char *)LLADDR(&sdl_m); if (ndp_ether_aton(eaddr, ea) == 0) sdl_m.sdl_alen = 6; @@ -478,12 +474,6 @@ get(host) return; } sin->sin6_addr = ((struct sockaddr_in6 *)res->ai_addr)->sin6_addr; -#ifdef __KAME__ - if (IN6_IS_ADDR_LINKLOCAL(&sin->sin6_addr)) { - *(u_int16_t *)&sin->sin6_addr.s6_addr[2] = - htons(((struct sockaddr_in6 *)res->ai_addr)->sin6_scope_id); - } -#endif dump(&sin->sin6_addr, 0); if (found_entry == 0) { getnameinfo((struct sockaddr *)sin, sin->sin6_len, host_buf, @@ -520,12 +510,8 @@ delete(host) return 1; } sin->sin6_addr = ((struct sockaddr_in6 *)res->ai_addr)->sin6_addr; -#ifdef __KAME__ - if (IN6_IS_ADDR_LINKLOCAL(&sin->sin6_addr)) { - *(u_int16_t *)&sin->sin6_addr.s6_addr[2] = - htons(((struct sockaddr_in6 *)res->ai_addr)->sin6_scope_id); - } -#endif + sin->sin6_scope_id = + ((struct sockaddr_in6 *)res->ai_addr)->sin6_scope_id; if (rtmsg(RTM_GET) < 0) { errx(1, "RTM_GET(%s) failed", host); /* NOTREACHED */ @@ -556,16 +542,8 @@ delete: NEXTADDR(RTA_DST, sin_m); rtm->rtm_flags |= RTF_LLDATA; if (rtmsg(RTM_DELETE) == 0) { - struct sockaddr_in6 s6 = *sin; /* XXX: for safety */ - -#ifdef __KAME__ - if (IN6_IS_ADDR_LINKLOCAL(&s6.sin6_addr)) { - s6.sin6_scope_id = ntohs(*(u_int16_t *)&s6.sin6_addr.s6_addr[2]); - *(u_int16_t *)&s6.sin6_addr.s6_addr[2] = 0; - } -#endif - getnameinfo((struct sockaddr *)&s6, - s6.sin6_len, host_buf, + getnameinfo((struct sockaddr *)sin, + sin->sin6_len, host_buf, sizeof(host_buf), NULL, 0, (nflag ? NI_NUMERICHOST : 0)); printf("%s (%s) deleted\n", host, host_buf); @@ -666,10 +644,6 @@ again:; /* XXX: should scope id be filled in the kernel? */ if (sin->sin6_scope_id == 0) sin->sin6_scope_id = sdl->sdl_index; -#ifdef __KAME__ - /* KAME specific hack; removed the embedded id */ - *(u_int16_t *)&sin->sin6_addr.s6_addr[2] = 0; -#endif } getnameinfo((struct sockaddr *)sin, sin->sin6_len, host_buf, sizeof(host_buf), NULL, 0, (nflag ? NI_NUMERICHOST : 0)); @@ -1331,22 +1305,6 @@ plist() p6.sin6_len = sizeof(p6); p6.sin6_addr = PR.prefix; #endif - - /* - * copy link index to sin6_scope_id field. - * XXX: KAME specific. - */ - if (IN6_IS_ADDR_LINKLOCAL(&p6.sin6_addr)) { - u_int16_t linkid; - - memcpy(&linkid, &p6.sin6_addr.s6_addr[2], - sizeof(linkid)); - linkid = ntohs(linkid); - p6.sin6_scope_id = linkid; - p6.sin6_addr.s6_addr[2] = 0; - p6.sin6_addr.s6_addr[3] = 0; - } - niflags = NI_NUMERICHOST; if (getnameinfo((struct sockaddr *)&p6, sizeof(p6), namebuf, sizeof(namebuf), |