/*
- * *****************************************************************
- * * *
- * * Copyright (c) Digital Equipment Corporation, 1991, 1994 *
- * * *
- * * All Rights Reserved. Unpublished rights reserved under *
- * * the copyright laws of the United States. *
- * * *
- * * The software contained on this media is proprietary to *
- * * and embodies the confidential technology of Digital *
- * * Equipment Corporation. Possession, use, duplication or *
- * * dissemination of the software and media is authorized only *
- * * pursuant to a valid written license from Digital Equipment *
- * * Corporation. *
- * * *
- * * RESTRICTED RIGHTS LEGEND Use, duplication, or disclosure *
- * * by the U.S. Government is subject to restrictions as set *
- * * forth in Subparagraph (c)(1)(ii) of DFARS 252.227-7013, *
- * * or in FAR 52.227-19, as applicable. *
- * * *
- * *****************************************************************
- */
-/*
- * HISTORY
- */
-/*
- * static char *rcsid = "@(#)$RCSfile: ppp_init.c,v $ $Revision: 1.1 $ (DEC) $Date: 1995/05/22 02:30:55 $";
- */
-/*
- * (c) Copyright 1990, 1991, 1992 OPEN SOFTWARE FOUNDATION, INC.
- * ALL RIGHTS RESERVED
- */
-/*
- * OSF/1 Release 1.2
- */
-
-/*
- * template for the initialization routine for a module/driver
+ * ppp_init.c --- PPP initialization/configuration for OSF/1.
*
- * - #define STRNAME to driver/module name (with quotes)
- * (maximum length FMNAMESZ, which is fixed at 8 + trailing 0).
+ * Get rid of svr4-style interface flag since the driver bits use
+ * use the old calling conventions.
*
- * - #define STRCONFIG to the configure entry point's name
+ * Configure should return ENOTSUP instead of EINVAL
*
- * - #define STRINFO to the driver/module's info structure name.
+ * Use sysconfigtab framework
*
- * - #define STRFLAGS to STR_IS_DEVICE or STR_IS_MODULE with others
- * as appropriate (e.g. STR_SYSV4_OPEN).
+ * Defer initialization callback until later in boot, to avoid panic.
*
- * - #define STRSYNCL, STRSYNCI, STRTTYS to appropriate values if
- * not the defaults below. See the manual.
- *
- * - Include this file into module's source file,
- * preferably after the streamtab definition
- *
- * - The input buffer, indata, should be of the form "variable=value\n".
- * It should always begin with "subsys=subsystem-name\n" and it should
- * end with a '\0'. An example would be a subsystem, foo,
- * which wants to use a specific device number. The input buffer,
- * indata, should be "subsys=foo\ndevno=123\n\0".
- *
- * - If your driver should take a specific character device number,
- * be sure to pass it within indata (e.g devno=123), else look at
- * outdata for assigned value.
- *
- * - Apart from this change, you'll have to update
- *
- * - kernel/streams/str_config.c
- * (insert a call to this routine)
- * - kernel/conf/files
- * (insert module's source file)
+ * 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"
+static int configured = 0;
+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_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[] = {
+ {"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
-static struct streamadm tmpl_sa;
+/* 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;
+ }
-extern struct streamtab ppp_asyncinfo;
-extern struct streamtab ppp_ifinfo;
-extern struct streamtab ppp_compinfo;
+ 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, indatalen, outdata, outdatalen)
- sysconfig_op_t op;
- char * indata;
- size_t indatalen;
- char * outdata;
- size_t outdatalen;
+ppp_configure(op, indata, indata_size, outdata, outdata_size)
+cfg_op_t op;
+char *indata, *outdata;
+ulong indata_size, outdata_size;
{
- static dev_t devno;
- int configured;
- int size;
- int ret = 0;
- int x;
-
- switch (op) {
-
- case SYSCONFIG_CONFIGURE:
-
- tmpl_sa.sa_version = OSF_STREAMS_11;
- tmpl_sa.sa_flags = STR_IS_MODULE|STR_SYSV4_OPEN;
- tmpl_sa.sa_ttys = NULL;
- tmpl_sa.sa_sync_level = SQLVL_QUEUE;
- tmpl_sa.sa_sync_info = 0;
-
- strcpy(tmpl_sa.sa_name, "pppif");
-
- if ((devno= strmod_add(NODEV, &ppp_ifinfo, &tmpl_sa)) == NODEV)
- ret = ENODEV;
- else {
- strcpy(tmpl_sa.sa_name, "pppasync");
- if ((devno = strmod_add(NODEV, &ppp_asyncinfo, &tmpl_sa)) == NODEV)
- ret = ENODEV;
- else {
- strcpy(tmpl_sa.sa_name, "pppcomp");
- if ((devno = strmod_add(NODEV, &ppp_compinfo, &tmpl_sa)) == NODEV)
- ret = ENODEV;
- }
- }
-
- for(x = 0; x < NPPP; x ++)
- ppp_attach(x);
-
- if (outdata && outdatalen>=0)
- bcopy(indata,outdata,outdatalen);
-
- break;
-
- default:
- ret = EINVAL;
- break;
- }
+ int ret = ESUCCESS;
+
+ switch (op) {
+
+#ifdef CFG_OP_CONFIGURE
+ case CFG_OP_CONFIGURE:
+#else
+ case SYSCONFIG_CONFIGURE:
+#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 */
+
+ 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 = ENOTSUP;
+ break;
+ }
- return(ret);
+ return(ret);
}