* 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>
* 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");
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;
* 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 $
*/
/*
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 */
int fd = ppp_fd;
int proto;
- if (debug)
- dbglog("sent %P", p, len);
+ dump_packet("sent", p, len);
if (len < PPP_HDRLEN)
return;
* 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>
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;
* 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>
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;
* 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>
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;
* 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>
#endif
#include "pppd.h"
+#include "fsm.h"
+#include "lcp.h"
static const char rcsid[] = RCSID;
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_