| 652 | } |
| 653 | |
| 654 | static int |
| 655 | rip6_attach(struct socket *so, int proto, struct thread *td) |
| 656 | { |
| 657 | struct inpcb *inp; |
| 658 | struct icmp6_filter *filter; |
| 659 | int error; |
| 660 | |
| 661 | inp = sotoinpcb(so); |
| 662 | KASSERT(inp == NULL, ("rip6_attach: inp != NULL")); |
| 663 | |
| 664 | error = priv_check(td, PRIV_NETINET_RAW); |
| 665 | if (error) |
| 666 | return (error); |
| 667 | error = soreserve(so, rip_sendspace, rip_recvspace); |
| 668 | if (error) |
| 669 | return (error); |
| 670 | filter = malloc(sizeof(struct icmp6_filter), M_PCB, M_NOWAIT); |
| 671 | if (filter == NULL) |
| 672 | return (ENOMEM); |
| 673 | INP_INFO_WLOCK(&V_ripcbinfo); |
| 674 | error = in_pcballoc(so, &V_ripcbinfo); |
| 675 | if (error) { |
| 676 | INP_INFO_WUNLOCK(&V_ripcbinfo); |
| 677 | free(filter, M_PCB); |
| 678 | return (error); |
| 679 | } |
| 680 | inp = (struct inpcb *)so->so_pcb; |
| 681 | INP_INFO_WUNLOCK(&V_ripcbinfo); |
| 682 | inp->inp_vflag |= INP_IPV6; |
| 683 | inp->inp_ip_p = (long)proto; |
| 684 | inp->in6p_hops = -1; /* use kernel default */ |
| 685 | inp->in6p_cksum = -1; |
| 686 | inp->in6p_icmp6filt = filter; |
| 687 | ICMP6_FILTER_SETPASSALL(inp->in6p_icmp6filt); |
| 688 | INP_WUNLOCK(inp); |
| 689 | return (0); |
| 690 | } |
| 691 | |
| 692 | static void |
| 693 | rip6_detach(struct socket *so) |
nothing calls this directly
no test coverage detected