]> git.ozlabs.org Git - ppp.git/blobdiff - osf1/ppp_init.c
mods from ftw
[ppp.git] / osf1 / ppp_init.c
index e39d259ff8df88e2b33403e9d6583ed33b43e081..f40f8c5e3391a99561d4b9b5dab599b0b5827f9f 100644 (file)
 /*
  *  ppp_init.c --- PPP initialization/configuration for OSF/1.
  *
+ * Get rid of svr4-style interface flag since the driver bits use
+ * use the old calling conventions.
+ *
+ * Configure should return ENOTSUP instead of EINVAL
+ *
+ * Use sysconfigtab framework
+ *
+ * Defer initialization callback until later in boot, to avoid panic.
+ *
  *  Note:  Checks for #ifdef CFG_OP_CONFIGURE is my cheap way of telling
  *      whether this system is V3.0+ or V2.0.  Is there a better way?  srt
+ *  Note:  Checks for #ifdef CFG_PT_VM_AVAIL is my cheap way of telling
+ *      whether this system is V4.0+ or earlier. smd
  */
 
 #include <sys/sysconfig.h>
 #include <sys/stream.h>
 
-#ifndef PPP_VD
-#include "ppp.h"
-#endif
-
 static int configured = 0;
-static struct streamadm        tmpl_sa = { OSF_STREAMS_11,
-    STR_IS_MODULE|STR_SYSV4_OPEN,
-    NULL,
-    SQLVL_MODULE,
-    NULL };
-
+static struct streamadm        tmpl_sa = {
+    OSF_STREAMS_11,
+    STR_IS_MODULE,
+    { NULL },  /* sa_name, filled in at boot time */
+    NULL,      /* sa_ttys */
+    SQLVL_ELSEWHERE,
+    "ppp"      /* "global" sync across all PPP modules */
+};
 
-extern struct streamtab ppp_asyncinfo;
-extern struct streamtab ppp_ifinfo;
+extern struct streamtab ppp_ahdlcinfo;
+extern struct streamtab if_pppinfo;
 extern struct streamtab ppp_compinfo;
+extern struct streamtab pppinfo;
 
 #ifdef CFG_OP_CONFIGURE
+/* the number of actual PPP interfaces is extended
+ * on-the-fly, as needed
+ */
+static int nppp = 1;
+
 cfg_subsys_attr_t ppp_attributes[] = {
-    {"", 0, 0, 0, 0, 0, 0}
+    {"nppp",       CFG_ATTR_INTTYPE, 
+       CFG_OP_QUERY | CFG_OP_CONFIGURE,
+       (caddr_t) &nppp, 1, 1024, 0},
+    {"", 0, 0, 0, 0, 0, 0} /* must be the last element */
 };
 #else
 typedef sysconfig_op_t cfg_op_t;
 #endif
 
