MCPcopy Create free account
hub / github.com/F-Stack/f-stack / sa6_embedscope

Function sa6_embedscope

freebsd/netinet6/scope6.c:317–343  ·  view source on GitHub ↗

* 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. */

Source from the content-addressed store, hash-verified

315 * address.
316 */
317int
318sa6_embedscope(struct sockaddr_in6 *sin6, int defaultok)
319{
320 u_int32_t zoneid;
321
322 if ((zoneid = sin6->sin6_scope_id) == 0 && defaultok)
323 zoneid = scope6_addr2default(&sin6->sin6_addr);
324
325 if (zoneid != 0 &&
326 (IN6_IS_SCOPE_LINKLOCAL(&sin6->sin6_addr) ||
327 IN6_IS_ADDR_MC_INTFACELOCAL(&sin6->sin6_addr))) {
328 /*
329 * At this moment, we only check interface-local and
330 * link-local scope IDs, and use interface indices as the
331 * zone IDs assuming a one-to-one mapping between interfaces
332 * and links.
333 */
334 if (V_if_index < zoneid || ifnet_byindex(zoneid) == NULL)
335 return (ENXIO);
336
337 /* XXX assignment to 16bit from 32bit variable */
338 sin6->sin6_addr.s6_addr16[1] = htons(zoneid & 0xffff);
339 sin6->sin6_scope_id = 0;
340 }
341
342 return 0;
343}
344
345/*
346 * generate standard sockaddr_in6 from embedded form.

Callers 15

ipfw_check_packetFunction · 0.85
SCTP6_ARE_ADDR_EQUALFunction · 0.85
sctp_inpcb_bindFunction · 0.85
sctp_add_remote_addrFunction · 0.85
tcp6_getcredFunction · 0.85
sysctl_dropFunction · 0.85
sysctl_switch_tlsFunction · 0.85
sctp_pathmtu_timerFunction · 0.85
in6_gif_ioctlFunction · 0.85
in6_controlFunction · 0.85
in6_validate_ifraFunction · 0.85

Calls 2

scope6_addr2defaultFunction · 0.85
ifnet_byindexFunction · 0.85

Tested by

no test coverage detected