sctp_opt_data.c revision 0f1702c5201310f0529cd5abb77652e5e9b241b6
74e20cfe817b82802b16fac8690dadcda76f54f5nh * CDDL HEADER START
74e20cfe817b82802b16fac8690dadcda76f54f5nh * The contents of this file are subject to the terms of the
74e20cfe817b82802b16fac8690dadcda76f54f5nh * Common Development and Distribution License (the "License").
74e20cfe817b82802b16fac8690dadcda76f54f5nh * You may not use this file except in compliance with the License.
74e20cfe817b82802b16fac8690dadcda76f54f5nh * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
74e20cfe817b82802b16fac8690dadcda76f54f5nh * See the License for the specific language governing permissions
74e20cfe817b82802b16fac8690dadcda76f54f5nh * and limitations under the License.
74e20cfe817b82802b16fac8690dadcda76f54f5nh * When distributing Covered Code, include this CDDL HEADER in each
74e20cfe817b82802b16fac8690dadcda76f54f5nh * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
74e20cfe817b82802b16fac8690dadcda76f54f5nh * If applicable, add the following below this CDDL HEADER, with the
74e20cfe817b82802b16fac8690dadcda76f54f5nh * fields enclosed by brackets "[]" replaced with your own identifying
74e20cfe817b82802b16fac8690dadcda76f54f5nh * information: Portions Copyright [yyyy] [name of copyright owner]
74e20cfe817b82802b16fac8690dadcda76f54f5nh * CDDL HEADER END
74e20cfe817b82802b16fac8690dadcda76f54f5nh * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
74e20cfe817b82802b16fac8690dadcda76f54f5nh * Use is subject to license terms.
74e20cfe817b82802b16fac8690dadcda76f54f5nh * Copy the standard header into its new location,
74e20cfe817b82802b16fac8690dadcda76f54f5nh * lay in the new options and then update the relevant
74e20cfe817b82802b16fac8690dadcda76f54f5nh * fields in both sctp_t and the standard header.
74e20cfe817b82802b16fac8690dadcda76f54f5nh * Returns 0 on success, errno otherwise.
74e20cfe817b82802b16fac8690dadcda76f54f5nhsctp_opt_set_header(sctp_t *sctp, const void *ptr, uint_t len)
74e20cfe817b82802b16fac8690dadcda76f54f5nh ip_optp = (uint8_t *)sctp->sctp_ipha + IP_SIMPLE_HDR_LENGTH;
74e20cfe817b82802b16fac8690dadcda76f54f5nh /* convert list termination to no-ops as needed */
74e20cfe817b82802b16fac8690dadcda76f54f5nh while (--padlen >= 0)
74e20cfe817b82802b16fac8690dadcda76f54f5nh * Move the existing SCTP header out where it belongs.
74e20cfe817b82802b16fac8690dadcda76f54f5nh ovbcopy(sctp->sctp_sctph, new_sctph, sizeof (sctp_hdr_t));
74e20cfe817b82802b16fac8690dadcda76f54f5nh * Insert the new user-supplied IP options.
74e20cfe817b82802b16fac8690dadcda76f54f5nh * Could be setting options before setting up connection.
74e20cfe817b82802b16fac8690dadcda76f54f5nh return (0);
74e20cfe817b82802b16fac8690dadcda76f54f5nh sp->spinfo_state = fp->state == SCTP_FADDRS_ALIVE ? SCTP_ACTIVE :
74e20cfe817b82802b16fac8690dadcda76f54f5nh /* count unack'd */
74e20cfe817b82802b16fac8690dadcda76f54f5nh for (meta = sctp->sctp_xmit_head; meta; meta = meta->b_next) {
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning * Count penddata chunks. We can only count chunks in SCTP (not
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning * data already delivered to socket layer).
74e20cfe817b82802b16fac8690dadcda76f54f5nh /* Un-Ordered Frag list */
74e20cfe817b82802b16fac8690dadcda76f54f5nh for (meta = sctp->sctp_uo_frags; meta != NULL; meta = meta->b_next)
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning return (sizeof (*sstat));
74e20cfe817b82802b16fac8690dadcda76f54f5nh * SCTP_GET_PEER_ADDR_INFO
74e20cfe817b82802b16fac8690dadcda76f54f5nhsctp_get_paddrinfo(sctp_t *sctp, void *ptr, socklen_t *optlen)
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning sin4 = (struct sockaddr_in *)&infop->spinfo_address;
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning IN6_INADDR_TO_V4MAPPED(&sin4->sin_addr, &faddr);
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning sin6 = (struct sockaddr_in6 *)&infop->spinfo_address;
74e20cfe817b82802b16fac8690dadcda76f54f5nh infop->spinfo_state = (fp->state == SCTP_FADDRS_ALIVE) ? SCTP_ACTIVE :
74e20cfe817b82802b16fac8690dadcda76f54f5nh return (0);
74e20cfe817b82802b16fac8690dadcda76f54f5nh * SCTP_RTOINFO
74e20cfe817b82802b16fac8690dadcda76f54f5nh srto->srto_initial = TICK_TO_MSEC(sctp->sctp_rto_initial);
09cb82ca24006b806e9f17e2135eef96364facfenh return (sizeof (*srto));
09cb82ca24006b806e9f17e2135eef96364facfenhsctp_set_rtoinfo(sctp_t *sctp, const void *invalp, uint_t inlen)
74e20cfe817b82802b16fac8690dadcda76f54f5nh ispriv = secpolicy_ip_config(sctp->sctp_credp, B_TRUE) == 0;
74e20cfe817b82802b16fac8690dadcda76f54f5nh * Bounds checking. Priviledged user can set the RTO initial
74e20cfe817b82802b16fac8690dadcda76f54f5nh * outside the ndd boundary.
74e20cfe817b82802b16fac8690dadcda76f54f5nh (!ispriv && (srto->srto_initial < sctps->sctps_rto_initialg_low ||
74e20cfe817b82802b16fac8690dadcda76f54f5nh (!ispriv && (srto->srto_max < sctps->sctps_rto_maxg_low ||
193974072f41a843678abf5f61979c748687e66bSherry Moore (!ispriv && (srto->srto_min < sctps->sctps_rto_ming_low ||
74e20cfe817b82802b16fac8690dadcda76f54f5nh sctp->sctp_rto_initial = MSEC_TO_TICK(srto->srto_initial);
74e20cfe817b82802b16fac8690dadcda76f54f5nh return (0);
74e20cfe817b82802b16fac8690dadcda76f54f5nh * SCTP_ASSOCINFO
74e20cfe817b82802b16fac8690dadcda76f54f5nh * Count the number of peer addresses
74e20cfe817b82802b16fac8690dadcda76f54f5nh for (i = 0, fp = sctp->sctp_faddrs; fp != NULL; fp = fp->next) {
74e20cfe817b82802b16fac8690dadcda76f54f5nh sap->sasoc_cookie_life = TICK_TO_MSEC(sctp->sctp_cookie_lifetime);
74e20cfe817b82802b16fac8690dadcda76f54f5nh return (sizeof (*sap));
74e20cfe817b82802b16fac8690dadcda76f54f5nhsctp_set_assocparams(sctp_t *sctp, const void *invalp, uint_t inlen)
return (EINVAL);
return (EINVAL);
return (EINVAL);
return (EINVAL);
return (sizeof (*si));
return (EINVAL);
return (EINVAL);
return (EINVAL);
return (EINVAL);
return (EINVAL);
return (EINVAL);
return (EAFNOSUPPORT);
return (EINVAL);
int retval;
if (retval) {
return (retval);
if (fp) {
return (sizeof (*spp));
int retval;
return (EINVAL);
if (retval != 0) {
return (retval);
return (EINVAL);
return (EINVAL);
return (EINVAL);
return (sizeof (*sinfo));
return (EINVAL);
return (EINVAL);
int retval;
return (EINVAL);
if (retval)
return (retval);
return (EINVAL);
int retval = 0;
return (EINVAL);
switch (level) {
case SOL_SOCKET:
switch (name) {
case SO_LINGER: {
case SO_DEBUG:
case SO_DONTROUTE:
case SO_USELOOPBACK:
case SO_BROADCAST:
case SO_REUSEADDR:
case SO_DGRAM_ERRIND:
case SO_SNDBUF:
case SO_RCVBUF:
case SO_ALLZONES:
case SO_MAC_EXEMPT:
case SO_PROTOTYPE:
case SO_DOMAIN:
case IPPROTO_SCTP:
switch (name) {
case SCTP_RTOINFO:
case SCTP_ASSOCINFO:
case SCTP_INITMSG:
case SCTP_NODELAY:
case SCTP_AUTOCLOSE:
case SCTP_ADAPTATION_LAYER:
case SCTP_PEER_ADDR_PARAMS:
case SCTP_DEFAULT_SEND_PARAM:
case SCTP_EVENTS: {
case SCTP_STATUS:
case SCTP_GET_PEER_ADDR_INFO:
case SCTP_GET_NLADDRS:
case SCTP_GET_LADDRS: {
int addr_cnt;
int addr_size;
if (retval == 0)
case SCTP_GET_NPADDRS: {
case SCTP_GET_PADDRS: {
int addr_cnt;
int addr_size;
if (retval == 0)
case SCTP_PRSCTP:
case SCTP_MAXSEG:
case SCTP_DISABLE_FRAGMENTS:
case IPPROTO_IP:
switch (name) {
case IP_OPTIONS:
case T_IP_OPTIONS: {
char *opt_ptr;
int opt_len;
if (opt_len > 0) {
obuf);
opt_len = 0;
case IP_TOS:
case T_IP_TOS:
case IP_TTL:
case IP_NEXTHOP:
*optlen = 0;
case IPPROTO_IPV6:
switch (name) {
case IPV6_UNICAST_HOPS:
case IPV6_RECVPKTINFO:
*i1 = 0;
case IPV6_RECVHOPLIMIT:
*i1 = 0;
case IPV6_RECVHOPOPTS:
*i1 = 0;
case IPV6_RECVDSTOPTS:
*i1 = 0;
case IPV6_RECVRTHDR:
*i1 = 0;
case IPV6_RECVRTHDRDSTOPTS:
*i1 = 0;
case IPV6_PKTINFO: {
case IPV6_NEXTHOP: {
case IPV6_HOPOPTS: {
int len;
if (len <= 0)
case IPV6_RTHDRDSTOPTS:
case IPV6_RTHDR:
case IPV6_DSTOPTS:
case IPV6_V6ONLY:
return (retval);
retval = 0;
return (EINVAL);
switch (level) {
case SOL_SOCKET:
switch (name) {
case SO_LINGER: {
case SO_DEBUG:
case SO_KEEPALIVE:
case SO_DONTROUTE:
case SO_USELOOPBACK:
case SO_BROADCAST:
case SO_REUSEADDR:
case SO_DGRAM_ERRIND:
case SO_SNDBUF:
if (*i1 < 0) {
case SO_RCVBUF:
if (*i1 != 0) {
case SO_ALLZONES:
B_TRUE)) {
case SO_MAC_EXEMPT:
case IPPROTO_SCTP:
switch (name) {
case SCTP_RTOINFO:
case SCTP_ASSOCINFO:
case SCTP_INITMSG:
case SCTP_NODELAY:
case SCTP_AUTOCLOSE:
case SCTP_PRIMARY_ADDR:
case SCTP_ADAPTATION_LAYER: {
case SCTP_PEER_ADDR_PARAMS:
inlen);
case SCTP_DEFAULT_SEND_PARAM:
case SCTP_EVENTS: {
case SCTP_ADD_ADDR:
case SCTP_REM_ADDR:
B_TRUE);
case SCTP_UC_SWAP: {
sizeof (sctp_upcalls_t));
case SCTP_PRSCTP:
case SCTP_MAXSEG:
case SCTP_DISABLE_FRAGMENTS:
case IPPROTO_IP:
switch (name) {
case IP_OPTIONS:
case T_IP_OPTIONS:
case IP_TOS:
case T_IP_TOS:
case IP_TTL:
case IP_SEC_OPT:
case IP_UNSPEC_SRC:
case IP_NEXTHOP: {
B_TRUE) == 0) {
case IPPROTO_IPV6: {
switch (name) {
case IPV6_UNICAST_HOPS:
case IPV6_UNSPEC_SRC:
case IPV6_RECVPKTINFO:
if (onoff)
case IPV6_RECVHOPLIMIT:
if (onoff)
case IPV6_RECVHOPOPTS:
if (onoff)
case IPV6_RECVDSTOPTS:
if (onoff)
case IPV6_RECVRTHDR:
if (onoff)
case IPV6_RECVRTHDRDSTOPTS:
if (onoff)
case IPV6_PKTINFO:
if (inlen != 0 &&
if (inlen == 0) {
case IPV6_NEXTHOP: {
if (inlen == 0) {
case IPV6_HOPOPTS: {
if (inlen != 0 &&
if (retval != 0)
case IPV6_RTHDRDSTOPTS: {
if (inlen != 0 &&
if (retval != 0)
case IPV6_DSTOPTS: {
if (inlen != 0 &&
if (retval != 0)
case IPV6_RTHDR: {
if (inlen != 0 &&
if (retval != 0)
case IPV6_SEC_OPT:
case IPV6_V6ONLY:
return (retval);
int err = 0;
case AF_INET:
if (err != 0) {
*addrlen = 0;
case AF_INET6:
if (err != 0) {
*addrlen = 0;
return (err);
int err = 0;
case AF_INET:
if (err != 0) {
*addrlen = 0;
case AF_INET6:
if (err != 0) {
*addrlen = 0;
return (err);
int family;
int max;
int cnt;
return (ENOTCONN);
switch (family) {
case AF_INET:
case AF_INET6:
switch (family) {
case AF_INET:
case AF_INET6: