FreeBSD/sys/netinet6/scope6.c
/*
 * generate standard sockaddr_in6 from embedded form.
 */
generate standard sockaddr_in6 from embedded form.
generate standard sockaddr_in6 from embedded form .
int
sa6_recoverscope(struct sockaddr_in6 *sin6)
{
	char ip6buf[INET6_ADDRSTRLEN];
	u_int32_t zoneid;
	if (IN6_IS_SCOPE_LINKLOCAL(&sin6->sin6_addr) ||
	    IN6_IS_ADDR_MC_INTFACELOCAL(&sin6->sin6_addr)) {
		zoneid = ntohs(sin6->sin6_addr.s6_addr16[1]);
		if (zoneid) {
			if (V_if_index < zoneid)
				return (ENXIO);
#if 0
			if (!ifnet_byindex(zoneid))
				return (ENXIO);
#endif
			if (sin6->sin6_scope_id != 0 &&
			    zoneid != sin6->sin6_scope_id) {
				log(LOG_NOTICE,
				    "%s: embedded scope mismatch: %s%%%d. "
				    "sin6_scope_id was overridden\n", __func__,
				    ip6_sprintf(ip6buf, &sin6->sin6_addr),
				    sin6->sin6_scope_id);
			}
			sin6->sin6_addr.s6_addr16[1] = 0;
			sin6->sin6_scope_id = zoneid;
		}
	}
	return 0;
}
int sa6_recoverscope ( struct sockaddr_in6 * sin6 ) { char ip6buf [ INET6_ADDRSTRLEN ] ; u_int32_t zoneid ; if ( IN6_IS_SCOPE_LINKLOCAL ( & sin6 -> sin6_addr ) || IN6_IS_ADDR_MC_INTFACELOCAL ( & sin6 -> sin6_addr ) ) { zoneid = ntohs ( sin6 -> sin6_addr . s6_addr16 [ 1 ] ) ; if ( zoneid ) { if ( V_if_index < zoneid ) return ( ENXIO ) ; #if 0 if ( ! ifnet_byindex ( zoneid ) ) return ( ENXIO ) ; #endif if ( sin6 -> sin6_scope_id != 0 && zoneid != sin6 -> sin6_scope_id ) { log ( LOG_NOTICE , " " " \n " , __func__ , ip6_sprintf ( ip6buf , & sin6 -> sin6_addr ) , sin6 -> sin6_scope_id ) ; } sin6 -> sin6_addr . s6_addr16 [ 1 ] = 0 ; sin6 -> sin6_scope_id = zoneid ; } } return 0 ; }
generate standard sockaddr_in6 from embedded form.
generate standard sockaddr_in6 from embedded form .
/*
		 * KAME assumption: link id == interface id
		 */ /* sanity check */ /* XXX: Disabled due to possible deadlock. */