]> git.ozlabs.org Git - ppp.git/commitdiff
add dump_packet, don't log lcp echo request/reply messages once
authorPaul Mackerras <paulus@samba.org>
Wed, 23 May 2001 03:39:14 +0000 (03:39 +0000)
committerPaul Mackerras <paulus@samba.org>
Wed, 23 May 2001 03:39:14 +0000 (03:39 +0000)
the link is up unless debug >= 2

pppd/main.c
pppd/pppd.h
pppd/sys-linux.c
pppd/sys-solaris.c
pppd/sys-sunos4.c
pppd/sys-svr4.c
pppd/utils.c

index 498f856430ce8244b1bc45a084d645a8225f2958..a09590e9509341cb33cc6955f1163b8c8a5b6e50 100644 (file)
@@ -17,7 +17,7 @@
  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#define RCSID  "$Id: main.c,v 1.106 2001/04/27 23:16:13 paulus Exp $"
+#define RCSID  "$Id: main.c,v 1.107 2001/05/23 03:39:13 paulus Exp $"
 
 #include <stdio.h>
 #include <ctype.h>
@@ -468,7 +468,10 @@ main(argc, argv)
         * Start opening the connection and wait for
         * incoming events (reply, timeout, etc.).
         */
-       notice("Connect: %s <--> %s", ifname, ppp_devnam);
+       if (ifunit >= 0)
+               notice("Connect: %s <--> %s", ifname, ppp_devnam);
+       else
+               notice("Starting negotiation on %s", ppp_devnam);
        gettimeofday(&start_time, NULL);
        link_stats_valid = 0;
        script_unsetenv("CONNECT_TIME");
@@ -942,14 +945,13 @@ get_input()
        return;
     }
 
-    if (debug /*&& (debugflags & DBG_INPACKET)*/)
-       dbglog("rcvd %P", p, len);
-
     if (len < PPP_HDRLEN) {
-       MAINDEBUG(("io(): Received short packet."));
+       dbglog("received short packet:%.*B", len, p);
        return;
     }
 
+    dump_packet("rcvd", p, len);
+
     p += 2;                            /* Skip address and control */
     GETSHORT(protocol, p);
     len -= PPP_HDRLEN;
index 0437e7b8f56f05d3f4bd1c34bf6eeede61f8d0c8..9e03a12c1f743f9115c70d9350521494799d6b42 100644 (file)
@@ -16,7 +16,7 @@
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- * $Id: pppd.h,v 1.61 2001/05/23 02:28:14 paulus Exp $
+ * $Id: pppd.h,v 1.62 2001/05/23 03:39:13 paulus Exp $
  */
 
 /*
@@ -447,6 +447,8 @@ void fatal __P((char *, ...));      /* log an error message and die(1) */
 void init_pr_log __P((char *, int));   /* initialize for using pr_log */
 void pr_log __P((void *, char *, ...));        /* printer fn, output to syslog */
 void end_pr_log __P((void));   /* finish up after using pr_log */
+void dump_packet __P((const char *, u_char *, int));
+                               /* dump packet to debug log if interesting */
 
 /* Procedures exported from auth.c */
 void link_required __P((int));   /* we are starting to use the link */
index 252262e0196d7abe8a09566c97e3ca235d39d3c6..918fa72c23dd0cca6fcc7295df5c5dca8e0d6443 100644 (file)
@@ -945,8 +945,7 @@ void output (int unit, unsigned char *p, int len)
     int fd = ppp_fd;
     int proto;
 
-    if (debug)
-       dbglog("sent %P", p, len);
+    dump_packet("sent", p, len);
 
     if (len < PPP_HDRLEN)
        return;
index ff9c7def8d6071cdb60f75395492c90c3b99943d..fed68f50f8213b167583fe7ff8e013df2093361a 100644 (file)
@@ -42,7 +42,7 @@
  * OR MODIFICATIONS.
  */
 
-#define RCSID  "$Id: sys-solaris.c,v 1.5 2001/04/27 23:16:13 paulus Exp $"
+#define RCSID  "$Id: sys-solaris.c,v 1.6 2001/05/23 03:39:13 paulus Exp $"
 
 #include <limits.h>
 #include <stdio.h>
