1#include <sys/types.h>
2#include <sys/errno.h>
3#include <sys/conf.h>
4#include <sun/vddrv.h>
5
6extern struct streamtab ppp_ahdlcinfo;
7extern int ppp_ahdlc_count;
8
9static struct vdldrv vd = {
10    VDMAGIC_USER,
11    "ppp_ahdl"
12};
13
14static int fmodsw_index = -1;
15
16int
17ppp_ahdlc_vdcmd(fun, vdp, vdi, vds)
18    unsigned int fun;
19    struct vddrv *vdp;
20    addr_t vdi;
21    struct vdstat *vds;
22{
23    int n;
24
25    switch (fun) {
26    case VDLOAD:
27	vdp->vdd_vdtab = (struct vdlinkage *) &vd;
28	if (fmodsw_index >= 0)
29	    return EBUSY;
30	for (n = 0; n < fmodcnt; ++n)
31	    if (fmodsw[n].f_str == 0)
32		break;
33	if (n >= fmodcnt)
34	    return ENODEV;
35	strncpy(fmodsw[n].f_name, vd.Drv_name, FMNAMESZ+1);
36	fmodsw[n].f_str = &ppp_ahdlcinfo;
37	fmodsw_index = n;
38	break;
39
40    case VDUNLOAD:
41	if (ppp_ahdlc_count > 0)
42	    return EBUSY;
43	if (fmodsw_index <= 0)
44	    return EINVAL;
45	fmodsw[fmodsw_index].f_name[0] = 0;
46	fmodsw[fmodsw_index].f_str = 0;
47	fmodsw_index = -1;
48	break;
49
50    case VDSTAT:
51	break;
52
53    default:
54	return EIO;
55    }
56    return 0;
57}
58