Lines Matching refs:cstate

118     static const char *cstate[] = { CHAPCS__LIST };  in chap_cstate()  local
121 if (clientstate < 0 || clientstate >= Dim(cstate)) { in chap_cstate()
125 return cstate[clientstate]; in chap_cstate()
148 chap_state *cstate = &chap[unit]; local
150 BZERO(cstate, sizeof(*cstate));
151 cstate->unit = unit;
152 cstate->clientstate = CHAPCS_INITIAL;
153 cstate->serverstate = CHAPSS_INITIAL;
154 cstate->timeouttime = CHAP_DEFTIMEOUT;
155 cstate->max_transmits = CHAP_DEFTRANSMITS;
172 chap_state *cstate = &chap[unit]; local
174 cstate->resp_name = our_name;
175 cstate->resp_type = digest;
177 if (cstate->clientstate == CHAPCS_INITIAL ||
178 cstate->clientstate == CHAPCS_PENDING) {
180 cstate->clientstate = CHAPCS_PENDING;
189 cstate->clientstate = CHAPCS_LISTEN;
202 chap_state *cstate = &chap[unit]; local
204 cstate->chal_name = our_name;
205 cstate->chal_type = digest;
207 if (cstate->serverstate == CHAPSS_INITIAL ||
208 cstate->serverstate == CHAPSS_PENDING) {
210 cstate->serverstate = CHAPSS_PENDING;
214 ChapGenChallenge(cstate);
215 ChapSendChallenge(cstate); /* crank it up dude! */
216 cstate->serverstate = CHAPSS_INITIAL_CHAL;
227 chap_state *cstate = (chap_state *) arg; local
231 if (cstate->serverstate != CHAPSS_INITIAL_CHAL &&
232 cstate->serverstate != CHAPSS_RECHALLENGE)
235 if (cstate->chal_transmits >= cstate->max_transmits) {
238 cstate->serverstate = CHAPSS_BADAUTH;
239 auth_peer_fail(cstate->unit, PPP_CHAP);
243 ChapSendChallenge(cstate); /* Re-send challenge */
254 chap_state *cstate = (chap_state *) arg; local
257 if (cstate->clientstate != CHAPCS_RESPONSE)
260 ChapSendResponse(cstate); /* re-send response */
271 chap_state *cstate = (chap_state *) arg; local
274 if (cstate->serverstate != CHAPSS_OPEN)
277 ChapGenChallenge(cstate);
278 ChapSendChallenge(cstate);
279 cstate->serverstate = CHAPSS_RECHALLENGE;
292 chap_state *cstate = &chap[unit]; local
294 if (cstate->clientstate == CHAPCS_INITIAL)
295 cstate->clientstate = CHAPCS_CLOSED;
296 else if (cstate->clientstate == CHAPCS_PENDING)
297 cstate->clientstate = CHAPCS_LISTEN;
299 if (cstate->serverstate == CHAPSS_INITIAL)
300 cstate->serverstate = CHAPSS_CLOSED;
301 else if (cstate->serverstate == CHAPSS_PENDING) {
302 ChapGenChallenge(cstate);
303 ChapSendChallenge(cstate);
304 cstate->serverstate = CHAPSS_INITIAL_CHAL;
318 chap_state *cstate = &chap[unit]; local
321 if (cstate->serverstate == CHAPSS_INITIAL_CHAL ||
322 cstate->serverstate == CHAPSS_RECHALLENGE)
323 UNTIMEOUT(ChapChallengeTimeout, cstate);
324 else if (cstate->serverstate == CHAPSS_OPEN
325 && cstate->chal_interval != 0)
326 UNTIMEOUT(ChapRechallenge, cstate);
327 if (cstate->clientstate == CHAPCS_RESPONSE)
328 UNTIMEOUT(ChapResponseTimeout, cstate);
330 cstate->clientstate = CHAPCS_INITIAL;
331 cstate->serverstate = CHAPSS_INITIAL;
342 chap_state *cstate = &chap[unit]; local
344 if (cstate->serverstate != CHAPSS_INITIAL &&
345 cstate->serverstate != CHAPSS_CLOSED)
347 if (cstate->clientstate != CHAPCS_INITIAL &&
348 cstate->clientstate != CHAPCS_CLOSED)
363 chap_state *cstate = &chap[unit]; local
393 ChapReceiveChallenge(cstate, inp, id, len);
397 ChapReceiveResponse(cstate, inp, id, len);
401 ChapReceiveFailure(cstate, inp, id, len);
405 ChapReceiveSuccess(cstate, inp, id, len);
420 ChapReceiveChallenge(cstate, inp, id, len) in ChapReceiveChallenge() argument
421 chap_state *cstate; in ChapReceiveChallenge()
435 if (cstate->clientstate == CHAPCS_CLOSED ||
436 cstate->clientstate == CHAPCS_PENDING) {
439 chap_cstate(cstate->clientstate));
483 if (cstate->peercname[0] == '\0') {
484 (void) strlcpy(cstate->peercname, rhostname,
485 sizeof (cstate->peercname));
486 } else if (strcmp(rhostname, cstate->peercname) != 0) {
487 if (++cstate->rename_count == 1) {
489 cstate->peercname, rhostname);
490 (void) strlcpy(cstate->peercname, rhostname,
491 sizeof (cstate->peercname));
494 if (cstate->rename_count == 2)
501 if (!get_secret(cstate->unit, cstate->resp_name, rhostname,
505 cstate->resp_name, rhostname);
509 if (cstate->clientstate == CHAPCS_RESPONSE)
510 UNTIMEOUT(ChapResponseTimeout, cstate);
512 cstate->resp_id = id;
513 cstate->resp_transmits = 0;
516 switch (cstate->resp_type) {
520 MD5Update(&mdContext, &cstate->resp_id, 1);
526 cstate->response[len] = (char) (drand48() * 0xff);
528 BCOPY(hash, cstate->response, MD5_SIGNATURE_SIZE);
530 cstate->resp_length = MD5_SIGNATURE_SIZE;
535 ChapMS(cstate, rchallenge, rchallenge_len, secret, secret_len);
541 ChapMSv2(cstate, rchallenge, rchallenge_len, secret, secret_len);
546 error("CHAP: unknown digest type %d", cstate->resp_type);
551 ChapSendResponse(cstate);
559 ChapReceiveResponse(cstate, inp, id, len) in ChapReceiveResponse() argument
560 chap_state *cstate; in ChapReceiveResponse()
573 if (cstate->serverstate == CHAPSS_CLOSED ||
574 cstate->serverstate == CHAPSS_PENDING) {
577 chap_sstate(cstate->serverstate));
581 if (id != cstate->chal_id) {
584 cstate->chal_id);
593 if (cstate->serverstate == CHAPSS_OPEN) {
596 ChapSendStatus(cstate, CHAP_SUCCESS);
599 if (cstate->serverstate == CHAPSS_BADAUTH) {
602 ChapSendStatus(cstate, CHAP_FAILURE);
620 UNTIMEOUT(ChapChallengeTimeout, cstate);
633 if (cstate->serverstate == CHAPSS_RECHALLENGE &&
637 } else if (!get_secret(cstate->unit, rhn, cstate->chal_name, secret,
640 rhn, cstate->chal_name);
644 switch (cstate->chal_type) {
650 MD5Update(&mdContext, &cstate->chal_id, 1);
652 MD5Update(&mdContext, cstate->challenge, cstate->chal_len);
662 if (ChapMSValidate(cstate, remmd, remmd_len, secret,
670 if (ChapMSv2Validate(cstate, rhostname, remmd, remmd_len,
677 error("CHAP: unknown digest type %d", cstate->chal_type);
682 ChapSendStatus(cstate, code);
685 old_state = cstate->serverstate;
686 cstate->serverstate = CHAPSS_OPEN;
688 auth_peer_success(cstate->unit, PPP_CHAP, rhostname, len);
690 if (cstate->chal_interval != 0)
691 TIMEOUT(ChapRechallenge, cstate, cstate->chal_interval);
698 (cstate->serverstate == CHAPSS_INITIAL_CHAL ? "" : "re"),
700 cstate->serverstate = CHAPSS_BADAUTH;
701 auth_peer_fail(cstate->unit, PPP_CHAP);
710 ChapReceiveSuccess(cstate, inp, id, len) in ChapReceiveSuccess() argument
711 chap_state *cstate; in ChapReceiveSuccess()
717 if (cstate->clientstate == CHAPCS_OPEN) {
724 if (cstate->clientstate != CHAPCS_RESPONSE) {
728 chap_cstate(cstate->clientstate));
732 UNTIMEOUT(ChapResponseTimeout, cstate);
740 cstate->clientstate = CHAPCS_OPEN;
742 auth_withpeer_success(cstate->unit, PPP_CHAP);
751 ChapReceiveFailure(cstate, inp, id, len) in ChapReceiveFailure() argument
752 chap_state *cstate; in ChapReceiveFailure()
757 if (cstate->clientstate != CHAPCS_RESPONSE) {
761 chap_cstate(cstate->clientstate));
765 UNTIMEOUT(ChapResponseTimeout, cstate);
774 auth_withpeer_fail(cstate->unit, PPP_CHAP);
782 ChapSendChallenge(cstate) in ChapSendChallenge() argument
783 chap_state *cstate; in ChapSendChallenge()
789 chal_len = cstate->chal_len;
790 name_len = strlen(cstate->chal_name);
797 PUTCHAR(cstate->chal_id, outp);
801 BCOPY(cstate->challenge, outp, chal_len);
804 BCOPY(cstate->chal_name, outp, name_len); /* append hostname */
806 output(cstate->unit, outpacket_buf, outlen + PPP_HDRLEN);
808 TIMEOUT(ChapChallengeTimeout, cstate, cstate->timeouttime);
809 ++cstate->chal_transmits;
817 ChapSendStatus(cstate, code) in ChapSendStatus() argument
818 chap_state *cstate; in ChapSendStatus()
825 if ((msgp = cstate->stat_message) != NULL) {
826 msglen = cstate->stat_length;
842 PUTCHAR(cstate->chal_id, outp);
845 output(cstate->unit, outpacket_buf, outlen + PPP_HDRLEN);
856 ChapGenChallenge(cstate) in ChapGenChallenge() argument
857 chap_state *cstate; in ChapGenChallenge()
860 u_char *ptr = cstate->challenge;
868 cstate->chal_len = chal_len;
869 cstate->chal_id = ++cstate->id;
870 cstate->chal_transmits = 0;
885 ChapSendResponse(cstate) in ChapSendResponse() argument
886 chap_state *cstate; in ChapSendResponse()
891 md_len = cstate->resp_length;
892 name_len = strlen(cstate->resp_name);
899 PUTCHAR(cstate->resp_id, outp); /* copy id from challenge packet */
903 BCOPY(cstate->response, outp, md_len); /* copy MD to buffer */
906 BCOPY(cstate->resp_name, outp, name_len); /* append our name */
909 output(cstate->unit, outpacket_buf, outlen + PPP_HDRLEN);
911 cstate->clientstate = CHAPCS_RESPONSE;
912 TIMEOUT(ChapResponseTimeout, cstate, cstate->timeouttime);
913 ++cstate->resp_transmits;