FreeBSD/sys/netinet6/scope6.c
/*
 * Validate the specified scope zone ID in the sin6_scope_id field.  If the ID
 * is unspecified (=0), needs to be specified, and the default zone ID can be
 * used, the default value will be used.
 * This routine then generates the kernel-internal form: if the address scope
 * of is interface-local or link-local, embed the interface index in the
 * address.
 */
Validate the specified scope zone ID in the sin6_scope_id field.  If the ID
is unspecified (=0), needs to be specified, and the default zone ID can be
used, the default value will be used.
This routine then generates the kernel-internal form: if the address scope
of is interface-local or link-local, embed the interface index in the
address.
Validate the specified scope zone ID in the sin6_scope_id field . If the ID is unspecified ( = 0 ) needs to be specified and the default zone ID can be used the default value will be used . This routine then generates the kernel - internal form : if the address scope of is interface - local or link - local embed the interface index in the address .
int
sa6_embedscope(struct sockaddr_in6 *sin6, int defaultok)
{
	u_int32_t zoneid;
	if ((zoneid = sin6->sin6_scope_id) == 0 && defaultok)
		zoneid = scope6_addr2default(&sin6->sin6_addr);
	if (zoneid != 0 &&
	    (IN6_IS_SCOPE_LINKLOCAL(&sin6->sin6_addr) ||
	    IN6_IS_ADDR_MC_INTFACELOCAL(&sin6->sin6_addr))) {
		if (V_if_index < zoneid || ifnet_byindex(zoneid) == NULL)
			return (ENXIO);
		sin6->sin6_addr.s6_addr16[1] = htons(zoneid & 0xffff);
		sin6->sin6_scope_id = 0;
	}
	return 0;
}
int sa6_embedscope ( struct sockaddr_in6 * sin6 , int defaultok ) { u_int32_t zoneid ; if ( ( zoneid = sin6 -> sin6_scope_id ) == 0 && defaultok ) zoneid = scope6_addr2default ( & sin6 -> sin6_addr ) ; if ( zoneid != 0 && ( IN6_IS_SCOPE_LINKLOCAL ( & sin6 -> sin6_addr ) || IN6_IS_ADDR_MC_INTFACELOCAL ( & sin6 -> sin6_addr ) ) ) { if ( V_if_index < zoneid || ifnet_byindex ( zoneid ) == NULL ) return ( ENXIO ) ; sin6 -> sin6_addr . s6_addr16 [ 1 ] = htons ( zoneid & 0xffff ) ; sin6 -> sin6_scope_id = 0 ; } return 0 ; }
Validate the specified scope zone ID in the sin6_scope_id field.
Validate the specified scope zone ID in the sin6_scope_id field .
/*
		 * At this moment, we only check interface-local and
		 * link-local scope IDs, and use interface indices as the
		 * zone IDs assuming a one-to-one mapping between interfaces
		 * and links.
		 */ /* XXX assignment to 16bit from 32bit variable */