+/* Add the PPP streams modules to the pool of available modules.
+ * If for some reason we can't add one of them, then remove the
+ * ones we did succeed in adding.
+ */
+static int
+ppp_initialize()
+{
+    dev_t devno = NODEV;
+    int ret = ESUCCESS;
+
+    if (!configured) {
+       strcpy(tmpl_sa.sa_name, "if_ppp");
+       if ((devno = strmod_add(NODEV, &if_pppinfo, &tmpl_sa)) == NODEV)
+           ret = ENODEV;
+
+       strcpy(tmpl_sa.sa_name, "ppp_ahdl");
+       if ((devno = strmod_add(NODEV, &ppp_ahdlcinfo, &tmpl_sa)) == NODEV) {
+           strcpy(tmpl_sa.sa_name, "if_ppp");
+           strmod_del(NODEV, &if_pppinfo, &tmpl_sa);
+           ret = ENODEV;
+       }
+
+       strcpy(tmpl_sa.sa_name, "pppcomp");
+       if ((devno = strmod_add(NODEV, &ppp_compinfo, &tmpl_sa)) == NODEV) {
+           strcpy(tmpl_sa.sa_name, "if_ppp");
+           strmod_del(NODEV, &if_pppinfo, &tmpl_sa);
+           strcpy(tmpl_sa.sa_name, "ppp_ahdl");
+           strmod_del(NODEV, &ppp_ahdlcinfo, &tmpl_sa);
+           ret = ENODEV;
+       }
+
+       strcpy(tmpl_sa.sa_name, "ppp");
+       tmpl_sa.sa_flags = STR_IS_DEVICE;
+       if ((devno = strmod_add(NODEV, &pppinfo, &tmpl_sa)) == NODEV) {
+           tmpl_sa.sa_flags = STR_IS_MODULE;
+           strcpy(tmpl_sa.sa_name, "if_ppp");
+           strmod_del(NODEV, &if_pppinfo, &tmpl_sa);
+           strcpy(tmpl_sa.sa_name, "ppp_ahdl");
+           strmod_del(NODEV, &ppp_ahdlcinfo, &tmpl_sa);
+           strcpy(tmpl_sa.sa_name, "pppcomp");
+           strmod_del(NODEV, &ppp_compinfo, &tmpl_sa);
+           ret = ENODEV;
+       }
+       configured = 1;
+    } else
+       ret = EINVAL;
+
+    return(ret);
+}
+
+#ifdef CFG_PT_VM_AVAIL
+static void
+ppp_callback(point, order, arg, event_arg)
+int    point;
+int    order;
+ulong  arg;
+ulong  event_arg;
+{
+    int ret;
+
+    ret = ppp_initialize();
+
+    return;            /* _callback returns void, losing info */
+}
+#endif /* CFG_PT_VM_AVAIL */
+
 int
 ppp_configure(op, indata, indata_size, outdata, outdata_size)
 cfg_op_t  op;
 char *indata, *outdata;
 ulong indata_size, outdata_size;
 {
-    dev_t devno = NODEV;
     int ret = ESUCCESS;
-    int i;
 
     switch (op) {
 
@@ -48,42 +130,33 @@ ulong indata_size, outdata_size;
       case CFG_OP_CONFIGURE:
 #else
       case SYSCONFIG_CONFIGURE:
-#endif
-       if (!configured) {
-           strcpy(tmpl_sa.sa_name, "pppif");
-           if ((devno=strmod_add(NODEV, &ppp_ifinfo, &tmpl_sa)) == NODEV)
-               return(ENODEV);
-
-           strcpy(tmpl_sa.sa_name, "pppasync");
-           if ((devno=strmod_add(NODEV, &ppp_asyncinfo, &tmpl_sa)) == NODEV) {
-               strcpy(tmpl_sa.sa_name, "pppif");
-               strmod_del(NODEV, &ppp_ifinfo, &tmpl_sa);
-               return(ENODEV);
-           }
+#endif /* CFG_OP_CONFIGURE */
+
+#ifdef CFG_PT_VM_AVAIL
+       ret = register_callback(ppp_callback, 
+               CFG_PT_OLD_CONF_ALL, CFG_ORD_DONTCARE, 0L);
+#else
+       ret = ppp_initialize();
+#endif /* CFG_PT_VM_AVAIL */
 
-           strcpy(tmpl_sa.sa_name, "pppcomp");
-           if ((devno = strmod_add(NODEV, &ppp_compinfo, &tmpl_sa)) == NODEV) {
-               strcpy(tmpl_sa.sa_name, "pppif");
-               strmod_del(NODEV, &ppp_ifinfo, &tmpl_sa);
-               strcpy(tmpl_sa.sa_name, "pppasync");
-               strmod_del(NODEV, &ppp_asyncinfo, &tmpl_sa);
-               return(ENODEV);
-           }
-
-           ppp_attach();
-
-           configured = 1;
-       } else
-           ret = EINVAL;
        break;
 
+#ifdef CFG_OP_QUERY
+      case CFG_OP_QUERY:
+#else
+      case SYSCONFIG_QUERY:
+#endif
+        break;
+
+#ifdef CFG_OP_RECONFIGURE
+      case CFG_OP_RECONFIGURE:
+        break;
+#endif
+
       default:
-       ret = EINVAL;
+       ret = ENOTSUP;
        break;
     }
 
     return(ret);
 }
-                                   
-
-