xref: /titanic_50/usr/src/uts/common/inet/snmpcom.c (revision f4b3ec61df05330d25f55a36b975b4d7519fdeb1)
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
5*f4b3ec61Sdh155122  * Common Development and Distribution License (the "License").
6*f4b3ec61Sdh155122  * 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  */
217c478bd9Sstevel@tonic-gate /*
22*f4b3ec61Sdh155122  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate /* Copyright (c) 1990 Mentat Inc. */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate /*
307c478bd9Sstevel@tonic-gate  * This file contains common code for handling Options Management requests
317c478bd9Sstevel@tonic-gate  * for SNMP/MIB.
327c478bd9Sstevel@tonic-gate  */
337c478bd9Sstevel@tonic-gate 
347c478bd9Sstevel@tonic-gate #include <sys/types.h>
357c478bd9Sstevel@tonic-gate #include <sys/stream.h>
367c478bd9Sstevel@tonic-gate #include <sys/stropts.h>
377c478bd9Sstevel@tonic-gate #include <sys/errno.h>
387c478bd9Sstevel@tonic-gate #define	_SUN_TPI_VERSION 2
397c478bd9Sstevel@tonic-gate #include <sys/tihdr.h>
407c478bd9Sstevel@tonic-gate #include <sys/ddi.h>
417c478bd9Sstevel@tonic-gate #include <sys/cmn_err.h>
427c478bd9Sstevel@tonic-gate #include <sys/policy.h>
437c478bd9Sstevel@tonic-gate 
447c478bd9Sstevel@tonic-gate #include <sys/socket.h>
457c478bd9Sstevel@tonic-gate #include <netinet/in.h>
467c478bd9Sstevel@tonic-gate 
477c478bd9Sstevel@tonic-gate #include <inet/common.h>
487c478bd9Sstevel@tonic-gate #include <inet/mi.h>
497c478bd9Sstevel@tonic-gate #include <inet/mib2.h>
507c478bd9Sstevel@tonic-gate #include <inet/optcom.h>
517c478bd9Sstevel@tonic-gate #include <inet/snmpcom.h>
527c478bd9Sstevel@tonic-gate 
53ff550d0eSmasputra #include <inet/ip.h>
54ff550d0eSmasputra #include <inet/ip6.h>
55ff550d0eSmasputra #include <inet/tcp.h>
56ff550d0eSmasputra #include <inet/udp_impl.h>
57ff550d0eSmasputra 
587c478bd9Sstevel@tonic-gate #define	DEFAULT_LENGTH	sizeof (long)
597c478bd9Sstevel@tonic-gate #define	DATA_MBLK_SIZE	1024
607c478bd9Sstevel@tonic-gate #define	TOAHDR_SIZE	(sizeof (struct T_optmgmt_ack) +\
617c478bd9Sstevel@tonic-gate 	sizeof (struct opthdr))
627c478bd9Sstevel@tonic-gate 
637c478bd9Sstevel@tonic-gate /* SNMP Option Request Structure */
647c478bd9Sstevel@tonic-gate typedef struct sor_s {
657c478bd9Sstevel@tonic-gate 	int	sor_group;
667c478bd9Sstevel@tonic-gate 	int	sor_code;		/* MIB2 index value */
677c478bd9Sstevel@tonic-gate 	int	sor_size;
687c478bd9Sstevel@tonic-gate } sor_t;
697c478bd9Sstevel@tonic-gate 
707c478bd9Sstevel@tonic-gate /*
717c478bd9Sstevel@tonic-gate  * Validation Table for set requests.
727c478bd9Sstevel@tonic-gate  */
737c478bd9Sstevel@tonic-gate static sor_t	req_arr[] = {
747c478bd9Sstevel@tonic-gate 	{ MIB2_IP,	1,	sizeof (int)			},
757c478bd9Sstevel@tonic-gate 	{ MIB2_IP,	2,	sizeof (int)			},
767c478bd9Sstevel@tonic-gate 	{ MIB2_IP,	21,	sizeof (mib2_ipRouteEntry_t)	},
777c478bd9Sstevel@tonic-gate 	{ MIB2_IP,	22,	sizeof (mib2_ipNetToMediaEntry_t)},
787c478bd9Sstevel@tonic-gate 	{ MIB2_TCP,	13,	sizeof (mib2_tcpConnEntry_t)	}
797c478bd9Sstevel@tonic-gate };
807c478bd9Sstevel@tonic-gate 
817c478bd9Sstevel@tonic-gate /*
827c478bd9Sstevel@tonic-gate  * Binary compatibility to what used to be T_CURRENT in older releases.
837c478bd9Sstevel@tonic-gate  * Unfortunately, the binary chosen for it was different and used by
847c478bd9Sstevel@tonic-gate  * T_PARTSUCCESS in the new name space. However T_PARTSUCESS is only
857c478bd9Sstevel@tonic-gate  * anticiapted in new T_OPTMGM_REQ (and not O_T_OPTMGMT_REQ messages).
867c478bd9Sstevel@tonic-gate  * Only a test for TBADFLAG which uses one of the MIB option levels
877c478bd9Sstevel@tonic-gate  * may have trouble with this provision for binary compatibility.
887c478bd9Sstevel@tonic-gate  */
897c478bd9Sstevel@tonic-gate #define	OLD_T_CURRENT	0x100	/* same value as T_PARTSUCCESS */
907c478bd9Sstevel@tonic-gate 
917c478bd9Sstevel@tonic-gate /*
927c478bd9Sstevel@tonic-gate  * MIB info returned in data part of M_PROTO msg.  All info for a single
937c478bd9Sstevel@tonic-gate  * request is appended in a chain of mblk's off of the M_PROTO T_OPTMGMT_ACK
947c478bd9Sstevel@tonic-gate  * ctl buffer.
957c478bd9Sstevel@tonic-gate  */
967c478bd9Sstevel@tonic-gate int
97ff550d0eSmasputra snmp_append_data(mblk_t *mpdata, char *blob, int len)
987c478bd9Sstevel@tonic-gate {
997c478bd9Sstevel@tonic-gate 
1007c478bd9Sstevel@tonic-gate 	if (!mpdata)
1017c478bd9Sstevel@tonic-gate 		return (0);
1027c478bd9Sstevel@tonic-gate 	while (mpdata->b_cont)
1037c478bd9Sstevel@tonic-gate 		mpdata = mpdata->b_cont;
1047c478bd9Sstevel@tonic-gate 	if (mpdata->b_wptr + len >= mpdata->b_datap->db_lim) {
1057c478bd9Sstevel@tonic-gate 		mpdata->b_cont = allocb(DATA_MBLK_SIZE, BPRI_HI);
1067c478bd9Sstevel@tonic-gate 		mpdata = mpdata->b_cont;
1077c478bd9Sstevel@tonic-gate 		if (!mpdata)
1087c478bd9Sstevel@tonic-gate 			return (0);
1097c478bd9Sstevel@tonic-gate 	}
1107c478bd9Sstevel@tonic-gate 	bcopy(blob, (char *)mpdata->b_wptr, len);
1117c478bd9Sstevel@tonic-gate 	mpdata->b_wptr += len;
1127c478bd9Sstevel@tonic-gate 	return (1);
1137c478bd9Sstevel@tonic-gate }
1147c478bd9Sstevel@tonic-gate 
1157c478bd9Sstevel@tonic-gate /*
1167c478bd9Sstevel@tonic-gate  * Need a form which avoids O(n^2) behavior locating the end of the
1177c478bd9Sstevel@tonic-gate  * chain every time.  This is it.
1187c478bd9Sstevel@tonic-gate  */
1197c478bd9Sstevel@tonic-gate int
1207c478bd9Sstevel@tonic-gate snmp_append_data2(mblk_t *mpdata, mblk_t **last_mpp, char *blob, int len)
1217c478bd9Sstevel@tonic-gate {
1227c478bd9Sstevel@tonic-gate 
1237c478bd9Sstevel@tonic-gate 	if (!mpdata)
1247c478bd9Sstevel@tonic-gate 		return (0);
1257c478bd9Sstevel@tonic-gate 	if (*last_mpp == NULL) {
1267c478bd9Sstevel@tonic-gate 		while (mpdata->b_cont)
1277c478bd9Sstevel@tonic-gate 			mpdata = mpdata->b_cont;
1287c478bd9Sstevel@tonic-gate 		*last_mpp = mpdata;
1297c478bd9Sstevel@tonic-gate 	}
1307c478bd9Sstevel@tonic-gate 	if ((*last_mpp)->b_wptr + len >= (*last_mpp)->b_datap->db_lim) {
1317c478bd9Sstevel@tonic-gate 		(*last_mpp)->b_cont = allocb(DATA_MBLK_SIZE, BPRI_HI);
1327c478bd9Sstevel@tonic-gate 		*last_mpp = (*last_mpp)->b_cont;
1337c478bd9Sstevel@tonic-gate 		if (!*last_mpp)
1347c478bd9Sstevel@tonic-gate 			return (0);
1357c478bd9Sstevel@tonic-gate 	}
1367c478bd9Sstevel@tonic-gate 	bcopy(blob, (char *)(*last_mpp)->b_wptr, len);
1377c478bd9Sstevel@tonic-gate 	(*last_mpp)->b_wptr += len;
1387c478bd9Sstevel@tonic-gate 	return (1);
1397c478bd9Sstevel@tonic-gate }
1407c478bd9Sstevel@tonic-gate 
1417c478bd9Sstevel@tonic-gate /*
1427c478bd9Sstevel@tonic-gate  * SNMP requests are issued using putmsg() on a stream containing all
1437c478bd9Sstevel@tonic-gate  * relevant modules.  The ctl part contains a O_T_OPTMGMT_REQ message,
1447c478bd9Sstevel@tonic-gate  * and the data part is NULL
1457c478bd9Sstevel@tonic-gate  * to process this msg. If snmpcom_req() returns FALSE, then the module
1467c478bd9Sstevel@tonic-gate  * will try optcom_req to see if its some sort of SOCKET or IP option.
1477c478bd9Sstevel@tonic-gate  * snmpcom_req returns TRUE whenever the first option is recognized as
1487c478bd9Sstevel@tonic-gate  * an SNMP request, even if a bad one.
1497c478bd9Sstevel@tonic-gate  *
1507c478bd9Sstevel@tonic-gate  * "get" is done by a single O_T_OPTMGMT_REQ with MGMT_flags set to T_CURRENT.
1517c478bd9Sstevel@tonic-gate  * All modules respond with one or msg's about what they know.  Responses
1527c478bd9Sstevel@tonic-gate  * are in T_OPTMGMT_ACK format.  The opthdr level/name fields identify what
1537c478bd9Sstevel@tonic-gate  * is begin returned, the len field how big it is (in bytes).  The info
1547c478bd9Sstevel@tonic-gate  * itself is in the data portion of the msg.  Fixed length info returned
1557c478bd9Sstevel@tonic-gate  * in one msg; each table in a separate msg.
1567c478bd9Sstevel@tonic-gate  *
1577c478bd9Sstevel@tonic-gate  * setfn() returns 1 if things ok, 0 if set request invalid or otherwise
1587c478bd9Sstevel@tonic-gate  * messed up.
1597c478bd9Sstevel@tonic-gate  *
1607c478bd9Sstevel@tonic-gate  * If the passed q is at the bottom of the module chain (q_next == NULL,
1617c478bd9Sstevel@tonic-gate  * a ctl msg with req->name, level, len all zero is sent upstream.  This
1627c478bd9Sstevel@tonic-gate  * is and EOD flag to the caller.
1637c478bd9Sstevel@tonic-gate  *
1647c478bd9Sstevel@tonic-gate  * IMPORTANT:
1657c478bd9Sstevel@tonic-gate  * - The msg type is M_PROTO, not M_PCPROTO!!!  This is by design,
1667c478bd9Sstevel@tonic-gate  *   since multiple messages will be sent to stream head and we want
1677c478bd9Sstevel@tonic-gate  *   them queued for reading, not discarded.
1687c478bd9Sstevel@tonic-gate  * - All requests which match a table entry are sent to all get/set functions
1697c478bd9Sstevel@tonic-gate  *   of each module.  The functions must simply ignore requests not meant
1707c478bd9Sstevel@tonic-gate  *   for them: getfn() returns 0, setfn() returns 1.
1717c478bd9Sstevel@tonic-gate  */
1727c478bd9Sstevel@tonic-gate boolean_t
173ff550d0eSmasputra snmpcom_req(queue_t *q, mblk_t *mp, pfi_t setfn, pfi_t getfn, cred_t *credp)
1747c478bd9Sstevel@tonic-gate {
1757c478bd9Sstevel@tonic-gate 	mblk_t			*mpctl;
1767c478bd9Sstevel@tonic-gate 	struct opthdr		*req;
1777c478bd9Sstevel@tonic-gate 	struct opthdr		*next_req;
1787c478bd9Sstevel@tonic-gate 	struct opthdr		*req_end;
1797c478bd9Sstevel@tonic-gate 	struct opthdr		*req_start;
1807c478bd9Sstevel@tonic-gate 	sor_t			*sreq;
1817c478bd9Sstevel@tonic-gate 	struct T_optmgmt_req	*tor = (struct T_optmgmt_req *)mp->b_rptr;
1827c478bd9Sstevel@tonic-gate 	struct T_optmgmt_ack	*toa;
183ff550d0eSmasputra 	boolean_t		pass_to_ip = B_FALSE;
1847c478bd9Sstevel@tonic-gate 
1857c478bd9Sstevel@tonic-gate 	if (mp->b_cont) {	/* don't deal with multiple mblk's */
1867c478bd9Sstevel@tonic-gate 		freemsg(mp->b_cont);
1877c478bd9Sstevel@tonic-gate 		mp->b_cont = (mblk_t *)0;
1887c478bd9Sstevel@tonic-gate 		optcom_err_ack(q, mp, TSYSERR, EBADMSG);
1897c478bd9Sstevel@tonic-gate 		return (B_TRUE);
1907c478bd9Sstevel@tonic-gate 	}
1917c478bd9Sstevel@tonic-gate 	if ((mp->b_wptr - mp->b_rptr) < sizeof (struct T_optmgmt_req) ||
1927c478bd9Sstevel@tonic-gate 	    !(req_start = (struct opthdr *)mi_offset_param(mp,
1937c478bd9Sstevel@tonic-gate 		tor->OPT_offset, tor->OPT_length)))
1947c478bd9Sstevel@tonic-gate 		goto bad_req1;
1957c478bd9Sstevel@tonic-gate 	if (! __TPI_OPT_ISALIGNED(req_start))
1967c478bd9Sstevel@tonic-gate 		goto bad_req1;
1977c478bd9Sstevel@tonic-gate 
1987c478bd9Sstevel@tonic-gate 	/*
1997c478bd9Sstevel@tonic-gate 	 * if first option not in the MIB2 or EXPER range, return false so
2007c478bd9Sstevel@tonic-gate 	 * optcom_req can scope things out.  Otherwise it's passed to each
2017c478bd9Sstevel@tonic-gate 	 * calling module to process or ignore as it sees fit.
2027c478bd9Sstevel@tonic-gate 	 */
2037c478bd9Sstevel@tonic-gate 	if ((!(req_start->level >= MIB2_RANGE_START &&
2047c478bd9Sstevel@tonic-gate 			req_start->level <= MIB2_RANGE_END)) &&
2057c478bd9Sstevel@tonic-gate 	    (!(req_start->level >= EXPER_RANGE_START &&
2067c478bd9Sstevel@tonic-gate 			req_start->level <= EXPER_RANGE_END)))
2077c478bd9Sstevel@tonic-gate 		return (B_FALSE);
2087c478bd9Sstevel@tonic-gate 
209ff550d0eSmasputra 	if (setfn == tcp_snmp_set || setfn == udp_snmp_set ||
210ff550d0eSmasputra 	    getfn == tcp_snmp_get || getfn == udp_snmp_get)
211ff550d0eSmasputra 		pass_to_ip = B_TRUE;
212ff550d0eSmasputra 
2137c478bd9Sstevel@tonic-gate 	switch (tor->MGMT_flags) {
2147c478bd9Sstevel@tonic-gate 
2157c478bd9Sstevel@tonic-gate 	case T_NEGOTIATE:
216*f4b3ec61Sdh155122 		if (secpolicy_ip_config(credp, B_FALSE) != 0) {
2177c478bd9Sstevel@tonic-gate 			optcom_err_ack(q, mp, TACCES, 0);
2187c478bd9Sstevel@tonic-gate 			return (B_TRUE);
2197c478bd9Sstevel@tonic-gate 		}
2207c478bd9Sstevel@tonic-gate 		req_end = (struct opthdr *)((uchar_t *)req_start +
2217c478bd9Sstevel@tonic-gate 			tor->OPT_length);
2227c478bd9Sstevel@tonic-gate 		for (req = req_start; req < req_end; req = next_req) {
2237c478bd9Sstevel@tonic-gate 			next_req =
2247c478bd9Sstevel@tonic-gate 				(struct opthdr *)((uchar_t *)&req[1] +
2257c478bd9Sstevel@tonic-gate 				_TPI_ALIGN_OPT(req->len));
2267c478bd9Sstevel@tonic-gate 			if (next_req > req_end)
2277c478bd9Sstevel@tonic-gate 				goto bad_req2;
2287c478bd9Sstevel@tonic-gate 			for (sreq = req_arr; sreq < A_END(req_arr); sreq++) {
2297c478bd9Sstevel@tonic-gate 				if (req->level == sreq->sor_group &&
2307c478bd9Sstevel@tonic-gate 				    req->name == sreq->sor_code)
2317c478bd9Sstevel@tonic-gate 					break;
2327c478bd9Sstevel@tonic-gate 			}
2337c478bd9Sstevel@tonic-gate 			if (sreq >= A_END(req_arr))
2347c478bd9Sstevel@tonic-gate 				goto bad_req3;
2357c478bd9Sstevel@tonic-gate 			if (!(*setfn)(q, req->level, req->name,
2367c478bd9Sstevel@tonic-gate 				(uchar_t *)&req[1], req->len))
2377c478bd9Sstevel@tonic-gate 				goto bad_req4;
2387c478bd9Sstevel@tonic-gate 		}
239ff550d0eSmasputra 		if (q->q_next != NULL)
2407c478bd9Sstevel@tonic-gate 			putnext(q, mp);
241ff550d0eSmasputra 		else if (pass_to_ip)
242ff550d0eSmasputra 			ip_output(Q_TO_CONN(q), mp, q, IP_WPUT);
2437c478bd9Sstevel@tonic-gate 		else
2447c478bd9Sstevel@tonic-gate 			freemsg(mp);
2457c478bd9Sstevel@tonic-gate 		return (B_TRUE);
2467c478bd9Sstevel@tonic-gate 
2477c478bd9Sstevel@tonic-gate 	case OLD_T_CURRENT:
2487c478bd9Sstevel@tonic-gate 	case T_CURRENT:
2497c478bd9Sstevel@tonic-gate 		mpctl = allocb(TOAHDR_SIZE, BPRI_MED);
2507c478bd9Sstevel@tonic-gate 		if (!mpctl) {
2517c478bd9Sstevel@tonic-gate 			optcom_err_ack(q, mp, TSYSERR, ENOMEM);
2527c478bd9Sstevel@tonic-gate 			return (B_TRUE);
2537c478bd9Sstevel@tonic-gate 		}
2547c478bd9Sstevel@tonic-gate 		mpctl->b_cont = allocb(DATA_MBLK_SIZE, BPRI_MED);
2557c478bd9Sstevel@tonic-gate 		if (!mpctl->b_cont) {
2567c478bd9Sstevel@tonic-gate 			freemsg(mpctl);
2577c478bd9Sstevel@tonic-gate 			optcom_err_ack(q, mp, TSYSERR, ENOMEM);
2587c478bd9Sstevel@tonic-gate 			return (B_TRUE);
2597c478bd9Sstevel@tonic-gate 		}
2607c478bd9Sstevel@tonic-gate 		mpctl->b_datap->db_type = M_PROTO;
2617c478bd9Sstevel@tonic-gate 		mpctl->b_wptr += TOAHDR_SIZE;
2627c478bd9Sstevel@tonic-gate 		toa = (struct T_optmgmt_ack *)mpctl->b_rptr;
2637c478bd9Sstevel@tonic-gate 		toa->PRIM_type = T_OPTMGMT_ACK;
2647c478bd9Sstevel@tonic-gate 		toa->OPT_offset = sizeof (struct T_optmgmt_ack);
2657c478bd9Sstevel@tonic-gate 		toa->OPT_length = sizeof (struct opthdr);
2667c478bd9Sstevel@tonic-gate 		toa->MGMT_flags = T_SUCCESS;
2677c478bd9Sstevel@tonic-gate 		if (!(*getfn)(q, mpctl))
2687c478bd9Sstevel@tonic-gate 			freemsg(mpctl);
2697c478bd9Sstevel@tonic-gate 		/*
2707c478bd9Sstevel@tonic-gate 		 * all data for this module has now been sent upstream.  If
2717c478bd9Sstevel@tonic-gate 		 * this is bottom module of stream, send up an EOD ctl msg,
2727c478bd9Sstevel@tonic-gate 		 * otherwise pass onto the next guy for processing.
2737c478bd9Sstevel@tonic-gate 		 */
274ff550d0eSmasputra 		if (q->q_next != NULL) {
2757c478bd9Sstevel@tonic-gate 			putnext(q, mp);
2767c478bd9Sstevel@tonic-gate 			return (B_TRUE);
277ff550d0eSmasputra 		} else if (pass_to_ip) {
278ff550d0eSmasputra 			ip_output(Q_TO_CONN(q), mp, q, IP_WPUT);
279ff550d0eSmasputra 			return (B_TRUE);
2807c478bd9Sstevel@tonic-gate 		}
2817c478bd9Sstevel@tonic-gate 		if (mp->b_cont) {
2827c478bd9Sstevel@tonic-gate 			freemsg(mp->b_cont);
2837c478bd9Sstevel@tonic-gate 			mp->b_cont = NULL;
2847c478bd9Sstevel@tonic-gate 		}
2857c478bd9Sstevel@tonic-gate 		mpctl = reallocb(mp, TOAHDR_SIZE, 1);
2867c478bd9Sstevel@tonic-gate 		if (!mpctl) {
2877c478bd9Sstevel@tonic-gate 			optcom_err_ack(q, mp, TSYSERR, ENOMEM);
2887c478bd9Sstevel@tonic-gate 			return (B_TRUE);
2897c478bd9Sstevel@tonic-gate 		}
2907c478bd9Sstevel@tonic-gate 		mpctl->b_datap->db_type = M_PROTO;
2917c478bd9Sstevel@tonic-gate 		mpctl->b_wptr = mpctl->b_rptr + TOAHDR_SIZE;
2927c478bd9Sstevel@tonic-gate 		toa = (struct T_optmgmt_ack *)mpctl->b_rptr;
2937c478bd9Sstevel@tonic-gate 		toa->PRIM_type = T_OPTMGMT_ACK;
2947c478bd9Sstevel@tonic-gate 		toa->OPT_offset = sizeof (struct T_optmgmt_ack);
2957c478bd9Sstevel@tonic-gate 		toa->OPT_length = sizeof (struct opthdr);
2967c478bd9Sstevel@tonic-gate 		toa->MGMT_flags = T_SUCCESS;
2977c478bd9Sstevel@tonic-gate 		req = (struct opthdr *)&toa[1];
2987c478bd9Sstevel@tonic-gate 		req->level = 0;
2997c478bd9Sstevel@tonic-gate 		req->name = 0;
3007c478bd9Sstevel@tonic-gate 		req->len = 0;
3017c478bd9Sstevel@tonic-gate 		qreply(q, mpctl);
3027c478bd9Sstevel@tonic-gate 		return (B_TRUE);
3037c478bd9Sstevel@tonic-gate 
3047c478bd9Sstevel@tonic-gate 	default:
3057c478bd9Sstevel@tonic-gate 		optcom_err_ack(q, mp, TBADFLAG, 0);
3067c478bd9Sstevel@tonic-gate 		return (B_TRUE);
3077c478bd9Sstevel@tonic-gate 	}
3087c478bd9Sstevel@tonic-gate 
3097c478bd9Sstevel@tonic-gate bad_req1:;
3107c478bd9Sstevel@tonic-gate 	printf("snmpcom bad_req1\n");
3117c478bd9Sstevel@tonic-gate 	goto bad_req;
3127c478bd9Sstevel@tonic-gate bad_req2:;
3137c478bd9Sstevel@tonic-gate 	printf("snmpcom bad_req2\n");
3147c478bd9Sstevel@tonic-gate 	goto bad_req;
3157c478bd9Sstevel@tonic-gate bad_req3:;
3167c478bd9Sstevel@tonic-gate 	printf("snmpcom bad_req3\n");
3177c478bd9Sstevel@tonic-gate 	goto bad_req;
3187c478bd9Sstevel@tonic-gate bad_req4:;
3197c478bd9Sstevel@tonic-gate 	printf("snmpcom bad_req4\n");
3207c478bd9Sstevel@tonic-gate 	/* FALLTHRU */
3217c478bd9Sstevel@tonic-gate bad_req:;
3227c478bd9Sstevel@tonic-gate 	optcom_err_ack(q, mp, TBADOPT, 0);
3237c478bd9Sstevel@tonic-gate 	return (B_TRUE);
3247c478bd9Sstevel@tonic-gate 
3257c478bd9Sstevel@tonic-gate }
326