* Select source address based on @fibnum, @dst and @scopeid. * Stores selected address to @srcp. * Returns 0 on success. * * Used by non-socket based consumers (ND code mostly) */
| 592 | * Used by non-socket based consumers (ND code mostly) |
| 593 | */ |
| 594 | int |
| 595 | in6_selectsrc_addr(uint32_t fibnum, const struct in6_addr *dst, |
| 596 | uint32_t scopeid, struct ifnet *ifp, struct in6_addr *srcp, |
| 597 | int *hlim) |
| 598 | { |
| 599 | struct ifnet *retifp; |
| 600 | struct sockaddr_in6 dst_sa; |
| 601 | int error; |
| 602 | |
| 603 | retifp = ifp; |
| 604 | bzero(&dst_sa, sizeof(dst_sa)); |
| 605 | dst_sa.sin6_family = AF_INET6; |
| 606 | dst_sa.sin6_len = sizeof(dst_sa); |
| 607 | dst_sa.sin6_addr = *dst; |
| 608 | dst_sa.sin6_scope_id = scopeid; |
| 609 | sa6_embedscope(&dst_sa, 0); |
| 610 | |
| 611 | error = in6_selectsrc(fibnum, &dst_sa, NULL, NULL, NULL, &retifp, srcp); |
| 612 | if (hlim != NULL) |
| 613 | *hlim = in6_selecthlim(NULL, retifp); |
| 614 | |
| 615 | return (error); |
| 616 | } |
| 617 | |
| 618 | /* |
| 619 | * clone - meaningful only for bsdi and freebsd |
no test coverage detected