ip_dummy.c revision fc80c0dfb0c877aee828d778ea32b77fcf7b1ef4
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello/*
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello * CDDL HEADER START
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello *
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello * The contents of this file are subject to the terms of the
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello * Common Development and Distribution License (the "License").
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello * You may not use this file except in compliance with the License.
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello *
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello * or http://www.opensolaris.org/os/licensing.
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello * See the License for the specific language governing permissions
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello * and limitations under the License.
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello *
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello * When distributing Covered Code, include this CDDL HEADER in each
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello * If applicable, add the following below this CDDL HEADER, with the
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello * fields enclosed by brackets "[]" replaced with your own identifying
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello * information: Portions Copyright [yyyy] [name of copyright owner]
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello *
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello * CDDL HEADER END
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello */
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello/*
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello * Use is subject to license terms.
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello */
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello#pragma ident "%Z%%M% %I% %E% SMI"
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello#include <sys/types.h>
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello#include <sys/conf.h>
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello#include <sys/modctl.h>
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello#include <inet/common.h>
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello/*
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello * Dummy streams module that is used by ICMP, UDP, and TCP by setting
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello * INETMODSTRTAB to dummymodinfo
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello *
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello * It's reason for existance is so that mibopen() that I_PUSH icmp, udp, and
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello * tcp can continue to push modules with those names, even though all the
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello * MIB information comes from IP.
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello */
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mellostatic int dummy_modclose(queue_t *q);
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mellostatic int dummy_modopen(queue_t *q, dev_t *devp, int flag,
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello int sflag, cred_t *credp);
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello/*
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello * This is common code for the tcp, udp, and icmp streams module which is
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello * an empty STREAMS module provided for compatibility for mibopen()
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello * code which I_PUSH modules with those names.
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello */
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mellostruct module_info dummy_mod_info = {
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello 5799, "dummymod", 1, INFPSZ, 65536, 1024
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello};
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mellostatic struct qinit dummyrmodinit = {
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello (pfi_t)putnext, NULL, dummy_modopen, dummy_modclose, NULL,
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello &dummy_mod_info
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello};
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mellostatic struct qinit dummywmodinit = {
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello (pfi_t)putnext, NULL, NULL, NULL, NULL, &dummy_mod_info
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello};
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mellostruct streamtab dummymodinfo = {
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello &dummyrmodinit, &dummywmodinit
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello};
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mellostatic int
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mellodummy_modclose(queue_t *q)
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello{
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello qprocsoff(q);
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello return (0);
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello}
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello/* ARGSUSED */
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mellostatic int
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mellodummy_modopen(queue_t *q, dev_t *devp, int flag, int sflag, cred_t *credp)
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello{
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello /* If the stream is already open, return immediately. */
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello if (q->q_ptr != NULL)
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello return (0);
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello /* If this is not a push of dummy as a module, fail. */
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello if (sflag != MODOPEN)
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello return (EINVAL);
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello qprocson(q);
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello return (0);
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello}
797f979d1fe26bfb1cdeb3e7a86ed24c0b654200Cody Peter Mello