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