X-Git-Url: http://git.ozlabs.org/?p=ppp.git;a=blobdiff_plain;f=pppd%2Fchap.c;h=64f39bc51c1bdc398189f1c372ef8dbf1f521583;hp=e0ea4afeee00e569bb28879fc4f32909043ae20d;hb=980125bd4c3a7f3160d133ac58d344f2cac883b3;hpb=0b63a24d54ba4708c88e31bdd74b0145956c1478 diff --git a/pppd/chap.c b/pppd/chap.c index e0ea4af..64f39bc 100644 --- a/pppd/chap.c +++ b/pppd/chap.c @@ -19,7 +19,7 @@ */ #ifndef lint -static char rcsid[] = "$Id: chap.c,v 1.1 1993/11/11 03:54:25 paulus Exp $"; +static char rcsid[] = "$Id: chap.c,v 1.3 1994/04/18 04:01:07 paulus Exp $"; #endif /* @@ -557,6 +557,8 @@ ChapReceiveSuccess(cstate, inp, id, len) return; } + UNTIMEOUT(ChapResponseTimeout, (caddr_t) cstate); + /* * Print message. */ @@ -591,6 +593,8 @@ ChapReceiveFailure(cstate, inp, id, len) return; } + UNTIMEOUT(ChapResponseTimeout, (caddr_t) cstate); + /* * Print message. */ @@ -738,6 +742,71 @@ ChapSendResponse(cstate) ++cstate->resp_transmits; } +/* + * ChapPrintPkt - print the contents of a CHAP packet. + */ +char *ChapCodenames[] = { + "Challenge", "Response", "Success", "Failure" +}; + +int +ChapPrintPkt(p, plen, printer, arg) + u_char *p; + int plen; + void (*printer) __ARGS((void *, char *, ...)); + void *arg; +{ + int code, id, len; + int clen, nlen; + u_char x; + + if (plen < CHAP_HEADERLEN) + return 0; + GETCHAR(code, p); + GETCHAR(id, p); + GETSHORT(len, p); + if (len < CHAP_HEADERLEN || len > plen) + return 0; + + if (code >= 1 && code <= sizeof(ChapCodenames) / sizeof(char *)) + printer(arg, " %s", ChapCodenames[code-1]); + else + printer(arg, " code=0x%x", code); + printer(arg, " id=0x%x", id); + len -= CHAP_HEADERLEN; + switch (code) { + case CHAP_CHALLENGE: + case CHAP_RESPONSE: + if (len < 1) + break; + clen = p[0]; + if (len < clen + 1) + break; + ++p; + nlen = len - clen - 1; + printer(arg, " <"); + for (; clen > 0; --clen) { + GETCHAR(x, p); + printer(arg, "%.2x", x); + } + printer(arg, ">, name = "); + print_string((char *)p, nlen, printer, arg); + break; + case CHAP_FAILURE: + case CHAP_SUCCESS: + printer(arg, " "); + print_string((char *)p, len, printer, arg); + break; + default: + for (clen = len; clen > 0; --clen) { + GETCHAR(x, p); + printer(arg, " %.2x", x); + } + } + + return len + CHAP_HEADERLEN; +} + #ifdef NO_DRAND48 double drand48()