17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * spppcomp_mod.c - modload support for PPP compression STREAMS module.
37c478bd9Sstevel@tonic-gate  *
4*89b43686SBayard Bell  * Copyright (c) 2011 Bayard G. Bell. All rights reserved.
5*89b43686SBayard Bell  *
6*89b43686SBayard Bell  * CONTRIBUTOR MAKES NO REPRESENTATION OR WARRANTIES ABOUT THE SUITABILITY
7*89b43686SBayard Bell  * OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
8*89b43686SBayard Bell  * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
9*89b43686SBayard Bell  * PARTICULAR PURPOSE, OR NON-INFRINGEMENT.  CONTRIBUTOR SHALL NOT BE LIABLE
10*89b43686SBayard Bell  * FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
11*89b43686SBayard Bell  * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES
12*89b43686SBayard Bell  *
137c478bd9Sstevel@tonic-gate  * Copyright (c) 2000 by Sun Microsystems, Inc.
147c478bd9Sstevel@tonic-gate  * All rights reserved.
157c478bd9Sstevel@tonic-gate  *
167c478bd9Sstevel@tonic-gate  * Permission to use, copy, modify, and distribute this software and its
177c478bd9Sstevel@tonic-gate  * documentation is hereby granted, provided that the above copyright
187c478bd9Sstevel@tonic-gate  * notice appears in all copies.
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * SUN MAKES NO REPRESENTATION OR WARRANTIES ABOUT THE SUITABILITY OF
217c478bd9Sstevel@tonic-gate  * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
227c478bd9Sstevel@tonic-gate  * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
237c478bd9Sstevel@tonic-gate  * PARTICULAR PURPOSE, OR NON-INFRINGEMENT.  SUN SHALL NOT BE LIABLE FOR
247c478bd9Sstevel@tonic-gate  * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
257c478bd9Sstevel@tonic-gate  * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES
267c478bd9Sstevel@tonic-gate  *
277c478bd9Sstevel@tonic-gate  * Copyright (c) 1994 The Australian National University.
287c478bd9Sstevel@tonic-gate  * All rights reserved.
297c478bd9Sstevel@tonic-gate  *
307c478bd9Sstevel@tonic-gate  * Permission to use, copy, modify, and distribute this software and its
317c478bd9Sstevel@tonic-gate  * documentation is hereby granted, provided that the above copyright
327c478bd9Sstevel@tonic-gate  * notice appears in all copies.  This software is provided without any
337c478bd9Sstevel@tonic-gate  * warranty, express or implied. The Australian National University
347c478bd9Sstevel@tonic-gate  * makes no representations about the suitability of this software for
357c478bd9Sstevel@tonic-gate  * any purpose.
367c478bd9Sstevel@tonic-gate  *
377c478bd9Sstevel@tonic-gate  * IN NO EVENT SHALL THE AUSTRALIAN NATIONAL UNIVERSITY BE LIABLE TO ANY
387c478bd9Sstevel@tonic-gate  * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
397c478bd9Sstevel@tonic-gate  * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
407c478bd9Sstevel@tonic-gate  * THE AUSTRALIAN NATIONAL UNIVERSITY HAVE BEEN ADVISED OF THE POSSIBILITY
417c478bd9Sstevel@tonic-gate  * OF SUCH DAMAGE.
427c478bd9Sstevel@tonic-gate  *
437c478bd9Sstevel@tonic-gate  * THE AUSTRALIAN NATIONAL UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
447c478bd9Sstevel@tonic-gate  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
457c478bd9Sstevel@tonic-gate  * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
467c478bd9Sstevel@tonic-gate  * ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO
477c478bd9Sstevel@tonic-gate  * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
487c478bd9Sstevel@tonic-gate  * OR MODIFICATIONS.
497c478bd9Sstevel@tonic-gate  *
507c478bd9Sstevel@tonic-gate  * This module is derived from the original SVR4 STREAMS PPP compression
517c478bd9Sstevel@tonic-gate  * module originally written by Paul Mackerras <paul.mackerras@cs.anu.edu.au>.
527c478bd9Sstevel@tonic-gate  *
537c478bd9Sstevel@tonic-gate  * James Carlson <james.d.carlson@sun.com> and Adi Masputra
547c478bd9Sstevel@tonic-gate  * <adi.masputra@sun.com> rewrote and restructured the code for improved
557c478bd9Sstevel@tonic-gate  * performance and scalability.
567c478bd9Sstevel@tonic-gate  */
577c478bd9Sstevel@tonic-gate 
587c478bd9Sstevel@tonic-gate #include <sys/types.h>
597c478bd9Sstevel@tonic-gate #include <sys/syslog.h>
607c478bd9Sstevel@tonic-gate #include <sys/conf.h>
617c478bd9Sstevel@tonic-gate #include <sys/errno.h>
627c478bd9Sstevel@tonic-gate #include <sys/ddi.h>
637c478bd9Sstevel@tonic-gate #include <sys/conf.h>
647c478bd9Sstevel@tonic-gate #include <sys/modctl.h>
657c478bd9Sstevel@tonic-gate #include <net/pppio.h>
667c478bd9Sstevel@tonic-gate 
677c478bd9Sstevel@tonic-gate #include "s_common.h"
687c478bd9Sstevel@tonic-gate 
697c478bd9Sstevel@tonic-gate /*
707c478bd9Sstevel@tonic-gate  * Globals for PPP compression loadable module wrapper
717c478bd9Sstevel@tonic-gate  */
727c478bd9Sstevel@tonic-gate extern struct streamtab spppcomp_tab;
737c478bd9Sstevel@tonic-gate extern const char spppcomp_module_description[];
747c478bd9Sstevel@tonic-gate 
757c478bd9Sstevel@tonic-gate static struct fmodsw fsw = {
767c478bd9Sstevel@tonic-gate 	COMP_MOD_NAME,				/* f_name */
777c478bd9Sstevel@tonic-gate 	&spppcomp_tab,				/* f_str */
787c478bd9Sstevel@tonic-gate 	D_NEW | D_MP | D_MTPERQ			/* f_flag */
797c478bd9Sstevel@tonic-gate };
807c478bd9Sstevel@tonic-gate 
817c478bd9Sstevel@tonic-gate static struct modlstrmod modlstrmod = {
827c478bd9Sstevel@tonic-gate 	&mod_strmodops,				/* strmod_modops */
837c478bd9Sstevel@tonic-gate 	(char *)spppcomp_module_description,	/* strmod_linkinfo */
847c478bd9Sstevel@tonic-gate 	&fsw					/* strmod_fmodsw */
857c478bd9Sstevel@tonic-gate };
867c478bd9Sstevel@tonic-gate 
877c478bd9Sstevel@tonic-gate static struct modlinkage modlinkage = {
887c478bd9Sstevel@tonic-gate 	MODREV_1,			/* ml_rev, has to be MODREV_1 */
897c478bd9Sstevel@tonic-gate 	(void *) &modlstrmod,		/* ml_linkage, NULL-terminated list */
907c478bd9Sstevel@tonic-gate 	NULL				/*  of linkage structures */
917c478bd9Sstevel@tonic-gate };
927c478bd9Sstevel@tonic-gate 
937c478bd9Sstevel@tonic-gate int
_init(void)947c478bd9Sstevel@tonic-gate _init(void)
957c478bd9Sstevel@tonic-gate {
967c478bd9Sstevel@tonic-gate 	return (mod_install(&modlinkage));
977c478bd9Sstevel@tonic-gate }
987c478bd9Sstevel@tonic-gate 
997c478bd9Sstevel@tonic-gate int
_fini(void)1007c478bd9Sstevel@tonic-gate _fini(void)
1017c478bd9Sstevel@tonic-gate {
1027c478bd9Sstevel@tonic-gate 	return (mod_remove(&modlinkage));
1037c478bd9Sstevel@tonic-gate }
1047c478bd9Sstevel@tonic-gate 
1057c478bd9Sstevel@tonic-gate int
_info(struct modinfo * modinfop)1067c478bd9Sstevel@tonic-gate _info(struct modinfo *modinfop)
1077c478bd9Sstevel@tonic-gate {
1087c478bd9Sstevel@tonic-gate 	return (mod_info(&modlinkage, modinfop));
1097c478bd9Sstevel@tonic-gate }
110