made loop_frame static
[mpls-ppp.git] / svr4 / ppp_mod.c
blob6b80093a908ec843b880c2c8ca8c4bc389131a18
1 /*
2 * ppp_mod.c - modload support for PPP pseudo-device driver.
4 * Copyright (c) 1994 The Australian National University.
5 * All rights reserved.
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.
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.
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.
27 * $Id: ppp_mod.c,v 1.3 1999/02/26 10:53:28 paulus Exp $
31 * This file is used under Solaris 2.
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 #include <sys/ksynch.h>
42 #ifdef __STDC__
43 #define __P(x) x
44 #else
45 #define __P(x) ()
46 #endif
48 static int ppp_identify __P((dev_info_t *));
49 static int ppp_attach __P((dev_info_t *, ddi_attach_cmd_t));
50 static int ppp_detach __P((dev_info_t *, ddi_detach_cmd_t));
51 static int ppp_devinfo __P((dev_info_t *, ddi_info_cmd_t, void *, void **));
53 extern struct streamtab pppinfo;
54 extern krwlock_t ppp_lower_lock;
56 static dev_info_t *ppp_dip;
58 static struct cb_ops cb_ppp_ops = {
59 nulldev, nulldev, nodev, nodev, /* cb_open, ... */
60 nodev, nodev, nodev, nodev, /* cb_dump, ... */
61 nodev, nodev, nodev, nochpoll, /* cb_devmap, ... */
62 ddi_prop_op, /* cb_prop_op */
63 &pppinfo, /* cb_stream */
64 D_NEW|D_MP|D_MTQPAIR|D_MTOUTPERIM|D_MTOCEXCL /* cb_flag */
67 static struct dev_ops ppp_ops = {
68 DEVO_REV, /* devo_rev */
69 0, /* devo_refcnt */
70 ppp_devinfo, /* devo_getinfo */
71 ppp_identify, /* devo_identify */
72 nulldev, /* devo_probe */
73 ppp_attach, /* devo_attach */
74 ppp_detach, /* devo_detach */
75 nodev, /* devo_reset */
76 &cb_ppp_ops, /* devo_cb_ops */
77 NULL /* devo_bus_ops */
81 * Module linkage information
84 static struct modldrv modldrv = {
85 &mod_driverops, /* says this is a pseudo driver */
86 "PPP-2.3 multiplexing driver",
87 &ppp_ops /* driver ops */
90 static struct modlinkage modlinkage = {
91 MODREV_1,
92 (void *) &modldrv,
93 NULL
96 int
97 _init(void)
99 return mod_install(&modlinkage);
103 _fini(void)
105 return mod_remove(&modlinkage);
109 _info(mip)
110 struct modinfo *mip;
112 return mod_info(&modlinkage, mip);
115 static int
116 ppp_identify(dip)
117 dev_info_t *dip;
119 return strcmp(ddi_get_name(dip), "ppp") == 0? DDI_IDENTIFIED:
120 DDI_NOT_IDENTIFIED;
123 static int
124 ppp_attach(dip, cmd)
125 dev_info_t *dip;
126 ddi_attach_cmd_t cmd;
129 if (cmd != DDI_ATTACH)
130 return DDI_FAILURE;
131 if (ddi_create_minor_node(dip, "ppp", S_IFCHR, 0, DDI_PSEUDO, CLONE_DEV)
132 == DDI_FAILURE) {
133 ddi_remove_minor_node(dip, NULL);
134 return DDI_FAILURE;
136 rw_init(&ppp_lower_lock, NULL, RW_DRIVER, NULL);
137 return DDI_SUCCESS;
140 static int
141 ppp_detach(dip, cmd)
142 dev_info_t *dip;
143 ddi_detach_cmd_t cmd;
145 rw_destroy(&ppp_lower_lock);
146 ddi_remove_minor_node(dip, NULL);
147 return DDI_SUCCESS;
150 static int
151 ppp_devinfo(dip, cmd, arg, result)
152 dev_info_t *dip;
153 ddi_info_cmd_t cmd;
154 void *arg;
155 void **result;
157 int error;
159 error = DDI_SUCCESS;
160 switch (cmd) {
161 case DDI_INFO_DEVT2DEVINFO:
162 if (ppp_dip == NULL)
163 error = DDI_FAILURE;
164 else
165 *result = (void *) ppp_dip;
166 break;
167 case DDI_INFO_DEVT2INSTANCE:
168 *result = NULL;
169 break;
170 default:
171 error = DDI_FAILURE;
173 return error;