From 94d661ac8cb907e0a869759f76cd7134c9105e6c Mon Sep 17 00:00:00 2001 From: brian Date: Mon, 9 Jun 1997 03:27:43 +0000 Subject: Overhaul ppp: o Use syslog o Remove references to stdout/stderr (incl perror()) o Introduce VarTerm - the interactive terminal or zero o Allow "set timeout" to affect current session o Change "set debug" to "set log" o Allow "set log [+|-]flag" o Make MSEXT and PASSWDAUTH stuff the default o Move all #ifdef DEBUG stuff into the code - this shouldn't be too much overhead. It's now controlled with "set log +debug" o Add "set log command, debug, tun, warn, error, alert" o Remove cdefs.h, and assume an ansi compiler. o Improve all diagnostic output o Don't trap SIGSEGV o SIGHUP now terminates again (log files are controlled by syslog) o Call CloseModem() when changing devices o Fix parsing of third arg of "delete" I think this fixes the "magic is same" problems that some people have been experiencing. The man page is being rewritten. It'll follow soon. --- usr.sbin/ppp/mbuf.c | 66 ++++++++++++++++++----------------------------------- 1 file changed, 22 insertions(+), 44 deletions(-) (limited to 'usr.sbin/ppp/mbuf.c') diff --git a/usr.sbin/ppp/mbuf.c b/usr.sbin/ppp/mbuf.c index 7454726..3fbaebe 100644 --- a/usr.sbin/ppp/mbuf.c +++ b/usr.sbin/ppp/mbuf.c @@ -17,10 +17,16 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: mbuf.c,v 1.5 1997/02/22 16:10:34 peter Exp $ + * $Id: mbuf.c,v 1.6 1997/05/10 01:22:15 brian Exp $ * */ +#include +#include +#include +#include #include "defs.h" +#include "loadalias.h" +#include "vars.h" struct memmap { struct mbuf *queue; @@ -49,19 +55,17 @@ int type; struct mbuf *bp; if (type > MB_MAX) - logprintf("bad type %d\n", type); + LogPrintf(LogERROR, "Bad mbuf type %d\n", type); bp = (struct mbuf *)malloc(sizeof(struct mbuf)); if (bp == NULL) { - logprintf("failed to allocate memory: %u\n", sizeof(struct mbuf)); - fprintf(stderr,"failed to allocate memory: %u\n", sizeof(struct mbuf)); - exit(0); + LogPrintf(LogALERT, "failed to allocate memory: %u\n", sizeof(struct mbuf)); + exit(1); } bzero(bp, sizeof(struct mbuf)); p = (u_char *)malloc(cnt); if (p == NULL) { - logprintf("failed to allocate memory: %d\n", cnt); - fprintf(stderr,"failed to allocate memory: %d\n", cnt); - exit(0); + LogPrintf(LogALERT, "failed to allocate memory: %d\n", cnt); + exit(1); } MemMap[type].count += cnt; totalalloced += cnt; @@ -144,53 +148,27 @@ int cnt; } } -void -DumpBp(bp) -struct mbuf *bp; -{ - u_char *cp; - int cnt, loc; - - logprintf("dump bp = %x (%d)\n", bp, plength(bp)); - loc = 0; - while (bp) { - cp = MBUF_CTOP(bp); - cnt = bp->cnt; - while (cnt > 0) { - logprintf("%02x", *cp++); - loc++; - if (loc == 16) { - loc = 0; - logprintf("\n"); - } else - logprintf(" "); - cnt--; - } - bp = bp->next; - } - if (loc) logprintf("\n"); -} - int ShowMemMap() { int i; - for (i = 0; i <= MB_MAX; i += 2) { - printf("%d: %d %d: %d\r\n", + if (!VarTerm) + return 1; + + for (i = 0; i <= MB_MAX; i += 2) + fprintf(VarTerm, "%d: %d %d: %d\n", i, MemMap[i].count, i+1, MemMap[i+1].count); - } - return(1); + + return 0; } void LogMemory() { -#ifdef DEBUG - logprintf("mem alloced: %d\n", totalalloced); - logprintf(" 1: %d 2: %d 3: %d 4: %d\n", + LogPrintf(LogDEBUG, "LogMemory: mem alloced: %d\n", totalalloced); + LogPrintf(LogDEBUG, "LogMemory: 1: %d 2: %d 3: %d 4: %d\n", MemMap[1].count, MemMap[2].count, MemMap[3].count, MemMap[4].count); - logprintf(" 5: %d 6: %d 7: %d 8: %d\n", + LogPrintf(LogDEBUG, "LogMemory: 5: %d 6: %d 7: %d 8: %d\n", MemMap[5].count, MemMap[6].count, MemMap[7].count, MemMap[8].count); -#endif } -- cgit v1.1