@@ -1292,8 +1292,7 @@ output(unit, p, len)
     int retries;
     struct pollfd pfd;
 
-    if (debug)
-       dbglog("sent %P", p, len);
+    dump_packet("sent", p, len);
 
     data.len = len;
     data.buf = (caddr_t) p;
index 9159b4cd7f49a9f2504bfd1aedf54dc9844a10c3..75e2120fc39ae1a3ae9c8ea0ee8891ae22141fae 100644 (file)
@@ -25,7 +25,7 @@
  * OR MODIFICATIONS.
  */
 
-#define RCSID  "$Id: sys-sunos4.c,v 1.27 2001/04/27 23:16:13 paulus Exp $"
+#define RCSID  "$Id: sys-sunos4.c,v 1.28 2001/05/23 03:39:13 paulus Exp $"
 
 #include <stdio.h>
 #include <stddef.h>
@@ -574,8 +574,7 @@ output(unit, p, len)
     int retries;
     struct pollfd pfd;
 
-    if (debug)
-       dbglog("sent %P", p, len);
+    dump_packet("sent", p, len);
 
     data.len = len;
     data.buf = (caddr_t) p;
index c64a78ae34826eed62e6a338ea337fb0c39570d3..c9969bde5ae32a0c443eddbfbdefea55df75e15c 100644 (file)
@@ -42,7 +42,7 @@
  * OR MODIFICATIONS.
  */
 
-#define RCSID  "$Id: sys-svr4.c,v 1.42 2000/04/06 23:11:05 masputra Exp $"
+#define RCSID  "$Id: sys-svr4.c,v 1.43 2001/05/23 03:39:14 paulus Exp $"
 
 #include <limits.h>
 #include <stdio.h>
@@ -1297,8 +1297,7 @@ output(unit, p, len)
     int retries;
     struct pollfd pfd;
 
-    if (debug)
-       dbglog("sent %P", p, len);
+    dump_packet("sent", p, len);
 
     data.len = len;
     data.buf = (caddr_t) p;
index f305ea339903501ee95a36aa57f70ea1ed8af874..580363a950dec0ee7f77afb1681c60f2880217b3 100644 (file)
@@ -17,7 +17,7 @@
  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#define RCSID  "$Id: utils.c,v 1.13 2001/03/16 02:08:13 paulus Exp $"
+#define RCSID  "$Id: utils.c,v 1.14 2001/05/23 03:39:14 paulus Exp $"
 
 #include <stdio.h>
 #include <ctype.h>
@@ -44,6 +44,8 @@
 #endif
 
 #include "pppd.h"
+#include "fsm.h"
+#include "lcp.h"
 
 static const char rcsid[] = RCSID;
 
@@ -761,6 +763,36 @@ dbglog __V((char *fmt, ...))
     va_end(pvar);
 }
 
+/*
+ * dump_packet - print out a packet in readable form if it is interesting.
+ * Assumes len >= PPP_HDRLEN.
+ */
+void
+dump_packet(const char *tag, unsigned char *p, int len)
+{
+    int proto;
+
+    if (!debug)
+       return;
+
+    /*
+     * don't print LCP echo request/reply packets if debug <= 1
+     * and the link is up.
+     */
+    proto = (p[2] << 8) + p[3];
+    if (debug <= 1 && unsuccess == 0 && proto == PPP_LCP
+       && len >= PPP_HDRLEN + HEADERLEN) {
+       unsigned char *lcp = p + PPP_HDRLEN;
+       int l = (lcp[2] << 8) + lcp[3];
+
+       if ((lcp[0] == ECHOREQ || lcp[0] == ECHOREP)
+           && l >= HEADERLEN && l <= len - PPP_HDRLEN)
+           return;
+    }
+
+    dbglog("%s %P", tag, p - PPP_HDRLEN, len + PPP_HDRLEN);
+}
+
 /* Procedures for locking the serial device using a lock file. */
 #ifndef LOCK_DIR
 #ifdef _linux_