Add support for the SCTP_ENABLE_STREAM_RESET socket option to
getsockopt(). This improves the support of RFC 6525. MFC after: 3 days
This commit is contained in:
parent
48ad9597cd
commit
6dac068475
@ -3296,6 +3296,33 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize,
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SCTP_ENABLE_STREAM_RESET:
|
||||
{
|
||||
struct sctp_assoc_value *av;
|
||||
|
||||
SCTP_CHECK_AND_CAST(av, optval, struct sctp_assoc_value, *optsize);
|
||||
SCTP_FIND_STCB(inp, stcb, av->assoc_id);
|
||||
|
||||
if (stcb) {
|
||||
av->assoc_value = (uint32_t) stcb->asoc.local_strreset_support;
|
||||
SCTP_TCB_UNLOCK(stcb);
|
||||
} else {
|
||||
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
|
||||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
|
||||
(av->assoc_id == SCTP_FUTURE_ASSOC)) {
|
||||
SCTP_INP_RLOCK(inp);
|
||||
av->assoc_value = (uint32_t) inp->local_strreset_support;
|
||||
SCTP_INP_RUNLOCK(inp);
|
||||
} else {
|
||||
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL);
|
||||
error = EINVAL;
|
||||
}
|
||||
}
|
||||
if (error == 0) {
|
||||
*optsize = sizeof(struct sctp_assoc_value);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, ENOPROTOOPT);
|
||||
error = ENOPROTOOPT;
|
||||
@ -4096,7 +4123,6 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
|
||||
case SCTP_ENABLE_STREAM_RESET:
|
||||
{
|
||||
struct sctp_assoc_value *av;
|
||||
uint8_t set_value = 0;
|
||||
|
||||
SCTP_CHECK_AND_CAST(av, optval, struct sctp_assoc_value, optsize);
|
||||
if (av->assoc_value & (~SCTP_ENABLE_VALUE_MASK)) {
|
||||
@ -4104,10 +4130,9 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
|
||||
error = EINVAL;
|
||||
break;
|
||||
}
|
||||
set_value = av->assoc_value & SCTP_ENABLE_VALUE_MASK;
|
||||
SCTP_FIND_STCB(inp, stcb, av->assoc_id);
|
||||
if (stcb) {
|
||||
stcb->asoc.local_strreset_support = set_value;
|
||||
stcb->asoc.local_strreset_support = (uint8_t) av->assoc_value;
|
||||
SCTP_TCB_UNLOCK(stcb);
|
||||
} else {
|
||||
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
|
||||
@ -4115,7 +4140,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
|
||||
(av->assoc_id == SCTP_FUTURE_ASSOC) ||
|
||||
(av->assoc_id == SCTP_ALL_ASSOC)) {
|
||||
SCTP_INP_WLOCK(inp);
|
||||
inp->local_strreset_support = set_value;
|
||||
inp->local_strreset_support = (uint8_t) av->assoc_value;
|
||||
SCTP_INP_WUNLOCK(inp);
|
||||
}
|
||||
if ((av->assoc_id == SCTP_CURRENT_ASSOC) ||
|
||||
@ -4123,7 +4148,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
|
||||
SCTP_INP_RLOCK(inp);
|
||||
LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) {
|
||||
SCTP_TCB_LOCK(stcb);
|
||||
stcb->asoc.local_strreset_support = set_value;
|
||||
stcb->asoc.local_strreset_support = (uint8_t) av->assoc_value;
|
||||
SCTP_TCB_UNLOCK(stcb);
|
||||
}
|
||||
SCTP_INP_RUNLOCK(inp);
|
||||
|
Loading…
Reference in New Issue
Block a user