| 6942 | |
| 6943 | #ifdef INET |
| 6944 | static int |
| 6945 | sctp_connect(struct socket *so, struct sockaddr *addr, struct thread *p) |
| 6946 | { |
| 6947 | struct epoch_tracker et; |
| 6948 | int error = 0; |
| 6949 | int create_lock_on = 0; |
| 6950 | uint32_t vrf_id; |
| 6951 | struct sctp_inpcb *inp; |
| 6952 | struct sctp_tcb *stcb = NULL; |
| 6953 | |
| 6954 | inp = (struct sctp_inpcb *)so->so_pcb; |
| 6955 | if (inp == NULL) { |
| 6956 | /* I made the same as TCP since we are not setup? */ |
| 6957 | SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); |
| 6958 | return (ECONNRESET); |
| 6959 | } |
| 6960 | if (addr == NULL) { |
| 6961 | SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); |
| 6962 | return EINVAL; |
| 6963 | } |
| 6964 | |
| 6965 | switch (addr->sa_family) { |
| 6966 | #ifdef INET6 |
| 6967 | case AF_INET6: |
| 6968 | { |
| 6969 | struct sockaddr_in6 *sin6; |
| 6970 | |
| 6971 | if (addr->sa_len != sizeof(struct sockaddr_in6)) { |
| 6972 | SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); |
| 6973 | return (EINVAL); |
| 6974 | } |
| 6975 | sin6 = (struct sockaddr_in6 *)addr; |
| 6976 | if (p != NULL && (error = prison_remote_ip6(p->td_ucred, &sin6->sin6_addr)) != 0) { |
| 6977 | SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, error); |
| 6978 | return (error); |
| 6979 | } |
| 6980 | break; |
| 6981 | } |
| 6982 | #endif |
| 6983 | #ifdef INET |
| 6984 | case AF_INET: |
| 6985 | { |
| 6986 | struct sockaddr_in *sin; |
| 6987 | |
| 6988 | if (addr->sa_len != sizeof(struct sockaddr_in)) { |
| 6989 | SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); |
| 6990 | return (EINVAL); |
| 6991 | } |
| 6992 | sin = (struct sockaddr_in *)addr; |
| 6993 | if (p != NULL && (error = prison_remote_ip4(p->td_ucred, &sin->sin_addr)) != 0) { |
| 6994 | SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, error); |
| 6995 | return (error); |
| 6996 | } |
| 6997 | break; |
| 6998 | } |
| 6999 | #endif |
| 7000 | default: |
| 7001 | SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EAFNOSUPPORT); |
nothing calls this directly
no test coverage detected