6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 #pragma ident "%Z%%M% %I% %E% SMI" /* SVr3.2H */
27
28 /*
29 * Dump STREAMS module. Could be used anywhere on a stream to
30 * print all message headers and data on to the console.
31 */
32
33 #include <sys/types.h>
34 #include <sys/param.h>
35 #include <sys/systm.h>
36 #include <sys/stream.h>
37 #include <sys/stropts.h>
38 #include <sys/errno.h>
39 #include <sys/cmn_err.h>
40 #include <sys/ddi.h>
41 #include <sys/strsun.h>
42
43 #include <sys/conf.h>
44 #include <sys/modctl.h>
45
46 static char hdr[100]; /* current message header */
47 static char hdrpad[100]; /* pad of same length as hdr[] */
268
269 struct qinit dedumpwinit = {
270 dedumpput, NULL, NULL, NULL, NULL, &dedump_minfo, NULL
271 };
272
273 struct streamtab dedumpinfo = {
274 &dedumprinit, &dedumpwinit, NULL, NULL,
275 };
276
277 static struct fmodsw fsw = {
278 "dedump",
279 &dedumpinfo,
280 D_MP | D_MTPERMOD /* just to serialize printfs */
281 };
282
283 static struct modlstrmod modlstrmod = {
284 &mod_strmodops, "dump streams module", &fsw
285 };
286
287 static struct modlinkage modlinkage = {
288 MODREV_1, &modlstrmod, NULL
289 };
290
291 int
292 _init(void)
293 {
294 int i;
295 msgfmt_t mf;
296
297 /*
298 * Sort msgfmt[] so that msgfmt[n] describes message type n.
299 */
300 for (i = 255; i != 0; i--) {
301 mf = msgfmt[i];
302 msgfmt[i].m_type = i;
303 (void) sprintf(msgfmt[i].m_desc, "M_BOGUS_0x%x", i);
304 msgfmt[i].m_print = dedump_raw;
305 if (mf.m_desc[0] != 0)
306 msgfmt[mf.m_type] = mf;
307 }
308
|
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 /*
27 * Dump STREAMS module. Could be used anywhere on a stream to
28 * print all message headers and data on to the console.
29 */
30
31 #include <sys/types.h>
32 #include <sys/param.h>
33 #include <sys/systm.h>
34 #include <sys/stream.h>
35 #include <sys/stropts.h>
36 #include <sys/errno.h>
37 #include <sys/cmn_err.h>
38 #include <sys/ddi.h>
39 #include <sys/strsun.h>
40
41 #include <sys/conf.h>
42 #include <sys/modctl.h>
43
44 static char hdr[100]; /* current message header */
45 static char hdrpad[100]; /* pad of same length as hdr[] */
266
267 struct qinit dedumpwinit = {
268 dedumpput, NULL, NULL, NULL, NULL, &dedump_minfo, NULL
269 };
270
271 struct streamtab dedumpinfo = {
272 &dedumprinit, &dedumpwinit, NULL, NULL,
273 };
274
275 static struct fmodsw fsw = {
276 "dedump",
277 &dedumpinfo,
278 D_MP | D_MTPERMOD /* just to serialize printfs */
279 };
280
281 static struct modlstrmod modlstrmod = {
282 &mod_strmodops, "dump streams module", &fsw
283 };
284
285 static struct modlinkage modlinkage = {
286 MODREV_1, { &modlstrmod, NULL }
287 };
288
289 int
290 _init(void)
291 {
292 int i;
293 msgfmt_t mf;
294
295 /*
296 * Sort msgfmt[] so that msgfmt[n] describes message type n.
297 */
298 for (i = 255; i != 0; i--) {
299 mf = msgfmt[i];
300 msgfmt[i].m_type = i;
301 (void) sprintf(msgfmt[i].m_desc, "M_BOGUS_0x%x", i);
302 msgfmt[i].m_print = dedump_raw;
303 if (mf.m_desc[0] != 0)
304 msgfmt[mf.m_type] = mf;
305 }
306
|