]> git.ozlabs.org Git - ppp.git/blob - osf1/ppp_init.c
Fixed bugs with regards to using other device names than "ppp"
[ppp.git] / osf1 / ppp_init.c
1 /*
2  *  ppp_init.c --- PPP initialization/configuration for OSF/1.
3  *
4  * Get rid of svr4-style interface flag since the driver bits use
5  * use the old calling conventions.
6  *
7  * Configure should return ENOTSUP instead of EINVAL
8  *
9  * Use sysconfigtab framework
10  *
11  * Defer initialization callback until later in boot, to avoid panic.
12  *
13  *  Note:  Checks for #ifdef CFG_OP_CONFIGURE is my cheap way of telling
14  *      whether this system is V3.0+ or V2.0.  Is there a better way?  srt
15  *  Note:  Checks for #ifdef CFG_PT_VM_AVAIL is my cheap way of telling
16  *      whether this system is V4.0+ or earlier. smd
17  */
18
19 #include <sys/sysconfig.h>
20 #include <sys/stream.h>
21
22 static int configured = 0;
23 static struct streamadm tmpl_sa = {
24     OSF_STREAMS_11,
25     STR_IS_MODULE,
26     { NULL },   /* sa_name, filled in at boot time */
27     NULL,       /* sa_ttys */
28     SQLVL_ELSEWHERE,
29     "ppp"       /* "global" sync across all PPP modules */
30 };
31
32 extern struct streamtab ppp_ahdlcinfo;
33 extern struct streamtab if_pppinfo;
34 extern struct streamtab ppp_compinfo;
35 extern struct streamtab pppinfo;
36
37 #ifdef CFG_OP_CONFIGURE
38 /* the number of actual PPP interfaces is extended
39  * on-the-fly, as needed
40  */
41 static int nppp = 1;
42
43 cfg_subsys_attr_t ppp_attributes[] = {
44     {"nppp",       CFG_ATTR_INTTYPE, 
45         CFG_OP_QUERY | CFG_OP_CONFIGURE,
46         (caddr_t) &nppp, 1, 1024, 0},
47     {"", 0, 0, 0, 0, 0, 0} /* must be the last element */
48 };
49 #else
50 typedef sysconfig_op_t cfg_op_t;
51 #endif
52
53 /* Add the PPP streams modules to the pool of available modules.
54  * If for some reason we can't add one of them, then remove the
55  * ones we did succeed in adding.
56  */
57 static int
58 ppp_initialize()
59 {
60     dev_t devno = NODEV;
61     int ret = ESUCCESS;
62
63     if (!configured) {
64         strcpy(tmpl_sa.sa_name, "if_ppp");
65         if ((devno = strmod_add(NODEV, &if_pppinfo, &tmpl_sa)) == NODEV)
66             ret = ENODEV;
67
68         strcpy(tmpl_sa.sa_name, "ppp_ahdl");
69         if ((devno = strmod_add(NODEV, &ppp_ahdlcinfo, &tmpl_sa)) == NODEV) {
70             strcpy(tmpl_sa.sa_name, "if_ppp");
71             strmod_del(NODEV, &if_pppinfo, &tmpl_sa);
72             ret = ENODEV;
73         }
74
75         strcpy(tmpl_sa.sa_name, "pppcomp");
76         if ((devno = strmod_add(NODEV, &ppp_compinfo, &tmpl_sa)) == NODEV) {
77             strcpy(tmpl_sa.sa_name, "if_ppp");
78             strmod_del(NODEV, &if_pppinfo, &tmpl_sa);
79             strcpy(tmpl_sa.sa_name, "ppp_ahdl");
80             strmod_del(NODEV, &ppp_ahdlcinfo, &tmpl_sa);
81             ret = ENODEV;
82         }
83
84         strcpy(tmpl_sa.sa_name, "ppp");
85         tmpl_sa.sa_flags = STR_IS_DEVICE;
86         if ((devno = strmod_add(NODEV, &pppinfo, &tmpl_sa)) == NODEV) {
87             tmpl_sa.sa_flags = STR_IS_MODULE;
88             strcpy(tmpl_sa.sa_name, "if_ppp");
89             strmod_del(NODEV, &if_pppinfo, &tmpl_sa);
90             strcpy(tmpl_sa.sa_name, "ppp_ahdl");
91             strmod_del(NODEV, &ppp_ahdlcinfo, &tmpl_sa);
92             strcpy(tmpl_sa.sa_name, "pppcomp");
93             strmod_del(NODEV, &ppp_compinfo, &tmpl_sa);
94             ret = ENODEV;
95         }
96         configured = 1;
97     } else
98         ret = EINVAL;
99
100     return(ret);
101 }
102
103 #ifdef CFG_PT_VM_AVAIL
104 static void
105 ppp_callback(point, order, arg, event_arg)
106 int     point;
107 int     order;
108 ulong   arg;
109 ulong   event_arg;
110 {
111     int ret;
112
113     ret = ppp_initialize();
114
115     return;             /* _callback returns void, losing info */
116 }
117 #endif /* CFG_PT_VM_AVAIL */
118
119 int
120 ppp_configure(op, indata, indata_size, outdata, outdata_size)
121 cfg_op_t  op;
122 char *indata, *outdata;
123 ulong indata_size, outdata_size;
124 {
125     int ret = ESUCCESS;
126
127     switch (op) {
128
129 #ifdef CFG_OP_CONFIGURE
130       case CFG_OP_CONFIGURE:
131 #else
132       case SYSCONFIG_CONFIGURE:
133 #endif /* CFG_OP_CONFIGURE */
134
135 #ifdef CFG_PT_VM_AVAIL
136         ret = register_callback(ppp_callback, 
137                 CFG_PT_OLD_CONF_ALL, CFG_ORD_DONTCARE, 0L);
138 #else
139         ret = ppp_initialize();
140 #endif /* CFG_PT_VM_AVAIL */
141
142         break;
143
144 #ifdef CFG_OP_QUERY
145       case CFG_OP_QUERY:
146 #else
147       case SYSCONFIG_QUERY:
148 #endif
149         break;
150
151 #ifdef CFG_OP_RECONFIGURE
152       case CFG_OP_RECONFIGURE:
153         break;
154 #endif
155
156       default:
157         ret = ENOTSUP;
158         break;
159     }
160
161     return(ret);
162 }