]> git.ozlabs.org Git - ppp.git/blobdiff - pppd/main.c
minor bugfixes, now 2.4.2b1, add pkts_in/out to pppd_stats,
[ppp.git] / pppd / main.c
index 24f88ec9934b588866713b1b790fc02c2ca37b13..498f856430ce8244b1bc45a084d645a8225f2958 100644 (file)
@@ -17,7 +17,7 @@
  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#define RCSID  "$Id: main.c,v 1.103 2001/03/08 05:11:14 paulus Exp $"
+#define RCSID  "$Id: main.c,v 1.106 2001/04/27 23:16:13 paulus Exp $"
 
 #include <stdio.h>
 #include <ctype.h>
@@ -304,11 +304,8 @@ main(argc, argv)
     if (the_channel->process_extra_options)
        (*the_channel->process_extra_options)();
 
-    if (dump_options || dryrun) {
-       init_pr_log(NULL, LOG_INFO);
-       print_options(pr_log, NULL);
-       end_pr_log();
-    }
+    if (debug)
+       setlogmask(LOG_UPTO(LOG_DEBUG));
 
     /*
      * Check that we are running as root.
@@ -340,15 +337,19 @@ main(argc, argv)
     if (the_channel->check_options)
        (*the_channel->check_options)();
 
+
+    if (dump_options || dryrun) {
+       init_pr_log(NULL, LOG_INFO);
+       print_options(pr_log, NULL);
+       end_pr_log();
+       if (dryrun)
+           die(0);
+    }
+
     /*
      * Initialize system-dependent stuff.
      */
     sys_init();
-    if (debug)
-       setlogmask(LOG_UPTO(LOG_DEBUG));
-
-    if (dryrun)
-       die(0);
 
     pppdb = tdb_open(_PATH_PPPDB, 0, 0, O_RDWR|O_CREAT, 0644);
     if (pppdb != NULL) {
@@ -452,7 +453,7 @@ main(argc, argv)
 
        /* set up the serial device as a ppp interface */
        tdb_writelock(pppdb);
-       fd_ppp = establish_ppp(devfd);
+       fd_ppp = the_channel->establish_ppp(devfd);
        if (fd_ppp < 0) {
            tdb_writeunlock(pppdb);
            status = EXIT_FATAL_ERROR;
@@ -498,7 +499,7 @@ main(argc, argv)
        if (link_stats_valid) {
            int t = (link_connect_time + 5) / 6;    /* 1/10ths of minutes */
            info("Connect time %d.%d minutes.", t/10, t%10);
-           info("Sent %d bytes, received %d bytes.",
+           info("Sent %u bytes, received %u bytes.",
                 link_stats.bytes_out, link_stats.bytes_in);
        }
 
@@ -521,9 +522,7 @@ main(argc, argv)
         */
        remove_fd(fd_ppp);
        clean_check();
-       if (demand)
-           restore_loop();
-       disestablish_ppp(devfd);        /* XXX */
+       the_channel->disestablish_ppp(devfd);
        fd_ppp = -1;
        if (!hungup)
            lcp_lowerdown(0);
@@ -1036,7 +1035,7 @@ cleanup()
     sys_cleanup();
 
     if (fd_ppp >= 0)
-       disestablish_ppp(devfd);
+       the_channel->disestablish_ppp(devfd);
     if (the_channel->cleanup)
        (*the_channel->cleanup)();
 
@@ -1088,9 +1087,6 @@ static struct timeval timenow;            /* Current time */
 
 /*
  * timeout - Schedule a timeout.
- *
- * Note that this timeout takes the number of milliseconds, NOT hz (as in
- * the kernel).
  */
 void
 timeout(func, arg, secs, usecs)
@@ -1099,10 +1095,10 @@ timeout(func, arg, secs, usecs)
     int secs, usecs;
 {
     struct callout *newp, *p, **pp;
-  
+
     MAINDEBUG(("Timeout %p:%p in %d.%03d seconds.", func, arg,
-              time / 1000, time % 1000));
-  
+              secs, usecs/1000));
+
     /*
      * Allocate timeout.
      */