| 3723 | } |
| 3724 | |
| 3725 | static int |
| 3726 | sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, |
| 3727 | void *p) |
| 3728 | { |
| 3729 | int error, set_opt; |
| 3730 | uint32_t *mopt; |
| 3731 | struct sctp_tcb *stcb = NULL; |
| 3732 | struct sctp_inpcb *inp = NULL; |
| 3733 | uint32_t vrf_id; |
| 3734 | |
| 3735 | if (optval == NULL) { |
| 3736 | SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); |
| 3737 | return (EINVAL); |
| 3738 | } |
| 3739 | inp = (struct sctp_inpcb *)so->so_pcb; |
| 3740 | if (inp == NULL) { |
| 3741 | SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); |
| 3742 | return (EINVAL); |
| 3743 | } |
| 3744 | vrf_id = inp->def_vrf_id; |
| 3745 | |
| 3746 | error = 0; |
| 3747 | switch (optname) { |
| 3748 | case SCTP_NODELAY: |
| 3749 | case SCTP_AUTOCLOSE: |
| 3750 | case SCTP_AUTO_ASCONF: |
| 3751 | case SCTP_EXPLICIT_EOR: |
| 3752 | case SCTP_DISABLE_FRAGMENTS: |
| 3753 | case SCTP_USE_EXT_RCVINFO: |
| 3754 | case SCTP_I_WANT_MAPPED_V4_ADDR: |
| 3755 | /* copy in the option value */ |
| 3756 | SCTP_CHECK_AND_CAST(mopt, optval, uint32_t, optsize); |
| 3757 | set_opt = 0; |
| 3758 | if (error) |
| 3759 | break; |
| 3760 | switch (optname) { |
| 3761 | case SCTP_DISABLE_FRAGMENTS: |
| 3762 | set_opt = SCTP_PCB_FLAGS_NO_FRAGMENT; |
| 3763 | break; |
| 3764 | case SCTP_AUTO_ASCONF: |
| 3765 | /* |
| 3766 | * NOTE: we don't really support this flag |
| 3767 | */ |
| 3768 | if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) { |
| 3769 | /* only valid for bound all sockets */ |
| 3770 | if ((SCTP_BASE_SYSCTL(sctp_auto_asconf) == 0) && |
| 3771 | (*mopt != 0)) { |
| 3772 | /* forbidden by admin */ |
| 3773 | SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EPERM); |
| 3774 | return (EPERM); |
| 3775 | } |
| 3776 | set_opt = SCTP_PCB_FLAGS_AUTO_ASCONF; |
| 3777 | } else { |
| 3778 | SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); |
| 3779 | return (EINVAL); |
| 3780 | } |
| 3781 | break; |
| 3782 | case SCTP_EXPLICIT_EOR: |
no test coverage detected