| 878 | } |
| 879 | |
| 880 | static int |
| 881 | rip_attach(struct socket *so, int proto, struct thread *td) |
| 882 | { |
| 883 | struct inpcb *inp; |
| 884 | int error; |
| 885 | |
| 886 | inp = sotoinpcb(so); |
| 887 | KASSERT(inp == NULL, ("rip_attach: inp != NULL")); |
| 888 | |
| 889 | error = priv_check(td, PRIV_NETINET_RAW); |
| 890 | if (error) |
| 891 | return (error); |
| 892 | if (proto >= IPPROTO_MAX || proto < 0) |
| 893 | return EPROTONOSUPPORT; |
| 894 | error = soreserve(so, rip_sendspace, rip_recvspace); |
| 895 | if (error) |
| 896 | return (error); |
| 897 | INP_INFO_WLOCK(&V_ripcbinfo); |
| 898 | error = in_pcballoc(so, &V_ripcbinfo); |
| 899 | if (error) { |
| 900 | INP_INFO_WUNLOCK(&V_ripcbinfo); |
| 901 | return (error); |
| 902 | } |
| 903 | inp = (struct inpcb *)so->so_pcb; |
| 904 | inp->inp_vflag |= INP_IPV4; |
| 905 | inp->inp_ip_p = proto; |
| 906 | inp->inp_ip_ttl = V_ip_defttl; |
| 907 | rip_inshash(inp); |
| 908 | INP_INFO_WUNLOCK(&V_ripcbinfo); |
| 909 | INP_WUNLOCK(inp); |
| 910 | return (0); |
| 911 | } |
| 912 | |
| 913 | static void |
| 914 | rip_detach(struct socket *so) |
nothing calls this directly
no test coverage detected