]> git.ozlabs.org Git - ppp.git/blobdiff - pppd/options.c
don't need to be group kmem any more
[ppp.git] / pppd / options.c
index c7c4b4ea5783bef908fbe21ec4a9bd3a46aeda69..6c146a04c28ecb57cc47218296e60f5ae6f4fb06 100644 (file)
@@ -18,7 +18,7 @@
  */
 
 #ifndef lint
-static char rcsid[] = "$Id: options.c,v 1.12 1994/08/22 00:36:38 paulus Exp $";
+static char rcsid[] = "$Id: options.c,v 1.15 1994/09/16 02:34:52 paulus Exp $";
 #endif
 
 #include <stdio.h>
@@ -57,6 +57,35 @@ char *strdup __ARGS((char *));
 #define GIDSET_TYPE    gid_t
 #endif
 
+/*
+ * Option variables and default values.
+ */
+int    debug = 0;              /* Debug flag */
+int    kdebugflag = 0;         /* Tell kernel to print debug messages */
+int    default_device = 1;     /* Using /dev/tty or equivalent */
+char   devnam[MAXPATHLEN] = "/dev/tty";        /* Device name */
+int    crtscts = 0;            /* Use hardware flow control */
+int    modem = 1;              /* Use modem control lines */
+int    inspeed = 0;            /* Input/Output speed requested */
+uint32 netmask = 0;            /* IP netmask to set on interface */
+int    lockflag = 0;           /* Create lock file to lock the serial dev */
+int    nodetach = 0;           /* Don't detach from controlling tty */
+char   *connector = NULL;      /* Script to establish physical link */
+char   *disconnector = NULL;   /* Script to disestablish physical link */
+char   user[MAXNAMELEN];       /* Username for PAP */
+char   passwd[MAXSECRETLEN];   /* Password for PAP */
+int    auth_required = 0;      /* Peer is required to authenticate */
+int    defaultroute = 0;       /* assign default route through interface */
+int    proxyarp = 0;           /* Set up proxy ARP entry for peer */
+int    persist = 0;            /* Reopen link after it goes down */
+int    uselogin = 0;           /* Use /etc/passwd for checking PAP */
+int    lcp_echo_interval = 0;  /* Interval between LCP echo-requests */
+int    lcp_echo_fails = 0;     /* Tolerance to unanswered echo-requests */
+char   our_name[MAXNAMELEN];   /* Our name for authentication purposes */
+char   remote_name[MAXNAMELEN]; /* Peer's name for authentication */
+int    usehostname = 0;        /* Use hostname for our_name */
+int    disable_defaultip = 0;  /* Don't use hostname for default IP adrs */
+
 /*
  * Prototypes
  */
@@ -89,6 +118,7 @@ static int setdisconnector __ARGS((char **));
 static int setdomain __ARGS((char **));
 static int setnetmask __ARGS((char **));
 static int setcrtscts __ARGS((void));
+static int setnocrtscts __ARGS((void));
 static int setxonxoff __ARGS((void));
 static int setnodetach __ARGS((void));
 static int setmodem __ARGS((void));
@@ -128,36 +158,6 @@ static int setnobsdcomp __ARGS((void));
 static int number_option __ARGS((char *, long *, int));
 static int readable __ARGS((int fd));
 
-/*
- * Option variables
- */
-extern char *progname;
-extern int debug;
-extern int kdebugflag;
-extern int modem;
-extern int lockflag;
-extern int crtscts;
-extern int nodetach;
-extern char *connector;
-extern char *disconnector;
-extern int inspeed;
-extern char devnam[];
-extern int default_device;
-extern u_long netmask;
-extern int detach;
-extern char user[];
-extern char passwd[];
-extern int auth_required;
-extern int proxyarp;
-extern int persist;
-extern int uselogin;
-extern u_long lcp_echo_interval;
-extern u_long lcp_echo_fails;
-extern char our_name[];
-extern char remote_name[];
-int usehostname;
-int disable_defaultip;
-
 /*
  * Valid arguments.
  */
