X-Git-Url: https://git.ozlabs.org/?p=ppp.git;a=blobdiff_plain;f=pppd%2Fchap.c;h=c11d5416a0d5deedbb8227caa2a457da4bedd743;hp=043dad9d00987cf5e61b93528940ed16cb5160a6;hb=3d7213eeb3549074c2b6cb961db7a28c65f82d5c;hpb=f1085e1db51d5fc24764f1e1a9f0101e86bf7ca0 diff --git a/pppd/chap.c b/pppd/chap.c index 043dad9..c11d541 100644 --- a/pppd/chap.c +++ b/pppd/chap.c @@ -19,7 +19,7 @@ */ #ifndef lint -static char rcsid[] = "$Id: chap.c,v 1.2 1994/04/11 07:13:44 paulus Exp $"; +static char rcsid[] = "$Id: chap.c,v 1.4 1994/09/21 06:47:37 paulus Exp $"; #endif /* @@ -31,26 +31,25 @@ static char rcsid[] = "$Id: chap.c,v 1.2 1994/04/11 07:13:44 paulus Exp $"; #include #include -#include "ppp.h" #include "pppd.h" #include "chap.h" #include "md5.h" -chap_state chap[NPPP]; /* CHAP state; one for each unit */ +chap_state chap[N_PPP]; /* CHAP state; one for each unit */ -static void ChapChallengeTimeout __ARGS((caddr_t)); -static void ChapResponseTimeout __ARGS((caddr_t)); -static void ChapReceiveChallenge __ARGS((chap_state *, u_char *, int, int)); -static void ChapReceiveResponse __ARGS((chap_state *, u_char *, int, int)); -static void ChapReceiveSuccess __ARGS((chap_state *, u_char *, int, int)); -static void ChapReceiveFailure __ARGS((chap_state *, u_char *, int, int)); -static void ChapSendStatus __ARGS((chap_state *, int)); -static void ChapSendChallenge __ARGS((chap_state *)); -static void ChapSendResponse __ARGS((chap_state *)); -static void ChapGenChallenge __ARGS((chap_state *)); +static void ChapChallengeTimeout __P((caddr_t)); +static void ChapResponseTimeout __P((caddr_t)); +static void ChapReceiveChallenge __P((chap_state *, u_char *, int, int)); +static void ChapReceiveResponse __P((chap_state *, u_char *, int, int)); +static void ChapReceiveSuccess __P((chap_state *, u_char *, int, int)); +static void ChapReceiveFailure __P((chap_state *, u_char *, int, int)); +static void ChapSendStatus __P((chap_state *, int)); +static void ChapSendChallenge __P((chap_state *)); +static void ChapSendResponse __P((chap_state *)); +static void ChapGenChallenge __P((chap_state *)); -extern double drand48 __ARGS((void)); -extern void srand48 __ARGS((long)); +extern double drand48 __P((void)); +extern void srand48 __P((long)); /* * ChapInit - Initialize a CHAP unit. @@ -148,7 +147,7 @@ ChapChallengeTimeout(arg) /* give up on peer */ syslog(LOG_ERR, "Peer failed to respond to CHAP challenge"); cstate->serverstate = CHAPSS_BADAUTH; - auth_peer_fail(cstate->unit, CHAP); + auth_peer_fail(cstate->unit, PPP_CHAP); return; } @@ -258,10 +257,10 @@ ChapProtocolReject(unit) if (cstate->serverstate != CHAPSS_INITIAL && cstate->serverstate != CHAPSS_CLOSED) - auth_peer_fail(unit, CHAP); + auth_peer_fail(unit, PPP_CHAP); if (cstate->clientstate != CHAPCS_INITIAL && cstate->clientstate != CHAPCS_CLOSED) - auth_withpeer_fail(unit, CHAP); + auth_withpeer_fail(unit, PPP_CHAP); ChapLowerDown(unit); /* shutdown chap */ } @@ -521,7 +520,7 @@ ChapReceiveResponse(cstate, inp, id, len) old_state = cstate->serverstate; cstate->serverstate = CHAPSS_OPEN; if (old_state == CHAPSS_INITIAL_CHAL) { - auth_peer_success(cstate->unit, CHAP); + auth_peer_success(cstate->unit, PPP_CHAP); } if (cstate->chal_interval != 0) TIMEOUT(ChapRechallenge, (caddr_t) cstate, cstate->chal_interval); @@ -529,7 +528,7 @@ ChapReceiveResponse(cstate, inp, id, len) } else { syslog(LOG_ERR, "CHAP peer authentication failed"); cstate->serverstate = CHAPSS_BADAUTH; - auth_peer_fail(cstate->unit, CHAP); + auth_peer_fail(cstate->unit, PPP_CHAP); } } @@ -557,6 +556,8 @@ ChapReceiveSuccess(cstate, inp, id, len) return; } + UNTIMEOUT(ChapResponseTimeout, (caddr_t) cstate); + /* * Print message. */ @@ -565,7 +566,7 @@ ChapReceiveSuccess(cstate, inp, id, len) cstate->clientstate = CHAPCS_OPEN; - auth_withpeer_success(cstate->unit, CHAP); + auth_withpeer_success(cstate->unit, PPP_CHAP); } @@ -591,6 +592,8 @@ ChapReceiveFailure(cstate, inp, id, len) return; } + UNTIMEOUT(ChapResponseTimeout, (caddr_t) cstate); + /* * Print message. */ @@ -598,7 +601,7 @@ ChapReceiveFailure(cstate, inp, id, len) PRINTMSG(inp, len); syslog(LOG_ERR, "CHAP authentication failed"); - auth_withpeer_fail(cstate->unit, CHAP); + auth_withpeer_fail(cstate->unit, PPP_CHAP); } @@ -618,7 +621,7 @@ ChapSendChallenge(cstate) outlen = CHAP_HEADERLEN + sizeof (u_char) + chal_len + name_len; outp = outpacket_buf; - MAKEHEADER(outp, CHAP); /* paste in a CHAP header */ + MAKEHEADER(outp, PPP_CHAP); /* paste in a CHAP header */ PUTCHAR(CHAP_CHALLENGE, outp); PUTCHAR(cstate->chal_id, outp); @@ -630,7 +633,7 @@ ChapSendChallenge(cstate) BCOPY(cstate->chal_name, outp, name_len); /* append hostname */ - output(cstate->unit, outpacket_buf, outlen + DLLHEADERLEN); + output(cstate->unit, outpacket_buf, outlen + PPP_HDRLEN); CHAPDEBUG((LOG_INFO, "ChapSendChallenge: Sent id %d.", cstate->chal_id)); @@ -660,13 +663,13 @@ ChapSendStatus(cstate, code) outlen = CHAP_HEADERLEN + msglen; outp = outpacket_buf; - MAKEHEADER(outp, CHAP); /* paste in a header */ + MAKEHEADER(outp, PPP_CHAP); /* paste in a header */ PUTCHAR(code, outp); PUTCHAR(cstate->chal_id, outp); PUTSHORT(outlen, outp); BCOPY(msg, outp, msglen); - output(cstate->unit, outpacket_buf, outlen + DLLHEADERLEN); + output(cstate->unit, outpacket_buf, outlen + PPP_HDRLEN); CHAPDEBUG((LOG_INFO, "ChapSendStatus: Sent code %d, id %d.", code, cstate->chal_id)); @@ -718,7 +721,7 @@ ChapSendResponse(cstate) outlen = CHAP_HEADERLEN + sizeof (u_char) + md_len + name_len; outp = outpacket_buf; - MAKEHEADER(outp, CHAP); + MAKEHEADER(outp, PPP_CHAP); PUTCHAR(CHAP_RESPONSE, outp); /* we are a response */ PUTCHAR(cstate->resp_id, outp); /* copy id from challenge packet */ @@ -731,7 +734,7 @@ ChapSendResponse(cstate) BCOPY(cstate->resp_name, outp, name_len); /* append our name */ /* send the packet */ - output(cstate->unit, outpacket_buf, outlen + DLLHEADERLEN); + output(cstate->unit, outpacket_buf, outlen + PPP_HDRLEN); cstate->clientstate = CHAPCS_RESPONSE; TIMEOUT(ChapResponseTimeout, (caddr_t) cstate, cstate->timeouttime); @@ -749,7 +752,7 @@ int ChapPrintPkt(p, plen, printer, arg) u_char *p; int plen; - void (*printer) __ARGS((void *, char *, ...)); + void (*printer) __P((void *, char *, ...)); void *arg; { int code, id, len;