]> git.ozlabs.org Git - ppp.git/blob - svr4/ppp_mod.c
added in deflate
[ppp.git] / svr4 / ppp_mod.c
1 /*
2  * ppp_mod.c - modload support for PPP pseudo-device driver.
3  *
4  * Copyright (c) 1994 The Australian National University.
5  * All rights reserved.
6  *
7  * Permission to use, copy, modify, and distribute this software and its
8  * documentation is hereby granted, provided that the above copyright
9  * notice appears in all copies.  This software is provided without any
10  * warranty, express or implied. The Australian National University
11  * makes no representations about the suitability of this software for
12  * any purpose.
13  *
14  * IN NO EVENT SHALL THE AUSTRALIAN NATIONAL UNIVERSITY BE LIABLE TO ANY
15  * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
16  * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
17  * THE AUSTRALIAN NATIONAL UNIVERSITY HAVE BEEN ADVISED OF THE POSSIBILITY
18  * OF SUCH DAMAGE.
19  *
20  * THE AUSTRALIAN NATIONAL UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
21  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
22  * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
23  * ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO
24  * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
25  * OR MODIFICATIONS.
26  *
27  * $Id: ppp_mod.c,v 1.2 1996/01/18 03:27:36 paulus Exp $
28  */
29
30 /*
31  * This file is used under Solaris 2.
32  */
33
34 #include <sys/types.h>
35 #include <sys/param.h>
36 #include <sys/stat.h>
37 #include <sys/conf.h>
38 #include <sys/modctl.h>
39 #include <sys/sunddi.h>
40
41 #ifdef __STDC__
42 #define __P(x)  x
43 #else
44 #define __P(x)  ()
45 #endif
46
47 static int ppp_identify __P((dev_info_t *));
48 static int ppp_attach __P((dev_info_t *, ddi_attach_cmd_t));
49 static int ppp_detach __P((dev_info_t *, ddi_detach_cmd_t));
50 static int ppp_devinfo __P((dev_info_t *, ddi_info_cmd_t, void *, void **));
51
52 extern struct streamtab pppinfo;
53
54 static dev_info_t *ppp_dip;
55
56 static struct cb_ops cb_ppp_ops = {
57     nulldev, nulldev, nodev, nodev,     /* cb_open, ... */
58     nodev, nodev, nodev, nodev,         /* cb_dump, ... */
59     nodev, nodev, nodev, nochpoll,      /* cb_devmap, ... */
60     ddi_prop_op,                        /* cb_prop_op */
61     &pppinfo,                           /* cb_stream */
62     D_NEW|D_MP|D_MTQPAIR|D_MTOUTPERIM|D_MTOCEXCL        /* cb_flag */
63 };
64
65 static struct dev_ops ppp_ops = {
66     DEVO_REV,                           /* devo_rev */
67     0,                                  /* devo_refcnt */
68     ppp_devinfo,                        /* devo_getinfo */
69     ppp_identify,                       /* devo_identify */
70     nulldev,                            /* devo_probe */
71     ppp_attach,                         /* devo_attach */
72     ppp_detach,                         /* devo_detach */
73     nodev,                              /* devo_reset */
74     &cb_ppp_ops,                        /* devo_cb_ops */
75     NULL                                /* devo_bus_ops */
76 };
77
78 /*
79  * Module linkage information
80  */
81
82 static struct modldrv modldrv = {
83     &mod_driverops,                     /* says this is a pseudo driver */
84     "PPP-2.3 multiplexing driver",
85     &ppp_ops                            /* driver ops */
86 };
87
88 static struct modlinkage modlinkage = {
89     MODREV_1,
90     (void *) &modldrv,
91     NULL
92 };
93
94 int
95 _init(void)
96 {
97     return mod_install(&modlinkage);
98 }
99
100 int
101 _fini(void)
102 {
103     return mod_remove(&modlinkage);
104 }
105
106 int
107 _info(mip)
108     struct modinfo *mip;
109 {
110     return mod_info(&modlinkage, mip);
111 }
112
113 static int
114 ppp_identify(dip)
115     dev_info_t *dip;
116 {
117     return strcmp(ddi_get_name(dip), "ppp") == 0? DDI_IDENTIFIED:
118         DDI_NOT_IDENTIFIED;
119 }
120
121 static int
122 ppp_attach(dip, cmd)
123     dev_info_t *dip;
124     ddi_attach_cmd_t cmd;
125 {
126
127     if (cmd != DDI_ATTACH)
128         return DDI_FAILURE;
129     if (ddi_create_minor_node(dip, "ppp", S_IFCHR, 0, DDI_PSEUDO, CLONE_DEV)
130         == DDI_FAILURE) {
131         ddi_remove_minor_node(dip, NULL);
132         return DDI_FAILURE;
133     }
134     return DDI_SUCCESS;
135 }
136
137 static int
138 ppp_detach(dip, cmd)
139     dev_info_t *dip;
140     ddi_detach_cmd_t cmd;
141 {
142     ddi_remove_minor_node(dip, NULL);
143     return DDI_SUCCESS;
144 }
145
146 static int
147 ppp_devinfo(dip, cmd, arg, result)
148     dev_info_t *dip;
149     ddi_info_cmd_t cmd;
150     void *arg;
151     void **result;
152 {
153     int error;
154
155     error = DDI_SUCCESS;
156     switch (cmd) {
157     case DDI_INFO_DEVT2DEVINFO:
158         if (ppp_dip == NULL)
159             error = DDI_FAILURE;
160         else
161             *result = (void *) ppp_dip;
162         break;
163     case DDI_INFO_DEVT2INSTANCE:
164         *result = NULL;
165         break;
166     default:
167         error = DDI_FAILURE;
168     }
169     return error;
170 }