@@ -190,8 +190,8 @@ static struct cmd {
     {"connect", 1, setconnector}, /* A program to set up a connection */
     {"disconnect", 1, setdisconnector},        /* program to disconnect serial dev. */
     {"crtscts", 0, setcrtscts},        /* set h/w flow control */
+    {"-crtscts", 0, setnocrtscts}, /* clear h/w flow control */
     {"xonxoff", 0, setxonxoff},        /* set s/w flow control */
-    {"-crtscts", 0, setxonxoff}, /* another name for xonxoff */
     {"debug", 0, setdebug},    /* Increase debugging level */
     {"kdebug", 1, setkdebug},  /* Enable kernel-level debugging */
     {"domain", 1, setdomain},  /* Add given domain name to hostname*/
@@ -1086,7 +1086,7 @@ setipaddr(arg)
 {
     struct hostent *hp;
     char *colon, *index();
-    u_long local, remote;
+    uint32 local, remote;
     ipcp_options *wo = &ipcp_wantoptions[0];
   
     /*
@@ -1189,7 +1189,7 @@ void
 setipdefault()
 {
     struct hostent *hp;
-    u_long local;
+    uint32 local;
     ipcp_options *wo = &ipcp_wantoptions[0];
 
     /*
@@ -1219,7 +1219,7 @@ static int
 setnetmask(argv)
     char **argv;
 {
-    u_long mask;
+    uint32 mask;
 
     if ((mask = inet_addr(*argv)) == -1 || (netmask & ~mask) != 0) {
        fprintf(stderr, "Invalid netmask %s\n", *argv);
@@ -1235,9 +1235,9 @@ setnetmask(argv)
  * been set. 
  */
 /* ARGSUSED */
-u_long
+uint32
 GetMask(addr)
-    u_long addr;
+    uint32 addr;
 {
     return(netmask);
 }
@@ -1250,6 +1250,13 @@ setcrtscts()
     return (1);
 }
 
+static int
+setnocrtscts()
+{
+    crtscts = -1;
+    return (1);
+}
+
 static int
 setxonxoff()
 {
@@ -1459,16 +1466,41 @@ static int setchapintv(argv)
 static int setbsdcomp(argv)
     char **argv;
 {
-    int bits;
+    int rbits, abits;
+    char *str, *endp;
 
-    if (!int_option(*argv, &bits))
+    str = *argv;
+    abits = rbits = strtol(str, &endp, 0);
+    if (endp != str && *endp == ',') {
+       str = endp + 1;
+       abits = strtol(str, &endp, 0);
+    }
+    if (*endp != 0 || endp == str) {
+       fprintf(stderr, "%s: invalid argument format for bsdcomp option\n",
+               progname);
+       return 0;
+    }
+    if (rbits != 0 && (rbits < MIN_BSD_BITS || rbits > MAX_BSD_BITS)
+       || abits != 0 && (abits < MIN_BSD_BITS || abits > MAX_BSD_BITS)) {
+       fprintf(stderr, "%s: bsdcomp option values must be 0 or %d .. %d\n",
+               progname, MIN_BSD_BITS, MAX_BSD_BITS);
        return 0;
-    ccp_wantoptions[0].bsd_compress = 1;
-    ccp_wantoptions[0].bsd_bits = bits;
+    }
+    if (rbits > 0) {
+       ccp_wantoptions[0].bsd_compress = 1;
+       ccp_wantoptions[0].bsd_bits = rbits;
+    } else
+       ccp_wantoptions[0].bsd_compress = 0;
+    if (abits > 0) {
+       ccp_allowoptions[0].bsd_compress = 1;
+       ccp_allowoptions[0].bsd_bits = abits;
+    } else
+       ccp_allowoptions[0].bsd_compress = 0;
     return 1;
 }
 
 static int setnobsdcomp()
 {
+    ccp_wantoptions[0].bsd_compress = 0;
     ccp_allowoptions[0].bsd_compress = 0;
 }