Home | History | Annotate | Download | only in ip
      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, Version 1.0 only
      6  * (the "License").  You may not use this file except in compliance
      7  * with the License.
      8  *
      9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
     10  * or http://www.opensolaris.org/os/licensing.
     11  * See the License for the specific language governing permissions
     12  * and limitations under the License.
     13  *
     14  * When distributing Covered Code, include this CDDL HEADER in each
     15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
     16  * If applicable, add the following below this CDDL HEADER, with the
     17  * fields enclosed by brackets "[]" replaced with your own identifying
     18  * information: Portions Copyright [yyyy] [name of copyright owner]
     19  *
     20  * CDDL HEADER END
     21  */
     22 /*
     23  * Copyright (c) 1995-1997, 2001 by Sun Microsystems, Inc.
     24  * All rights reserved.
     25  */
     26 
     27 /* Automatic tunnel module */
     28 
     29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
     30 
     31 #include <sys/types.h>
     32 #include <sys/stream.h>
     33 #include <sys/stropts.h>
     34 
     35 #include <sys/socket.h>
     36 #include <sys/isa_defs.h>
     37 #include <net/if.h>
     38 #include <net/if_arp.h>
     39 #include <netinet/in.h>
     40 
     41 #include <inet/common.h>
     42 #include <inet/arp.h>
     43 
     44 #include <netinet/ip6.h>
     45 #include <netinet/icmp6.h>
     46 #include <inet/ip.h>
     47 #include <inet/ip6.h>
     48 #include <net/if_dl.h>
     49 #include <inet/ip_if.h>
     50 #include <inet/tun.h>
     51 
     52 #include <sys/conf.h>
     53 #include <sys/modctl.h>
     54 #include <sys/stat.h>
     55 
     56 /* streams linkages */
     57 static struct module_info atuninfo = {
     58 	ATUN_MODID, ATUN_NAME, 1, INFPSZ, 65536, 1024
     59 };
     60 
     61 static struct qinit atunrinit = {
     62 	(pfi_t)tun_rput,
     63 	(pfi_t)tun_rsrv,
     64 	tun_open,
     65 	tun_close,
     66 	NULL,
     67 	&atuninfo,
     68 	NULL
     69 };
     70 
     71 static struct qinit atunwinit = {
     72 	(pfi_t)tun_wput,
     73 	(pfi_t)tun_wsrv,
     74 	NULL,
     75 	NULL,
     76 	NULL,
     77 	&atuninfo,
     78 	NULL
     79 };
     80 
     81 static struct streamtab atun_strtab = {
     82 		&atunrinit, &atunwinit, NULL, NULL
     83 };
     84 
     85 static struct fmodsw atun_fmodsw = {
     86 	ATUN_NAME,
     87 	&atun_strtab,
     88 	(D_MP | D_MTQPAIR | D_MTPUTSHARED)
     89 	};
     90 
     91 static struct modlstrmod modlstrmod = {
     92 	&mod_strmodops, "auto-tunneling module", &atun_fmodsw
     93 	};
     94 
     95 static struct modlinkage modlinkage = {
     96 	MODREV_1,
     97 	&modlstrmod,
     98 	NULL
     99 	};
    100 
    101 
    102 int
    103 _init(void)
    104 {
    105 	return (mod_install(&modlinkage));
    106 }
    107 
    108 int
    109 _fini(void)
    110 {
    111 	return (mod_remove(&modlinkage));
    112 }
    113 
    114 int
    115 _info(struct modinfo *modinfop)
    116 {
    117 	return (mod_info(&modlinkage, modinfop));
    118 }
    119