1 /* 2 * CDDL HEADER START 3 * 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. 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 2007 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 #include <sys/types.h> 27 #include <sys/conf.h> 28 #include <sys/modctl.h> 29 #include <inet/common.h> 30 31 /* 32 * Dummy streams module that is used by ICMP, UDP, and TCP by setting 33 * INETMODSTRTAB to dummymodinfo 34 * 35 * It's reason for existance is so that mibopen() that I_PUSH icmp, udp, and 36 * tcp can continue to push modules with those names, even though all the 37 * MIB information comes from IP. 38 */ 39 40 static int dummy_modclose(queue_t *, int, cred_t *); 41 static int dummy_modopen(queue_t *q, dev_t *devp, int flag, 42 int sflag, cred_t *credp); 43 44 /* 45 * This is common code for the tcp, udp, and icmp streams module which is 46 * an empty STREAMS module provided for compatibility for mibopen() 47 * code which I_PUSH modules with those names. 48 */ 49 struct module_info dummy_mod_info = { 50 5799, "dummymod", 1, INFPSZ, 65536, 1024 51 }; 52 53 54 static struct qinit dummyrmodinit = { 55 (pfi_t)putnext, NULL, dummy_modopen, dummy_modclose, NULL, 56 &dummy_mod_info 57 }; 58 59 static struct qinit dummywmodinit = { 60 (pfi_t)putnext, NULL, NULL, NULL, NULL, &dummy_mod_info 61 }; 62 63 struct streamtab dummymodinfo = { 64 &dummyrmodinit, &dummywmodinit 65 }; 66 67 /* ARGSUSED */ 68 static int 69 dummy_modclose(queue_t *q, int flags __unused, cred_t *credp __unused) 70 { 71 qprocsoff(q); 72 return (0); 73 } 74 75 /* ARGSUSED */ 76 static int 77 dummy_modopen(queue_t *q, dev_t *devp, int flag, int sflag, cred_t *credp) 78 { 79 /* If the stream is already open, return immediately. */ 80 if (q->q_ptr != NULL) 81 return (0); 82 83 /* If this is not a push of dummy as a module, fail. */ 84 if (sflag != MODOPEN) 85 return (EINVAL); 86 87 qprocson(q); 88 return (0); 89 } 90