Don't fall over if the channel doesn't have a disconnect method.
[mpls-ppp.git] / sunos4 / ppp_vdcmd.c
blob68095c92ec7cf9de6a4a8729954dc9ee58c6cb95
1 #include <sys/types.h>
2 #include <sys/errno.h>
3 #include <sys/conf.h>
4 #include <sun/vddrv.h>
6 extern struct streamtab pppinfo;
7 extern int ppp_count;
8 extern int nchrdev;
10 static struct vdldrv vd = {
11 VDMAGIC_PSEUDO,
12 "ppp"
15 extern int nodev();
17 static struct cdevsw ppp_cdevsw = {
18 nodev, nodev, nodev, nodev, nodev, nodev, nodev, 0,
19 &pppinfo
22 static struct cdevsw old_entry;
24 int
25 ppp_vdcmd(fun, vdp, vdi, vds)
26 unsigned int fun;
27 struct vddrv *vdp;
28 addr_t vdi;
29 struct vdstat *vds;
31 static int majnum = -1;
32 int n, maj;
34 switch (fun) {
35 case VDLOAD:
37 * It seems like modload doesn't install the cdevsw entry
38 * for us. Oh well...
40 for (maj = 1; maj < nchrdev; ++maj)
41 if (cdevsw[maj].d_open == vd_unuseddev)
42 break;
43 if (maj >= nchrdev)
44 return ENODEV;
45 vd.Drv_charmajor = maj;
46 old_entry = cdevsw[maj];
47 cdevsw[maj] = ppp_cdevsw;
48 vd.Drv_cdevsw = &ppp_cdevsw;
49 vdp->vdd_vdtab = (struct vdlinkage *) &vd;
50 majnum = maj;
51 break;
53 case VDUNLOAD:
54 if (ppp_count > 0)
55 return EBUSY;
56 if (vd.Drv_charmajor > 0)
57 cdevsw[vd.Drv_charmajor] = old_entry;
58 break;
60 case VDSTAT:
62 * We have to fool the modstat command into thinking
63 * that this module is actually a driver! This is
64 * so that installation commands that use the -exec
65 * option of modload to run a shell script find out
66 * the block and/or char major numbers of the driver
67 * loaded (so that the shell script can go off to
68 * /dev and *MAKE* the bloody device nodes- remember
69 * they might change from one load to another if
70 * you don't hardwire the number!).
72 vds->vds_magic = VDMAGIC_DRV;
73 vds->vds_modinfo[0] = (char) 0;
74 vds->vds_modinfo[1] = (char) majnum;
75 break;
77 default:
78 return EIO;
80 return 0;