1*fc80c0dfSnordmark /*
2*fc80c0dfSnordmark * CDDL HEADER START
3*fc80c0dfSnordmark *
4*fc80c0dfSnordmark * The contents of this file are subject to the terms of the
5*fc80c0dfSnordmark * Common Development and Distribution License (the "License").
6*fc80c0dfSnordmark * You may not use this file except in compliance with the License.
7*fc80c0dfSnordmark *
8*fc80c0dfSnordmark * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*fc80c0dfSnordmark * or http://www.opensolaris.org/os/licensing.
10*fc80c0dfSnordmark * See the License for the specific language governing permissions
11*fc80c0dfSnordmark * and limitations under the License.
12*fc80c0dfSnordmark *
13*fc80c0dfSnordmark * When distributing Covered Code, include this CDDL HEADER in each
14*fc80c0dfSnordmark * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*fc80c0dfSnordmark * If applicable, add the following below this CDDL HEADER, with the
16*fc80c0dfSnordmark * fields enclosed by brackets "[]" replaced with your own identifying
17*fc80c0dfSnordmark * information: Portions Copyright [yyyy] [name of copyright owner]
18*fc80c0dfSnordmark *
19*fc80c0dfSnordmark * CDDL HEADER END
20*fc80c0dfSnordmark */
21*fc80c0dfSnordmark /*
22*fc80c0dfSnordmark * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23*fc80c0dfSnordmark * Use is subject to license terms.
24*fc80c0dfSnordmark */
25*fc80c0dfSnordmark
26*fc80c0dfSnordmark #pragma ident "%Z%%M% %I% %E% SMI"
27*fc80c0dfSnordmark
28*fc80c0dfSnordmark #include <sys/types.h>
29*fc80c0dfSnordmark #include <sys/conf.h>
30*fc80c0dfSnordmark #include <sys/modctl.h>
31*fc80c0dfSnordmark #include <inet/common.h>
32*fc80c0dfSnordmark
33*fc80c0dfSnordmark /*
34*fc80c0dfSnordmark * Dummy streams module that is used by ICMP, UDP, and TCP by setting
35*fc80c0dfSnordmark * INETMODSTRTAB to dummymodinfo
36*fc80c0dfSnordmark *
37*fc80c0dfSnordmark * It's reason for existance is so that mibopen() that I_PUSH icmp, udp, and
38*fc80c0dfSnordmark * tcp can continue to push modules with those names, even though all the
39*fc80c0dfSnordmark * MIB information comes from IP.
40*fc80c0dfSnordmark */
41*fc80c0dfSnordmark
42*fc80c0dfSnordmark static int dummy_modclose(queue_t *q);
43*fc80c0dfSnordmark static int dummy_modopen(queue_t *q, dev_t *devp, int flag,
44*fc80c0dfSnordmark int sflag, cred_t *credp);
45*fc80c0dfSnordmark
46*fc80c0dfSnordmark /*
47*fc80c0dfSnordmark * This is common code for the tcp, udp, and icmp streams module which is
48*fc80c0dfSnordmark * an empty STREAMS module provided for compatibility for mibopen()
49*fc80c0dfSnordmark * code which I_PUSH modules with those names.
50*fc80c0dfSnordmark */
51*fc80c0dfSnordmark struct module_info dummy_mod_info = {
52*fc80c0dfSnordmark 5799, "dummymod", 1, INFPSZ, 65536, 1024
53*fc80c0dfSnordmark };
54*fc80c0dfSnordmark
55*fc80c0dfSnordmark
56*fc80c0dfSnordmark static struct qinit dummyrmodinit = {
57*fc80c0dfSnordmark (pfi_t)putnext, NULL, dummy_modopen, dummy_modclose, NULL,
58*fc80c0dfSnordmark &dummy_mod_info
59*fc80c0dfSnordmark };
60*fc80c0dfSnordmark
61*fc80c0dfSnordmark static struct qinit dummywmodinit = {
62*fc80c0dfSnordmark (pfi_t)putnext, NULL, NULL, NULL, NULL, &dummy_mod_info
63*fc80c0dfSnordmark };
64*fc80c0dfSnordmark
65*fc80c0dfSnordmark struct streamtab dummymodinfo = {
66*fc80c0dfSnordmark &dummyrmodinit, &dummywmodinit
67*fc80c0dfSnordmark };
68*fc80c0dfSnordmark
69*fc80c0dfSnordmark static int
dummy_modclose(queue_t * q)70*fc80c0dfSnordmark dummy_modclose(queue_t *q)
71*fc80c0dfSnordmark {
72*fc80c0dfSnordmark qprocsoff(q);
73*fc80c0dfSnordmark return (0);
74*fc80c0dfSnordmark }
75*fc80c0dfSnordmark
76*fc80c0dfSnordmark /* ARGSUSED */
77*fc80c0dfSnordmark static int
dummy_modopen(queue_t * q,dev_t * devp,int flag,int sflag,cred_t * credp)78*fc80c0dfSnordmark dummy_modopen(queue_t *q, dev_t *devp, int flag, int sflag, cred_t *credp)
79*fc80c0dfSnordmark {
80*fc80c0dfSnordmark /* If the stream is already open, return immediately. */
81*fc80c0dfSnordmark if (q->q_ptr != NULL)
82*fc80c0dfSnordmark return (0);
83*fc80c0dfSnordmark
84*fc80c0dfSnordmark /* If this is not a push of dummy as a module, fail. */
85*fc80c0dfSnordmark if (sflag != MODOPEN)
86*fc80c0dfSnordmark return (EINVAL);
87*fc80c0dfSnordmark
88*fc80c0dfSnordmark qprocson(q);
89*fc80c0dfSnordmark return (0);
90*fc80c0dfSnordmark }
91