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

Function in6_selectsrc_socket

freebsd/netinet6/in6_src.c:552–585  ·  view source on GitHub ↗

* Select source address based on @inp, @dstsock and @opts. * Stores selected address to @srcp. If @scope_ambiguous is set, * embed scope from selected outgoing interface. If @hlim pointer * is provided, stores calculated hop limit there. * Returns 0 on success. */

Source from the content-addressed store, hash-verified

550 * Returns 0 on success.
551 */
552int
553in6_selectsrc_socket(struct sockaddr_in6 *dstsock, struct ip6_pktopts *opts,
554 struct inpcb *inp, struct ucred *cred, int scope_ambiguous,
555 struct in6_addr *srcp, int *hlim)
556{
557 struct ifnet *retifp;
558 uint32_t fibnum;
559 int error;
560
561 fibnum = inp->inp_inc.inc_fibnum;
562 retifp = NULL;
563
564 error = in6_selectsrc(fibnum, dstsock, opts, inp, cred, &retifp, srcp);
565 if (error != 0)
566 return (error);
567
568 if (hlim != NULL)
569 *hlim = in6_selecthlim(inp, retifp);
570
571 if (retifp == NULL || scope_ambiguous == 0)
572 return (0);
573
574 /*
575 * Application should provide a proper zone ID or the use of
576 * default zone IDs should be enabled. Unfortunately, some
577 * applications do not behave as it should, so we need a
578 * workaround. Even if an appropriate ID is not determined
579 * (when it's required), if we can determine the outgoing
580 * interface. determine the zone ID based on the interface.
581 */
582 error = in6_setscope(&dstsock->sin6_addr, retifp, NULL);
583
584 return (error);
585}
586
587/*
588 * Select source address based on @fibnum, @dst and @scopeid.

Callers 4

in6_pcbladdrFunction · 0.85
udp6_outputFunction · 0.85
rip6_outputFunction · 0.85
rip6_connectFunction · 0.85

Calls 3

in6_selectsrcFunction · 0.85
in6_selecthlimFunction · 0.85
in6_setscopeFunction · 0.85

Tested by

no test coverage detected