* Select the interface for transmitting IPv6 multicast datagrams. * * Either an instance of struct in6_addr or an instance of struct ipv6_mreqn * may be passed to this socket option. An address of in6addr_any or an * interface index of 0 is used to remove a previous selection. * When no interface is selected, one is chosen for every send. */
| 2407 | * When no interface is selected, one is chosen for every send. |
| 2408 | */ |
| 2409 | static int |
| 2410 | in6p_set_multicast_if(struct inpcb *inp, struct sockopt *sopt) |
| 2411 | { |
| 2412 | struct ifnet *ifp; |
| 2413 | struct ip6_moptions *imo; |
| 2414 | u_int ifindex; |
| 2415 | int error; |
| 2416 | |
| 2417 | if (sopt->sopt_valsize != sizeof(u_int)) |
| 2418 | return (EINVAL); |
| 2419 | |
| 2420 | error = sooptcopyin(sopt, &ifindex, sizeof(u_int), sizeof(u_int)); |
| 2421 | if (error) |
| 2422 | return (error); |
| 2423 | if (V_if_index < ifindex) |
| 2424 | return (EINVAL); |
| 2425 | if (ifindex == 0) |
| 2426 | ifp = NULL; |
| 2427 | else { |
| 2428 | ifp = ifnet_byindex(ifindex); |
| 2429 | if (ifp == NULL) |
| 2430 | return (EINVAL); |
| 2431 | if ((ifp->if_flags & IFF_MULTICAST) == 0) |
| 2432 | return (EADDRNOTAVAIL); |
| 2433 | } |
| 2434 | imo = in6p_findmoptions(inp); |
| 2435 | imo->im6o_multicast_ifp = ifp; |
| 2436 | INP_WUNLOCK(inp); |
| 2437 | |
| 2438 | return (0); |
| 2439 | } |
| 2440 | |
| 2441 | /* |
| 2442 | * Atomically set source filters on a socket for an IPv6 multicast group. |
no test coverage detected