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 #pragma ident "%Z%%M% %I% %E% SMI" 27 28 #include <sys/types.h> 29 #include <sys/conf.h> 30 #include <sys/modctl.h> 31 #include <inet/common.h> 32 33 /* 34 * Dummy streams module that is used by ICMP, UDP, and TCP by setting 35 * INETMODSTRTAB to dummymodinfo 36 * 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. 40 */ 41 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); 45 46 /* 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. 50 */ 51 struct module_info dummy_mod_info = { 52 5799, "dummymod", 1, INFPSZ, 65536, 1024 53 }; 54 55 56 static struct qinit dummyrmodinit = { 57 (pfi_t)putnext, NULL, dummy_modopen, dummy_modclose, NULL, 58 &dummy_mod_info 59 }; 60 61 static struct qinit dummywmodinit = { 62 (pfi_t)putnext, NULL, NULL, NULL, NULL, &dummy_mod_info 63 }; 64 65 struct streamtab dummymodinfo = { 66 &dummyrmodinit, &dummywmodinit 67 }; 68 69 static int 70 dummy_modclose(queue_t *q) 71 { 72 qprocsoff(q); 73 return (0); 74 } 75 76 /* ARGSUSED */ 77 static int 78 dummy_modopen(queue_t *q, dev_t *devp, int flag, int sflag, cred_t *credp) 79 { 80 /* If the stream is already open, return immediately. */ 81 if (q->q_ptr != NULL) 82 return (0); 83 84 /* If this is not a push of dummy as a module, fail. */ 85 if (sflag != MODOPEN) 86 return (EINVAL); 87 88 qprocson(q); 89 return (0); 90 } 91