xref: /onnv-gate/usr/src/uts/common/inet/sctp/sctp_snmp.c (revision 1676:37f4a3e2bd99)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*1676Sjpk  * Common Development and Distribution License (the "License").
6*1676Sjpk  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
22*1676Sjpk  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
270Sstevel@tonic-gate 
280Sstevel@tonic-gate #include <sys/types.h>
290Sstevel@tonic-gate #include <sys/stream.h>
300Sstevel@tonic-gate #include <sys/cmn_err.h>
310Sstevel@tonic-gate #define	_SUN_TPI_VERSION 2
320Sstevel@tonic-gate #include <sys/tihdr.h>
330Sstevel@tonic-gate #include <sys/ddi.h>
340Sstevel@tonic-gate #include <sys/sunddi.h>
35*1676Sjpk #include <sys/tsol/tndb.h>
360Sstevel@tonic-gate 
370Sstevel@tonic-gate #include <netinet/in.h>
380Sstevel@tonic-gate 
390Sstevel@tonic-gate #include <inet/common.h>
400Sstevel@tonic-gate #include <inet/ip.h>
410Sstevel@tonic-gate #include <inet/mib2.h>
420Sstevel@tonic-gate #include <inet/snmpcom.h>
430Sstevel@tonic-gate #include <inet/kstatcom.h>
440Sstevel@tonic-gate #include <inet/ipclassifier.h>
450Sstevel@tonic-gate #include "sctp_impl.h"
460Sstevel@tonic-gate #include "sctp_addr.h"
470Sstevel@tonic-gate 
480Sstevel@tonic-gate mib2_sctp_t	sctp_mib;
490Sstevel@tonic-gate kstat_t		*sctp_mibkp;	/* kstat exporting sctp_mib data */
500Sstevel@tonic-gate 
510Sstevel@tonic-gate static int sctp_snmp_state(sctp_t *sctp);
520Sstevel@tonic-gate 
530Sstevel@tonic-gate static int
540Sstevel@tonic-gate sctp_kstat_update(kstat_t *kp, int rw)
550Sstevel@tonic-gate {
560Sstevel@tonic-gate 	sctp_named_kstat_t	*sctpkp;
570Sstevel@tonic-gate 	sctp_t			*sctp, *sctp_prev;
580Sstevel@tonic-gate 	zoneid_t		zoneid;
590Sstevel@tonic-gate 
600Sstevel@tonic-gate 	if (kp == NULL|| kp->ks_data == NULL)
610Sstevel@tonic-gate 		return (EIO);
620Sstevel@tonic-gate 
630Sstevel@tonic-gate 	if (rw == KSTAT_WRITE)
640Sstevel@tonic-gate 		return (EACCES);
650Sstevel@tonic-gate 
660Sstevel@tonic-gate 	zoneid = getzoneid();
670Sstevel@tonic-gate 
680Sstevel@tonic-gate 	/*
690Sstevel@tonic-gate 	 * Get the number of current associations and gather their
700Sstevel@tonic-gate 	 * individual set of statistics.
710Sstevel@tonic-gate 	 */
720Sstevel@tonic-gate 	SET_MIB(sctp_mib.sctpCurrEstab, 0);
730Sstevel@tonic-gate 	sctp = gsctp;
740Sstevel@tonic-gate 	sctp_prev = NULL;
750Sstevel@tonic-gate 	mutex_enter(&sctp_g_lock);
760Sstevel@tonic-gate 	while (sctp != NULL) {
770Sstevel@tonic-gate 		mutex_enter(&sctp->sctp_reflock);
780Sstevel@tonic-gate 		if (sctp->sctp_condemned) {
790Sstevel@tonic-gate 			mutex_exit(&sctp->sctp_reflock);
800Sstevel@tonic-gate 			sctp = list_next(&sctp_g_list, sctp);
810Sstevel@tonic-gate 			continue;
820Sstevel@tonic-gate 		}
830Sstevel@tonic-gate 		sctp->sctp_refcnt++;
840Sstevel@tonic-gate 		mutex_exit(&sctp->sctp_reflock);
850Sstevel@tonic-gate 		mutex_exit(&sctp_g_lock);
860Sstevel@tonic-gate 		if (sctp_prev != NULL)
870Sstevel@tonic-gate 			SCTP_REFRELE(sctp_prev);
880Sstevel@tonic-gate 		if (sctp->sctp_connp->conn_zoneid != zoneid)
890Sstevel@tonic-gate 			goto next_sctp;
900Sstevel@tonic-gate 		if (sctp->sctp_state == SCTPS_ESTABLISHED ||
910Sstevel@tonic-gate 		    sctp->sctp_state == SCTPS_SHUTDOWN_PENDING ||
920Sstevel@tonic-gate 		    sctp->sctp_state == SCTPS_SHUTDOWN_RECEIVED) {
930Sstevel@tonic-gate 			BUMP_MIB(&sctp_mib, sctpCurrEstab);
940Sstevel@tonic-gate 		}
950Sstevel@tonic-gate 
960Sstevel@tonic-gate 		if (sctp->sctp_opkts) {
970Sstevel@tonic-gate 			UPDATE_MIB(&sctp_mib, sctpOutSCTPPkts,
980Sstevel@tonic-gate 			    sctp->sctp_opkts);
990Sstevel@tonic-gate 			sctp->sctp_opkts = 0;
1000Sstevel@tonic-gate 		}
1010Sstevel@tonic-gate 
1020Sstevel@tonic-gate 		if (sctp->sctp_obchunks) {
1030Sstevel@tonic-gate 			UPDATE_MIB(&sctp_mib, sctpOutCtrlChunks,
1040Sstevel@tonic-gate 			    sctp->sctp_obchunks);
1050Sstevel@tonic-gate 			sctp->sctp_obchunks = 0;
1060Sstevel@tonic-gate 		}
1070Sstevel@tonic-gate 
1080Sstevel@tonic-gate 		if (sctp->sctp_odchunks) {
1090Sstevel@tonic-gate 			UPDATE_MIB(&sctp_mib, sctpOutOrderChunks,
1100Sstevel@tonic-gate 			    sctp->sctp_odchunks);
1110Sstevel@tonic-gate 			sctp->sctp_odchunks = 0;
1120Sstevel@tonic-gate 		}
1130Sstevel@tonic-gate 
1140Sstevel@tonic-gate 		if (sctp->sctp_oudchunks) {
1150Sstevel@tonic-gate 			UPDATE_MIB(&sctp_mib, sctpOutUnorderChunks,
1160Sstevel@tonic-gate 			    sctp->sctp_oudchunks);
1170Sstevel@tonic-gate 			sctp->sctp_oudchunks = 0;
1180Sstevel@tonic-gate 		}
1190Sstevel@tonic-gate 
1200Sstevel@tonic-gate 		if (sctp->sctp_rxtchunks) {
1210Sstevel@tonic-gate 			UPDATE_MIB(&sctp_mib, sctpRetransChunks,
1220Sstevel@tonic-gate 			    sctp->sctp_rxtchunks);
1230Sstevel@tonic-gate 			sctp->sctp_rxtchunks = 0;
1240Sstevel@tonic-gate 		}
1250Sstevel@tonic-gate 
1260Sstevel@tonic-gate 		if (sctp->sctp_ipkts) {
1270Sstevel@tonic-gate 			UPDATE_MIB(&sctp_mib, sctpInSCTPPkts, sctp->sctp_ipkts);
1280Sstevel@tonic-gate 			sctp->sctp_ipkts = 0;
1290Sstevel@tonic-gate 		}
1300Sstevel@tonic-gate 
1310Sstevel@tonic-gate 		if (sctp->sctp_ibchunks) {
1320Sstevel@tonic-gate 			UPDATE_MIB(&sctp_mib, sctpInCtrlChunks,
1330Sstevel@tonic-gate 			    sctp->sctp_ibchunks);
1340Sstevel@tonic-gate 			sctp->sctp_ibchunks = 0;
1350Sstevel@tonic-gate 		}
1360Sstevel@tonic-gate 
1370Sstevel@tonic-gate 		if (sctp->sctp_idchunks) {
1380Sstevel@tonic-gate 			UPDATE_MIB(&sctp_mib, sctpInOrderChunks,
1390Sstevel@tonic-gate 			    sctp->sctp_idchunks);
1400Sstevel@tonic-gate 			sctp->sctp_idchunks = 0;
1410Sstevel@tonic-gate 		}
1420Sstevel@tonic-gate 
1430Sstevel@tonic-gate 		if (sctp->sctp_iudchunks) {
1440Sstevel@tonic-gate 			UPDATE_MIB(&sctp_mib, sctpInUnorderChunks,
1450Sstevel@tonic-gate 			    sctp->sctp_iudchunks);
1460Sstevel@tonic-gate 			sctp->sctp_iudchunks = 0;
1470Sstevel@tonic-gate 		}
1480Sstevel@tonic-gate 
1490Sstevel@tonic-gate 		if (sctp->sctp_fragdmsgs) {
1500Sstevel@tonic-gate 			UPDATE_MIB(&sctp_mib, sctpFragUsrMsgs,
1510Sstevel@tonic-gate 			    sctp->sctp_fragdmsgs);
1520Sstevel@tonic-gate 			sctp->sctp_fragdmsgs = 0;
1530Sstevel@tonic-gate 		}
1540Sstevel@tonic-gate 
1550Sstevel@tonic-gate 		if (sctp->sctp_reassmsgs) {
1560Sstevel@tonic-gate 			UPDATE_MIB(&sctp_mib, sctpReasmUsrMsgs,
1570Sstevel@tonic-gate 			    sctp->sctp_reassmsgs);
1580Sstevel@tonic-gate 			sctp->sctp_reassmsgs = 0;
1590Sstevel@tonic-gate 		}
1600Sstevel@tonic-gate 
1610Sstevel@tonic-gate next_sctp:
1620Sstevel@tonic-gate 		sctp_prev = sctp;
1630Sstevel@tonic-gate 		mutex_enter(&sctp_g_lock);
1640Sstevel@tonic-gate 		sctp = list_next(&sctp_g_list, sctp);
1650Sstevel@tonic-gate 	}
1660Sstevel@tonic-gate 	mutex_exit(&sctp_g_lock);
1670Sstevel@tonic-gate 	if (sctp_prev != NULL)
1680Sstevel@tonic-gate 		SCTP_REFRELE(sctp_prev);
1690Sstevel@tonic-gate 
1700Sstevel@tonic-gate 	/* Copy data from the SCTP MIB */
1710Sstevel@tonic-gate 	sctpkp = (sctp_named_kstat_t *)kp->ks_data;
1720Sstevel@tonic-gate 
1730Sstevel@tonic-gate 	/* These are from global ndd params. */
1740Sstevel@tonic-gate 	sctpkp->sctpRtoMin.value.ui32 = sctp_rto_ming;
1750Sstevel@tonic-gate 	sctpkp->sctpRtoMax.value.ui32 = sctp_rto_maxg;
1760Sstevel@tonic-gate 	sctpkp->sctpRtoInitial.value.ui32 = sctp_rto_initialg;
1770Sstevel@tonic-gate 	sctpkp->sctpValCookieLife.value.ui32 = sctp_cookie_life;
1780Sstevel@tonic-gate 	sctpkp->sctpMaxInitRetr.value.ui32 = sctp_max_init_retr;
1790Sstevel@tonic-gate 
1800Sstevel@tonic-gate 	sctpkp->sctpCurrEstab.value.i32 = sctp_mib.sctpCurrEstab;
1810Sstevel@tonic-gate 	sctpkp->sctpActiveEstab.value.i32 = sctp_mib.sctpActiveEstab;
1820Sstevel@tonic-gate 	sctpkp->sctpPassiveEstab.value.i32 = sctp_mib.sctpPassiveEstab;
1830Sstevel@tonic-gate 	sctpkp->sctpAborted.value.i32 = sctp_mib.sctpAborted;
1840Sstevel@tonic-gate 	sctpkp->sctpShutdowns.value.i32 = sctp_mib.sctpShutdowns;
1850Sstevel@tonic-gate 	sctpkp->sctpOutOfBlue.value.i32 = sctp_mib.sctpOutOfBlue;
1860Sstevel@tonic-gate 	sctpkp->sctpChecksumError.value.i32 = sctp_mib.sctpChecksumError;
1870Sstevel@tonic-gate 	sctpkp->sctpOutCtrlChunks.value.i64 = sctp_mib.sctpOutCtrlChunks;
1880Sstevel@tonic-gate 	sctpkp->sctpOutOrderChunks.value.i64 = sctp_mib.sctpOutOrderChunks;
1890Sstevel@tonic-gate 	sctpkp->sctpOutUnorderChunks.value.i64 = sctp_mib.sctpOutUnorderChunks;
1900Sstevel@tonic-gate 	sctpkp->sctpRetransChunks.value.i64 = sctp_mib.sctpRetransChunks;
1910Sstevel@tonic-gate 	sctpkp->sctpOutAck.value.i32 = sctp_mib.sctpOutAck;
1920Sstevel@tonic-gate 	sctpkp->sctpOutAckDelayed.value.i32 = sctp_mib.sctpOutAckDelayed;
1930Sstevel@tonic-gate 	sctpkp->sctpOutWinUpdate.value.i32 = sctp_mib.sctpOutWinUpdate;
1940Sstevel@tonic-gate 	sctpkp->sctpOutFastRetrans.value.i32 = sctp_mib.sctpOutFastRetrans;
1950Sstevel@tonic-gate 	sctpkp->sctpOutWinProbe.value.i32 = sctp_mib.sctpOutWinProbe;
1960Sstevel@tonic-gate 	sctpkp->sctpInCtrlChunks.value.i64 = sctp_mib.sctpInCtrlChunks;
1970Sstevel@tonic-gate 	sctpkp->sctpInOrderChunks.value.i64 = sctp_mib.sctpInOrderChunks;
1980Sstevel@tonic-gate 	sctpkp->sctpInUnorderChunks.value.i64 = sctp_mib.sctpInUnorderChunks;
1990Sstevel@tonic-gate 	sctpkp->sctpInAck.value.i32 = sctp_mib.sctpInAck;
2000Sstevel@tonic-gate 	sctpkp->sctpInDupAck.value.i32 = sctp_mib.sctpInDupAck;
2010Sstevel@tonic-gate 	sctpkp->sctpInAckUnsent.value.i32 = sctp_mib.sctpInAckUnsent;
2020Sstevel@tonic-gate 	sctpkp->sctpFragUsrMsgs.value.i64 = sctp_mib.sctpFragUsrMsgs;
2030Sstevel@tonic-gate 	sctpkp->sctpReasmUsrMsgs.value.i64 = sctp_mib.sctpReasmUsrMsgs;
2040Sstevel@tonic-gate 	sctpkp->sctpOutSCTPPkts.value.i64 = sctp_mib.sctpOutSCTPPkts;
2050Sstevel@tonic-gate 	sctpkp->sctpInSCTPPkts.value.i64 = sctp_mib.sctpInSCTPPkts;
2060Sstevel@tonic-gate 	sctpkp->sctpInInvalidCookie.value.i32 = sctp_mib.sctpInInvalidCookie;
2070Sstevel@tonic-gate 	sctpkp->sctpTimRetrans.value.i32 = sctp_mib.sctpTimRetrans;
2080Sstevel@tonic-gate 	sctpkp->sctpTimRetransDrop.value.i32 = sctp_mib.sctpTimRetransDrop;
2090Sstevel@tonic-gate 	sctpkp->sctpTimHeartBeatProbe.value.i32 =
2100Sstevel@tonic-gate 	    sctp_mib.sctpTimHeartBeatProbe;
2110Sstevel@tonic-gate 	sctpkp->sctpTimHeartBeatDrop.value.i32 = sctp_mib.sctpTimHeartBeatDrop;
2120Sstevel@tonic-gate 	sctpkp->sctpListenDrop.value.i32 = sctp_mib.sctpListenDrop;
2130Sstevel@tonic-gate 	sctpkp->sctpInClosed.value.i32 = sctp_mib.sctpInClosed;
2140Sstevel@tonic-gate 
2150Sstevel@tonic-gate 	return (0);
2160Sstevel@tonic-gate }
2170Sstevel@tonic-gate 
2180Sstevel@tonic-gate void
2190Sstevel@tonic-gate sctp_kstat_init(void)
2200Sstevel@tonic-gate {
2210Sstevel@tonic-gate 	sctp_named_kstat_t template = {
2220Sstevel@tonic-gate 		{ "sctpRtoAlgorithm",		KSTAT_DATA_INT32, 0 },
2230Sstevel@tonic-gate 		{ "sctpRtoMin",			KSTAT_DATA_UINT32, 0 },
2240Sstevel@tonic-gate 		{ "sctpRtoMax",			KSTAT_DATA_UINT32, 0 },
2250Sstevel@tonic-gate 		{ "sctpRtoInitial",		KSTAT_DATA_UINT32, 0 },
2260Sstevel@tonic-gate 		{ "sctpMaxAssocs",		KSTAT_DATA_INT32, 0 },
2270Sstevel@tonic-gate 		{ "sctpValCookieLife",		KSTAT_DATA_UINT32, 0 },
2280Sstevel@tonic-gate 		{ "sctpMaxInitRetr",		KSTAT_DATA_UINT32, 0 },
2290Sstevel@tonic-gate 		{ "sctpCurrEstab",		KSTAT_DATA_INT32, 0 },
2300Sstevel@tonic-gate 		{ "sctpActiveEstab",		KSTAT_DATA_INT32, 0 },
2310Sstevel@tonic-gate 		{ "sctpPassiveEstab",		KSTAT_DATA_INT32, 0 },
2320Sstevel@tonic-gate 		{ "sctpAborted",		KSTAT_DATA_INT32, 0 },
2330Sstevel@tonic-gate 		{ "sctpShutdowns",		KSTAT_DATA_INT32, 0 },
2340Sstevel@tonic-gate 		{ "sctpOutOfBlue",		KSTAT_DATA_INT32, 0 },
2350Sstevel@tonic-gate 		{ "sctpChecksumError",		KSTAT_DATA_INT32, 0 },
2360Sstevel@tonic-gate 		{ "sctpOutCtrlChunks",		KSTAT_DATA_INT64, 0 },
2370Sstevel@tonic-gate 		{ "sctpOutOrderChunks",		KSTAT_DATA_INT64, 0 },
2380Sstevel@tonic-gate 		{ "sctpOutUnorderChunks",	KSTAT_DATA_INT64, 0 },
2390Sstevel@tonic-gate 		{ "sctpRetransChunks",		KSTAT_DATA_INT64, 0 },
2400Sstevel@tonic-gate 		{ "sctpOutAck",			KSTAT_DATA_INT32, 0 },
2410Sstevel@tonic-gate 		{ "sctpOutAckDelayed",		KSTAT_DATA_INT32, 0 },
2420Sstevel@tonic-gate 		{ "sctpOutWinUpdate",		KSTAT_DATA_INT32, 0 },
2430Sstevel@tonic-gate 		{ "sctpOutFastRetrans",		KSTAT_DATA_INT32, 0 },
2440Sstevel@tonic-gate 		{ "sctpOutWinProbe",		KSTAT_DATA_INT32, 0 },
2450Sstevel@tonic-gate 		{ "sctpInCtrlChunks",		KSTAT_DATA_INT64, 0 },
2460Sstevel@tonic-gate 		{ "sctpInOrderChunks",		KSTAT_DATA_INT64, 0 },
2470Sstevel@tonic-gate 		{ "sctpInUnorderChunks",	KSTAT_DATA_INT64, 0 },
2480Sstevel@tonic-gate 		{ "sctpInAck",			KSTAT_DATA_INT32, 0 },
2490Sstevel@tonic-gate 		{ "sctpInDupAck",		KSTAT_DATA_INT32, 0 },
2500Sstevel@tonic-gate 		{ "sctpInAckUnsent",		KSTAT_DATA_INT32, 0 },
2510Sstevel@tonic-gate 		{ "sctpFragUsrMsgs",		KSTAT_DATA_INT64, 0 },
2520Sstevel@tonic-gate 		{ "sctpReasmUsrMsgs",		KSTAT_DATA_INT64, 0 },
2530Sstevel@tonic-gate 		{ "sctpOutSCTPPkts",		KSTAT_DATA_INT64, 0 },
2540Sstevel@tonic-gate 		{ "sctpInSCTPPkts",		KSTAT_DATA_INT64, 0 },
2550Sstevel@tonic-gate 		{ "sctpInInvalidCookie",	KSTAT_DATA_INT32, 0 },
2560Sstevel@tonic-gate 		{ "sctpTimRetrans",		KSTAT_DATA_INT32, 0 },
2570Sstevel@tonic-gate 		{ "sctpTimRetransDrop",		KSTAT_DATA_INT32, 0 },
2580Sstevel@tonic-gate 		{ "sctpTimHearBeatProbe",	KSTAT_DATA_INT32, 0 },
2590Sstevel@tonic-gate 		{ "sctpTimHearBeatDrop",	KSTAT_DATA_INT32, 0 },
2600Sstevel@tonic-gate 		{ "sctpListenDrop",		KSTAT_DATA_INT32, 0 },
2610Sstevel@tonic-gate 		{ "sctpInClosed",		KSTAT_DATA_INT32, 0 }
2620Sstevel@tonic-gate 	};
2630Sstevel@tonic-gate 
2640Sstevel@tonic-gate 	sctp_mibkp = kstat_create("sctp", 0, "sctp", "mib2", KSTAT_TYPE_NAMED,
2650Sstevel@tonic-gate 	    NUM_OF_FIELDS(sctp_named_kstat_t), 0);
2660Sstevel@tonic-gate 
2670Sstevel@tonic-gate 	if (sctp_mibkp == NULL)
2680Sstevel@tonic-gate 		return;
2690Sstevel@tonic-gate 
2700Sstevel@tonic-gate 	/* These won't change. */
2710Sstevel@tonic-gate 	template.sctpRtoAlgorithm.value.i32 = MIB2_SCTP_RTOALGO_VANJ;
2720Sstevel@tonic-gate 	template.sctpMaxAssocs.value.i32 = -1;
2730Sstevel@tonic-gate 
2740Sstevel@tonic-gate 	bcopy(&template, sctp_mibkp->ks_data, sizeof (template));
2750Sstevel@tonic-gate 
2760Sstevel@tonic-gate 	sctp_mibkp->ks_update = sctp_kstat_update;
2770Sstevel@tonic-gate 
2780Sstevel@tonic-gate 	kstat_install(sctp_mibkp);
2790Sstevel@tonic-gate }
2800Sstevel@tonic-gate 
2810Sstevel@tonic-gate void
2820Sstevel@tonic-gate sctp_kstat_fini(void)
2830Sstevel@tonic-gate {
2840Sstevel@tonic-gate 	if (sctp_mibkp != NULL) {
2850Sstevel@tonic-gate 		kstat_delete(sctp_mibkp);
2860Sstevel@tonic-gate 		sctp_mibkp = NULL;
2870Sstevel@tonic-gate 	}
2880Sstevel@tonic-gate }
2890Sstevel@tonic-gate 
2900Sstevel@tonic-gate /*
2910Sstevel@tonic-gate  * Return SNMP global stats in buffer in mpdata.
2920Sstevel@tonic-gate  * Return associatiation table in mp_conn_data,
2930Sstevel@tonic-gate  * local address table in mp_local_data, and
2940Sstevel@tonic-gate  * remote address table in mp_rem_data.
2950Sstevel@tonic-gate  */
2960Sstevel@tonic-gate mblk_t *
2970Sstevel@tonic-gate sctp_snmp_get_mib2(queue_t *q, mblk_t *mpctl)
2980Sstevel@tonic-gate {
2990Sstevel@tonic-gate 	mblk_t			*mpdata, *mp_ret;
3000Sstevel@tonic-gate 	mblk_t			*mp_conn_ctl = NULL;
3010Sstevel@tonic-gate 	mblk_t			*mp_conn_data;
3020Sstevel@tonic-gate 	mblk_t			*mp_conn_tail = NULL;
3030Sstevel@tonic-gate 	mblk_t			*mp_local_ctl = NULL;
3040Sstevel@tonic-gate 	mblk_t			*mp_local_data;
3050Sstevel@tonic-gate 	mblk_t			*mp_local_tail = NULL;
3060Sstevel@tonic-gate 	mblk_t			*mp_rem_ctl = NULL;
3070Sstevel@tonic-gate 	mblk_t			*mp_rem_data;
3080Sstevel@tonic-gate 	mblk_t			*mp_rem_tail = NULL;
309*1676Sjpk 	mblk_t			*mp_attr_ctl = NULL;
310*1676Sjpk 	mblk_t			*mp_attr_data;
311*1676Sjpk 	mblk_t			*mp_attr_tail = NULL;
3120Sstevel@tonic-gate 	struct opthdr		*optp;
3130Sstevel@tonic-gate 	sctp_t			*sctp, *sctp_prev = NULL;
3140Sstevel@tonic-gate 	sctp_faddr_t		*fp;
3150Sstevel@tonic-gate 	mib2_sctpConnEntry_t	sce;
3160Sstevel@tonic-gate 	mib2_sctpConnLocalEntry_t	scle;
3170Sstevel@tonic-gate 	mib2_sctpConnRemoteEntry_t	scre;
318*1676Sjpk 	mib2_transportMLPEntry_t	mlp;
3190Sstevel@tonic-gate 	int			i;
3200Sstevel@tonic-gate 	int			l;
3210Sstevel@tonic-gate 	int			scanned = 0;
3220Sstevel@tonic-gate 	zoneid_t		zoneid = Q_TO_CONN(q)->conn_zoneid;
323*1676Sjpk 	conn_t			*connp;
324*1676Sjpk 	boolean_t		needattr;
325*1676Sjpk 	int			idx;
3260Sstevel@tonic-gate 
3270Sstevel@tonic-gate 	/*
3280Sstevel@tonic-gate 	 * Make copies of the original message.
3290Sstevel@tonic-gate 	 * mpctl will hold SCTP counters,
3300Sstevel@tonic-gate 	 * mp_conn_ctl will hold list of connections.
3310Sstevel@tonic-gate 	 */
3320Sstevel@tonic-gate 	mp_ret = copymsg(mpctl);
3330Sstevel@tonic-gate 	mp_conn_ctl = copymsg(mpctl);
3340Sstevel@tonic-gate 	mp_local_ctl = copymsg(mpctl);
3350Sstevel@tonic-gate 	mp_rem_ctl = copymsg(mpctl);
336*1676Sjpk 	mp_attr_ctl = copymsg(mpctl);
3370Sstevel@tonic-gate 
3380Sstevel@tonic-gate 	mpdata = mpctl->b_cont;
3390Sstevel@tonic-gate 
340*1676Sjpk 	if (mp_conn_ctl == NULL || mp_local_ctl == NULL ||
341*1676Sjpk 	    mp_rem_ctl == NULL || mp_attr_ctl == NULL || mpdata == NULL) {
342*1676Sjpk 		freemsg(mp_attr_ctl);
3430Sstevel@tonic-gate 		freemsg(mp_rem_ctl);
3440Sstevel@tonic-gate 		freemsg(mp_local_ctl);
3450Sstevel@tonic-gate 		freemsg(mp_conn_ctl);
3460Sstevel@tonic-gate 		freemsg(mp_ret);
3470Sstevel@tonic-gate 		freemsg(mpctl);
3480Sstevel@tonic-gate 		return (NULL);
3490Sstevel@tonic-gate 	}
3500Sstevel@tonic-gate 	mp_conn_data = mp_conn_ctl->b_cont;
3510Sstevel@tonic-gate 	mp_local_data = mp_local_ctl->b_cont;
3520Sstevel@tonic-gate 	mp_rem_data = mp_rem_ctl->b_cont;
353*1676Sjpk 	mp_attr_data = mp_attr_ctl->b_cont;
3540Sstevel@tonic-gate 
3550Sstevel@tonic-gate 	/* hostname address parameters are not supported in Solaris */
3560Sstevel@tonic-gate 	sce.sctpAssocRemHostName.o_length = 0;
3570Sstevel@tonic-gate 	sce.sctpAssocRemHostName.o_bytes[0] = 0;
3580Sstevel@tonic-gate 
3590Sstevel@tonic-gate 	/* build table of connections -- need count in fixed part */
3600Sstevel@tonic-gate 	SET_MIB(sctp_mib.sctpRtoAlgorithm, MIB2_SCTP_RTOALGO_VANJ);
3610Sstevel@tonic-gate 	SET_MIB(sctp_mib.sctpRtoMin, sctp_rto_ming);
3620Sstevel@tonic-gate 	SET_MIB(sctp_mib.sctpRtoMax, sctp_rto_maxg);
3630Sstevel@tonic-gate 	SET_MIB(sctp_mib.sctpRtoInitial, sctp_rto_initialg);
3640Sstevel@tonic-gate 	SET_MIB(sctp_mib.sctpMaxAssocs, -1);
3650Sstevel@tonic-gate 	SET_MIB(sctp_mib.sctpValCookieLife, sctp_cookie_life);
3660Sstevel@tonic-gate 	SET_MIB(sctp_mib.sctpMaxInitRetr, sctp_max_init_retr);
3670Sstevel@tonic-gate 	SET_MIB(sctp_mib.sctpCurrEstab, 0);
3680Sstevel@tonic-gate 
369*1676Sjpk 	idx = 0;
3700Sstevel@tonic-gate 	sctp = gsctp;
3710Sstevel@tonic-gate 	mutex_enter(&sctp_g_lock);
3720Sstevel@tonic-gate 	while (sctp != NULL) {
3730Sstevel@tonic-gate 		mutex_enter(&sctp->sctp_reflock);
3740Sstevel@tonic-gate 		if (sctp->sctp_condemned) {
3750Sstevel@tonic-gate 			mutex_exit(&sctp->sctp_reflock);
3760Sstevel@tonic-gate 			sctp = list_next(&sctp_g_list, sctp);
3770Sstevel@tonic-gate 			continue;
3780Sstevel@tonic-gate 		}
3790Sstevel@tonic-gate 		sctp->sctp_refcnt++;
3800Sstevel@tonic-gate 		mutex_exit(&sctp->sctp_reflock);
3810Sstevel@tonic-gate 		mutex_exit(&sctp_g_lock);
3820Sstevel@tonic-gate 		if (sctp_prev != NULL)
3830Sstevel@tonic-gate 			SCTP_REFRELE(sctp_prev);
3840Sstevel@tonic-gate 		if (sctp->sctp_connp->conn_zoneid != zoneid)
3850Sstevel@tonic-gate 			goto next_sctp;
3860Sstevel@tonic-gate 		if (sctp->sctp_state == SCTPS_ESTABLISHED ||
3870Sstevel@tonic-gate 		    sctp->sctp_state == SCTPS_SHUTDOWN_PENDING ||
3880Sstevel@tonic-gate 		    sctp->sctp_state == SCTPS_SHUTDOWN_RECEIVED) {
3890Sstevel@tonic-gate 			BUMP_MIB(&sctp_mib, sctpCurrEstab);
3900Sstevel@tonic-gate 		}
3910Sstevel@tonic-gate 		UPDATE_MIB(&sctp_mib, sctpOutSCTPPkts, sctp->sctp_opkts);
3920Sstevel@tonic-gate 		sctp->sctp_opkts = 0;
3930Sstevel@tonic-gate 		UPDATE_MIB(&sctp_mib, sctpOutCtrlChunks, sctp->sctp_obchunks);
3940Sstevel@tonic-gate 		sctp->sctp_obchunks = 0;
3950Sstevel@tonic-gate 		UPDATE_MIB(&sctp_mib, sctpOutOrderChunks, sctp->sctp_odchunks);
3960Sstevel@tonic-gate 		sctp->sctp_odchunks = 0;
3970Sstevel@tonic-gate 		UPDATE_MIB(&sctp_mib, sctpOutUnorderChunks,
3980Sstevel@tonic-gate 		    sctp->sctp_oudchunks);
3990Sstevel@tonic-gate 		sctp->sctp_oudchunks = 0;
4000Sstevel@tonic-gate 		UPDATE_MIB(&sctp_mib, sctpRetransChunks, sctp->sctp_rxtchunks);
4010Sstevel@tonic-gate 		sctp->sctp_rxtchunks = 0;
4020Sstevel@tonic-gate 		UPDATE_MIB(&sctp_mib, sctpInSCTPPkts, sctp->sctp_ipkts);
4030Sstevel@tonic-gate 		sctp->sctp_ipkts = 0;
4040Sstevel@tonic-gate 		UPDATE_MIB(&sctp_mib, sctpInCtrlChunks, sctp->sctp_ibchunks);
4050Sstevel@tonic-gate 		sctp->sctp_ibchunks = 0;
4060Sstevel@tonic-gate 		UPDATE_MIB(&sctp_mib, sctpInOrderChunks, sctp->sctp_idchunks);
4070Sstevel@tonic-gate 		sctp->sctp_idchunks = 0;
4080Sstevel@tonic-gate 		UPDATE_MIB(&sctp_mib, sctpInUnorderChunks,
4090Sstevel@tonic-gate 		    sctp->sctp_iudchunks);
4100Sstevel@tonic-gate 		sctp->sctp_iudchunks = 0;
4110Sstevel@tonic-gate 		UPDATE_MIB(&sctp_mib, sctpFragUsrMsgs, sctp->sctp_fragdmsgs);
4120Sstevel@tonic-gate 		sctp->sctp_fragdmsgs = 0;
4130Sstevel@tonic-gate 		UPDATE_MIB(&sctp_mib, sctpReasmUsrMsgs, sctp->sctp_reassmsgs);
4140Sstevel@tonic-gate 		sctp->sctp_reassmsgs = 0;
4150Sstevel@tonic-gate 
4160Sstevel@tonic-gate 		sce.sctpAssocId = ntohl(sctp->sctp_lvtag);
4170Sstevel@tonic-gate 		sce.sctpAssocLocalPort = ntohs(sctp->sctp_lport);
4180Sstevel@tonic-gate 		sce.sctpAssocRemPort = ntohs(sctp->sctp_fport);
4190Sstevel@tonic-gate 
4200Sstevel@tonic-gate 		RUN_SCTP(sctp);
4210Sstevel@tonic-gate 		if (sctp->sctp_primary != NULL) {
4220Sstevel@tonic-gate 			fp = sctp->sctp_primary;
4230Sstevel@tonic-gate 
4240Sstevel@tonic-gate 			if (IN6_IS_ADDR_V4MAPPED(&fp->faddr)) {
4250Sstevel@tonic-gate 				sce.sctpAssocRemPrimAddrType =
4260Sstevel@tonic-gate 				    MIB2_SCTP_ADDR_V4;
4270Sstevel@tonic-gate 			} else {
4280Sstevel@tonic-gate 				sce.sctpAssocRemPrimAddrType =
4290Sstevel@tonic-gate 				    MIB2_SCTP_ADDR_V6;
4300Sstevel@tonic-gate 			}
4310Sstevel@tonic-gate 			sce.sctpAssocRemPrimAddr = fp->faddr;
4320Sstevel@tonic-gate 			sce.sctpAssocLocPrimAddr = fp->saddr;
4330Sstevel@tonic-gate 			sce.sctpAssocHeartBeatInterval = TICK_TO_MSEC(
4340Sstevel@tonic-gate 			    fp->hb_interval);
4350Sstevel@tonic-gate 		} else {
4360Sstevel@tonic-gate 			sce.sctpAssocRemPrimAddrType = MIB2_SCTP_ADDR_V4;
4370Sstevel@tonic-gate 			bzero(&sce.sctpAssocRemPrimAddr,
4380Sstevel@tonic-gate 			    sizeof (sce.sctpAssocRemPrimAddr));
4390Sstevel@tonic-gate 			bzero(&sce.sctpAssocLocPrimAddr,
4400Sstevel@tonic-gate 			    sizeof (sce.sctpAssocLocPrimAddr));
4410Sstevel@tonic-gate 			sce.sctpAssocHeartBeatInterval =
4420Sstevel@tonic-gate 			    sctp_heartbeat_interval;
4430Sstevel@tonic-gate 		}
4440Sstevel@tonic-gate 
4450Sstevel@tonic-gate 		/*
4460Sstevel@tonic-gate 		 * Table for local addresses
4470Sstevel@tonic-gate 		 */
4480Sstevel@tonic-gate 		scanned = 0;
4490Sstevel@tonic-gate 		for (i = 0; i < SCTP_IPIF_HASH; i++) {
4500Sstevel@tonic-gate 			sctp_saddr_ipif_t	*obj;
4510Sstevel@tonic-gate 
4520Sstevel@tonic-gate 			if (sctp->sctp_saddrs[i].ipif_count == 0)
4530Sstevel@tonic-gate 				continue;
4540Sstevel@tonic-gate 			obj = list_head(&sctp->sctp_saddrs[i].sctp_ipif_list);
4550Sstevel@tonic-gate 			for (l = 0; l < sctp->sctp_saddrs[i].ipif_count; l++) {
4560Sstevel@tonic-gate 				sctp_ipif_t	*sctp_ipif;
4570Sstevel@tonic-gate 				in6_addr_t	addr;
4580Sstevel@tonic-gate 
4590Sstevel@tonic-gate 				sctp_ipif = obj->saddr_ipifp;
4600Sstevel@tonic-gate 				addr = sctp_ipif->sctp_ipif_saddr;
4610Sstevel@tonic-gate 				scanned++;
4620Sstevel@tonic-gate 				scle.sctpAssocId = ntohl(sctp->sctp_lvtag);
4630Sstevel@tonic-gate 				if (IN6_IS_ADDR_V4MAPPED(&addr)) {
4640Sstevel@tonic-gate 					scle.sctpAssocLocalAddrType =
4650Sstevel@tonic-gate 					    MIB2_SCTP_ADDR_V4;
4660Sstevel@tonic-gate 				} else {
4670Sstevel@tonic-gate 					scle.sctpAssocLocalAddrType =
4680Sstevel@tonic-gate 					    MIB2_SCTP_ADDR_V6;
4690Sstevel@tonic-gate 				}
4700Sstevel@tonic-gate 				scle.sctpAssocLocalAddr = addr;
4710Sstevel@tonic-gate 				(void) snmp_append_data2(mp_local_data,
4720Sstevel@tonic-gate 				    &mp_local_tail, (char *)&scle,
4730Sstevel@tonic-gate 				    sizeof (scle));
4740Sstevel@tonic-gate 				if (scanned >= sctp->sctp_nsaddrs)
4750Sstevel@tonic-gate 					goto done;
4760Sstevel@tonic-gate 				obj = list_next(&sctp->
4770Sstevel@tonic-gate 				    sctp_saddrs[i].sctp_ipif_list, obj);
4780Sstevel@tonic-gate 			}
4790Sstevel@tonic-gate 		}
4800Sstevel@tonic-gate done:
4810Sstevel@tonic-gate 		/*
4820Sstevel@tonic-gate 		 * Table for remote addresses
4830Sstevel@tonic-gate 		 */
4840Sstevel@tonic-gate 		for (fp = sctp->sctp_faddrs; fp; fp = fp->next) {
4850Sstevel@tonic-gate 			scre.sctpAssocId = ntohl(sctp->sctp_lvtag);
4860Sstevel@tonic-gate 			if (IN6_IS_ADDR_V4MAPPED(&fp->faddr)) {
4870Sstevel@tonic-gate 				scre.sctpAssocRemAddrType = MIB2_SCTP_ADDR_V4;
4880Sstevel@tonic-gate 			} else {
4890Sstevel@tonic-gate 				scre.sctpAssocRemAddrType = MIB2_SCTP_ADDR_V6;
4900Sstevel@tonic-gate 			}
4910Sstevel@tonic-gate 			scre.sctpAssocRemAddr = fp->faddr;
4920Sstevel@tonic-gate 			if (fp->state == SCTP_FADDRS_ALIVE) {
4930Sstevel@tonic-gate 				scre.sctpAssocRemAddrActive =
4940Sstevel@tonic-gate 				    scre.sctpAssocRemAddrHBActive =
4950Sstevel@tonic-gate 				    MIB2_SCTP_ACTIVE;
4960Sstevel@tonic-gate 			} else {
4970Sstevel@tonic-gate 				scre.sctpAssocRemAddrActive =
4980Sstevel@tonic-gate 				    scre.sctpAssocRemAddrHBActive =
4990Sstevel@tonic-gate 				    MIB2_SCTP_INACTIVE;
5000Sstevel@tonic-gate 			}
5010Sstevel@tonic-gate 			scre.sctpAssocRemAddrRTO = TICK_TO_MSEC(fp->rto);
5020Sstevel@tonic-gate 			scre.sctpAssocRemAddrMaxPathRtx = fp->max_retr;
5030Sstevel@tonic-gate 			scre.sctpAssocRemAddrRtx = fp->T3expire;
5040Sstevel@tonic-gate 			(void) snmp_append_data2(mp_rem_data, &mp_rem_tail,
5050Sstevel@tonic-gate 			    (char *)&scre, sizeof (scre));
5060Sstevel@tonic-gate 		}
507*1676Sjpk 		connp = sctp->sctp_connp;
508*1676Sjpk 		needattr = B_FALSE;
509*1676Sjpk 		bzero(&mlp, sizeof (mlp));
510*1676Sjpk 		if (connp->conn_mlp_type != mlptSingle) {
511*1676Sjpk 			if (connp->conn_mlp_type == mlptShared ||
512*1676Sjpk 			    connp->conn_mlp_type == mlptBoth)
513*1676Sjpk 				mlp.tme_flags |= MIB2_TMEF_SHARED;
514*1676Sjpk 			if (connp->conn_mlp_type == mlptPrivate ||
515*1676Sjpk 			    connp->conn_mlp_type == mlptBoth)
516*1676Sjpk 				mlp.tme_flags |= MIB2_TMEF_PRIVATE;
517*1676Sjpk 			needattr = B_TRUE;
518*1676Sjpk 		}
519*1676Sjpk 		if (connp->conn_peercred != NULL) {
520*1676Sjpk 			ts_label_t *tsl;
521*1676Sjpk 
522*1676Sjpk 			tsl = crgetlabel(connp->conn_peercred);
523*1676Sjpk 			mlp.tme_doi = label2doi(tsl);
524*1676Sjpk 			mlp.tme_label = *label2bslabel(tsl);
525*1676Sjpk 			needattr = B_TRUE;
526*1676Sjpk 		}
5270Sstevel@tonic-gate 		WAKE_SCTP(sctp);
5280Sstevel@tonic-gate 		sce.sctpAssocState = sctp_snmp_state(sctp);
5290Sstevel@tonic-gate 		sce.sctpAssocInStreams = sctp->sctp_num_istr;
5300Sstevel@tonic-gate 		sce.sctpAssocOutStreams = sctp->sctp_num_ostr;
5310Sstevel@tonic-gate 		sce.sctpAssocMaxRetr = sctp->sctp_pa_max_rxt;
5320Sstevel@tonic-gate 		/* A 0 here indicates that no primary process is known */
5330Sstevel@tonic-gate 		sce.sctpAssocPrimProcess = 0;
5340Sstevel@tonic-gate 		sce.sctpAssocT1expired = sctp->sctp_T1expire;
5350Sstevel@tonic-gate 		sce.sctpAssocT2expired = sctp->sctp_T2expire;
5360Sstevel@tonic-gate 		sce.sctpAssocRtxChunks = sctp->sctp_T3expire;
5370Sstevel@tonic-gate 		sce.sctpAssocStartTime = sctp->sctp_assoc_start_time;
5380Sstevel@tonic-gate 		sce.sctpConnEntryInfo.ce_sendq = sctp->sctp_unacked +
5390Sstevel@tonic-gate 		    sctp->sctp_unsent;
5400Sstevel@tonic-gate 		sce.sctpConnEntryInfo.ce_recvq = sctp->sctp_rxqueued;
5410Sstevel@tonic-gate 		sce.sctpConnEntryInfo.ce_swnd = sctp->sctp_frwnd;
5420Sstevel@tonic-gate 		sce.sctpConnEntryInfo.ce_rwnd = sctp->sctp_rwnd;
5430Sstevel@tonic-gate 		sce.sctpConnEntryInfo.ce_mss = sctp->sctp_mss;
5440Sstevel@tonic-gate 		(void) snmp_append_data2(mp_conn_data, &mp_conn_tail,
5450Sstevel@tonic-gate 		    (char *)&sce, sizeof (sce));
546*1676Sjpk 		mlp.tme_connidx = idx++;
547*1676Sjpk 		if (needattr)
548*1676Sjpk 			(void) snmp_append_data2(mp_attr_ctl->b_cont,
549*1676Sjpk 			    &mp_attr_tail, (char *)&mlp, sizeof (mlp));
5500Sstevel@tonic-gate next_sctp:
5510Sstevel@tonic-gate 		sctp_prev = sctp;
5520Sstevel@tonic-gate 		mutex_enter(&sctp_g_lock);
5530Sstevel@tonic-gate 		sctp = list_next(&sctp_g_list, sctp);
5540Sstevel@tonic-gate 	}
5550Sstevel@tonic-gate 	mutex_exit(&sctp_g_lock);
5560Sstevel@tonic-gate 	if (sctp_prev != NULL)
5570Sstevel@tonic-gate 		SCTP_REFRELE(sctp_prev);
5580Sstevel@tonic-gate 
5590Sstevel@tonic-gate 	/* fixed length structure for IPv4 and IPv6 counters */
5600Sstevel@tonic-gate 	SET_MIB(sctp_mib.sctpEntrySize, sizeof (sce));
5610Sstevel@tonic-gate 	SET_MIB(sctp_mib.sctpLocalEntrySize, sizeof (scle));
5620Sstevel@tonic-gate 	SET_MIB(sctp_mib.sctpRemoteEntrySize, sizeof (scre));
5630Sstevel@tonic-gate 	optp = (struct opthdr *)&mpctl->b_rptr[sizeof (struct T_optmgmt_ack)];
5640Sstevel@tonic-gate 	optp->level = MIB2_SCTP;
5650Sstevel@tonic-gate 	optp->name = 0;
5660Sstevel@tonic-gate 	(void) snmp_append_data(mpdata, (char *)&sctp_mib, sizeof (sctp_mib));
5670Sstevel@tonic-gate 	optp->len = msgdsize(mpdata);
5680Sstevel@tonic-gate 	qreply(q, mpctl);
5690Sstevel@tonic-gate 
5700Sstevel@tonic-gate 	/* table of connections... */
5710Sstevel@tonic-gate 	optp = (struct opthdr *)&mp_conn_ctl->b_rptr[
5720Sstevel@tonic-gate 	    sizeof (struct T_optmgmt_ack)];
5730Sstevel@tonic-gate 	optp->level = MIB2_SCTP;
5740Sstevel@tonic-gate 	optp->name = MIB2_SCTP_CONN;
5750Sstevel@tonic-gate 	optp->len = msgdsize(mp_conn_data);
5760Sstevel@tonic-gate 	qreply(q, mp_conn_ctl);
5770Sstevel@tonic-gate 
5780Sstevel@tonic-gate 	/* assoc local address table */
5790Sstevel@tonic-gate 	optp = (struct opthdr *)&mp_local_ctl->b_rptr[
5800Sstevel@tonic-gate 	    sizeof (struct T_optmgmt_ack)];
5810Sstevel@tonic-gate 	optp->level = MIB2_SCTP;
5820Sstevel@tonic-gate 	optp->name = MIB2_SCTP_CONN_LOCAL;
5830Sstevel@tonic-gate 	optp->len = msgdsize(mp_local_data);
5840Sstevel@tonic-gate 	qreply(q, mp_local_ctl);
5850Sstevel@tonic-gate 
5860Sstevel@tonic-gate 	/* assoc remote address table */
5870Sstevel@tonic-gate 	optp = (struct opthdr *)&mp_rem_ctl->b_rptr[
5880Sstevel@tonic-gate 	    sizeof (struct T_optmgmt_ack)];
5890Sstevel@tonic-gate 	optp->level = MIB2_SCTP;
5900Sstevel@tonic-gate 	optp->name = MIB2_SCTP_CONN_REMOTE;
5910Sstevel@tonic-gate 	optp->len = msgdsize(mp_rem_data);
5920Sstevel@tonic-gate 	qreply(q, mp_rem_ctl);
5930Sstevel@tonic-gate 
594*1676Sjpk 	/* table of MLP attributes */
595*1676Sjpk 	optp = (struct opthdr *)&mp_attr_ctl->b_rptr[
596*1676Sjpk 	    sizeof (struct T_optmgmt_ack)];
597*1676Sjpk 	optp->level = MIB2_SCTP;
598*1676Sjpk 	optp->name = EXPER_XPORT_MLP;
599*1676Sjpk 	optp->len = msgdsize(mp_attr_data);
600*1676Sjpk 	if (optp->len == 0)
601*1676Sjpk 		freemsg(mp_attr_ctl);
602*1676Sjpk 	else
603*1676Sjpk 		qreply(q, mp_attr_ctl);
604*1676Sjpk 
6050Sstevel@tonic-gate 	return (mp_ret);
6060Sstevel@tonic-gate }
6070Sstevel@tonic-gate 
6080Sstevel@tonic-gate /* Translate SCTP state to MIB2 SCTP state. */
6090Sstevel@tonic-gate static int
6100Sstevel@tonic-gate sctp_snmp_state(sctp_t *sctp)
6110Sstevel@tonic-gate {
6120Sstevel@tonic-gate 	if (sctp == NULL)
6130Sstevel@tonic-gate 		return (0);
6140Sstevel@tonic-gate 
6150Sstevel@tonic-gate 	switch (sctp->sctp_state) {
6160Sstevel@tonic-gate 	case SCTPS_IDLE:
6170Sstevel@tonic-gate 	case SCTPS_BOUND:
6180Sstevel@tonic-gate 		return (MIB2_SCTP_closed);
6190Sstevel@tonic-gate 	case SCTPS_LISTEN:
6200Sstevel@tonic-gate 		return (MIB2_SCTP_listen);
6210Sstevel@tonic-gate 	case SCTPS_COOKIE_WAIT:
6220Sstevel@tonic-gate 		return (MIB2_SCTP_cookieWait);
6230Sstevel@tonic-gate 	case SCTPS_COOKIE_ECHOED:
6240Sstevel@tonic-gate 		return (MIB2_SCTP_cookieEchoed);
6250Sstevel@tonic-gate 	case SCTPS_ESTABLISHED:
6260Sstevel@tonic-gate 		return (MIB2_SCTP_established);
6270Sstevel@tonic-gate 	case SCTPS_SHUTDOWN_PENDING:
6280Sstevel@tonic-gate 		return (MIB2_SCTP_shutdownPending);
6290Sstevel@tonic-gate 	case SCTPS_SHUTDOWN_SENT:
6300Sstevel@tonic-gate 		return (MIB2_SCTP_shutdownSent);
6310Sstevel@tonic-gate 	case SCTPS_SHUTDOWN_RECEIVED:
6320Sstevel@tonic-gate 		return (MIB2_SCTP_shutdownReceived);
6330Sstevel@tonic-gate 	case SCTPS_SHUTDOWN_ACK_SENT:
6340Sstevel@tonic-gate 		return (MIB2_SCTP_shutdownAckSent);
6350Sstevel@tonic-gate 	default:
6360Sstevel@tonic-gate 		return (0);
6370Sstevel@tonic-gate 	}
6380Sstevel@tonic-gate }
639