xref: /titanic_50/usr/src/uts/common/inet/snmpcom.c (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 1992,1997-2003 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate /* Copyright (c) 1990 Mentat Inc. */
27*7c478bd9Sstevel@tonic-gate 
28*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate /*
31*7c478bd9Sstevel@tonic-gate  * This file contains common code for handling Options Management requests
32*7c478bd9Sstevel@tonic-gate  * for SNMP/MIB.
33*7c478bd9Sstevel@tonic-gate  */
34*7c478bd9Sstevel@tonic-gate 
35*7c478bd9Sstevel@tonic-gate #include <sys/types.h>
36*7c478bd9Sstevel@tonic-gate #include <sys/stream.h>
37*7c478bd9Sstevel@tonic-gate #include <sys/stropts.h>
38*7c478bd9Sstevel@tonic-gate #include <sys/errno.h>
39*7c478bd9Sstevel@tonic-gate #define	_SUN_TPI_VERSION 2
40*7c478bd9Sstevel@tonic-gate #include <sys/tihdr.h>
41*7c478bd9Sstevel@tonic-gate #include <sys/ddi.h>
42*7c478bd9Sstevel@tonic-gate #include <sys/cmn_err.h>
43*7c478bd9Sstevel@tonic-gate #include <sys/policy.h>
44*7c478bd9Sstevel@tonic-gate 
45*7c478bd9Sstevel@tonic-gate #include <sys/socket.h>
46*7c478bd9Sstevel@tonic-gate #include <netinet/in.h>
47*7c478bd9Sstevel@tonic-gate 
48*7c478bd9Sstevel@tonic-gate #include <inet/common.h>
49*7c478bd9Sstevel@tonic-gate #include <inet/mi.h>
50*7c478bd9Sstevel@tonic-gate #include <inet/mib2.h>
51*7c478bd9Sstevel@tonic-gate #include <inet/optcom.h>
52*7c478bd9Sstevel@tonic-gate #include <inet/snmpcom.h>
53*7c478bd9Sstevel@tonic-gate 
54*7c478bd9Sstevel@tonic-gate #define	DEFAULT_LENGTH	sizeof (long)
55*7c478bd9Sstevel@tonic-gate #define	DATA_MBLK_SIZE	1024
56*7c478bd9Sstevel@tonic-gate #define	TOAHDR_SIZE	(sizeof (struct T_optmgmt_ack) +\
57*7c478bd9Sstevel@tonic-gate 	sizeof (struct opthdr))
58*7c478bd9Sstevel@tonic-gate 
59*7c478bd9Sstevel@tonic-gate /* SNMP Option Request Structure */
60*7c478bd9Sstevel@tonic-gate typedef struct sor_s {
61*7c478bd9Sstevel@tonic-gate 	int	sor_group;
62*7c478bd9Sstevel@tonic-gate 	int	sor_code;		/* MIB2 index value */
63*7c478bd9Sstevel@tonic-gate 	int	sor_size;
64*7c478bd9Sstevel@tonic-gate } sor_t;
65*7c478bd9Sstevel@tonic-gate 
66*7c478bd9Sstevel@tonic-gate /*
67*7c478bd9Sstevel@tonic-gate  * Validation Table for set requests.
68*7c478bd9Sstevel@tonic-gate  */
69*7c478bd9Sstevel@tonic-gate static sor_t	req_arr[] = {
70*7c478bd9Sstevel@tonic-gate 	{ MIB2_IP,	1,	sizeof (int)			},
71*7c478bd9Sstevel@tonic-gate 	{ MIB2_IP,	2,	sizeof (int)			},
72*7c478bd9Sstevel@tonic-gate 	{ MIB2_IP,	21,	sizeof (mib2_ipRouteEntry_t)	},
73*7c478bd9Sstevel@tonic-gate 	{ MIB2_IP,	22,	sizeof (mib2_ipNetToMediaEntry_t)},
74*7c478bd9Sstevel@tonic-gate 	{ MIB2_TCP,	13,	sizeof (mib2_tcpConnEntry_t)	}
75*7c478bd9Sstevel@tonic-gate };
76*7c478bd9Sstevel@tonic-gate 
77*7c478bd9Sstevel@tonic-gate /*
78*7c478bd9Sstevel@tonic-gate  * Binary compatibility to what used to be T_CURRENT in older releases.
79*7c478bd9Sstevel@tonic-gate  * Unfortunately, the binary chosen for it was different and used by
80*7c478bd9Sstevel@tonic-gate  * T_PARTSUCCESS in the new name space. However T_PARTSUCESS is only
81*7c478bd9Sstevel@tonic-gate  * anticiapted in new T_OPTMGM_REQ (and not O_T_OPTMGMT_REQ messages).
82*7c478bd9Sstevel@tonic-gate  * Only a test for TBADFLAG which uses one of the MIB option levels
83*7c478bd9Sstevel@tonic-gate  * may have trouble with this provision for binary compatibility.
84*7c478bd9Sstevel@tonic-gate  */
85*7c478bd9Sstevel@tonic-gate #define	OLD_T_CURRENT	0x100	/* same value as T_PARTSUCCESS */
86*7c478bd9Sstevel@tonic-gate 
87*7c478bd9Sstevel@tonic-gate /*
88*7c478bd9Sstevel@tonic-gate  * MIB info returned in data part of M_PROTO msg.  All info for a single
89*7c478bd9Sstevel@tonic-gate  * request is appended in a chain of mblk's off of the M_PROTO T_OPTMGMT_ACK
90*7c478bd9Sstevel@tonic-gate  * ctl buffer.
91*7c478bd9Sstevel@tonic-gate  */
92*7c478bd9Sstevel@tonic-gate int
93*7c478bd9Sstevel@tonic-gate snmp_append_data(mpdata, blob, len)
94*7c478bd9Sstevel@tonic-gate 	mblk_t	*mpdata;
95*7c478bd9Sstevel@tonic-gate 	char	*blob;
96*7c478bd9Sstevel@tonic-gate 	int	len;
97*7c478bd9Sstevel@tonic-gate {
98*7c478bd9Sstevel@tonic-gate 
99*7c478bd9Sstevel@tonic-gate 	if (!mpdata)
100*7c478bd9Sstevel@tonic-gate 		return (0);
101*7c478bd9Sstevel@tonic-gate 	while (mpdata->b_cont)
102*7c478bd9Sstevel@tonic-gate 		mpdata = mpdata->b_cont;
103*7c478bd9Sstevel@tonic-gate 	if (mpdata->b_wptr + len >= mpdata->b_datap->db_lim) {
104*7c478bd9Sstevel@tonic-gate 		mpdata->b_cont = allocb(DATA_MBLK_SIZE, BPRI_HI);
105*7c478bd9Sstevel@tonic-gate 		mpdata = mpdata->b_cont;
106*7c478bd9Sstevel@tonic-gate 		if (!mpdata)
107*7c478bd9Sstevel@tonic-gate 			return (0);
108*7c478bd9Sstevel@tonic-gate 	}
109*7c478bd9Sstevel@tonic-gate 	bcopy(blob, (char *)mpdata->b_wptr, len);
110*7c478bd9Sstevel@tonic-gate 	mpdata->b_wptr += len;
111*7c478bd9Sstevel@tonic-gate 	return (1);
112*7c478bd9Sstevel@tonic-gate }
113*7c478bd9Sstevel@tonic-gate 
114*7c478bd9Sstevel@tonic-gate /*
115*7c478bd9Sstevel@tonic-gate  * Need a form which avoids O(n^2) behavior locating the end of the
116*7c478bd9Sstevel@tonic-gate  * chain every time.  This is it.
117*7c478bd9Sstevel@tonic-gate  */
118*7c478bd9Sstevel@tonic-gate int
119*7c478bd9Sstevel@tonic-gate snmp_append_data2(mblk_t *mpdata, mblk_t **last_mpp, char *blob, int len)
120*7c478bd9Sstevel@tonic-gate {
121*7c478bd9Sstevel@tonic-gate 
122*7c478bd9Sstevel@tonic-gate 	if (!mpdata)
123*7c478bd9Sstevel@tonic-gate 		return (0);
124*7c478bd9Sstevel@tonic-gate 	if (*last_mpp == NULL) {
125*7c478bd9Sstevel@tonic-gate 		while (mpdata->b_cont)
126*7c478bd9Sstevel@tonic-gate 			mpdata = mpdata->b_cont;
127*7c478bd9Sstevel@tonic-gate 		*last_mpp = mpdata;
128*7c478bd9Sstevel@tonic-gate 	}
129*7c478bd9Sstevel@tonic-gate 	if ((*last_mpp)->b_wptr + len >= (*last_mpp)->b_datap->db_lim) {
130*7c478bd9Sstevel@tonic-gate 		(*last_mpp)->b_cont = allocb(DATA_MBLK_SIZE, BPRI_HI);
131*7c478bd9Sstevel@tonic-gate 		*last_mpp = (*last_mpp)->b_cont;
132*7c478bd9Sstevel@tonic-gate 		if (!*last_mpp)
133*7c478bd9Sstevel@tonic-gate 			return (0);
134*7c478bd9Sstevel@tonic-gate 	}
135*7c478bd9Sstevel@tonic-gate 	bcopy(blob, (char *)(*last_mpp)->b_wptr, len);
136*7c478bd9Sstevel@tonic-gate 	(*last_mpp)->b_wptr += len;
137*7c478bd9Sstevel@tonic-gate 	return (1);
138*7c478bd9Sstevel@tonic-gate }
139*7c478bd9Sstevel@tonic-gate 
140*7c478bd9Sstevel@tonic-gate /*
141*7c478bd9Sstevel@tonic-gate  * SNMP requests are issued using putmsg() on a stream containing all
142*7c478bd9Sstevel@tonic-gate  * relevant modules.  The ctl part contains a O_T_OPTMGMT_REQ message,
143*7c478bd9Sstevel@tonic-gate  * and the data part is NULL
144*7c478bd9Sstevel@tonic-gate  * to process this msg. If snmpcom_req() returns FALSE, then the module
145*7c478bd9Sstevel@tonic-gate  * will try optcom_req to see if its some sort of SOCKET or IP option.
146*7c478bd9Sstevel@tonic-gate  * snmpcom_req returns TRUE whenever the first option is recognized as
147*7c478bd9Sstevel@tonic-gate  * an SNMP request, even if a bad one.
148*7c478bd9Sstevel@tonic-gate  *
149*7c478bd9Sstevel@tonic-gate  * "get" is done by a single O_T_OPTMGMT_REQ with MGMT_flags set to T_CURRENT.
150*7c478bd9Sstevel@tonic-gate  * All modules respond with one or msg's about what they know.  Responses
151*7c478bd9Sstevel@tonic-gate  * are in T_OPTMGMT_ACK format.  The opthdr level/name fields identify what
152*7c478bd9Sstevel@tonic-gate  * is begin returned, the len field how big it is (in bytes).  The info
153*7c478bd9Sstevel@tonic-gate  * itself is in the data portion of the msg.  Fixed length info returned
154*7c478bd9Sstevel@tonic-gate  * in one msg; each table in a separate msg.
155*7c478bd9Sstevel@tonic-gate  *
156*7c478bd9Sstevel@tonic-gate  * setfn() returns 1 if things ok, 0 if set request invalid or otherwise
157*7c478bd9Sstevel@tonic-gate  * messed up.
158*7c478bd9Sstevel@tonic-gate  *
159*7c478bd9Sstevel@tonic-gate  * If the passed q is at the bottom of the module chain (q_next == NULL,
160*7c478bd9Sstevel@tonic-gate  * a ctl msg with req->name, level, len all zero is sent upstream.  This
161*7c478bd9Sstevel@tonic-gate  * is and EOD flag to the caller.
162*7c478bd9Sstevel@tonic-gate  *
163*7c478bd9Sstevel@tonic-gate  * IMPORTANT:
164*7c478bd9Sstevel@tonic-gate  * - The msg type is M_PROTO, not M_PCPROTO!!!  This is by design,
165*7c478bd9Sstevel@tonic-gate  *   since multiple messages will be sent to stream head and we want
166*7c478bd9Sstevel@tonic-gate  *   them queued for reading, not discarded.
167*7c478bd9Sstevel@tonic-gate  * - All requests which match a table entry are sent to all get/set functions
168*7c478bd9Sstevel@tonic-gate  *   of each module.  The functions must simply ignore requests not meant
169*7c478bd9Sstevel@tonic-gate  *   for them: getfn() returns 0, setfn() returns 1.
170*7c478bd9Sstevel@tonic-gate  */
171*7c478bd9Sstevel@tonic-gate boolean_t
172*7c478bd9Sstevel@tonic-gate snmpcom_req(q, mp, setfn, getfn, credp)
173*7c478bd9Sstevel@tonic-gate 	queue_t	*q;
174*7c478bd9Sstevel@tonic-gate 	mblk_t	*mp;
175*7c478bd9Sstevel@tonic-gate 	pfi_t	setfn;
176*7c478bd9Sstevel@tonic-gate 	pfi_t	getfn;
177*7c478bd9Sstevel@tonic-gate 	cred_t	*credp;
178*7c478bd9Sstevel@tonic-gate {
179*7c478bd9Sstevel@tonic-gate 	mblk_t			*mpctl;
180*7c478bd9Sstevel@tonic-gate 	struct opthdr		*req;
181*7c478bd9Sstevel@tonic-gate 	struct opthdr		*next_req;
182*7c478bd9Sstevel@tonic-gate 	struct opthdr		*req_end;
183*7c478bd9Sstevel@tonic-gate 	struct opthdr		*req_start;
184*7c478bd9Sstevel@tonic-gate 	sor_t			*sreq;
185*7c478bd9Sstevel@tonic-gate 	struct T_optmgmt_req	*tor = (struct T_optmgmt_req *)mp->b_rptr;
186*7c478bd9Sstevel@tonic-gate 	struct T_optmgmt_ack	*toa;
187*7c478bd9Sstevel@tonic-gate 
188*7c478bd9Sstevel@tonic-gate 	if (mp->b_cont) {	/* don't deal with multiple mblk's */
189*7c478bd9Sstevel@tonic-gate 		freemsg(mp->b_cont);
190*7c478bd9Sstevel@tonic-gate 		mp->b_cont = (mblk_t *)0;
191*7c478bd9Sstevel@tonic-gate 		optcom_err_ack(q, mp, TSYSERR, EBADMSG);
192*7c478bd9Sstevel@tonic-gate 		return (B_TRUE);
193*7c478bd9Sstevel@tonic-gate 	}
194*7c478bd9Sstevel@tonic-gate 	if ((mp->b_wptr - mp->b_rptr) < sizeof (struct T_optmgmt_req) ||
195*7c478bd9Sstevel@tonic-gate 	    !(req_start = (struct opthdr *)mi_offset_param(mp,
196*7c478bd9Sstevel@tonic-gate 		tor->OPT_offset, tor->OPT_length)))
197*7c478bd9Sstevel@tonic-gate 		goto bad_req1;
198*7c478bd9Sstevel@tonic-gate 	if (! __TPI_OPT_ISALIGNED(req_start))
199*7c478bd9Sstevel@tonic-gate 		goto bad_req1;
200*7c478bd9Sstevel@tonic-gate 
201*7c478bd9Sstevel@tonic-gate 	/*
202*7c478bd9Sstevel@tonic-gate 	 * if first option not in the MIB2 or EXPER range, return false so
203*7c478bd9Sstevel@tonic-gate 	 * optcom_req can scope things out.  Otherwise it's passed to each
204*7c478bd9Sstevel@tonic-gate 	 * calling module to process or ignore as it sees fit.
205*7c478bd9Sstevel@tonic-gate 	 */
206*7c478bd9Sstevel@tonic-gate 	if ((!(req_start->level >= MIB2_RANGE_START &&
207*7c478bd9Sstevel@tonic-gate 			req_start->level <= MIB2_RANGE_END)) &&
208*7c478bd9Sstevel@tonic-gate 	    (!(req_start->level >= EXPER_RANGE_START &&
209*7c478bd9Sstevel@tonic-gate 			req_start->level <= EXPER_RANGE_END)))
210*7c478bd9Sstevel@tonic-gate 		return (B_FALSE);
211*7c478bd9Sstevel@tonic-gate 
212*7c478bd9Sstevel@tonic-gate 	switch (tor->MGMT_flags) {
213*7c478bd9Sstevel@tonic-gate 
214*7c478bd9Sstevel@tonic-gate 	case T_NEGOTIATE:
215*7c478bd9Sstevel@tonic-gate 		if (secpolicy_net_config(credp, B_FALSE) != 0) {
216*7c478bd9Sstevel@tonic-gate 			optcom_err_ack(q, mp, TACCES, 0);
217*7c478bd9Sstevel@tonic-gate 			return (B_TRUE);
218*7c478bd9Sstevel@tonic-gate 		}
219*7c478bd9Sstevel@tonic-gate 		req_end = (struct opthdr *)((uchar_t *)req_start +
220*7c478bd9Sstevel@tonic-gate 			tor->OPT_length);
221*7c478bd9Sstevel@tonic-gate 		for (req = req_start; req < req_end; req = next_req) {
222*7c478bd9Sstevel@tonic-gate 			next_req =
223*7c478bd9Sstevel@tonic-gate 				(struct opthdr *)((uchar_t *)&req[1] +
224*7c478bd9Sstevel@tonic-gate 				_TPI_ALIGN_OPT(req->len));
225*7c478bd9Sstevel@tonic-gate 			if (next_req > req_end)
226*7c478bd9Sstevel@tonic-gate 				goto bad_req2;
227*7c478bd9Sstevel@tonic-gate 			for (sreq = req_arr; sreq < A_END(req_arr); sreq++) {
228*7c478bd9Sstevel@tonic-gate 				if (req->level == sreq->sor_group &&
229*7c478bd9Sstevel@tonic-gate 				    req->name == sreq->sor_code)
230*7c478bd9Sstevel@tonic-gate 					break;
231*7c478bd9Sstevel@tonic-gate 			}
232*7c478bd9Sstevel@tonic-gate 			if (sreq >= A_END(req_arr))
233*7c478bd9Sstevel@tonic-gate 				goto bad_req3;
234*7c478bd9Sstevel@tonic-gate 			if (!(*setfn)(q, req->level, req->name,
235*7c478bd9Sstevel@tonic-gate 				(uchar_t *)&req[1], req->len))
236*7c478bd9Sstevel@tonic-gate 				goto bad_req4;
237*7c478bd9Sstevel@tonic-gate 		}
238*7c478bd9Sstevel@tonic-gate 		if (q->q_next)
239*7c478bd9Sstevel@tonic-gate 			putnext(q, mp);
240*7c478bd9Sstevel@tonic-gate 		else
241*7c478bd9Sstevel@tonic-gate 			freemsg(mp);
242*7c478bd9Sstevel@tonic-gate 		return (B_TRUE);
243*7c478bd9Sstevel@tonic-gate 
244*7c478bd9Sstevel@tonic-gate 	case OLD_T_CURRENT:
245*7c478bd9Sstevel@tonic-gate 	case T_CURRENT:
246*7c478bd9Sstevel@tonic-gate 		mpctl = allocb(TOAHDR_SIZE, BPRI_MED);
247*7c478bd9Sstevel@tonic-gate 		if (!mpctl) {
248*7c478bd9Sstevel@tonic-gate 			optcom_err_ack(q, mp, TSYSERR, ENOMEM);
249*7c478bd9Sstevel@tonic-gate 			return (B_TRUE);
250*7c478bd9Sstevel@tonic-gate 		}
251*7c478bd9Sstevel@tonic-gate 		mpctl->b_cont = allocb(DATA_MBLK_SIZE, BPRI_MED);
252*7c478bd9Sstevel@tonic-gate 		if (!mpctl->b_cont) {
253*7c478bd9Sstevel@tonic-gate 			freemsg(mpctl);
254*7c478bd9Sstevel@tonic-gate 			optcom_err_ack(q, mp, TSYSERR, ENOMEM);
255*7c478bd9Sstevel@tonic-gate 			return (B_TRUE);
256*7c478bd9Sstevel@tonic-gate 		}
257*7c478bd9Sstevel@tonic-gate 		mpctl->b_datap->db_type = M_PROTO;
258*7c478bd9Sstevel@tonic-gate 		mpctl->b_wptr += TOAHDR_SIZE;
259*7c478bd9Sstevel@tonic-gate 		toa = (struct T_optmgmt_ack *)mpctl->b_rptr;
260*7c478bd9Sstevel@tonic-gate 		toa->PRIM_type = T_OPTMGMT_ACK;
261*7c478bd9Sstevel@tonic-gate 		toa->OPT_offset = sizeof (struct T_optmgmt_ack);
262*7c478bd9Sstevel@tonic-gate 		toa->OPT_length = sizeof (struct opthdr);
263*7c478bd9Sstevel@tonic-gate 		toa->MGMT_flags = T_SUCCESS;
264*7c478bd9Sstevel@tonic-gate 		if (!(*getfn)(q, mpctl))
265*7c478bd9Sstevel@tonic-gate 			freemsg(mpctl);
266*7c478bd9Sstevel@tonic-gate 		/*
267*7c478bd9Sstevel@tonic-gate 		 * all data for this module has now been sent upstream.  If
268*7c478bd9Sstevel@tonic-gate 		 * this is bottom module of stream, send up an EOD ctl msg,
269*7c478bd9Sstevel@tonic-gate 		 * otherwise pass onto the next guy for processing.
270*7c478bd9Sstevel@tonic-gate 		 */
271*7c478bd9Sstevel@tonic-gate 		if (q->q_next) {
272*7c478bd9Sstevel@tonic-gate 			putnext(q, mp);
273*7c478bd9Sstevel@tonic-gate 			return (B_TRUE);
274*7c478bd9Sstevel@tonic-gate 		}
275*7c478bd9Sstevel@tonic-gate 		if (mp->b_cont) {
276*7c478bd9Sstevel@tonic-gate 			freemsg(mp->b_cont);
277*7c478bd9Sstevel@tonic-gate 			mp->b_cont = NULL;
278*7c478bd9Sstevel@tonic-gate 		}
279*7c478bd9Sstevel@tonic-gate 		mpctl = reallocb(mp, TOAHDR_SIZE, 1);
280*7c478bd9Sstevel@tonic-gate 		if (!mpctl) {
281*7c478bd9Sstevel@tonic-gate 			optcom_err_ack(q, mp, TSYSERR, ENOMEM);
282*7c478bd9Sstevel@tonic-gate 			return (B_TRUE);
283*7c478bd9Sstevel@tonic-gate 		}
284*7c478bd9Sstevel@tonic-gate 		mpctl->b_datap->db_type = M_PROTO;
285*7c478bd9Sstevel@tonic-gate 		mpctl->b_wptr = mpctl->b_rptr + TOAHDR_SIZE;
286*7c478bd9Sstevel@tonic-gate 		toa = (struct T_optmgmt_ack *)mpctl->b_rptr;
287*7c478bd9Sstevel@tonic-gate 		toa->PRIM_type = T_OPTMGMT_ACK;
288*7c478bd9Sstevel@tonic-gate 		toa->OPT_offset = sizeof (struct T_optmgmt_ack);
289*7c478bd9Sstevel@tonic-gate 		toa->OPT_length = sizeof (struct opthdr);
290*7c478bd9Sstevel@tonic-gate 		toa->MGMT_flags = T_SUCCESS;
291*7c478bd9Sstevel@tonic-gate 		req = (struct opthdr *)&toa[1];
292*7c478bd9Sstevel@tonic-gate 		req->level = 0;
293*7c478bd9Sstevel@tonic-gate 		req->name = 0;
294*7c478bd9Sstevel@tonic-gate 		req->len = 0;
295*7c478bd9Sstevel@tonic-gate 		qreply(q, mpctl);
296*7c478bd9Sstevel@tonic-gate 		return (B_TRUE);
297*7c478bd9Sstevel@tonic-gate 
298*7c478bd9Sstevel@tonic-gate 	default:
299*7c478bd9Sstevel@tonic-gate 		optcom_err_ack(q, mp, TBADFLAG, 0);
300*7c478bd9Sstevel@tonic-gate 		return (B_TRUE);
301*7c478bd9Sstevel@tonic-gate 	}
302*7c478bd9Sstevel@tonic-gate 
303*7c478bd9Sstevel@tonic-gate bad_req1:;
304*7c478bd9Sstevel@tonic-gate 	printf("snmpcom bad_req1\n");
305*7c478bd9Sstevel@tonic-gate 	goto bad_req;
306*7c478bd9Sstevel@tonic-gate bad_req2:;
307*7c478bd9Sstevel@tonic-gate 	printf("snmpcom bad_req2\n");
308*7c478bd9Sstevel@tonic-gate 	goto bad_req;
309*7c478bd9Sstevel@tonic-gate bad_req3:;
310*7c478bd9Sstevel@tonic-gate 	printf("snmpcom bad_req3\n");
311*7c478bd9Sstevel@tonic-gate 	goto bad_req;
312*7c478bd9Sstevel@tonic-gate bad_req4:;
313*7c478bd9Sstevel@tonic-gate 	printf("snmpcom bad_req4\n");
314*7c478bd9Sstevel@tonic-gate 	/* FALLTHRU */
315*7c478bd9Sstevel@tonic-gate bad_req:;
316*7c478bd9Sstevel@tonic-gate 	optcom_err_ack(q, mp, TBADOPT, 0);
317*7c478bd9Sstevel@tonic-gate 	return (B_TRUE);
318*7c478bd9Sstevel@tonic-gate 
319*7c478bd9Sstevel@tonic-gate }
320