sctp_ifap is used to bypass normal local address validation checks */
| 2803 | |
| 2804 | /* sctp_ifap is used to bypass normal local address validation checks */ |
| 2805 | int |
| 2806 | sctp_inpcb_bind(struct socket *so, struct sockaddr *addr, |
| 2807 | struct sctp_ifa *sctp_ifap, struct thread *p) |
| 2808 | { |
| 2809 | /* bind a ep to a socket address */ |
| 2810 | struct sctppcbhead *head; |
| 2811 | struct sctp_inpcb *inp, *inp_tmp; |
| 2812 | struct inpcb *ip_inp; |
| 2813 | int port_reuse_active = 0; |
| 2814 | int bindall; |
| 2815 | uint16_t lport; |
| 2816 | int error; |
| 2817 | uint32_t vrf_id; |
| 2818 | |
| 2819 | lport = 0; |
| 2820 | bindall = 1; |
| 2821 | inp = (struct sctp_inpcb *)so->so_pcb; |
| 2822 | ip_inp = (struct inpcb *)so->so_pcb; |
| 2823 | #ifdef SCTP_DEBUG |
| 2824 | if (addr) { |
| 2825 | SCTPDBG(SCTP_DEBUG_PCB1, "Bind called port: %d\n", |
| 2826 | ntohs(((struct sockaddr_in *)addr)->sin_port)); |
| 2827 | SCTPDBG(SCTP_DEBUG_PCB1, "Addr: "); |
| 2828 | SCTPDBG_ADDR(SCTP_DEBUG_PCB1, addr); |
| 2829 | } |
| 2830 | #endif |
| 2831 | if ((inp->sctp_flags & SCTP_PCB_FLAGS_UNBOUND) == 0) { |
| 2832 | /* already did a bind, subsequent binds NOT allowed ! */ |
| 2833 | SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL); |
| 2834 | return (EINVAL); |
| 2835 | } |
| 2836 | #ifdef INVARIANTS |
| 2837 | if (p == NULL) |
| 2838 | panic("null proc/thread"); |
| 2839 | #endif |
| 2840 | if (addr != NULL) { |
| 2841 | switch (addr->sa_family) { |
| 2842 | #ifdef INET |
| 2843 | case AF_INET: |
| 2844 | { |
| 2845 | struct sockaddr_in *sin; |
| 2846 | |
| 2847 | /* IPV6_V6ONLY socket? */ |
| 2848 | if (SCTP_IPV6_V6ONLY(inp)) { |
| 2849 | SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL); |
| 2850 | return (EINVAL); |
| 2851 | } |
| 2852 | if (addr->sa_len != sizeof(*sin)) { |
| 2853 | SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL); |
| 2854 | return (EINVAL); |
| 2855 | } |
| 2856 | |
| 2857 | sin = (struct sockaddr_in *)addr; |
| 2858 | lport = sin->sin_port; |
| 2859 | /* |
| 2860 | * For LOOPBACK the prison_local_ip4() call |
| 2861 | * will transmute the ip address to the |
| 2862 | * proper value. |
no test coverage detected