| 1032 | } |
| 1033 | |
| 1034 | static int |
| 1035 | udp6_attach(struct socket *so, int proto, struct thread *td) |
| 1036 | { |
| 1037 | struct inpcb *inp; |
| 1038 | struct inpcbinfo *pcbinfo; |
| 1039 | int error; |
| 1040 | |
| 1041 | pcbinfo = udp_get_inpcbinfo(so->so_proto->pr_protocol); |
| 1042 | inp = sotoinpcb(so); |
| 1043 | KASSERT(inp == NULL, ("udp6_attach: inp != NULL")); |
| 1044 | |
| 1045 | if (so->so_snd.sb_hiwat == 0 || so->so_rcv.sb_hiwat == 0) { |
| 1046 | error = soreserve(so, udp_sendspace, udp_recvspace); |
| 1047 | if (error) |
| 1048 | return (error); |
| 1049 | } |
| 1050 | INP_INFO_WLOCK(pcbinfo); |
| 1051 | error = in_pcballoc(so, pcbinfo); |
| 1052 | if (error) { |
| 1053 | INP_INFO_WUNLOCK(pcbinfo); |
| 1054 | return (error); |
| 1055 | } |
| 1056 | inp = (struct inpcb *)so->so_pcb; |
| 1057 | inp->inp_vflag |= INP_IPV6; |
| 1058 | if ((inp->inp_flags & IN6P_IPV6_V6ONLY) == 0) |
| 1059 | inp->inp_vflag |= INP_IPV4; |
| 1060 | inp->in6p_hops = -1; /* use kernel default */ |
| 1061 | inp->in6p_cksum = -1; /* just to be sure */ |
| 1062 | /* |
| 1063 | * XXX: ugly!! |
| 1064 | * IPv4 TTL initialization is necessary for an IPv6 socket as well, |
| 1065 | * because the socket may be bound to an IPv6 wildcard address, |
| 1066 | * which may match an IPv4-mapped IPv6 address. |
| 1067 | */ |
| 1068 | inp->inp_ip_ttl = V_ip_defttl; |
| 1069 | |
| 1070 | error = udp_newudpcb(inp); |
| 1071 | if (error) { |
| 1072 | in_pcbdetach(inp); |
| 1073 | in_pcbfree(inp); |
| 1074 | INP_INFO_WUNLOCK(pcbinfo); |
| 1075 | return (error); |
| 1076 | } |
| 1077 | INP_WUNLOCK(inp); |
| 1078 | INP_INFO_WUNLOCK(pcbinfo); |
| 1079 | return (0); |
| 1080 | } |
| 1081 | |
| 1082 | static int |
| 1083 | udp6_bind(struct socket *so, struct sockaddr *nam, struct thread *td) |
nothing calls this directly
no test coverage detected