]> git.ozlabs.org Git - ppp.git/blobdiff - pppd/chap.c
added options checking routine; decide whether to use old forms in
[ppp.git] / pppd / chap.c
index b7a95cc2b04517d3a3f0792407ed8df162c339f8..99b11758bf5989b64a1afa6bb2d0e95e83530ec9 100644 (file)
@@ -19,7 +19,7 @@
  */
 
 #ifndef lint
-static char rcsid[] = "$Id: chap.c,v 1.5 1994/10/22 11:54:04 paulus Exp $";
+static char rcsid[] = "$Id: chap.c,v 1.11 1996/04/04 03:35:58 paulus Exp $";
 #endif
 
 /*
@@ -36,7 +36,13 @@ static char rcsid[] = "$Id: chap.c,v 1.5 1994/10/22 11:54:04 paulus Exp $";
 #include "chap.h"
 #include "md5.h"
 
-chap_state chap[N_PPP];                /* CHAP state; one for each unit */
+struct protent chap_protent = {
+    PPP_CHAP, ChapInit, ChapInput, ChapProtocolReject,
+    ChapLowerUp, ChapLowerDown, NULL, NULL,
+    ChapPrintPkt, NULL, 1, "CHAP", NULL, NULL
+};
+
+chap_state chap[NUM_PPP];              /* CHAP state; one for each unit */
 
 static void ChapChallengeTimeout __P((caddr_t));
 static void ChapResponseTimeout __P((caddr_t));
@@ -67,7 +73,7 @@ ChapInit(unit)
     cstate->serverstate = CHAPSS_INITIAL;
     cstate->timeouttime = CHAP_DEFTIMEOUT;
     cstate->max_transmits = CHAP_DEFTRANSMITS;
-    srand48((long) time(NULL));        /* joggle random number generator */
+    /* random number generator is initialized in magic_init */
 }
 
 
@@ -189,9 +195,6 @@ ChapRechallenge(arg)
     ChapGenChallenge(cstate);
     ChapSendChallenge(cstate);
     cstate->serverstate = CHAPSS_RECHALLENGE;
-
-    if (cstate->chal_interval != 0)
-       TIMEOUT(ChapRechallenge, (caddr_t) cstate, cstate->chal_interval);
 }
 
 
@@ -427,9 +430,7 @@ ChapReceiveResponse(cstate, inp, id, len)
     int secret_len, old_state;
     int code;
     char rhostname[256];
-    u_char buf[256];
     MD5_CTX mdContext;
-    u_char msg[256];
     char secret[MAXSECRETLEN];
 
     CHAPDEBUG((LOG_INFO, "ChapReceiveResponse: Rcvd id %d.", id));
@@ -506,7 +507,7 @@ ChapReceiveResponse(cstate, inp, id, len)
            MD5Final(&mdContext); 
 
            /* compare local and remote MDs and send the appropriate status */
-           if (bcmp (mdContext.digest, remmd, MD5_SIGNATURE_SIZE) == 0)
+           if (memcmp (mdContext.digest, remmd, MD5_SIGNATURE_SIZE) == 0)
                code = CHAP_SUCCESS;    /* they are the same! */
            break;
 
@@ -581,9 +582,6 @@ ChapReceiveFailure(cstate, inp, id, len)
     u_char id;
     int len;
 {
-    u_char msglen;
-    u_char *msg;
-  
     CHAPDEBUG((LOG_INFO, "ChapReceiveFailure: Rcvd id %d.", id));
 
     if (cstate->clientstate != CHAPCS_RESPONSE) {
@@ -806,18 +804,3 @@ ChapPrintPkt(p, plen, printer, arg)
 
     return len + CHAP_HEADERLEN;
 }
-
-#ifdef NO_DRAND48
-
-double drand48()
-{
-  return (double)random() / (double)0x7fffffffL; /* 2**31-1 */
-}
-
-void srand48(seedval)
-long seedval;
-{
-  srand((int)seedval);
-}
-
-#endif