X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=pppd%2Futils.c;h=580363a950dec0ee7f77afb1681c60f2880217b3;hb=cc593def97b4f6f271fad15805b61c4773c4e30a;hp=e873ed65244f6fd2a55f80f2166edb0189dd604c;hpb=2d2fefe2c60d60a34491b0f7b2f904aeb39847c1;p=ppp.git diff --git a/pppd/utils.c b/pppd/utils.c index e873ed6..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.12 2001/03/12 22:56:45 paulus Exp $" +#define RCSID "$Id: utils.c,v 1.14 2001/05/23 03:39:14 paulus Exp $" #include #include @@ -44,6 +44,8 @@ #endif #include "pppd.h" +#include "fsm.h" +#include "lcp.h" static const char rcsid[] = RCSID; @@ -215,6 +217,10 @@ vslprintf(buf, buflen, fmt, args) val = i; base = 10; break; + case 'u': + val = va_arg(args, unsigned int); + base = 10; + break; case 'o': val = va_arg(args, unsigned int); base = 8; @@ -757,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_