]> git.ozlabs.org Git - ppp.git/blobdiff - pppd/main.c
update_link_stats(): treat link stats as unsigned, not signed
[ppp.git] / pppd / main.c
index a80b0a5a83f5aa0b79459352ecbaf1104b72e7d2..409628c4b0a03383d7647d32be1993851f7cce63 100644 (file)
@@ -17,7 +17,7 @@
  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#define RCSID  "$Id: main.c,v 1.110 2002/01/14 14:25:10 dfs Exp $"
+#define RCSID  "$Id: main.c,v 1.117 2002/10/27 12:04:07 fcusack Exp $"
 
 #include <stdio.h>
 #include <ctype.h>
 
 #include <stdio.h>
 #include <ctype.h>
@@ -53,6 +53,7 @@
 #include "upap.h"
 #include "chap.h"
 #include "ccp.h"
 #include "upap.h"
 #include "chap.h"
 #include "ccp.h"
+#include "ecp.h"
 #include "pathnames.h"
 
 #ifdef USE_TDB
 #include "pathnames.h"
 
 #ifdef USE_TDB
@@ -97,7 +98,8 @@ volatile int status;          /* exit status for pppd */
 int unsuccess;                 /* # unsuccessful connection attempts */
 int do_callback;               /* != 0 if we should do callback next */
 int doing_callback;            /* != 0 if we are doing callback */
 int unsuccess;                 /* # unsuccessful connection attempts */
 int do_callback;               /* != 0 if we should do callback next */
 int doing_callback;            /* != 0 if we are doing callback */
-
+int ppp_session_number;                /* Session number, for channels with such a
+                                  concept (eg PPPoE) */
 #ifdef USE_TDB
 TDB_CONTEXT *pppdb;            /* database for storing status etc. */
 #endif
 #ifdef USE_TDB
 TDB_CONTEXT *pppdb;            /* database for storing status etc. */
 #endif
@@ -106,6 +108,8 @@ char db_key[32];
 
 int (*holdoff_hook) __P((void)) = NULL;
 int (*new_phase_hook) __P((int)) = NULL;
 
 int (*holdoff_hook) __P((void)) = NULL;
 int (*new_phase_hook) __P((int)) = NULL;
+void (*snoop_recv_hook) __P((unsigned char *p, int len)) = NULL;
+void (*snoop_send_hook) __P((unsigned char *p, int len)) = NULL;
 
 static int conn_running;       /* we have a [dis]connector running */
 static int devfd;              /* fd of underlying device */
 
 static int conn_running;       /* we have a [dis]connector running */
 static int devfd;              /* fd of underlying device */
@@ -218,6 +222,7 @@ struct protent *protocols[] = {
     &ipv6cp_protent,
 #endif
     &ccp_protent,
     &ipv6cp_protent,
 #endif
     &ccp_protent,
+    &ecp_protent,
 #ifdef IPX_CHANGE
     &ipxcp_protent,
 #endif
 #ifdef IPX_CHANGE
     &ipxcp_protent,
 #endif
@@ -355,10 +360,19 @@ main(argc, argv)
        init_pr_log(NULL, LOG_INFO);
        print_options(pr_log, NULL);
        end_pr_log();
        init_pr_log(NULL, LOG_INFO);
        print_options(pr_log, NULL);
        end_pr_log();
-       if (dryrun)
-           die(0);
     }
 
     }
 
+    /*
+     * Early check for remote number authorization.
+     */
+    if (!auth_number()) {
+       warn("calling number %q is not authorized", remote_number);
+       exit(EXIT_CNID_AUTH_FAILED);
+    }
+
+    if (dryrun)
+       die(0);
+
     /*
      * Initialize system-dependent stuff.
      */
     /*
      * Initialize system-dependent stuff.
      */
@@ -966,6 +980,7 @@ get_input()
     }
 
     dump_packet("rcvd", p, len);
     }
 
     dump_packet("rcvd", p, len);
+    if (snoop_recv_hook) snoop_recv_hook(p, len);
 
     p += 2;                            /* Skip address and control */
     GETSHORT(protocol, p);
 
     p += 2;                            /* Skip address and control */
     GETSHORT(protocol, p);
@@ -1101,11 +1116,11 @@ update_link_stats(u)
     link_connect_time = now.tv_sec - start_time.tv_sec;
     link_stats_valid = 1;
 
     link_connect_time = now.tv_sec - start_time.tv_sec;
     link_stats_valid = 1;
 
-    slprintf(numbuf, sizeof(numbuf), "%d", link_connect_time);
+    slprintf(numbuf, sizeof(numbuf), "%u", link_connect_time);
     script_setenv("CONNECT_TIME", numbuf, 0);
     script_setenv("CONNECT_TIME", numbuf, 0);
-    slprintf(numbuf, sizeof(numbuf), "%d", link_stats.bytes_out);
+    slprintf(numbuf, sizeof(numbuf), "%u", link_stats.bytes_out);
     script_setenv("BYTES_SENT", numbuf, 0);
     script_setenv("BYTES_SENT", numbuf, 0);
-    slprintf(numbuf, sizeof(numbuf), "%d", link_stats.bytes_in);
+    slprintf(numbuf, sizeof(numbuf), "%u", link_stats.bytes_in);
     script_setenv("BYTES_RCVD", numbuf, 0);
 }
 
     script_setenv("BYTES_RCVD", numbuf, 0);
 }
 
@@ -1666,7 +1681,7 @@ remove_notifier(notif, func, arg)
 }
 
 /*
 }
 
 /*
- * notify - call a set of functions registered with add_notify.
+ * notify - call a set of functions registered with add_notifier.
  */
 void
 notify(notif, val)
  */
 void
 notify(notif, val)