Merge commit 'b1e7e97d3b60469b243b3b2e22c7d8cbd11c7c90'
[unleashed.git] / kernel / net / ip / ip_dummy.c
blob57b23ba2861bb683d599f7f74f15b78de717e167
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
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.
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]
19 * CDDL HEADER END
22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #pragma ident "%Z%%M% %I% %E% SMI"
28 #include <sys/types.h>
29 #include <sys/conf.h>
30 #include <sys/modctl.h>
31 #include <inet/common.h>
34 * Dummy streams module that is used by ICMP, UDP, and TCP by setting
35 * INETMODSTRTAB to dummymodinfo
37 * It's reason for existance is so that mibopen() that I_PUSH icmp, udp, and
38 * tcp can continue to push modules with those names, even though all the
39 * MIB information comes from IP.
42 static int dummy_modclose(queue_t *q);
43 static int dummy_modopen(queue_t *q, dev_t *devp, int flag,
44 int sflag, cred_t *credp);
47 * This is common code for the tcp, udp, and icmp streams module which is
48 * an empty STREAMS module provided for compatibility for mibopen()
49 * code which I_PUSH modules with those names.
51 struct module_info dummy_mod_info = {
52 5799, "dummymod", 1, INFPSZ, 65536, 1024
56 static struct qinit dummyrmodinit = {
57 (pfi_t)putnext, NULL, dummy_modopen, dummy_modclose, NULL,
58 &dummy_mod_info
61 static struct qinit dummywmodinit = {
62 (pfi_t)putnext, NULL, NULL, NULL, NULL, &dummy_mod_info
65 struct streamtab dummymodinfo = {
66 &dummyrmodinit, &dummywmodinit
69 static int
70 dummy_modclose(queue_t *q)
72 qprocsoff(q);
73 return (0);
76 /* ARGSUSED */
77 static int
78 dummy_modopen(queue_t *q, dev_t *devp, int flag, int sflag, cred_t *credp)
80 /* If the stream is already open, return immediately. */
81 if (q->q_ptr != NULL)
82 return (0);
84 /* If this is not a push of dummy as a module, fail. */
85 if (sflag != MODOPEN)
86 return (EINVAL);
88 qprocson(q);
89 return (0);