diff options
author | Paul Mackerras <paulus@samba.org> | 2001-05-23 03:39:14 +0000 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2001-05-23 03:39:14 +0000 |
commit | cc593def97b4f6f271fad15805b61c4773c4e30a (patch) | |
tree | 25c9c8a7fde92c75586c577cd3eca4b3c2c3c810 /pppd/utils.c | |
parent | 4cc66b91de920c8572a11511be24a8a6949cb5b8 (diff) | |
download | ppp-cc593def97b4f6f271fad15805b61c4773c4e30a.tar.gz |
add dump_packet, don't log lcp echo request/reply messages once
the link is up unless debug >= 2
Diffstat (limited to 'pppd/utils.c')
-rw-r--r-- | pppd/utils.c | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/pppd/utils.c b/pppd/utils.c index f305ea3..580363a 100644 --- a/pppd/utils.c +++ b/pppd/utils.c @@ -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_ |