17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 545916cd2Sjpk * Common Development and Distribution License (the "License"). 645916cd2Sjpk * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 2177c67f2fSkcpoon 227c478bd9Sstevel@tonic-gate /* 23fd7b5aedSGeorge Shepherd * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 26c1bf5ca0SJohn Levon /* 27c1bf5ca0SJohn Levon * Copyright (c) 2018, Joyent, Inc. 28c1bf5ca0SJohn Levon */ 29c1bf5ca0SJohn Levon 307c478bd9Sstevel@tonic-gate #include <sys/types.h> 317c478bd9Sstevel@tonic-gate #include <sys/stream.h> 327c478bd9Sstevel@tonic-gate #define _SUN_TPI_VERSION 2 337c478bd9Sstevel@tonic-gate #include <sys/tihdr.h> 347c478bd9Sstevel@tonic-gate #include <sys/socket.h> 357c478bd9Sstevel@tonic-gate #include <sys/xti_inet.h> 367c478bd9Sstevel@tonic-gate #include <sys/systm.h> 377c478bd9Sstevel@tonic-gate #include <sys/ddi.h> 387c478bd9Sstevel@tonic-gate #include <sys/sunddi.h> 397c478bd9Sstevel@tonic-gate #include <sys/kmem.h> 407c478bd9Sstevel@tonic-gate #include <sys/strsubr.h> 417c478bd9Sstevel@tonic-gate #include <sys/strsun.h> 427c478bd9Sstevel@tonic-gate #include <sys/policy.h> 437c478bd9Sstevel@tonic-gate 447c478bd9Sstevel@tonic-gate #include <inet/common.h> 457c478bd9Sstevel@tonic-gate #include <netinet/ip6.h> 467c478bd9Sstevel@tonic-gate #include <inet/ip.h> 477c478bd9Sstevel@tonic-gate #include <inet/ip_ire.h> 4843d18f1cSpriyanka #include <inet/ip_if.h> 49bd670b35SErik Nordmark #include <inet/proto_set.h> 507c478bd9Sstevel@tonic-gate #include <inet/ipclassifier.h> 517c478bd9Sstevel@tonic-gate #include <inet/ipsec_impl.h> 527c478bd9Sstevel@tonic-gate 537c478bd9Sstevel@tonic-gate #include <netinet/in.h> 547c478bd9Sstevel@tonic-gate #include <netinet/ip.h> 557c478bd9Sstevel@tonic-gate #include <netinet/tcp.h> 567c478bd9Sstevel@tonic-gate 577c478bd9Sstevel@tonic-gate #include <inet/common.h> 587c478bd9Sstevel@tonic-gate #include <inet/ip.h> 597c478bd9Sstevel@tonic-gate #include <inet/ip6.h> 607c478bd9Sstevel@tonic-gate #include <inet/sctp_itf.h> 617c478bd9Sstevel@tonic-gate #include "sctp_impl.h" 627c478bd9Sstevel@tonic-gate #include "sctp_asconf.h" 637c478bd9Sstevel@tonic-gate #include "sctp_addr.h" 647c478bd9Sstevel@tonic-gate 657c478bd9Sstevel@tonic-gate static int sctp_getpeeraddrs(sctp_t *, void *, int *); 667c478bd9Sstevel@tonic-gate 677c478bd9Sstevel@tonic-gate static int 687c478bd9Sstevel@tonic-gate sctp_get_status(sctp_t *sctp, void *ptr) 697c478bd9Sstevel@tonic-gate { 707c478bd9Sstevel@tonic-gate struct sctp_status *sstat = ptr; 717c478bd9Sstevel@tonic-gate sctp_faddr_t *fp; 727c478bd9Sstevel@tonic-gate struct sockaddr_in *sin; 737c478bd9Sstevel@tonic-gate struct sockaddr_in6 *sin6; 747c478bd9Sstevel@tonic-gate struct sctp_paddrinfo *sp; 757c478bd9Sstevel@tonic-gate mblk_t *meta, *mp; 767c478bd9Sstevel@tonic-gate int i; 77bd670b35SErik Nordmark conn_t *connp = sctp->sctp_connp; 787c478bd9Sstevel@tonic-gate 797c478bd9Sstevel@tonic-gate sstat->sstat_state = sctp->sctp_state; 807c478bd9Sstevel@tonic-gate sstat->sstat_rwnd = sctp->sctp_frwnd; 817c478bd9Sstevel@tonic-gate 827c478bd9Sstevel@tonic-gate sp = &sstat->sstat_primary; 837c478bd9Sstevel@tonic-gate if (!sctp->sctp_primary) { 847c478bd9Sstevel@tonic-gate bzero(sp, sizeof (*sp)); 857c478bd9Sstevel@tonic-gate goto noprim; 867c478bd9Sstevel@tonic-gate } 877c478bd9Sstevel@tonic-gate fp = sctp->sctp_primary; 887c478bd9Sstevel@tonic-gate 896be61d4eSchandrasekar marimuthu - Sun Microsystems - Bangalore India if (fp->sf_isv4) { 907c478bd9Sstevel@tonic-gate sin = (struct sockaddr_in *)&sp->spinfo_address; 917c478bd9Sstevel@tonic-gate sin->sin_family = AF_INET; 92bd670b35SErik Nordmark sin->sin_port = connp->conn_fport; 936be61d4eSchandrasekar marimuthu - Sun Microsystems - Bangalore India IN6_V4MAPPED_TO_INADDR(&fp->sf_faddr, &sin->sin_addr); 947c478bd9Sstevel@tonic-gate sp->spinfo_mtu = sctp->sctp_hdr_len; 957c478bd9Sstevel@tonic-gate } else { 967c478bd9Sstevel@tonic-gate sin6 = (struct sockaddr_in6 *)&sp->spinfo_address; 977c478bd9Sstevel@tonic-gate sin6->sin6_family = AF_INET6; 98bd670b35SErik Nordmark sin6->sin6_port = connp->conn_fport; 996be61d4eSchandrasekar marimuthu - Sun Microsystems - Bangalore India sin6->sin6_addr = fp->sf_faddr; 1007c478bd9Sstevel@tonic-gate sp->spinfo_mtu = sctp->sctp_hdr6_len; 1017c478bd9Sstevel@tonic-gate } 1026be61d4eSchandrasekar marimuthu - Sun Microsystems - Bangalore India sp->spinfo_state = fp->sf_state == SCTP_FADDRS_ALIVE ? SCTP_ACTIVE : 1037c478bd9Sstevel@tonic-gate SCTP_INACTIVE; 1046be61d4eSchandrasekar marimuthu - Sun Microsystems - Bangalore India sp->spinfo_cwnd = fp->sf_cwnd; 1056be61d4eSchandrasekar marimuthu - Sun Microsystems - Bangalore India sp->spinfo_srtt = fp->sf_srtt; 1066be61d4eSchandrasekar marimuthu - Sun Microsystems - Bangalore India sp->spinfo_rto = fp->sf_rto; 1076be61d4eSchandrasekar marimuthu - Sun Microsystems - Bangalore India sp->spinfo_mtu += fp->sf_pmss; 1087c478bd9Sstevel@tonic-gate 1097c478bd9Sstevel@tonic-gate noprim: 1107c478bd9Sstevel@tonic-gate sstat->sstat_unackdata = 0; 1117c478bd9Sstevel@tonic-gate sstat->sstat_penddata = 0; 1127c478bd9Sstevel@tonic-gate sstat->sstat_instrms = sctp->sctp_num_istr; 1137c478bd9Sstevel@tonic-gate sstat->sstat_outstrms = sctp->sctp_num_ostr; 1147c478bd9Sstevel@tonic-gate sstat->sstat_fragmentation_point = sctp->sctp_mss - 1157c478bd9Sstevel@tonic-gate sizeof (sctp_data_hdr_t); 1167c478bd9Sstevel@tonic-gate 1177c478bd9Sstevel@tonic-gate /* count unack'd */ 1187c478bd9Sstevel@tonic-gate for (meta = sctp->sctp_xmit_head; meta; meta = meta->b_next) { 1197c478bd9Sstevel@tonic-gate for (mp = meta->b_cont; mp; mp = mp->b_next) { 1207c478bd9Sstevel@tonic-gate if (!SCTP_CHUNK_ISSENT(mp)) { 1217c478bd9Sstevel@tonic-gate break; 1227c478bd9Sstevel@tonic-gate } 1237c478bd9Sstevel@tonic-gate if (!SCTP_CHUNK_ISACKED(mp)) { 1247c478bd9Sstevel@tonic-gate sstat->sstat_unackdata++; 1257c478bd9Sstevel@tonic-gate } 1267c478bd9Sstevel@tonic-gate } 1277c478bd9Sstevel@tonic-gate } 1287c478bd9Sstevel@tonic-gate 1297c478bd9Sstevel@tonic-gate /* 1307c478bd9Sstevel@tonic-gate * Count penddata chunks. We can only count chunks in SCTP (not 1317c478bd9Sstevel@tonic-gate * data already delivered to socket layer). 1327c478bd9Sstevel@tonic-gate */ 1337c478bd9Sstevel@tonic-gate if (sctp->sctp_instr != NULL) { 1347c478bd9Sstevel@tonic-gate for (i = 0; i < sctp->sctp_num_istr; i++) { 1357c478bd9Sstevel@tonic-gate for (meta = sctp->sctp_instr[i].istr_reass; 1367c478bd9Sstevel@tonic-gate meta != NULL; meta = meta->b_next) { 1377c478bd9Sstevel@tonic-gate for (mp = meta->b_cont; mp; mp = mp->b_cont) { 1387c478bd9Sstevel@tonic-gate if (DB_TYPE(mp) != M_CTL) { 1397c478bd9Sstevel@tonic-gate sstat->sstat_penddata++; 1407c478bd9Sstevel@tonic-gate } 1417c478bd9Sstevel@tonic-gate } 1427c478bd9Sstevel@tonic-gate } 1437c478bd9Sstevel@tonic-gate } 1447c478bd9Sstevel@tonic-gate } 1457c478bd9Sstevel@tonic-gate /* Un-Ordered Frag list */ 1467c478bd9Sstevel@tonic-gate for (meta = sctp->sctp_uo_frags; meta != NULL; meta = meta->b_next) 1477c478bd9Sstevel@tonic-gate sstat->sstat_penddata++; 1487c478bd9Sstevel@tonic-gate 1497c478bd9Sstevel@tonic-gate return (sizeof (*sstat)); 1507c478bd9Sstevel@tonic-gate } 1517c478bd9Sstevel@tonic-gate 1527c478bd9Sstevel@tonic-gate /* 1537c478bd9Sstevel@tonic-gate * SCTP_GET_PEER_ADDR_INFO 1547c478bd9Sstevel@tonic-gate */ 1557c478bd9Sstevel@tonic-gate static int 1567c478bd9Sstevel@tonic-gate sctp_get_paddrinfo(sctp_t *sctp, void *ptr, socklen_t *optlen) 1577c478bd9Sstevel@tonic-gate { 1587c478bd9Sstevel@tonic-gate struct sctp_paddrinfo *infop = ptr; 1597c478bd9Sstevel@tonic-gate struct sockaddr_in *sin4; 1607c478bd9Sstevel@tonic-gate struct sockaddr_in6 *sin6; 1617c478bd9Sstevel@tonic-gate in6_addr_t faddr; 1627c478bd9Sstevel@tonic-gate sctp_faddr_t *fp; 1637c478bd9Sstevel@tonic-gate 1647c478bd9Sstevel@tonic-gate switch (infop->spinfo_address.ss_family) { 1657c478bd9Sstevel@tonic-gate case AF_INET: 1667c478bd9Sstevel@tonic-gate sin4 = (struct sockaddr_in *)&infop->spinfo_address; 1677c478bd9Sstevel@tonic-gate IN6_INADDR_TO_V4MAPPED(&sin4->sin_addr, &faddr); 1687c478bd9Sstevel@tonic-gate break; 1697c478bd9Sstevel@tonic-gate case AF_INET6: 1707c478bd9Sstevel@tonic-gate sin6 = (struct sockaddr_in6 *)&infop->spinfo_address; 1717c478bd9Sstevel@tonic-gate faddr = sin6->sin6_addr; 1727c478bd9Sstevel@tonic-gate break; 1737c478bd9Sstevel@tonic-gate default: 1747c478bd9Sstevel@tonic-gate return (EAFNOSUPPORT); 1757c478bd9Sstevel@tonic-gate } 1767c478bd9Sstevel@tonic-gate 1777c478bd9Sstevel@tonic-gate if ((fp = sctp_lookup_faddr(sctp, &faddr)) == NULL) 1787c478bd9Sstevel@tonic-gate return (EINVAL); 1797c478bd9Sstevel@tonic-gate 1806be61d4eSchandrasekar marimuthu - Sun Microsystems - Bangalore India infop->spinfo_state = (fp->sf_state == SCTP_FADDRS_ALIVE) ? 1816be61d4eSchandrasekar marimuthu - Sun Microsystems - Bangalore India SCTP_ACTIVE : SCTP_INACTIVE; 1826be61d4eSchandrasekar marimuthu - Sun Microsystems - Bangalore India infop->spinfo_cwnd = fp->sf_cwnd; 1836be61d4eSchandrasekar marimuthu - Sun Microsystems - Bangalore India infop->spinfo_srtt = TICK_TO_MSEC(fp->sf_srtt); 1846be61d4eSchandrasekar marimuthu - Sun Microsystems - Bangalore India infop->spinfo_rto = TICK_TO_MSEC(fp->sf_rto); 1856be61d4eSchandrasekar marimuthu - Sun Microsystems - Bangalore India infop->spinfo_mtu = fp->sf_pmss; 1867c478bd9Sstevel@tonic-gate 1877c478bd9Sstevel@tonic-gate *optlen = sizeof (struct sctp_paddrinfo); 1887c478bd9Sstevel@tonic-gate return (0); 1897c478bd9Sstevel@tonic-gate } 1907c478bd9Sstevel@tonic-gate 1917c478bd9Sstevel@tonic-gate /* 1927c478bd9Sstevel@tonic-gate * SCTP_RTOINFO 1937c478bd9Sstevel@tonic-gate */ 1947c478bd9Sstevel@tonic-gate static int 1957c478bd9Sstevel@tonic-gate sctp_get_rtoinfo(sctp_t *sctp, void *ptr) 1967c478bd9Sstevel@tonic-gate { 1977c478bd9Sstevel@tonic-gate struct sctp_rtoinfo *srto = ptr; 1987c478bd9Sstevel@tonic-gate 1997c478bd9Sstevel@tonic-gate srto->srto_initial = TICK_TO_MSEC(sctp->sctp_rto_initial); 2007c478bd9Sstevel@tonic-gate srto->srto_max = TICK_TO_MSEC(sctp->sctp_rto_max); 2017c478bd9Sstevel@tonic-gate srto->srto_min = TICK_TO_MSEC(sctp->sctp_rto_min); 2027c478bd9Sstevel@tonic-gate 2037c478bd9Sstevel@tonic-gate return (sizeof (*srto)); 2047c478bd9Sstevel@tonic-gate } 2057c478bd9Sstevel@tonic-gate 2067c478bd9Sstevel@tonic-gate static int 207bd670b35SErik Nordmark sctp_set_rtoinfo(sctp_t *sctp, const void *invalp) 2087c478bd9Sstevel@tonic-gate { 2097c478bd9Sstevel@tonic-gate const struct sctp_rtoinfo *srto; 2107c478bd9Sstevel@tonic-gate boolean_t ispriv; 211f4b3ec61Sdh sctp_stack_t *sctps = sctp->sctp_sctps; 212bd670b35SErik Nordmark conn_t *connp = sctp->sctp_connp; 21305cdb43cSchandrasekar marimuthu - Sun Microsystems - Bangalore India uint32_t new_min, new_max; 2147c478bd9Sstevel@tonic-gate 2157c478bd9Sstevel@tonic-gate srto = invalp; 2167c478bd9Sstevel@tonic-gate 217bd670b35SErik Nordmark ispriv = secpolicy_ip_config(connp->conn_cred, B_TRUE) == 0; 2187c478bd9Sstevel@tonic-gate 2197c478bd9Sstevel@tonic-gate /* 2207c478bd9Sstevel@tonic-gate * Bounds checking. Priviledged user can set the RTO initial 2217c478bd9Sstevel@tonic-gate * outside the ndd boundary. 2227c478bd9Sstevel@tonic-gate */ 2237c478bd9Sstevel@tonic-gate if (srto->srto_initial != 0 && 224f4b3ec61Sdh (!ispriv && (srto->srto_initial < sctps->sctps_rto_initialg_low || 225b34b8d1aSkcpoon srto->srto_initial > sctps->sctps_rto_initialg_high))) { 2267c478bd9Sstevel@tonic-gate return (EINVAL); 2277c478bd9Sstevel@tonic-gate } 2287c478bd9Sstevel@tonic-gate if (srto->srto_max != 0 && 229f4b3ec61Sdh (!ispriv && (srto->srto_max < sctps->sctps_rto_maxg_low || 230b34b8d1aSkcpoon srto->srto_max > sctps->sctps_rto_maxg_high))) { 2317c478bd9Sstevel@tonic-gate return (EINVAL); 2327c478bd9Sstevel@tonic-gate } 2337c478bd9Sstevel@tonic-gate if (srto->srto_min != 0 && 234f4b3ec61Sdh (!ispriv && (srto->srto_min < sctps->sctps_rto_ming_low || 235b34b8d1aSkcpoon srto->srto_min > sctps->sctps_rto_ming_high))) { 2367c478bd9Sstevel@tonic-gate return (EINVAL); 2377c478bd9Sstevel@tonic-gate } 2387c478bd9Sstevel@tonic-gate 23905cdb43cSchandrasekar marimuthu - Sun Microsystems - Bangalore India new_min = (srto->srto_min != 0) ? srto->srto_min : sctp->sctp_rto_min; 24005cdb43cSchandrasekar marimuthu - Sun Microsystems - Bangalore India new_max = (srto->srto_max != 0) ? srto->srto_max : sctp->sctp_rto_max; 24105cdb43cSchandrasekar marimuthu - Sun Microsystems - Bangalore India if (new_max < new_min) { 24205cdb43cSchandrasekar marimuthu - Sun Microsystems - Bangalore India return (EINVAL); 24305cdb43cSchandrasekar marimuthu - Sun Microsystems - Bangalore India } 24405cdb43cSchandrasekar marimuthu - Sun Microsystems - Bangalore India 2457c478bd9Sstevel@tonic-gate if (srto->srto_initial != 0) { 2467c478bd9Sstevel@tonic-gate sctp->sctp_rto_initial = MSEC_TO_TICK(srto->srto_initial); 2477c478bd9Sstevel@tonic-gate } 24805cdb43cSchandrasekar marimuthu - Sun Microsystems - Bangalore India 24905cdb43cSchandrasekar marimuthu - Sun Microsystems - Bangalore India /* Ensure that sctp_rto_max will never be zero. */ 2507c478bd9Sstevel@tonic-gate if (srto->srto_max != 0) { 25105cdb43cSchandrasekar marimuthu - Sun Microsystems - Bangalore India sctp->sctp_rto_max = MAX(MSEC_TO_TICK(srto->srto_max), 1); 2527c478bd9Sstevel@tonic-gate } 2537c478bd9Sstevel@tonic-gate if (srto->srto_min != 0) { 2547c478bd9Sstevel@tonic-gate sctp->sctp_rto_min = MSEC_TO_TICK(srto->srto_min); 2557c478bd9Sstevel@tonic-gate } 2567c478bd9Sstevel@tonic-gate 2577c478bd9Sstevel@tonic-gate return (0); 2587c478bd9Sstevel@tonic-gate } 2597c478bd9Sstevel@tonic-gate 2607c478bd9Sstevel@tonic-gate /* 2617c478bd9Sstevel@tonic-gate * SCTP_ASSOCINFO 2627c478bd9Sstevel@tonic-gate */ 2637c478bd9Sstevel@tonic-gate static int 2647c478bd9Sstevel@tonic-gate sctp_get_assocparams(sctp_t *sctp, void *ptr) 2657c478bd9Sstevel@tonic-gate { 2667c478bd9Sstevel@tonic-gate struct sctp_assocparams *sap = ptr; 2677c478bd9Sstevel@tonic-gate sctp_faddr_t *fp; 2687c478bd9Sstevel@tonic-gate uint16_t i; 2697c478bd9Sstevel@tonic-gate 2707c478bd9Sstevel@tonic-gate sap->sasoc_asocmaxrxt = sctp->sctp_pa_max_rxt; 2717c478bd9Sstevel@tonic-gate 2727c478bd9Sstevel@tonic-gate /* 2737c478bd9Sstevel@tonic-gate * Count the number of peer addresses 2747c478bd9Sstevel@tonic-gate */ 2756be61d4eSchandrasekar marimuthu - Sun Microsystems - Bangalore India for (i = 0, fp = sctp->sctp_faddrs; fp != NULL; fp = fp->sf_next) { 2767c478bd9Sstevel@tonic-gate i++; 2777c478bd9Sstevel@tonic-gate } 2787c478bd9Sstevel@tonic-gate sap->sasoc_number_peer_destinations = i; 2797c478bd9Sstevel@tonic-gate sap->sasoc_peer_rwnd = sctp->sctp_frwnd; 2807c478bd9Sstevel@tonic-gate sap->sasoc_local_rwnd = sctp->sctp_rwnd; 2817c478bd9Sstevel@tonic-gate sap->sasoc_cookie_life = TICK_TO_MSEC(sctp->sctp_cookie_lifetime); 2827c478bd9Sstevel@tonic-gate 2837c478bd9Sstevel@tonic-gate return (sizeof (*sap)); 2847c478bd9Sstevel@tonic-gate } 2857c478bd9Sstevel@tonic-gate 2867c478bd9Sstevel@tonic-gate static int 287bd670b35SErik Nordmark sctp_set_assocparams(sctp_t *sctp, const void *invalp) 2887c478bd9Sstevel@tonic-gate { 2897c478bd9Sstevel@tonic-gate const struct sctp_assocparams *sap = invalp; 2907c478bd9Sstevel@tonic-gate uint32_t sum = 0; 2917c478bd9Sstevel@tonic-gate sctp_faddr_t *fp; 292f4b3ec61Sdh sctp_stack_t *sctps = sctp->sctp_sctps; 2937c478bd9Sstevel@tonic-gate 2947c478bd9Sstevel@tonic-gate if (sap->sasoc_asocmaxrxt) { 2957c478bd9Sstevel@tonic-gate if (sctp->sctp_faddrs) { 2967c478bd9Sstevel@tonic-gate /* 2977c478bd9Sstevel@tonic-gate * Bounds check: as per rfc2960, assoc max retr cannot 2987c478bd9Sstevel@tonic-gate * exceed the sum of all individual path max retr's. 2997c478bd9Sstevel@tonic-gate */ 3006be61d4eSchandrasekar marimuthu - Sun Microsystems - Bangalore India for (fp = sctp->sctp_faddrs; fp; fp = fp->sf_next) { 3016be61d4eSchandrasekar marimuthu - Sun Microsystems - Bangalore India sum += fp->sf_max_retr; 3027c478bd9Sstevel@tonic-gate } 3037c478bd9Sstevel@tonic-gate if (sap->sasoc_asocmaxrxt > sum) { 3047c478bd9Sstevel@tonic-gate return (EINVAL); 3057c478bd9Sstevel@tonic-gate } 3067c478bd9Sstevel@tonic-gate } 307f4b3ec61Sdh if (sap->sasoc_asocmaxrxt < sctps->sctps_pa_max_retr_low || 308f4b3ec61Sdh sap->sasoc_asocmaxrxt > sctps->sctps_pa_max_retr_high) { 3097c478bd9Sstevel@tonic-gate /* 3107c478bd9Sstevel@tonic-gate * Out of bounds. 3117c478bd9Sstevel@tonic-gate */ 3127c478bd9Sstevel@tonic-gate return (EINVAL); 3137c478bd9Sstevel@tonic-gate } 3147c478bd9Sstevel@tonic-gate } 3157c478bd9Sstevel@tonic-gate if (sap->sasoc_cookie_life != 0 && 316f4b3ec61Sdh (sap->sasoc_cookie_life < sctps->sctps_cookie_life_low || 317b34b8d1aSkcpoon sap->sasoc_cookie_life > sctps->sctps_cookie_life_high)) { 318b34b8d1aSkcpoon return (EINVAL); 3197c478bd9Sstevel@tonic-gate } 3207c478bd9Sstevel@tonic-gate 3217c478bd9Sstevel@tonic-gate if (sap->sasoc_asocmaxrxt > 0) { 3227c478bd9Sstevel@tonic-gate sctp->sctp_pa_max_rxt = sap->sasoc_asocmaxrxt; 3237c478bd9Sstevel@tonic-gate } 3247c478bd9Sstevel@tonic-gate if (sap->sasoc_cookie_life > 0) { 3257c478bd9Sstevel@tonic-gate sctp->sctp_cookie_lifetime = MSEC_TO_TICK( 3267c478bd9Sstevel@tonic-gate sap->sasoc_cookie_life); 3277c478bd9Sstevel@tonic-gate } 3287c478bd9Sstevel@tonic-gate return (0); 3297c478bd9Sstevel@tonic-gate } 3307c478bd9Sstevel@tonic-gate 3317c478bd9Sstevel@tonic-gate /* 3327c478bd9Sstevel@tonic-gate * SCTP_INITMSG 3337c478bd9Sstevel@tonic-gate */ 3347c478bd9Sstevel@tonic-gate static int 3357c478bd9Sstevel@tonic-gate sctp_get_initmsg(sctp_t *sctp, void *ptr) 3367c478bd9Sstevel@tonic-gate { 3377c478bd9Sstevel@tonic-gate struct sctp_initmsg *si = ptr; 3387c478bd9Sstevel@tonic-gate 3397c478bd9Sstevel@tonic-gate si->sinit_num_ostreams = sctp->sctp_num_ostr; 3407c478bd9Sstevel@tonic-gate si->sinit_max_instreams = sctp->sctp_num_istr; 3417c478bd9Sstevel@tonic-gate si->sinit_max_attempts = sctp->sctp_max_init_rxt; 342fd7b5aedSGeorge Shepherd si->sinit_max_init_timeo = TICK_TO_MSEC(sctp->sctp_rto_max_init); 3437c478bd9Sstevel@tonic-gate 3447c478bd9Sstevel@tonic-gate return (sizeof (*si)); 3457c478bd9Sstevel@tonic-gate } 3467c478bd9Sstevel@tonic-gate 3477c478bd9Sstevel@tonic-gate static int 3487c478bd9Sstevel@tonic-gate sctp_set_initmsg(sctp_t *sctp, const void *invalp, uint_t inlen) 3497c478bd9Sstevel@tonic-gate { 3507c478bd9Sstevel@tonic-gate const struct sctp_initmsg *si = invalp; 351f4b3ec61Sdh sctp_stack_t *sctps = sctp->sctp_sctps; 352bd670b35SErik Nordmark conn_t *connp = sctp->sctp_connp; 3537c478bd9Sstevel@tonic-gate 3547c478bd9Sstevel@tonic-gate if (sctp->sctp_state > SCTPS_LISTEN) { 3557c478bd9Sstevel@tonic-gate return (EINVAL); 3567c478bd9Sstevel@tonic-gate } 3577c478bd9Sstevel@tonic-gate if (inlen < sizeof (*si)) { 3587c478bd9Sstevel@tonic-gate return (EINVAL); 3597c478bd9Sstevel@tonic-gate } 3607c478bd9Sstevel@tonic-gate if (si->sinit_num_ostreams != 0 && 361f4b3ec61Sdh (si->sinit_num_ostreams < sctps->sctps_initial_out_streams_low || 362f4b3ec61Sdh si->sinit_num_ostreams > 363f4b3ec61Sdh sctps->sctps_initial_out_streams_high)) { 3647c478bd9Sstevel@tonic-gate /* 3657c478bd9Sstevel@tonic-gate * Out of bounds. 3667c478bd9Sstevel@tonic-gate */ 3677c478bd9Sstevel@tonic-gate return (EINVAL); 3687c478bd9Sstevel@tonic-gate } 3697c478bd9Sstevel@tonic-gate if (si->sinit_max_instreams != 0 && 370f4b3ec61Sdh (si->sinit_max_instreams < sctps->sctps_max_in_streams_low || 371b34b8d1aSkcpoon si->sinit_max_instreams > sctps->sctps_max_in_streams_high)) { 3727c478bd9Sstevel@tonic-gate return (EINVAL); 3737c478bd9Sstevel@tonic-gate } 3747c478bd9Sstevel@tonic-gate if (si->sinit_max_attempts != 0 && 375f4b3ec61Sdh (si->sinit_max_attempts < sctps->sctps_max_init_retr_low || 376b34b8d1aSkcpoon si->sinit_max_attempts > sctps->sctps_max_init_retr_high)) { 3777c478bd9Sstevel@tonic-gate return (EINVAL); 3787c478bd9Sstevel@tonic-gate } 3797c478bd9Sstevel@tonic-gate if (si->sinit_max_init_timeo != 0 && 380bd670b35SErik Nordmark (secpolicy_ip_config(connp->conn_cred, B_TRUE) != 0 && 381b34b8d1aSkcpoon (si->sinit_max_init_timeo < sctps->sctps_rto_maxg_low || 382b34b8d1aSkcpoon si->sinit_max_init_timeo > sctps->sctps_rto_maxg_high))) { 3837c478bd9Sstevel@tonic-gate return (EINVAL); 3847c478bd9Sstevel@tonic-gate } 3857c478bd9Sstevel@tonic-gate if (si->sinit_num_ostreams != 0) 3867c478bd9Sstevel@tonic-gate sctp->sctp_num_ostr = si->sinit_num_ostreams; 3877c478bd9Sstevel@tonic-gate 3887c478bd9Sstevel@tonic-gate if (si->sinit_max_instreams != 0) 3897c478bd9Sstevel@tonic-gate sctp->sctp_num_istr = si->sinit_max_instreams; 3907c478bd9Sstevel@tonic-gate 3917c478bd9Sstevel@tonic-gate if (si->sinit_max_attempts != 0) 3927c478bd9Sstevel@tonic-gate sctp->sctp_max_init_rxt = si->sinit_max_attempts; 3937c478bd9Sstevel@tonic-gate 3947c478bd9Sstevel@tonic-gate if (si->sinit_max_init_timeo != 0) { 395fd7b5aedSGeorge Shepherd sctp->sctp_rto_max_init = 3967c478bd9Sstevel@tonic-gate MSEC_TO_TICK(si->sinit_max_init_timeo); 3977c478bd9Sstevel@tonic-gate } 3987c478bd9Sstevel@tonic-gate return (0); 3997c478bd9Sstevel@tonic-gate } 4007c478bd9Sstevel@tonic-gate 4017c478bd9Sstevel@tonic-gate /* 4027c478bd9Sstevel@tonic-gate * SCTP_PEER_ADDR_PARAMS 4037c478bd9Sstevel@tonic-gate */ 4047c478bd9Sstevel@tonic-gate static int 4057c478bd9Sstevel@tonic-gate sctp_find_peer_fp(sctp_t *sctp, const struct sockaddr_storage *ss, 4067c478bd9Sstevel@tonic-gate sctp_faddr_t **fpp) 4077c478bd9Sstevel@tonic-gate { 4087c478bd9Sstevel@tonic-gate struct sockaddr_in *sin; 4097c478bd9Sstevel@tonic-gate struct sockaddr_in6 *sin6; 4107c478bd9Sstevel@tonic-gate in6_addr_t addr; 4117c478bd9Sstevel@tonic-gate 4127c478bd9Sstevel@tonic-gate if (ss->ss_family == AF_INET) { 4137c478bd9Sstevel@tonic-gate sin = (struct sockaddr_in *)ss; 4147c478bd9Sstevel@tonic-gate IN6_IPADDR_TO_V4MAPPED(sin->sin_addr.s_addr, &addr); 4157c478bd9Sstevel@tonic-gate } else if (ss->ss_family == AF_INET6) { 4167c478bd9Sstevel@tonic-gate sin6 = (struct sockaddr_in6 *)ss; 4177c478bd9Sstevel@tonic-gate addr = sin6->sin6_addr; 4187c478bd9Sstevel@tonic-gate } else if (ss->ss_family) { 4197c478bd9Sstevel@tonic-gate return (EAFNOSUPPORT); 4207c478bd9Sstevel@tonic-gate } 4217c478bd9Sstevel@tonic-gate 4227c478bd9Sstevel@tonic-gate if (!ss->ss_family || 4237c478bd9Sstevel@tonic-gate SCTP_IS_ADDR_UNSPEC(IN6_IS_ADDR_V4MAPPED(&addr), addr)) { 4247c478bd9Sstevel@tonic-gate *fpp = NULL; 4257c478bd9Sstevel@tonic-gate } else { 4267c478bd9Sstevel@tonic-gate *fpp = sctp_lookup_faddr(sctp, &addr); 4277c478bd9Sstevel@tonic-gate if (*fpp == NULL) { 4287c478bd9Sstevel@tonic-gate return (EINVAL); 4297c478bd9Sstevel@tonic-gate } 4307c478bd9Sstevel@tonic-gate } 4317c478bd9Sstevel@tonic-gate return (0); 4327c478bd9Sstevel@tonic-gate } 4337c478bd9Sstevel@tonic-gate 4347c478bd9Sstevel@tonic-gate static int 4357c478bd9Sstevel@tonic-gate sctp_get_peer_addr_params(sctp_t *sctp, void *ptr) 4367c478bd9Sstevel@tonic-gate { 4377c478bd9Sstevel@tonic-gate struct sctp_paddrparams *spp = ptr; 4387c478bd9Sstevel@tonic-gate sctp_faddr_t *fp; 4397c478bd9Sstevel@tonic-gate int retval; 4407c478bd9Sstevel@tonic-gate 4417c478bd9Sstevel@tonic-gate retval = sctp_find_peer_fp(sctp, &spp->spp_address, &fp); 4427c478bd9Sstevel@tonic-gate if (retval) { 4437c478bd9Sstevel@tonic-gate return (retval); 4447c478bd9Sstevel@tonic-gate } 4457c478bd9Sstevel@tonic-gate if (fp) { 4466be61d4eSchandrasekar marimuthu - Sun Microsystems - Bangalore India spp->spp_hbinterval = TICK_TO_MSEC(fp->sf_hb_interval); 4476be61d4eSchandrasekar marimuthu - Sun Microsystems - Bangalore India spp->spp_pathmaxrxt = fp->sf_max_retr; 4487c478bd9Sstevel@tonic-gate } else { 4497c478bd9Sstevel@tonic-gate spp->spp_hbinterval = TICK_TO_MSEC(sctp->sctp_hb_interval); 4507c478bd9Sstevel@tonic-gate spp->spp_pathmaxrxt = sctp->sctp_pp_max_rxt; 4517c478bd9Sstevel@tonic-gate } 4527c478bd9Sstevel@tonic-gate return (sizeof (*spp)); 4537c478bd9Sstevel@tonic-gate } 4547c478bd9Sstevel@tonic-gate 4557c478bd9Sstevel@tonic-gate static int 456bd670b35SErik Nordmark sctp_set_peer_addr_params(sctp_t *sctp, const void *invalp) 4577c478bd9Sstevel@tonic-gate { 4587c478bd9Sstevel@tonic-gate const struct sctp_paddrparams *spp = invalp; 4597c478bd9Sstevel@tonic-gate sctp_faddr_t *fp, *fp2; 4607c478bd9Sstevel@tonic-gate int retval; 4617c478bd9Sstevel@tonic-gate uint32_t sum = 0; 4627c478bd9Sstevel@tonic-gate int64_t now; 463f4b3ec61Sdh sctp_stack_t *sctps = sctp->sctp_sctps; 4647c478bd9Sstevel@tonic-gate 4657c478bd9Sstevel@tonic-gate retval = sctp_find_peer_fp(sctp, &spp->spp_address, &fp); 4667c478bd9Sstevel@tonic-gate if (retval != 0) { 4677c478bd9Sstevel@tonic-gate return (retval); 4687c478bd9Sstevel@tonic-gate } 4697c478bd9Sstevel@tonic-gate 4707c478bd9Sstevel@tonic-gate if (spp->spp_hbinterval && spp->spp_hbinterval != UINT32_MAX && 471f4b3ec61Sdh (spp->spp_hbinterval < sctps->sctps_heartbeat_interval_low || 472b34b8d1aSkcpoon spp->spp_hbinterval > sctps->sctps_heartbeat_interval_high)) { 4737c478bd9Sstevel@tonic-gate return (EINVAL); 4747c478bd9Sstevel@tonic-gate } 4757c478bd9Sstevel@tonic-gate if (spp->spp_pathmaxrxt && 476f4b3ec61Sdh (spp->spp_pathmaxrxt < sctps->sctps_pp_max_retr_low || 477b34b8d1aSkcpoon spp->spp_pathmaxrxt > sctps->sctps_pp_max_retr_high)) { 4787c478bd9Sstevel@tonic-gate return (EINVAL); 4797c478bd9Sstevel@tonic-gate } 4807c478bd9Sstevel@tonic-gate if (spp->spp_pathmaxrxt && sctp->sctp_faddrs) { 4816be61d4eSchandrasekar marimuthu - Sun Microsystems - Bangalore India for (fp2 = sctp->sctp_faddrs; fp2; fp2 = fp2->sf_next) { 4827c478bd9Sstevel@tonic-gate if (!fp || fp2 == fp) { 4837c478bd9Sstevel@tonic-gate sum += spp->spp_pathmaxrxt; 4847c478bd9Sstevel@tonic-gate } else { 4856be61d4eSchandrasekar marimuthu - Sun Microsystems - Bangalore India sum += fp2->sf_max_retr; 4867c478bd9Sstevel@tonic-gate } 4877c478bd9Sstevel@tonic-gate } 4887c478bd9Sstevel@tonic-gate if (sctp->sctp_pa_max_rxt > sum) { 4897c478bd9Sstevel@tonic-gate return (EINVAL); 4907c478bd9Sstevel@tonic-gate } 4917c478bd9Sstevel@tonic-gate } 4927c478bd9Sstevel@tonic-gate 493d3d50737SRafael Vanoni now = ddi_get_lbolt64(); 4947c478bd9Sstevel@tonic-gate if (fp != NULL) { 4957c478bd9Sstevel@tonic-gate if (spp->spp_hbinterval == UINT32_MAX) { 4967c478bd9Sstevel@tonic-gate /* 4977c478bd9Sstevel@tonic-gate * Send heartbeat immediatelly, don't modify the 4987c478bd9Sstevel@tonic-gate * current setting. 4997c478bd9Sstevel@tonic-gate */ 5007c478bd9Sstevel@tonic-gate sctp_send_heartbeat(sctp, fp); 5017c478bd9Sstevel@tonic-gate } else { 5026be61d4eSchandrasekar marimuthu - Sun Microsystems - Bangalore India fp->sf_hb_interval = MSEC_TO_TICK(spp->spp_hbinterval); 5036be61d4eSchandrasekar marimuthu - Sun Microsystems - Bangalore India fp->sf_hb_expiry = now + SET_HB_INTVL(fp); 5047c478bd9Sstevel@tonic-gate /* 5057c478bd9Sstevel@tonic-gate * Restart the heartbeat timer using the new intrvl. 5067c478bd9Sstevel@tonic-gate * We need to call sctp_heartbeat_timer() to set 5077c478bd9Sstevel@tonic-gate * the earliest heartbeat expiry time. 5087c478bd9Sstevel@tonic-gate */ 5097c478bd9Sstevel@tonic-gate sctp_heartbeat_timer(sctp); 5107c478bd9Sstevel@tonic-gate } 5117c478bd9Sstevel@tonic-gate if (spp->spp_pathmaxrxt) { 5126be61d4eSchandrasekar marimuthu - Sun Microsystems - Bangalore India fp->sf_max_retr = spp->spp_pathmaxrxt; 5137c478bd9Sstevel@tonic-gate } 5147c478bd9Sstevel@tonic-gate } else { 5156be61d4eSchandrasekar marimuthu - Sun Microsystems - Bangalore India for (fp2 = sctp->sctp_faddrs; fp2 != NULL; fp2 = fp2->sf_next) { 5167c478bd9Sstevel@tonic-gate if (spp->spp_hbinterval == UINT32_MAX) { 5177c478bd9Sstevel@tonic-gate /* 5187c478bd9Sstevel@tonic-gate * Send heartbeat immediatelly, don't modify 5197c478bd9Sstevel@tonic-gate * the current setting. 5207c478bd9Sstevel@tonic-gate */ 5217c478bd9Sstevel@tonic-gate sctp_send_heartbeat(sctp, fp2); 5227c478bd9Sstevel@tonic-gate } else { 5236be61d4eSchandrasekar marimuthu - Sun Microsystems - Bangalore India fp2->sf_hb_interval = MSEC_TO_TICK( 5247c478bd9Sstevel@tonic-gate spp->spp_hbinterval); 5256be61d4eSchandrasekar marimuthu - Sun Microsystems - Bangalore India fp2->sf_hb_expiry = now + SET_HB_INTVL(fp2); 5267c478bd9Sstevel@tonic-gate } 5277c478bd9Sstevel@tonic-gate if (spp->spp_pathmaxrxt) { 5286be61d4eSchandrasekar marimuthu - Sun Microsystems - Bangalore India fp2->sf_max_retr = spp->spp_pathmaxrxt; 5297c478bd9Sstevel@tonic-gate } 5307c478bd9Sstevel@tonic-gate } 5317c478bd9Sstevel@tonic-gate if (spp->spp_hbinterval != UINT32_MAX) { 5327c478bd9Sstevel@tonic-gate sctp->sctp_hb_interval = MSEC_TO_TICK( 5337c478bd9Sstevel@tonic-gate spp->spp_hbinterval); 5347c478bd9Sstevel@tonic-gate /* Restart the heartbeat timer using the new intrvl. */ 5357c478bd9Sstevel@tonic-gate sctp_timer(sctp, sctp->sctp_heartbeat_mp, 5367c478bd9Sstevel@tonic-gate sctp->sctp_hb_interval); 5377c478bd9Sstevel@tonic-gate } 5387c478bd9Sstevel@tonic-gate if (spp->spp_pathmaxrxt) { 5397c478bd9Sstevel@tonic-gate sctp->sctp_pp_max_rxt = spp->spp_pathmaxrxt; 5407c478bd9Sstevel@tonic-gate } 5417c478bd9Sstevel@tonic-gate } 5427c478bd9Sstevel@tonic-gate return (0); 5437c478bd9Sstevel@tonic-gate } 5447c478bd9Sstevel@tonic-gate 5457c478bd9Sstevel@tonic-gate /* 5467c478bd9Sstevel@tonic-gate * SCTP_DEFAULT_SEND_PARAM 5477c478bd9Sstevel@tonic-gate */ 5487c478bd9Sstevel@tonic-gate static int 5497c478bd9Sstevel@tonic-gate sctp_get_def_send_params(sctp_t *sctp, void *ptr) 5507c478bd9Sstevel@tonic-gate { 5517c478bd9Sstevel@tonic-gate struct sctp_sndrcvinfo *sinfo = ptr; 5527c478bd9Sstevel@tonic-gate 5537c478bd9Sstevel@tonic-gate sinfo->sinfo_stream = sctp->sctp_def_stream; 5547c478bd9Sstevel@tonic-gate sinfo->sinfo_ssn = 0; 5557c478bd9Sstevel@tonic-gate sinfo->sinfo_flags = sctp->sctp_def_flags; 5567c478bd9Sstevel@tonic-gate sinfo->sinfo_ppid = sctp->sctp_def_ppid; 5577c478bd9Sstevel@tonic-gate sinfo->sinfo_context = sctp->sctp_def_context; 5587c478bd9Sstevel@tonic-gate sinfo->sinfo_timetolive = sctp->sctp_def_timetolive; 5597c478bd9Sstevel@tonic-gate sinfo->sinfo_tsn = 0; 5607c478bd9Sstevel@tonic-gate sinfo->sinfo_cumtsn = 0; 5617c478bd9Sstevel@tonic-gate 5627c478bd9Sstevel@tonic-gate return (sizeof (*sinfo)); 5637c478bd9Sstevel@tonic-gate } 5647c478bd9Sstevel@tonic-gate 5657c478bd9Sstevel@tonic-gate static int 566bd670b35SErik Nordmark sctp_set_def_send_params(sctp_t *sctp, const void *invalp) 5677c478bd9Sstevel@tonic-gate { 5687c478bd9Sstevel@tonic-gate const struct sctp_sndrcvinfo *sinfo = invalp; 5697c478bd9Sstevel@tonic-gate 5707c478bd9Sstevel@tonic-gate if (sinfo->sinfo_stream >= sctp->sctp_num_ostr) { 5717c478bd9Sstevel@tonic-gate return (EINVAL); 5727c478bd9Sstevel@tonic-gate } 5737c478bd9Sstevel@tonic-gate 5747c478bd9Sstevel@tonic-gate sctp->sctp_def_stream = sinfo->sinfo_stream; 5757c478bd9Sstevel@tonic-gate sctp->sctp_def_flags = sinfo->sinfo_flags; 5767c478bd9Sstevel@tonic-gate sctp->sctp_def_ppid = sinfo->sinfo_ppid; 5777c478bd9Sstevel@tonic-gate sctp->sctp_def_context = sinfo->sinfo_context; 5787c478bd9Sstevel@tonic-gate sctp->sctp_def_timetolive = sinfo->sinfo_timetolive; 5797c478bd9Sstevel@tonic-gate 5807c478bd9Sstevel@tonic-gate return (0); 5817c478bd9Sstevel@tonic-gate } 5827c478bd9Sstevel@tonic-gate 5837c478bd9Sstevel@tonic-gate static int 584bd670b35SErik Nordmark sctp_set_prim(sctp_t *sctp, const void *invalp) 5857c478bd9Sstevel@tonic-gate { 5867c478bd9Sstevel@tonic-gate const struct sctp_setpeerprim *pp = invalp; 5877c478bd9Sstevel@tonic-gate int retval; 5887c478bd9Sstevel@tonic-gate sctp_faddr_t *fp; 5897c478bd9Sstevel@tonic-gate 5907c478bd9Sstevel@tonic-gate retval = sctp_find_peer_fp(sctp, &pp->sspp_addr, &fp); 5917c478bd9Sstevel@tonic-gate if (retval) 5927c478bd9Sstevel@tonic-gate return (retval); 5937c478bd9Sstevel@tonic-gate 5947c478bd9Sstevel@tonic-gate if (fp == NULL) 5957c478bd9Sstevel@tonic-gate return (EINVAL); 5967c478bd9Sstevel@tonic-gate if (fp == sctp->sctp_primary) 5977c478bd9Sstevel@tonic-gate return (0); 5987c478bd9Sstevel@tonic-gate sctp->sctp_primary = fp; 5997c478bd9Sstevel@tonic-gate 6007c478bd9Sstevel@tonic-gate /* Only switch current if fp is alive */ 6016be61d4eSchandrasekar marimuthu - Sun Microsystems - Bangalore India if (fp->sf_state != SCTP_FADDRS_ALIVE || fp == sctp->sctp_current) { 6027c478bd9Sstevel@tonic-gate return (0); 6037c478bd9Sstevel@tonic-gate } 60477c67f2fSkcpoon sctp_set_faddr_current(sctp, fp); 6057c478bd9Sstevel@tonic-gate 6067c478bd9Sstevel@tonic-gate return (0); 6077c478bd9Sstevel@tonic-gate } 6087c478bd9Sstevel@tonic-gate 609bd670b35SErik Nordmark /* 610bd670b35SErik Nordmark * Table of all known options handled on a SCTP protocol stack. 611bd670b35SErik Nordmark * 612bd670b35SErik Nordmark * Note: This table contains options processed by both SCTP and IP levels 613bd670b35SErik Nordmark * and is the superset of options that can be performed on a SCTP and IP 614bd670b35SErik Nordmark * stack. 615bd670b35SErik Nordmark */ 616bd670b35SErik Nordmark opdes_t sctp_opt_arr[] = { 617bd670b35SErik Nordmark 618bd670b35SErik Nordmark { SO_LINGER, SOL_SOCKET, OA_RW, OA_RW, OP_NP, 0, 619bd670b35SErik Nordmark sizeof (struct linger), 0 }, 620bd670b35SErik Nordmark 621bd670b35SErik Nordmark { SO_DEBUG, SOL_SOCKET, OA_RW, OA_RW, OP_NP, 0, sizeof (int), 0 }, 622bd670b35SErik Nordmark { SO_KEEPALIVE, SOL_SOCKET, OA_RW, OA_RW, OP_NP, 0, sizeof (int), 0 }, 623bd670b35SErik Nordmark { SO_DONTROUTE, SOL_SOCKET, OA_RW, OA_RW, OP_NP, 0, sizeof (int), 0 }, 624bd670b35SErik Nordmark { SO_USELOOPBACK, SOL_SOCKET, OA_RW, OA_RW, OP_NP, 0, sizeof (int), 0 625bd670b35SErik Nordmark }, 626bd670b35SErik Nordmark { SO_BROADCAST, SOL_SOCKET, OA_RW, OA_RW, OP_NP, 0, sizeof (int), 0 }, 627bd670b35SErik Nordmark { SO_REUSEADDR, SOL_SOCKET, OA_RW, OA_RW, OP_NP, 0, sizeof (int), 0 }, 628bd670b35SErik Nordmark { SO_OOBINLINE, SOL_SOCKET, OA_RW, OA_RW, OP_NP, 0, sizeof (int), 0 }, 629bd670b35SErik Nordmark { SO_TYPE, SOL_SOCKET, OA_R, OA_R, OP_NP, 0, sizeof (int), 0 }, 630bd670b35SErik Nordmark { SO_SNDBUF, SOL_SOCKET, OA_RW, OA_RW, OP_NP, 0, sizeof (int), 0 }, 631bd670b35SErik Nordmark { SO_RCVBUF, SOL_SOCKET, OA_RW, OA_RW, OP_NP, 0, sizeof (int), 0 }, 632bd670b35SErik Nordmark { SO_DGRAM_ERRIND, SOL_SOCKET, OA_RW, OA_RW, OP_NP, 0, sizeof (int), 0 633bd670b35SErik Nordmark }, 634bd670b35SErik Nordmark { SO_SND_COPYAVOID, SOL_SOCKET, OA_RW, OA_RW, OP_NP, 0, sizeof (int), 0 }, 635bd670b35SErik Nordmark { SO_ANON_MLP, SOL_SOCKET, OA_RW, OA_RW, OP_NP, 0, sizeof (int), 636bd670b35SErik Nordmark 0 }, 637bd670b35SErik Nordmark { SO_MAC_EXEMPT, SOL_SOCKET, OA_RW, OA_RW, OP_NP, 0, sizeof (int), 638bd670b35SErik Nordmark 0 }, 639bd670b35SErik Nordmark { SO_ALLZONES, SOL_SOCKET, OA_R, OA_RW, OP_CONFIG, 0, sizeof (int), 640bd670b35SErik Nordmark 0 }, 641bd670b35SErik Nordmark { SO_EXCLBIND, SOL_SOCKET, OA_RW, OA_RW, OP_NP, 0, sizeof (int), 0 }, 642bd670b35SErik Nordmark 643bd670b35SErik Nordmark { SO_DOMAIN, SOL_SOCKET, OA_R, OA_R, OP_NP, 0, sizeof (int), 0 }, 644bd670b35SErik Nordmark 645bd670b35SErik Nordmark { SO_PROTOTYPE, SOL_SOCKET, OA_R, OA_R, OP_NP, 0, sizeof (int), 0 }, 646bd670b35SErik Nordmark 647bd670b35SErik Nordmark { SCTP_ADAPTATION_LAYER, IPPROTO_SCTP, OA_RW, OA_RW, OP_NP, 0, 648bd670b35SErik Nordmark sizeof (struct sctp_setadaptation), 0 }, 649bd670b35SErik Nordmark { SCTP_ADD_ADDR, IPPROTO_SCTP, OA_RW, OA_RW, OP_NP, OP_VARLEN, 650bd670b35SErik Nordmark sizeof (int), 0 }, 651bd670b35SErik Nordmark { SCTP_ASSOCINFO, IPPROTO_SCTP, OA_RW, OA_RW, OP_NP, 0, 652bd670b35SErik Nordmark sizeof (struct sctp_assocparams), 0 }, 653bd670b35SErik Nordmark { SCTP_AUTOCLOSE, IPPROTO_SCTP, OA_RW, OA_RW, OP_NP, 0, sizeof (int), 0 }, 654bd670b35SErik Nordmark { SCTP_DEFAULT_SEND_PARAM, IPPROTO_SCTP, OA_RW, OA_RW, OP_NP, 0, 655bd670b35SErik Nordmark sizeof (struct sctp_sndrcvinfo), 0 }, 656bd670b35SErik Nordmark { SCTP_DISABLE_FRAGMENTS, IPPROTO_SCTP, OA_RW, OA_RW, OP_NP, 0, 657bd670b35SErik Nordmark sizeof (int), 0 }, 658bd670b35SErik Nordmark { SCTP_EVENTS, IPPROTO_SCTP, OA_RW, OA_RW, OP_NP, 0, 659bd670b35SErik Nordmark sizeof (struct sctp_event_subscribe), 0 }, 660bd670b35SErik Nordmark { SCTP_GET_LADDRS, IPPROTO_SCTP, OA_R, OA_R, OP_NP, OP_VARLEN, 661bd670b35SErik Nordmark sizeof (int), 0 }, 662bd670b35SErik Nordmark { SCTP_GET_NLADDRS, IPPROTO_SCTP, OA_R, OA_R, OP_NP, 0, sizeof (int), 0 }, 663bd670b35SErik Nordmark { SCTP_GET_NPADDRS, IPPROTO_SCTP, OA_R, OA_R, OP_NP, 0, sizeof (int), 0 }, 664bd670b35SErik Nordmark { SCTP_GET_PADDRS, IPPROTO_SCTP, OA_R, OA_R, OP_NP, OP_VARLEN, 665bd670b35SErik Nordmark sizeof (int), 0 }, 666bd670b35SErik Nordmark { SCTP_GET_PEER_ADDR_INFO, IPPROTO_SCTP, OA_R, OA_R, OP_NP, 0, 667bd670b35SErik Nordmark sizeof (struct sctp_paddrinfo), 0 }, 668bd670b35SErik Nordmark { SCTP_INITMSG, IPPROTO_SCTP, OA_RW, OA_RW, OP_NP, 0, 669bd670b35SErik Nordmark sizeof (struct sctp_initmsg), 0 }, 670bd670b35SErik Nordmark { SCTP_I_WANT_MAPPED_V4_ADDR, IPPROTO_SCTP, OA_RW, OA_RW, OP_NP, 0, 671bd670b35SErik Nordmark sizeof (int), 0 }, 672bd670b35SErik Nordmark { SCTP_MAXSEG, IPPROTO_SCTP, OA_RW, OA_RW, OP_NP, 0, sizeof (int), 0 }, 673bd670b35SErik Nordmark { SCTP_NODELAY, IPPROTO_SCTP, OA_RW, OA_RW, OP_NP, 0, sizeof (int), 0 }, 674bd670b35SErik Nordmark { SCTP_PEER_ADDR_PARAMS, IPPROTO_SCTP, OA_RW, OA_RW, OP_NP, 0, 675bd670b35SErik Nordmark sizeof (struct sctp_paddrparams), 0 }, 676bd670b35SErik Nordmark { SCTP_PRIMARY_ADDR, IPPROTO_SCTP, OA_W, OA_W, OP_NP, 0, 677bd670b35SErik Nordmark sizeof (struct sctp_setpeerprim), 0 }, 678bd670b35SErik Nordmark { SCTP_PRSCTP, IPPROTO_SCTP, OA_RW, OA_RW, OP_NP, 0, sizeof (int), 0 }, 679bd670b35SErik Nordmark { SCTP_GET_ASSOC_STATS, IPPROTO_SCTP, OA_R, OA_R, OP_NP, 0, 680bd670b35SErik Nordmark sizeof (sctp_assoc_stats_t), 0 }, 681bd670b35SErik Nordmark { SCTP_REM_ADDR, IPPROTO_SCTP, OA_RW, OA_RW, OP_NP, OP_VARLEN, 682bd670b35SErik Nordmark sizeof (int), 0 }, 683bd670b35SErik Nordmark { SCTP_RTOINFO, IPPROTO_SCTP, OA_RW, OA_RW, OP_NP, 0, 684bd670b35SErik Nordmark sizeof (struct sctp_rtoinfo), 0 }, 685bd670b35SErik Nordmark { SCTP_SET_PEER_PRIMARY_ADDR, IPPROTO_SCTP, OA_W, OA_W, OP_NP, 0, 686bd670b35SErik Nordmark sizeof (struct sctp_setprim), 0 }, 687bd670b35SErik Nordmark { SCTP_STATUS, IPPROTO_SCTP, OA_R, OA_R, OP_NP, 0, 688bd670b35SErik Nordmark sizeof (struct sctp_status), 0 }, 689bd670b35SErik Nordmark { SCTP_UC_SWAP, IPPROTO_SCTP, OA_W, OA_W, OP_NP, 0, 690bd670b35SErik Nordmark sizeof (struct sctp_uc_swap), 0 }, 691bd670b35SErik Nordmark 692bd670b35SErik Nordmark { IP_OPTIONS, IPPROTO_IP, OA_RW, OA_RW, OP_NP, 693bd670b35SErik Nordmark (OP_VARLEN|OP_NODEFAULT), 694bd670b35SErik Nordmark 40, -1 /* not initialized */ }, 695bd670b35SErik Nordmark { T_IP_OPTIONS, IPPROTO_IP, OA_RW, OA_RW, OP_NP, 696bd670b35SErik Nordmark (OP_VARLEN|OP_NODEFAULT), 697bd670b35SErik Nordmark 40, -1 /* not initialized */ }, 698bd670b35SErik Nordmark 699bd670b35SErik Nordmark { IP_TOS, IPPROTO_IP, OA_RW, OA_RW, OP_NP, 0, sizeof (int), 0 }, 700bd670b35SErik Nordmark { T_IP_TOS, IPPROTO_IP, OA_RW, OA_RW, OP_NP, 0, sizeof (int), 0 }, 701bd670b35SErik Nordmark { IP_TTL, IPPROTO_IP, OA_RW, OA_RW, OP_NP, OP_DEF_FN, 702bd670b35SErik Nordmark sizeof (int), -1 /* not initialized */ }, 703bd670b35SErik Nordmark 704bd670b35SErik Nordmark { IP_SEC_OPT, IPPROTO_IP, OA_RW, OA_RW, OP_NP, OP_NODEFAULT, 705bd670b35SErik Nordmark sizeof (ipsec_req_t), -1 /* not initialized */ }, 706bd670b35SErik Nordmark 707bd670b35SErik Nordmark { IP_BOUND_IF, IPPROTO_IP, OA_RW, OA_RW, OP_NP, 0, 708bd670b35SErik Nordmark sizeof (int), 0 /* no ifindex */ }, 709bd670b35SErik Nordmark 710bd670b35SErik Nordmark { IP_UNSPEC_SRC, IPPROTO_IP, OA_R, OA_RW, OP_RAW, 0, 711bd670b35SErik Nordmark sizeof (int), 0 }, 712bd670b35SErik Nordmark 713bd670b35SErik Nordmark { IPV6_UNICAST_HOPS, IPPROTO_IPV6, OA_RW, OA_RW, OP_NP, OP_DEF_FN, 714bd670b35SErik Nordmark sizeof (int), -1 /* not initialized */ }, 715bd670b35SErik Nordmark 716bd670b35SErik Nordmark { IPV6_BOUND_IF, IPPROTO_IPV6, OA_RW, OA_RW, OP_NP, 0, 717bd670b35SErik Nordmark sizeof (int), 0 /* no ifindex */ }, 718bd670b35SErik Nordmark 719bd670b35SErik Nordmark { IP_DONTFRAG, IPPROTO_IP, OA_RW, OA_RW, OP_NP, 0, sizeof (int), 0 }, 720bd670b35SErik Nordmark 721bd670b35SErik Nordmark { IP_NEXTHOP, IPPROTO_IP, OA_R, OA_RW, OP_CONFIG, 0, 722bd670b35SErik Nordmark sizeof (in_addr_t), -1 /* not initialized */ }, 723bd670b35SErik Nordmark 724bd670b35SErik Nordmark { IPV6_UNSPEC_SRC, IPPROTO_IPV6, OA_R, OA_RW, OP_RAW, 0, 725bd670b35SErik Nordmark sizeof (int), 0 }, 726bd670b35SErik Nordmark 727bd670b35SErik Nordmark { IPV6_PKTINFO, IPPROTO_IPV6, OA_RW, OA_RW, OP_NP, 728bd670b35SErik Nordmark (OP_NODEFAULT|OP_VARLEN), 729bd670b35SErik Nordmark sizeof (struct in6_pktinfo), -1 /* not initialized */ }, 730bd670b35SErik Nordmark { IPV6_NEXTHOP, IPPROTO_IPV6, OA_RW, OA_RW, OP_NP, 731bd670b35SErik Nordmark OP_NODEFAULT, 732bd670b35SErik Nordmark sizeof (sin6_t), -1 /* not initialized */ }, 733bd670b35SErik Nordmark { IPV6_HOPOPTS, IPPROTO_IPV6, OA_RW, OA_RW, OP_NP, 734bd670b35SErik Nordmark (OP_VARLEN|OP_NODEFAULT), 255*8, 735bd670b35SErik Nordmark -1 /* not initialized */ }, 736bd670b35SErik Nordmark { IPV6_DSTOPTS, IPPROTO_IPV6, OA_RW, OA_RW, OP_NP, 737bd670b35SErik Nordmark (OP_VARLEN|OP_NODEFAULT), 255*8, 738bd670b35SErik Nordmark -1 /* not initialized */ }, 739bd670b35SErik Nordmark { IPV6_RTHDRDSTOPTS, IPPROTO_IPV6, OA_RW, OA_RW, OP_NP, 740bd670b35SErik Nordmark (OP_VARLEN|OP_NODEFAULT), 255*8, 741bd670b35SErik Nordmark -1 /* not initialized */ }, 742bd670b35SErik Nordmark { IPV6_RTHDR, IPPROTO_IPV6, OA_RW, OA_RW, OP_NP, 743bd670b35SErik Nordmark (OP_VARLEN|OP_NODEFAULT), 255*8, 744bd670b35SErik Nordmark -1 /* not initialized */ }, 745bd670b35SErik Nordmark { IPV6_TCLASS, IPPROTO_IPV6, OA_RW, OA_RW, OP_NP, 746bd670b35SErik Nordmark OP_NODEFAULT, 747bd670b35SErik Nordmark sizeof (int), -1 /* not initialized */ }, 748bd670b35SErik Nordmark { IPV6_PATHMTU, IPPROTO_IPV6, OA_RW, OA_RW, OP_NP, 749bd670b35SErik Nordmark OP_NODEFAULT, 750bd670b35SErik Nordmark sizeof (struct ip6_mtuinfo), -1 /* not initialized */ }, 751bd670b35SErik Nordmark { IPV6_DONTFRAG, IPPROTO_IPV6, OA_RW, OA_RW, OP_NP, 0, 752bd670b35SErik Nordmark sizeof (int), 0 }, 753bd670b35SErik Nordmark { IPV6_USE_MIN_MTU, IPPROTO_IPV6, OA_RW, OA_RW, OP_NP, 0, 754bd670b35SErik Nordmark sizeof (int), 0 }, 755bd670b35SErik Nordmark { IPV6_V6ONLY, IPPROTO_IPV6, OA_RW, OA_RW, OP_NP, 0, 756bd670b35SErik Nordmark sizeof (int), 0 }, 757bd670b35SErik Nordmark 758bd670b35SErik Nordmark /* Enable receipt of ancillary data */ 759bd670b35SErik Nordmark { IPV6_RECVPKTINFO, IPPROTO_IPV6, OA_RW, OA_RW, OP_NP, 0, 760bd670b35SErik Nordmark sizeof (int), 0 }, 761bd670b35SErik Nordmark { IPV6_RECVHOPLIMIT, IPPROTO_IPV6, OA_RW, OA_RW, OP_NP, 0, 762bd670b35SErik Nordmark sizeof (int), 0 }, 763bd670b35SErik Nordmark { IPV6_RECVTCLASS, IPPROTO_IPV6, OA_RW, OA_RW, OP_NP, 0, 764bd670b35SErik Nordmark sizeof (int), 0 }, 765bd670b35SErik Nordmark { IPV6_RECVHOPOPTS, IPPROTO_IPV6, OA_RW, OA_RW, OP_NP, 0, 766bd670b35SErik Nordmark sizeof (int), 0 }, 767bd670b35SErik Nordmark { _OLD_IPV6_RECVDSTOPTS, IPPROTO_IPV6, OA_RW, OA_RW, OP_NP, 0, 768bd670b35SErik Nordmark sizeof (int), 0 }, 769bd670b35SErik Nordmark { IPV6_RECVDSTOPTS, IPPROTO_IPV6, OA_RW, OA_RW, OP_NP, 0, 770bd670b35SErik Nordmark sizeof (int), 0 }, 771bd670b35SErik Nordmark { IPV6_RECVRTHDR, IPPROTO_IPV6, OA_RW, OA_RW, OP_NP, 0, 772bd670b35SErik Nordmark sizeof (int), 0 }, 773bd670b35SErik Nordmark { IPV6_RECVRTHDRDSTOPTS, IPPROTO_IPV6, OA_RW, OA_RW, OP_NP, 0, 774bd670b35SErik Nordmark sizeof (int), 0 }, 775bd670b35SErik Nordmark { IPV6_RECVTCLASS, IPPROTO_IPV6, OA_RW, OA_RW, OP_NP, 0, 776bd670b35SErik Nordmark sizeof (int), 0 }, 777bd670b35SErik Nordmark 778bd670b35SErik Nordmark { IPV6_SEC_OPT, IPPROTO_IPV6, OA_RW, OA_RW, OP_NP, OP_NODEFAULT, 779bd670b35SErik Nordmark sizeof (ipsec_req_t), -1 /* not initialized */ }, 780bd670b35SErik Nordmark { IPV6_SRC_PREFERENCES, IPPROTO_IPV6, OA_RW, OA_RW, OP_NP, 0, 781bd670b35SErik Nordmark sizeof (uint32_t), IPV6_PREFER_SRC_DEFAULT }, 782bd670b35SErik Nordmark }; 783bd670b35SErik Nordmark 784bd670b35SErik Nordmark uint_t sctp_opt_arr_size = A_CNT(sctp_opt_arr); 785bd670b35SErik Nordmark 7867c478bd9Sstevel@tonic-gate /* Handy on off switch for socket option processing. */ 7877c478bd9Sstevel@tonic-gate #define ONOFF(x) ((x) == 0 ? 0 : 1) 7887c478bd9Sstevel@tonic-gate 7897c478bd9Sstevel@tonic-gate /* 7907c478bd9Sstevel@tonic-gate * SCTP routine to get the values of options. 7917c478bd9Sstevel@tonic-gate */ 7927c478bd9Sstevel@tonic-gate int 7937c478bd9Sstevel@tonic-gate sctp_get_opt(sctp_t *sctp, int level, int name, void *ptr, socklen_t *optlen) 7947c478bd9Sstevel@tonic-gate { 7957c478bd9Sstevel@tonic-gate int *i1 = (int *)ptr; 7967c478bd9Sstevel@tonic-gate int retval = 0; 7977c478bd9Sstevel@tonic-gate int buflen = *optlen; 798bd670b35SErik Nordmark conn_t *connp = sctp->sctp_connp; 799bd670b35SErik Nordmark conn_opt_arg_t coas; 800bd670b35SErik Nordmark 801bd670b35SErik Nordmark coas.coa_connp = connp; 802bd670b35SErik Nordmark coas.coa_ixa = connp->conn_ixa; 803bd670b35SErik Nordmark coas.coa_ipp = &connp->conn_xmit_ipp; 80488cda078Skcpoon 8057c478bd9Sstevel@tonic-gate /* In most cases, the return buffer is just an int */ 8067c478bd9Sstevel@tonic-gate *optlen = sizeof (int32_t); 8077c478bd9Sstevel@tonic-gate 8087c478bd9Sstevel@tonic-gate RUN_SCTP(sctp); 8097c478bd9Sstevel@tonic-gate 810b34b8d1aSkcpoon if (connp->conn_state_flags & CONN_CLOSING) { 811b34b8d1aSkcpoon WAKE_SCTP(sctp); 812b34b8d1aSkcpoon return (EINVAL); 813b34b8d1aSkcpoon } 814b34b8d1aSkcpoon 815bd670b35SErik Nordmark /* 816bd670b35SErik Nordmark * Check that the level and name are supported by SCTP, and that 817bd670b35SErik Nordmark * the length and credentials are ok. 818bd670b35SErik Nordmark */ 819bd670b35SErik Nordmark retval = proto_opt_check(level, name, buflen, NULL, sctp_opt_arr, 820bd670b35SErik Nordmark sctp_opt_arr_size, B_FALSE, B_TRUE, connp->conn_cred); 821bd670b35SErik Nordmark if (retval != 0) { 822bd670b35SErik Nordmark WAKE_SCTP(sctp); 823bd670b35SErik Nordmark if (retval < 0) { 824bd670b35SErik Nordmark retval = proto_tlitosyserr(-retval); 8257c478bd9Sstevel@tonic-gate } 826bd670b35SErik Nordmark return (retval); 827bd670b35SErik Nordmark } 8287c478bd9Sstevel@tonic-gate 829bd670b35SErik Nordmark switch (level) { 8307c478bd9Sstevel@tonic-gate case IPPROTO_SCTP: 8317c478bd9Sstevel@tonic-gate switch (name) { 8327c478bd9Sstevel@tonic-gate case SCTP_RTOINFO: 8337c478bd9Sstevel@tonic-gate *optlen = sctp_get_rtoinfo(sctp, ptr); 8347c478bd9Sstevel@tonic-gate break; 8357c478bd9Sstevel@tonic-gate case SCTP_ASSOCINFO: 8367c478bd9Sstevel@tonic-gate *optlen = sctp_get_assocparams(sctp, ptr); 8377c478bd9Sstevel@tonic-gate break; 8387c478bd9Sstevel@tonic-gate case SCTP_INITMSG: 8397c478bd9Sstevel@tonic-gate *optlen = sctp_get_initmsg(sctp, ptr); 8407c478bd9Sstevel@tonic-gate break; 8417c478bd9Sstevel@tonic-gate case SCTP_NODELAY: 8427c478bd9Sstevel@tonic-gate *i1 = sctp->sctp_ndelay; 8437c478bd9Sstevel@tonic-gate break; 8447c478bd9Sstevel@tonic-gate case SCTP_AUTOCLOSE: 8457c478bd9Sstevel@tonic-gate *i1 = TICK_TO_SEC(sctp->sctp_autoclose); 8467c478bd9Sstevel@tonic-gate break; 847558fbd03Skcpoon case SCTP_ADAPTATION_LAYER: 848558fbd03Skcpoon ((struct sctp_setadaptation *)ptr)->ssb_adaptation_ind = 849558fbd03Skcpoon sctp->sctp_tx_adaptation_code; 8507c478bd9Sstevel@tonic-gate break; 8517c478bd9Sstevel@tonic-gate case SCTP_PEER_ADDR_PARAMS: 8527c478bd9Sstevel@tonic-gate *optlen = sctp_get_peer_addr_params(sctp, ptr); 8537c478bd9Sstevel@tonic-gate break; 8547c478bd9Sstevel@tonic-gate case SCTP_DEFAULT_SEND_PARAM: 8557c478bd9Sstevel@tonic-gate *optlen = sctp_get_def_send_params(sctp, ptr); 8567c478bd9Sstevel@tonic-gate break; 8577c478bd9Sstevel@tonic-gate case SCTP_EVENTS: { 8587c478bd9Sstevel@tonic-gate struct sctp_event_subscribe *ev; 8597c478bd9Sstevel@tonic-gate 8607c478bd9Sstevel@tonic-gate ev = (struct sctp_event_subscribe *)ptr; 8617c478bd9Sstevel@tonic-gate ev->sctp_data_io_event = 8627c478bd9Sstevel@tonic-gate ONOFF(sctp->sctp_recvsndrcvinfo); 8637c478bd9Sstevel@tonic-gate ev->sctp_association_event = 8647c478bd9Sstevel@tonic-gate ONOFF(sctp->sctp_recvassocevnt); 8657c478bd9Sstevel@tonic-gate ev->sctp_address_event = 8667c478bd9Sstevel@tonic-gate ONOFF(sctp->sctp_recvpathevnt); 8677c478bd9Sstevel@tonic-gate ev->sctp_send_failure_event = 8687c478bd9Sstevel@tonic-gate ONOFF(sctp->sctp_recvsendfailevnt); 8697c478bd9Sstevel@tonic-gate ev->sctp_peer_error_event = 8707c478bd9Sstevel@tonic-gate ONOFF(sctp->sctp_recvpeererr); 8717c478bd9Sstevel@tonic-gate ev->sctp_shutdown_event = 8727c478bd9Sstevel@tonic-gate ONOFF(sctp->sctp_recvshutdownevnt); 8737c478bd9Sstevel@tonic-gate ev->sctp_partial_delivery_event = 8747c478bd9Sstevel@tonic-gate ONOFF(sctp->sctp_recvpdevnt); 875558fbd03Skcpoon ev->sctp_adaptation_layer_event = 876b34b8d1aSkcpoon ONOFF(sctp->sctp_recvalevnt); 8777c478bd9Sstevel@tonic-gate *optlen = sizeof (struct sctp_event_subscribe); 8787c478bd9Sstevel@tonic-gate break; 8797c478bd9Sstevel@tonic-gate } 8807c478bd9Sstevel@tonic-gate case SCTP_STATUS: 8817c478bd9Sstevel@tonic-gate *optlen = sctp_get_status(sctp, ptr); 8827c478bd9Sstevel@tonic-gate break; 8837c478bd9Sstevel@tonic-gate case SCTP_GET_PEER_ADDR_INFO: 8847c478bd9Sstevel@tonic-gate retval = sctp_get_paddrinfo(sctp, ptr, optlen); 8857c478bd9Sstevel@tonic-gate break; 8867c478bd9Sstevel@tonic-gate case SCTP_GET_NLADDRS: 8877c478bd9Sstevel@tonic-gate *(int32_t *)ptr = sctp->sctp_nsaddrs; 8887c478bd9Sstevel@tonic-gate break; 8897c478bd9Sstevel@tonic-gate case SCTP_GET_LADDRS: { 8907c478bd9Sstevel@tonic-gate int addr_cnt; 8917c478bd9Sstevel@tonic-gate int addr_size; 8927c478bd9Sstevel@tonic-gate 893bd670b35SErik Nordmark if (connp->conn_family == AF_INET) 8947c478bd9Sstevel@tonic-gate addr_size = sizeof (struct sockaddr_in); 8957c478bd9Sstevel@tonic-gate else 8967c478bd9Sstevel@tonic-gate addr_size = sizeof (struct sockaddr_in6); 8977c478bd9Sstevel@tonic-gate addr_cnt = buflen / addr_size; 8987c478bd9Sstevel@tonic-gate retval = sctp_getmyaddrs(sctp, ptr, &addr_cnt); 8997c478bd9Sstevel@tonic-gate if (retval == 0) 9007c478bd9Sstevel@tonic-gate *optlen = addr_cnt * addr_size; 9017c478bd9Sstevel@tonic-gate break; 9027c478bd9Sstevel@tonic-gate } 9037c478bd9Sstevel@tonic-gate case SCTP_GET_NPADDRS: { 9047c478bd9Sstevel@tonic-gate int i; 9057c478bd9Sstevel@tonic-gate sctp_faddr_t *fp; 9067c478bd9Sstevel@tonic-gate 9077c478bd9Sstevel@tonic-gate for (i = 0, fp = sctp->sctp_faddrs; fp != NULL; 9086be61d4eSchandrasekar marimuthu - Sun Microsystems - Bangalore India i++, fp = fp->sf_next) 9097c478bd9Sstevel@tonic-gate ; 9107c478bd9Sstevel@tonic-gate *(int32_t *)ptr = i; 9117c478bd9Sstevel@tonic-gate break; 9127c478bd9Sstevel@tonic-gate } 9137c478bd9Sstevel@tonic-gate case SCTP_GET_PADDRS: { 9147c478bd9Sstevel@tonic-gate int addr_cnt; 9157c478bd9Sstevel@tonic-gate int addr_size; 9167c478bd9Sstevel@tonic-gate 917bd670b35SErik Nordmark if (connp->conn_family == AF_INET) 9187c478bd9Sstevel@tonic-gate addr_size = sizeof (struct sockaddr_in); 9197c478bd9Sstevel@tonic-gate else 9207c478bd9Sstevel@tonic-gate addr_size = sizeof (struct sockaddr_in6); 9217c478bd9Sstevel@tonic-gate addr_cnt = buflen / addr_size; 9227c478bd9Sstevel@tonic-gate retval = sctp_getpeeraddrs(sctp, ptr, &addr_cnt); 9237c478bd9Sstevel@tonic-gate if (retval == 0) 9247c478bd9Sstevel@tonic-gate *optlen = addr_cnt * addr_size; 9257c478bd9Sstevel@tonic-gate break; 9267c478bd9Sstevel@tonic-gate } 9277c478bd9Sstevel@tonic-gate case SCTP_PRSCTP: 9287c478bd9Sstevel@tonic-gate *i1 = sctp->sctp_prsctp_aware ? 1 : 0; 9297c478bd9Sstevel@tonic-gate break; 9309f13099eSGeorge Shepherd 9319f13099eSGeorge Shepherd case SCTP_GET_ASSOC_STATS: { 9329f13099eSGeorge Shepherd sctp_assoc_stats_t *sas; 9339f13099eSGeorge Shepherd 9349f13099eSGeorge Shepherd sas = (sctp_assoc_stats_t *)ptr; 9359f13099eSGeorge Shepherd 9369f13099eSGeorge Shepherd /* 9379f13099eSGeorge Shepherd * Copy the current stats to the stats struct. 93835e12f9cSGeorge Shepherd * For stats which can be reset by snmp users 93935e12f9cSGeorge Shepherd * add the cumulative and current stats for 94035e12f9cSGeorge Shepherd * the raw totals to output to the user. 9419f13099eSGeorge Shepherd */ 9429f13099eSGeorge Shepherd sas->sas_gapcnt = sctp->sctp_gapcnt; 9439f13099eSGeorge Shepherd sas->sas_outseqtsns = sctp->sctp_outseqtsns; 9449f13099eSGeorge Shepherd sas->sas_osacks = sctp->sctp_osacks; 9459f13099eSGeorge Shepherd sas->sas_isacks = sctp->sctp_isacks; 9469f13099eSGeorge Shepherd sas->sas_idupchunks = sctp->sctp_idupchunks; 94735e12f9cSGeorge Shepherd sas->sas_rtxchunks = sctp->sctp_rxtchunks + 94835e12f9cSGeorge Shepherd sctp->sctp_cum_rxtchunks; 94935e12f9cSGeorge Shepherd sas->sas_octrlchunks = sctp->sctp_obchunks + 95035e12f9cSGeorge Shepherd sctp->sctp_cum_obchunks; 95135e12f9cSGeorge Shepherd sas->sas_ictrlchunks = sctp->sctp_ibchunks + 95235e12f9cSGeorge Shepherd sctp->sctp_cum_ibchunks; 95335e12f9cSGeorge Shepherd sas->sas_oodchunks = sctp->sctp_odchunks + 95435e12f9cSGeorge Shepherd sctp->sctp_cum_odchunks; 95535e12f9cSGeorge Shepherd sas->sas_iodchunks = sctp->sctp_idchunks + 95635e12f9cSGeorge Shepherd sctp->sctp_cum_idchunks; 95735e12f9cSGeorge Shepherd sas->sas_ouodchunks = sctp->sctp_oudchunks + 95835e12f9cSGeorge Shepherd sctp->sctp_cum_oudchunks; 95935e12f9cSGeorge Shepherd sas->sas_iuodchunks = sctp->sctp_iudchunks + 96035e12f9cSGeorge Shepherd sctp->sctp_cum_iudchunks; 9619f13099eSGeorge Shepherd 9629f13099eSGeorge Shepherd /* 9639f13099eSGeorge Shepherd * Copy out the maximum observed RTO since the 9649f13099eSGeorge Shepherd * time this data was last requested 9659f13099eSGeorge Shepherd */ 9669f13099eSGeorge Shepherd if (sctp->sctp_maxrto == 0) { 9679f13099eSGeorge Shepherd /* unchanged during obervation period */ 9689f13099eSGeorge Shepherd sas->sas_maxrto = sctp->sctp_prev_maxrto; 9699f13099eSGeorge Shepherd } else { 9709f13099eSGeorge Shepherd /* record new period maximum */ 9719f13099eSGeorge Shepherd sas->sas_maxrto = sctp->sctp_maxrto; 9729f13099eSGeorge Shepherd } 9739f13099eSGeorge Shepherd /* Record the value sent to the user this period */ 9749f13099eSGeorge Shepherd sctp->sctp_prev_maxrto = sas->sas_maxrto; 9759f13099eSGeorge Shepherd 9769f13099eSGeorge Shepherd /* Mark beginning of a new observation period */ 9779f13099eSGeorge Shepherd sctp->sctp_maxrto = 0; 9789f13099eSGeorge Shepherd 9799f13099eSGeorge Shepherd *optlen = sizeof (sctp_assoc_stats_t); 9809f13099eSGeorge Shepherd break; 9819f13099eSGeorge Shepherd } 9827c478bd9Sstevel@tonic-gate case SCTP_I_WANT_MAPPED_V4_ADDR: 9837c478bd9Sstevel@tonic-gate case SCTP_MAXSEG: 9847c478bd9Sstevel@tonic-gate case SCTP_DISABLE_FRAGMENTS: 9857c478bd9Sstevel@tonic-gate default: 986bd670b35SErik Nordmark /* Not yet supported. */ 98788cda078Skcpoon retval = ENOPROTOOPT; 9887c478bd9Sstevel@tonic-gate break; 9897c478bd9Sstevel@tonic-gate } 990bd670b35SErik Nordmark WAKE_SCTP(sctp); 991bd670b35SErik Nordmark return (retval); 9927c478bd9Sstevel@tonic-gate case IPPROTO_IP: 993bd670b35SErik Nordmark if (connp->conn_family != AF_INET) { 9947c478bd9Sstevel@tonic-gate retval = EINVAL; 9957c478bd9Sstevel@tonic-gate break; 9967c478bd9Sstevel@tonic-gate } 9977c478bd9Sstevel@tonic-gate switch (name) { 9987c478bd9Sstevel@tonic-gate case IP_OPTIONS: 9997c478bd9Sstevel@tonic-gate case T_IP_OPTIONS: { 10007c478bd9Sstevel@tonic-gate /* 10017c478bd9Sstevel@tonic-gate * This is compatible with BSD in that in only return 10027c478bd9Sstevel@tonic-gate * the reverse source route with the final destination 10037c478bd9Sstevel@tonic-gate * as the last entry. The first 4 bytes of the option 10047c478bd9Sstevel@tonic-gate * will contain the final destination. Allocate a 10057c478bd9Sstevel@tonic-gate * buffer large enough to hold all the options, we 10067c478bd9Sstevel@tonic-gate * add IP_ADDR_LEN to SCTP_MAX_IP_OPTIONS_LENGTH since 100745916cd2Sjpk * ip_opt_get_user() adds the final destination 10087c478bd9Sstevel@tonic-gate * at the start. 10097c478bd9Sstevel@tonic-gate */ 10107c478bd9Sstevel@tonic-gate int opt_len; 10117c478bd9Sstevel@tonic-gate uchar_t obuf[SCTP_MAX_IP_OPTIONS_LENGTH + IP_ADDR_LEN]; 10127c478bd9Sstevel@tonic-gate 1013bd670b35SErik Nordmark opt_len = ip_opt_get_user(connp, obuf); 1014bd670b35SErik Nordmark ASSERT(opt_len <= sizeof (obuf)); 1015bd670b35SErik Nordmark 10167c478bd9Sstevel@tonic-gate if (buflen < opt_len) { 10177c478bd9Sstevel@tonic-gate /* Silently truncate */ 10187c478bd9Sstevel@tonic-gate opt_len = buflen; 10197c478bd9Sstevel@tonic-gate } 10207c478bd9Sstevel@tonic-gate *optlen = opt_len; 10217c478bd9Sstevel@tonic-gate bcopy(obuf, ptr, opt_len); 1022bd670b35SErik Nordmark WAKE_SCTP(sctp); 1023bd670b35SErik Nordmark return (0); 10247c478bd9Sstevel@tonic-gate } 10257c478bd9Sstevel@tonic-gate default: 10267c478bd9Sstevel@tonic-gate break; 10277c478bd9Sstevel@tonic-gate } 10287c478bd9Sstevel@tonic-gate break; 10297c478bd9Sstevel@tonic-gate } 1030bd670b35SErik Nordmark mutex_enter(&connp->conn_lock); 1031bd670b35SErik Nordmark retval = conn_opt_get(&coas, level, name, ptr); 1032bd670b35SErik Nordmark mutex_exit(&connp->conn_lock); 10337c478bd9Sstevel@tonic-gate WAKE_SCTP(sctp); 1034bd670b35SErik Nordmark if (retval == -1) 1035bd670b35SErik Nordmark return (EINVAL); 1036bd670b35SErik Nordmark *optlen = retval; 1037bd670b35SErik Nordmark return (0); 10387c478bd9Sstevel@tonic-gate } 10397c478bd9Sstevel@tonic-gate 10407c478bd9Sstevel@tonic-gate int 10417c478bd9Sstevel@tonic-gate sctp_set_opt(sctp_t *sctp, int level, int name, const void *invalp, 10427c478bd9Sstevel@tonic-gate socklen_t inlen) 10437c478bd9Sstevel@tonic-gate { 10447c478bd9Sstevel@tonic-gate int *i1 = (int *)invalp; 10457c478bd9Sstevel@tonic-gate boolean_t onoff; 10467c478bd9Sstevel@tonic-gate int retval = 0, addrcnt; 10477c478bd9Sstevel@tonic-gate conn_t *connp = sctp->sctp_connp; 1048f4b3ec61Sdh sctp_stack_t *sctps = sctp->sctp_sctps; 1049bd670b35SErik Nordmark conn_opt_arg_t coas; 1050bd670b35SErik Nordmark 1051bd670b35SErik Nordmark coas.coa_connp = connp; 1052bd670b35SErik Nordmark coas.coa_ixa = connp->conn_ixa; 1053bd670b35SErik Nordmark coas.coa_ipp = &connp->conn_xmit_ipp; 1054bd670b35SErik Nordmark coas.coa_ancillary = B_FALSE; 1055bd670b35SErik Nordmark coas.coa_changed = 0; 10567c478bd9Sstevel@tonic-gate 10577c478bd9Sstevel@tonic-gate /* In all cases, the size of the option must be bigger than int */ 10587c478bd9Sstevel@tonic-gate if (inlen >= sizeof (int32_t)) { 10597c478bd9Sstevel@tonic-gate onoff = ONOFF(*i1); 1060*ab82c29bSToomas Soome } else { 1061*ab82c29bSToomas Soome return (EINVAL); 10627c478bd9Sstevel@tonic-gate } 1063*ab82c29bSToomas Soome 10647c478bd9Sstevel@tonic-gate retval = 0; 10657c478bd9Sstevel@tonic-gate 10667c478bd9Sstevel@tonic-gate RUN_SCTP(sctp); 10677c478bd9Sstevel@tonic-gate 1068b34b8d1aSkcpoon if (connp->conn_state_flags & CONN_CLOSING) { 1069b34b8d1aSkcpoon WAKE_SCTP(sctp); 1070b34b8d1aSkcpoon return (EINVAL); 1071b34b8d1aSkcpoon } 1072b34b8d1aSkcpoon 1073bd670b35SErik Nordmark /* 1074bd670b35SErik Nordmark * Check that the level and name are supported by SCTP, and that 1075bd670b35SErik Nordmark * the length an credentials are ok. 1076bd670b35SErik Nordmark */ 1077bd670b35SErik Nordmark retval = proto_opt_check(level, name, inlen, NULL, sctp_opt_arr, 1078bd670b35SErik Nordmark sctp_opt_arr_size, B_TRUE, B_FALSE, connp->conn_cred); 1079bd670b35SErik Nordmark if (retval != 0) { 1080bd670b35SErik Nordmark if (retval < 0) { 1081bd670b35SErik Nordmark retval = proto_tlitosyserr(-retval); 1082bd670b35SErik Nordmark } 1083bd670b35SErik Nordmark goto done; 1084bd670b35SErik Nordmark } 1085bd670b35SErik Nordmark 1086bd670b35SErik Nordmark /* Note: both SCTP and TCP interpret l_linger as being in seconds */ 10877c478bd9Sstevel@tonic-gate switch (level) { 10887c478bd9Sstevel@tonic-gate case SOL_SOCKET: 10897c478bd9Sstevel@tonic-gate switch (name) { 10907c478bd9Sstevel@tonic-gate case SO_SNDBUF: 1091f4b3ec61Sdh if (*i1 > sctps->sctps_max_buf) { 10927c478bd9Sstevel@tonic-gate retval = ENOBUFS; 1093bd670b35SErik Nordmark goto done; 10947c478bd9Sstevel@tonic-gate } 10957c478bd9Sstevel@tonic-gate if (*i1 < 0) { 10967c478bd9Sstevel@tonic-gate retval = EINVAL; 1097bd670b35SErik Nordmark goto done; 10987c478bd9Sstevel@tonic-gate } 1099bd670b35SErik Nordmark connp->conn_sndbuf = *i1; 1100bd670b35SErik Nordmark if (sctps->sctps_snd_lowat_fraction != 0) { 1101bd670b35SErik Nordmark connp->conn_sndlowat = connp->conn_sndbuf / 1102f4b3ec61Sdh sctps->sctps_snd_lowat_fraction; 1103bd670b35SErik Nordmark } 1104bd670b35SErik Nordmark goto done; 11057c478bd9Sstevel@tonic-gate case SO_RCVBUF: 1106f4b3ec61Sdh if (*i1 > sctps->sctps_max_buf) { 11077c478bd9Sstevel@tonic-gate retval = ENOBUFS; 1108bd670b35SErik Nordmark goto done; 11097c478bd9Sstevel@tonic-gate } 11107c478bd9Sstevel@tonic-gate /* Silently ignore zero */ 11117c478bd9Sstevel@tonic-gate if (*i1 != 0) { 11127cae9885SAnders Persson struct sock_proto_props sopp; 11137cae9885SAnders Persson 11147c478bd9Sstevel@tonic-gate /* 11157c478bd9Sstevel@tonic-gate * Insist on a receive window that is at least 11167c478bd9Sstevel@tonic-gate * sctp_recv_hiwat_minmss * MSS (default 4*MSS) 11177c478bd9Sstevel@tonic-gate * to avoid funny interactions of Nagle 11187c478bd9Sstevel@tonic-gate * algorithm, SWS avoidance and delayed 11197c478bd9Sstevel@tonic-gate * acknowledgement. 11207c478bd9Sstevel@tonic-gate */ 11217c478bd9Sstevel@tonic-gate *i1 = MAX(*i1, 1122f4b3ec61Sdh sctps->sctps_recv_hiwat_minmss * 1123f4b3ec61Sdh sctp->sctp_mss); 1124bd670b35SErik Nordmark /* 1125bd670b35SErik Nordmark * Note that sctp_rwnd is modified by the 1126bd670b35SErik Nordmark * protocol and here we just whack it. 1127bd670b35SErik Nordmark */ 1128bd670b35SErik Nordmark connp->conn_rcvbuf = sctp->sctp_rwnd = *i1; 1129a215d4ebSKacheong Poon sctp->sctp_arwnd = sctp->sctp_rwnd; 11307d546a59Svi sctp->sctp_pd_point = sctp->sctp_rwnd; 11317cae9885SAnders Persson 11327cae9885SAnders Persson sopp.sopp_flags = SOCKOPT_RCVHIWAT; 1133bd670b35SErik Nordmark sopp.sopp_rxhiwat = connp->conn_rcvbuf; 11347cae9885SAnders Persson sctp->sctp_ulp_prop(sctp->sctp_ulpd, &sopp); 11357cae9885SAnders Persson 11367c478bd9Sstevel@tonic-gate } 11377c478bd9Sstevel@tonic-gate /* 11387c478bd9Sstevel@tonic-gate * XXX should we return the rwnd here 11397c478bd9Sstevel@tonic-gate * and sctp_opt_get ? 11407c478bd9Sstevel@tonic-gate */ 1141bd670b35SErik Nordmark goto done; 11425d0bc3edSsommerfe case SO_ALLZONES: 11435d0bc3edSsommerfe if (sctp->sctp_state >= SCTPS_BOUND) { 11445d0bc3edSsommerfe retval = EINVAL; 1145bd670b35SErik Nordmark goto done; 11465d0bc3edSsommerfe } 11475d0bc3edSsommerfe break; 114845916cd2Sjpk case SO_MAC_EXEMPT: 11495d3b8cb7SBill Sommerfeld if (sctp->sctp_state >= SCTPS_BOUND) { 11505d3b8cb7SBill Sommerfeld retval = EINVAL; 1151bd670b35SErik Nordmark goto done; 11525d3b8cb7SBill Sommerfeld } 11537c478bd9Sstevel@tonic-gate break; 11547c478bd9Sstevel@tonic-gate } 11557c478bd9Sstevel@tonic-gate break; 11567c478bd9Sstevel@tonic-gate 11577c478bd9Sstevel@tonic-gate case IPPROTO_SCTP: 11587c478bd9Sstevel@tonic-gate switch (name) { 11597c478bd9Sstevel@tonic-gate case SCTP_RTOINFO: 1160bd670b35SErik Nordmark retval = sctp_set_rtoinfo(sctp, invalp); 11617c478bd9Sstevel@tonic-gate break; 11627c478bd9Sstevel@tonic-gate case SCTP_ASSOCINFO: 1163bd670b35SErik Nordmark retval = sctp_set_assocparams(sctp, invalp); 11647c478bd9Sstevel@tonic-gate break; 11657c478bd9Sstevel@tonic-gate case SCTP_INITMSG: 11667c478bd9Sstevel@tonic-gate retval = sctp_set_initmsg(sctp, invalp, inlen); 11677c478bd9Sstevel@tonic-gate break; 11687c478bd9Sstevel@tonic-gate case SCTP_NODELAY: 11697c478bd9Sstevel@tonic-gate sctp->sctp_ndelay = ONOFF(*i1); 11707c478bd9Sstevel@tonic-gate break; 11717c478bd9Sstevel@tonic-gate case SCTP_AUTOCLOSE: 11727c478bd9Sstevel@tonic-gate if (SEC_TO_TICK(*i1) < 0) { 11737c478bd9Sstevel@tonic-gate retval = EINVAL; 11747c478bd9Sstevel@tonic-gate break; 11757c478bd9Sstevel@tonic-gate } 11767c478bd9Sstevel@tonic-gate /* Convert the number of seconds to ticks. */ 11777c478bd9Sstevel@tonic-gate sctp->sctp_autoclose = SEC_TO_TICK(*i1); 11787c478bd9Sstevel@tonic-gate sctp_heartbeat_timer(sctp); 11797c478bd9Sstevel@tonic-gate break; 11807c478bd9Sstevel@tonic-gate case SCTP_SET_PEER_PRIMARY_ADDR: 1181bd670b35SErik Nordmark retval = sctp_set_peerprim(sctp, invalp); 11827c478bd9Sstevel@tonic-gate break; 11837c478bd9Sstevel@tonic-gate case SCTP_PRIMARY_ADDR: 1184bd670b35SErik Nordmark retval = sctp_set_prim(sctp, invalp); 11857c478bd9Sstevel@tonic-gate break; 1186558fbd03Skcpoon case SCTP_ADAPTATION_LAYER: { 1187558fbd03Skcpoon struct sctp_setadaptation *ssb; 11887c478bd9Sstevel@tonic-gate 1189558fbd03Skcpoon ssb = (struct sctp_setadaptation *)invalp; 1190558fbd03Skcpoon sctp->sctp_send_adaptation = 1; 1191558fbd03Skcpoon sctp->sctp_tx_adaptation_code = ssb->ssb_adaptation_ind; 11927c478bd9Sstevel@tonic-gate break; 11937c478bd9Sstevel@tonic-gate } 11947c478bd9Sstevel@tonic-gate case SCTP_PEER_ADDR_PARAMS: 1195bd670b35SErik Nordmark retval = sctp_set_peer_addr_params(sctp, invalp); 11967c478bd9Sstevel@tonic-gate break; 11977c478bd9Sstevel@tonic-gate case SCTP_DEFAULT_SEND_PARAM: 1198bd670b35SErik Nordmark retval = sctp_set_def_send_params(sctp, invalp); 11997c478bd9Sstevel@tonic-gate break; 12007c478bd9Sstevel@tonic-gate case SCTP_EVENTS: { 12017c478bd9Sstevel@tonic-gate struct sctp_event_subscribe *ev; 12027c478bd9Sstevel@tonic-gate 12037c478bd9Sstevel@tonic-gate ev = (struct sctp_event_subscribe *)invalp; 12047c478bd9Sstevel@tonic-gate sctp->sctp_recvsndrcvinfo = 12057c478bd9Sstevel@tonic-gate ONOFF(ev->sctp_data_io_event); 12067c478bd9Sstevel@tonic-gate sctp->sctp_recvassocevnt = 12077c478bd9Sstevel@tonic-gate ONOFF(ev->sctp_association_event); 12087c478bd9Sstevel@tonic-gate sctp->sctp_recvpathevnt = 12097c478bd9Sstevel@tonic-gate ONOFF(ev->sctp_address_event); 12107c478bd9Sstevel@tonic-gate sctp->sctp_recvsendfailevnt = 12117c478bd9Sstevel@tonic-gate ONOFF(ev->sctp_send_failure_event); 12127c478bd9Sstevel@tonic-gate sctp->sctp_recvpeererr = 12137c478bd9Sstevel@tonic-gate ONOFF(ev->sctp_peer_error_event); 12147c478bd9Sstevel@tonic-gate sctp->sctp_recvshutdownevnt = 12157c478bd9Sstevel@tonic-gate ONOFF(ev->sctp_shutdown_event); 12167c478bd9Sstevel@tonic-gate sctp->sctp_recvpdevnt = 12177c478bd9Sstevel@tonic-gate ONOFF(ev->sctp_partial_delivery_event); 12187c478bd9Sstevel@tonic-gate sctp->sctp_recvalevnt = 1219558fbd03Skcpoon ONOFF(ev->sctp_adaptation_layer_event); 12207c478bd9Sstevel@tonic-gate break; 12217c478bd9Sstevel@tonic-gate } 12227c478bd9Sstevel@tonic-gate case SCTP_ADD_ADDR: 12237c478bd9Sstevel@tonic-gate case SCTP_REM_ADDR: 12247c478bd9Sstevel@tonic-gate /* 12257c478bd9Sstevel@tonic-gate * The sctp_t has to be bound first before 12267c478bd9Sstevel@tonic-gate * the address list can be changed. 12277c478bd9Sstevel@tonic-gate */ 12287c478bd9Sstevel@tonic-gate if (sctp->sctp_state < SCTPS_BOUND) { 12297c478bd9Sstevel@tonic-gate retval = EINVAL; 12307c478bd9Sstevel@tonic-gate break; 12317c478bd9Sstevel@tonic-gate } 1232bd670b35SErik Nordmark if (connp->conn_family == AF_INET) { 12337c478bd9Sstevel@tonic-gate addrcnt = inlen / sizeof (struct sockaddr_in); 12347c478bd9Sstevel@tonic-gate } else { 1235bd670b35SErik Nordmark ASSERT(connp->conn_family == AF_INET6); 12367c478bd9Sstevel@tonic-gate addrcnt = inlen / sizeof (struct sockaddr_in6); 12377c478bd9Sstevel@tonic-gate } 12387c478bd9Sstevel@tonic-gate if (name == SCTP_ADD_ADDR) { 12397c478bd9Sstevel@tonic-gate retval = sctp_bind_add(sctp, invalp, addrcnt, 1240bd670b35SErik Nordmark B_TRUE, connp->conn_lport); 12417c478bd9Sstevel@tonic-gate } else { 12427c478bd9Sstevel@tonic-gate retval = sctp_bind_del(sctp, invalp, addrcnt, 12437c478bd9Sstevel@tonic-gate B_TRUE); 12447c478bd9Sstevel@tonic-gate } 12457c478bd9Sstevel@tonic-gate break; 12467c478bd9Sstevel@tonic-gate case SCTP_UC_SWAP: { 12477c478bd9Sstevel@tonic-gate struct sctp_uc_swap *us; 12487c478bd9Sstevel@tonic-gate 12497c478bd9Sstevel@tonic-gate /* 12507c478bd9Sstevel@tonic-gate * Change handle & upcalls. 12517c478bd9Sstevel@tonic-gate */ 12527c478bd9Sstevel@tonic-gate us = (struct sctp_uc_swap *)invalp; 12537c478bd9Sstevel@tonic-gate sctp->sctp_ulpd = us->sus_handle; 12540f1702c5SYu Xiangning sctp->sctp_upcalls = us->sus_upcalls; 12557c478bd9Sstevel@tonic-gate break; 12567c478bd9Sstevel@tonic-gate } 12577c478bd9Sstevel@tonic-gate case SCTP_PRSCTP: 12587c478bd9Sstevel@tonic-gate sctp->sctp_prsctp_aware = onoff; 12597c478bd9Sstevel@tonic-gate break; 12607c478bd9Sstevel@tonic-gate case SCTP_I_WANT_MAPPED_V4_ADDR: 12617c478bd9Sstevel@tonic-gate case SCTP_MAXSEG: 12627c478bd9Sstevel@tonic-gate case SCTP_DISABLE_FRAGMENTS: 12637c478bd9Sstevel@tonic-gate /* Not yet supported. */ 126488cda078Skcpoon retval = ENOPROTOOPT; 12657c478bd9Sstevel@tonic-gate break; 12667c478bd9Sstevel@tonic-gate } 1267bd670b35SErik Nordmark goto done; 12687c478bd9Sstevel@tonic-gate 12697c478bd9Sstevel@tonic-gate case IPPROTO_IP: 1270bd670b35SErik Nordmark if (connp->conn_family != AF_INET) { 12717c478bd9Sstevel@tonic-gate retval = ENOPROTOOPT; 1272bd670b35SErik Nordmark goto done; 12737c478bd9Sstevel@tonic-gate } 12747c478bd9Sstevel@tonic-gate switch (name) { 12757c478bd9Sstevel@tonic-gate case IP_SEC_OPT: 12767c478bd9Sstevel@tonic-gate /* 12777c478bd9Sstevel@tonic-gate * We should not allow policy setting after 12787c478bd9Sstevel@tonic-gate * we start listening for connections. 12797c478bd9Sstevel@tonic-gate */ 12807c478bd9Sstevel@tonic-gate if (sctp->sctp_state >= SCTPS_LISTEN) { 12817c478bd9Sstevel@tonic-gate retval = EINVAL; 1282bd670b35SErik Nordmark goto done; 128343d18f1cSpriyanka } 128443d18f1cSpriyanka break; 128543d18f1cSpriyanka } 12867c478bd9Sstevel@tonic-gate break; 1287bd670b35SErik Nordmark case IPPROTO_IPV6: 1288bd670b35SErik Nordmark if (connp->conn_family != AF_INET6) { 1289bd670b35SErik Nordmark retval = EINVAL; 1290bd670b35SErik Nordmark goto done; 12917c478bd9Sstevel@tonic-gate } 12927c478bd9Sstevel@tonic-gate 12937c478bd9Sstevel@tonic-gate switch (name) { 12947c478bd9Sstevel@tonic-gate case IPV6_RECVPKTINFO: 12957c478bd9Sstevel@tonic-gate /* Send it with the next msg */ 12967c478bd9Sstevel@tonic-gate sctp->sctp_recvifindex = 0; 1297bd670b35SErik Nordmark break; 1298bd670b35SErik Nordmark case IPV6_RECVTCLASS: 1299bd670b35SErik Nordmark /* Force it to be sent up with the next msg */ 1300bd670b35SErik Nordmark sctp->sctp_recvtclass = 0xffffffffU; 13017c478bd9Sstevel@tonic-gate break; 13027c478bd9Sstevel@tonic-gate case IPV6_RECVHOPLIMIT: 1303bd670b35SErik Nordmark /* Force it to be sent up with the next msg */ 13047c478bd9Sstevel@tonic-gate sctp->sctp_recvhops = 0xffffffffU; 13057c478bd9Sstevel@tonic-gate break; 13067c478bd9Sstevel@tonic-gate case IPV6_SEC_OPT: 13077c478bd9Sstevel@tonic-gate /* 13087c478bd9Sstevel@tonic-gate * We should not allow policy setting after 13097c478bd9Sstevel@tonic-gate * we start listening for connections. 13107c478bd9Sstevel@tonic-gate */ 13117c478bd9Sstevel@tonic-gate if (sctp->sctp_state >= SCTPS_LISTEN) { 13127c478bd9Sstevel@tonic-gate retval = EINVAL; 1313bd670b35SErik Nordmark goto done; 13147c478bd9Sstevel@tonic-gate } 13157c478bd9Sstevel@tonic-gate break; 13167c478bd9Sstevel@tonic-gate case IPV6_V6ONLY: 13177c478bd9Sstevel@tonic-gate /* 13187c478bd9Sstevel@tonic-gate * After the bound state, setting the v6only option 13197c478bd9Sstevel@tonic-gate * is too late. 13207c478bd9Sstevel@tonic-gate */ 13217c478bd9Sstevel@tonic-gate if (sctp->sctp_state >= SCTPS_BOUND) { 13227c478bd9Sstevel@tonic-gate retval = EINVAL; 1323bd670b35SErik Nordmark goto done; 13247c478bd9Sstevel@tonic-gate } 13257c478bd9Sstevel@tonic-gate break; 13267c478bd9Sstevel@tonic-gate } 13277c478bd9Sstevel@tonic-gate break; 13287c478bd9Sstevel@tonic-gate } 13297c478bd9Sstevel@tonic-gate 1330bd670b35SErik Nordmark retval = conn_opt_set(&coas, level, name, inlen, (uchar_t *)invalp, 1331bd670b35SErik Nordmark B_FALSE, connp->conn_cred); 1332bd670b35SErik Nordmark if (retval != 0) 1333bd670b35SErik Nordmark goto done; 1334bd670b35SErik Nordmark 1335bd670b35SErik Nordmark if (coas.coa_changed & COA_ROUTE_CHANGED) { 1336bd670b35SErik Nordmark sctp_faddr_t *fp; 1337bd670b35SErik Nordmark /* 1338bd670b35SErik Nordmark * We recache the information which might pick a different 1339bd670b35SErik Nordmark * source and redo IPsec as a result. 1340bd670b35SErik Nordmark */ 13416be61d4eSchandrasekar marimuthu - Sun Microsystems - Bangalore India for (fp = sctp->sctp_faddrs; fp != NULL; fp = fp->sf_next) 1342bd670b35SErik Nordmark sctp_get_dest(sctp, fp); 1343bd670b35SErik Nordmark } 1344bd670b35SErik Nordmark if (coas.coa_changed & COA_HEADER_CHANGED) { 1345bd670b35SErik Nordmark retval = sctp_build_hdrs(sctp, KM_NOSLEEP); 1346bd670b35SErik Nordmark if (retval != 0) 1347bd670b35SErik Nordmark goto done; 1348bd670b35SErik Nordmark } 1349bd670b35SErik Nordmark if (coas.coa_changed & COA_WROFF_CHANGED) { 1350bd670b35SErik Nordmark connp->conn_wroff = connp->conn_ht_iphc_allocated + 1351bd670b35SErik Nordmark sctps->sctps_wroff_xtra; 1352bd670b35SErik Nordmark if (sctp->sctp_current != NULL) { 1353bd670b35SErik Nordmark /* 1354bd670b35SErik Nordmark * Could be setting options before setting up 1355bd670b35SErik Nordmark * connection. 1356bd670b35SErik Nordmark */ 1357bd670b35SErik Nordmark sctp_set_ulp_prop(sctp); 1358bd670b35SErik Nordmark } 1359bd670b35SErik Nordmark } 1360bd670b35SErik Nordmark done: 13617c478bd9Sstevel@tonic-gate WAKE_SCTP(sctp); 13627c478bd9Sstevel@tonic-gate return (retval); 13637c478bd9Sstevel@tonic-gate } 13647c478bd9Sstevel@tonic-gate 13657c478bd9Sstevel@tonic-gate /* 13667c478bd9Sstevel@tonic-gate * SCTP exported kernel interface for geting the first source address of 13677c478bd9Sstevel@tonic-gate * a sctp_t. The parameter addr is assumed to have enough space to hold 13687c478bd9Sstevel@tonic-gate * one socket address. 13697c478bd9Sstevel@tonic-gate */ 13707c478bd9Sstevel@tonic-gate int 13717c478bd9Sstevel@tonic-gate sctp_getsockname(sctp_t *sctp, struct sockaddr *addr, socklen_t *addrlen) 13727c478bd9Sstevel@tonic-gate { 13737c478bd9Sstevel@tonic-gate int err = 0; 13747c478bd9Sstevel@tonic-gate int addrcnt = 1; 13757c478bd9Sstevel@tonic-gate sin_t *sin4; 13767c478bd9Sstevel@tonic-gate sin6_t *sin6; 1377bd670b35SErik Nordmark conn_t *connp = sctp->sctp_connp; 13787c478bd9Sstevel@tonic-gate 13797c478bd9Sstevel@tonic-gate ASSERT(sctp != NULL); 13807c478bd9Sstevel@tonic-gate 13817c478bd9Sstevel@tonic-gate RUN_SCTP(sctp); 1382bd670b35SErik Nordmark addr->sa_family = connp->conn_family; 1383bd670b35SErik Nordmark switch (connp->conn_family) { 13847c478bd9Sstevel@tonic-gate case AF_INET: 13857c478bd9Sstevel@tonic-gate sin4 = (sin_t *)addr; 13867c478bd9Sstevel@tonic-gate if ((sctp->sctp_state <= SCTPS_LISTEN) && 13877c478bd9Sstevel@tonic-gate sctp->sctp_bound_to_all) { 13887c478bd9Sstevel@tonic-gate sin4->sin_addr.s_addr = INADDR_ANY; 1389bd670b35SErik Nordmark sin4->sin_port = connp->conn_lport; 13907c478bd9Sstevel@tonic-gate } else { 13917c478bd9Sstevel@tonic-gate err = sctp_getmyaddrs(sctp, sin4, &addrcnt); 13927c478bd9Sstevel@tonic-gate if (err != 0) { 13937c478bd9Sstevel@tonic-gate *addrlen = 0; 13947c478bd9Sstevel@tonic-gate break; 13957c478bd9Sstevel@tonic-gate } 13967c478bd9Sstevel@tonic-gate } 13977c478bd9Sstevel@tonic-gate *addrlen = sizeof (struct sockaddr_in); 13987c478bd9Sstevel@tonic-gate break; 13997c478bd9Sstevel@tonic-gate case AF_INET6: 14007c478bd9Sstevel@tonic-gate sin6 = (sin6_t *)addr; 14017c478bd9Sstevel@tonic-gate if ((sctp->sctp_state <= SCTPS_LISTEN) && 14027c478bd9Sstevel@tonic-gate sctp->sctp_bound_to_all) { 14037c478bd9Sstevel@tonic-gate bzero(&sin6->sin6_addr, sizeof (sin6->sin6_addr)); 1404bd670b35SErik Nordmark sin6->sin6_port = connp->conn_lport; 14057c478bd9Sstevel@tonic-gate } else { 14067c478bd9Sstevel@tonic-gate err = sctp_getmyaddrs(sctp, sin6, &addrcnt); 14077c478bd9Sstevel@tonic-gate if (err != 0) { 14087c478bd9Sstevel@tonic-gate *addrlen = 0; 14097c478bd9Sstevel@tonic-gate break; 14107c478bd9Sstevel@tonic-gate } 14117c478bd9Sstevel@tonic-gate } 14127c478bd9Sstevel@tonic-gate *addrlen = sizeof (struct sockaddr_in6); 1413bd670b35SErik Nordmark /* Note that flowinfo is only returned for getpeername */ 14147c478bd9Sstevel@tonic-gate break; 14157c478bd9Sstevel@tonic-gate } 14167c478bd9Sstevel@tonic-gate WAKE_SCTP(sctp); 14177c478bd9Sstevel@tonic-gate return (err); 14187c478bd9Sstevel@tonic-gate } 14197c478bd9Sstevel@tonic-gate 14207c478bd9Sstevel@tonic-gate /* 14217c478bd9Sstevel@tonic-gate * SCTP exported kernel interface for geting the primary peer address of 14227c478bd9Sstevel@tonic-gate * a sctp_t. The parameter addr is assumed to have enough space to hold 14237c478bd9Sstevel@tonic-gate * one socket address. 14247c478bd9Sstevel@tonic-gate */ 14257c478bd9Sstevel@tonic-gate int 14267c478bd9Sstevel@tonic-gate sctp_getpeername(sctp_t *sctp, struct sockaddr *addr, socklen_t *addrlen) 14277c478bd9Sstevel@tonic-gate { 14287c478bd9Sstevel@tonic-gate int err = 0; 14297c478bd9Sstevel@tonic-gate int addrcnt = 1; 14307c478bd9Sstevel@tonic-gate sin6_t *sin6; 1431bd670b35SErik Nordmark conn_t *connp = sctp->sctp_connp; 14327c478bd9Sstevel@tonic-gate 14337c478bd9Sstevel@tonic-gate ASSERT(sctp != NULL); 14347c478bd9Sstevel@tonic-gate 14357c478bd9Sstevel@tonic-gate RUN_SCTP(sctp); 1436bd670b35SErik Nordmark addr->sa_family = connp->conn_family; 1437bd670b35SErik Nordmark switch (connp->conn_family) { 14387c478bd9Sstevel@tonic-gate case AF_INET: 14397c478bd9Sstevel@tonic-gate err = sctp_getpeeraddrs(sctp, addr, &addrcnt); 14407c478bd9Sstevel@tonic-gate if (err != 0) { 14417c478bd9Sstevel@tonic-gate *addrlen = 0; 14427c478bd9Sstevel@tonic-gate break; 14437c478bd9Sstevel@tonic-gate } 14447c478bd9Sstevel@tonic-gate *addrlen = sizeof (struct sockaddr_in); 14457c478bd9Sstevel@tonic-gate break; 14467c478bd9Sstevel@tonic-gate case AF_INET6: 14477c478bd9Sstevel@tonic-gate sin6 = (sin6_t *)addr; 14487c478bd9Sstevel@tonic-gate err = sctp_getpeeraddrs(sctp, sin6, &addrcnt); 14497c478bd9Sstevel@tonic-gate if (err != 0) { 14507c478bd9Sstevel@tonic-gate *addrlen = 0; 14517c478bd9Sstevel@tonic-gate break; 14527c478bd9Sstevel@tonic-gate } 14537c478bd9Sstevel@tonic-gate *addrlen = sizeof (struct sockaddr_in6); 14547c478bd9Sstevel@tonic-gate break; 14557c478bd9Sstevel@tonic-gate } 14567c478bd9Sstevel@tonic-gate WAKE_SCTP(sctp); 14577c478bd9Sstevel@tonic-gate return (err); 14587c478bd9Sstevel@tonic-gate } 14597c478bd9Sstevel@tonic-gate 14607c478bd9Sstevel@tonic-gate /* 14617c478bd9Sstevel@tonic-gate * Return a list of IP addresses of the peer endpoint of this sctp_t. 14627c478bd9Sstevel@tonic-gate * The parameter paddrs is supposed to be either (struct sockaddr_in *) or 14637c478bd9Sstevel@tonic-gate * (struct sockaddr_in6 *) depending on the address family of the sctp_t. 14647c478bd9Sstevel@tonic-gate */ 14657c478bd9Sstevel@tonic-gate int 14667c478bd9Sstevel@tonic-gate sctp_getpeeraddrs(sctp_t *sctp, void *paddrs, int *addrcnt) 14677c478bd9Sstevel@tonic-gate { 14687c478bd9Sstevel@tonic-gate int family; 14697c478bd9Sstevel@tonic-gate struct sockaddr_in *sin4; 14707c478bd9Sstevel@tonic-gate struct sockaddr_in6 *sin6; 14717c478bd9Sstevel@tonic-gate int max; 14727c478bd9Sstevel@tonic-gate int cnt; 14737c478bd9Sstevel@tonic-gate sctp_faddr_t *fp = sctp->sctp_faddrs; 14747c478bd9Sstevel@tonic-gate in6_addr_t addr; 1475bd670b35SErik Nordmark conn_t *connp = sctp->sctp_connp; 14767c478bd9Sstevel@tonic-gate 14777c478bd9Sstevel@tonic-gate ASSERT(sctp != NULL); 14787c478bd9Sstevel@tonic-gate 14797c478bd9Sstevel@tonic-gate if (sctp->sctp_faddrs == NULL) 14807c478bd9Sstevel@tonic-gate return (ENOTCONN); 14817c478bd9Sstevel@tonic-gate 1482bd670b35SErik Nordmark family = connp->conn_family; 14837c478bd9Sstevel@tonic-gate max = *addrcnt; 14847c478bd9Sstevel@tonic-gate 14857c478bd9Sstevel@tonic-gate /* If we want only one, give the primary */ 14867c478bd9Sstevel@tonic-gate if (max == 1) { 14876be61d4eSchandrasekar marimuthu - Sun Microsystems - Bangalore India addr = sctp->sctp_primary->sf_faddr; 14887c478bd9Sstevel@tonic-gate switch (family) { 14897c478bd9Sstevel@tonic-gate case AF_INET: 14907c478bd9Sstevel@tonic-gate sin4 = paddrs; 14917c478bd9Sstevel@tonic-gate IN6_V4MAPPED_TO_INADDR(&addr, &sin4->sin_addr); 1492bd670b35SErik Nordmark sin4->sin_port = connp->conn_fport; 14937c478bd9Sstevel@tonic-gate sin4->sin_family = AF_INET; 14947c478bd9Sstevel@tonic-gate break; 14957c478bd9Sstevel@tonic-gate 14967c478bd9Sstevel@tonic-gate case AF_INET6: 14977c478bd9Sstevel@tonic-gate sin6 = paddrs; 14987c478bd9Sstevel@tonic-gate sin6->sin6_addr = addr; 1499bd670b35SErik Nordmark sin6->sin6_port = connp->conn_fport; 15007c478bd9Sstevel@tonic-gate sin6->sin6_family = AF_INET6; 1501bd670b35SErik Nordmark sin6->sin6_flowinfo = connp->conn_flowinfo; 1502bd670b35SErik Nordmark if (IN6_IS_ADDR_LINKSCOPE(&addr) && 15036be61d4eSchandrasekar marimuthu - Sun Microsystems - Bangalore India (sctp->sctp_primary->sf_ixa->ixa_flags & 1504bd670b35SErik Nordmark IXAF_SCOPEID_SET)) { 1505bd670b35SErik Nordmark sin6->sin6_scope_id = 15066be61d4eSchandrasekar marimuthu - Sun Microsystems - Bangalore India sctp->sctp_primary->sf_ixa->ixa_scopeid; 1507bd670b35SErik Nordmark } else { 1508bd670b35SErik Nordmark sin6->sin6_scope_id = 0; 1509bd670b35SErik Nordmark } 1510bd670b35SErik Nordmark sin6->__sin6_src_id = 0; 15117c478bd9Sstevel@tonic-gate break; 15127c478bd9Sstevel@tonic-gate } 15137c478bd9Sstevel@tonic-gate return (0); 15147c478bd9Sstevel@tonic-gate } 15157c478bd9Sstevel@tonic-gate 15166be61d4eSchandrasekar marimuthu - Sun Microsystems - Bangalore India for (cnt = 0; cnt < max && fp != NULL; cnt++, fp = fp->sf_next) { 15176be61d4eSchandrasekar marimuthu - Sun Microsystems - Bangalore India addr = fp->sf_faddr; 15187c478bd9Sstevel@tonic-gate switch (family) { 15197c478bd9Sstevel@tonic-gate case AF_INET: 15207c478bd9Sstevel@tonic-gate ASSERT(IN6_IS_ADDR_V4MAPPED(&addr)); 15217c478bd9Sstevel@tonic-gate sin4 = (struct sockaddr_in *)paddrs + cnt; 15227c478bd9Sstevel@tonic-gate IN6_V4MAPPED_TO_INADDR(&addr, &sin4->sin_addr); 1523bd670b35SErik Nordmark sin4->sin_port = connp->conn_fport; 15247c478bd9Sstevel@tonic-gate sin4->sin_family = AF_INET; 15257c478bd9Sstevel@tonic-gate break; 15267c478bd9Sstevel@tonic-gate case AF_INET6: 15277c478bd9Sstevel@tonic-gate sin6 = (struct sockaddr_in6 *)paddrs + cnt; 15287c478bd9Sstevel@tonic-gate sin6->sin6_addr = addr; 1529bd670b35SErik Nordmark sin6->sin6_port = connp->conn_fport; 15307c478bd9Sstevel@tonic-gate sin6->sin6_family = AF_INET6; 1531bd670b35SErik Nordmark sin6->sin6_flowinfo = connp->conn_flowinfo; 1532bd670b35SErik Nordmark if (IN6_IS_ADDR_LINKSCOPE(&addr) && 15336be61d4eSchandrasekar marimuthu - Sun Microsystems - Bangalore India (fp->sf_ixa->ixa_flags & IXAF_SCOPEID_SET)) 15346be61d4eSchandrasekar marimuthu - Sun Microsystems - Bangalore India sin6->sin6_scope_id = fp->sf_ixa->ixa_scopeid; 1535bd670b35SErik Nordmark else 1536bd670b35SErik Nordmark sin6->sin6_scope_id = 0; 1537bd670b35SErik Nordmark sin6->__sin6_src_id = 0; 15387c478bd9Sstevel@tonic-gate break; 15397c478bd9Sstevel@tonic-gate } 15407c478bd9Sstevel@tonic-gate } 15417c478bd9Sstevel@tonic-gate *addrcnt = cnt; 15427c478bd9Sstevel@tonic-gate return (0); 15437c478bd9Sstevel@tonic-gate } 1544