Lines Matching defs:cstate

128     static const char *cstate[] = { CHAPCS__LIST };
131 if (clientstate < 0 || clientstate >= Dim(cstate)) {
135 return cstate[clientstate];
158 chap_state *cstate = &chap[unit];
160 BZERO(cstate, sizeof(*cstate));
161 cstate->unit = unit;
162 cstate->clientstate = CHAPCS_INITIAL;
163 cstate->serverstate = CHAPSS_INITIAL;
164 cstate->timeouttime = CHAP_DEFTIMEOUT;
165 cstate->max_transmits = CHAP_DEFTRANSMITS;
182 chap_state *cstate = &chap[unit];
184 cstate->resp_name = our_name;
185 cstate->resp_type = digest;
187 if (cstate->clientstate == CHAPCS_INITIAL ||
188 cstate->clientstate == CHAPCS_PENDING) {
190 cstate->clientstate = CHAPCS_PENDING;
199 cstate->clientstate = CHAPCS_LISTEN;
212 chap_state *cstate = &chap[unit];
214 cstate->chal_name = our_name;
215 cstate->chal_type = digest;
217 if (cstate->serverstate == CHAPSS_INITIAL ||
218 cstate->serverstate == CHAPSS_PENDING) {
220 cstate->serverstate = CHAPSS_PENDING;
224 ChapGenChallenge(cstate);
225 ChapSendChallenge(cstate); /* crank it up dude! */
226 cstate->serverstate = CHAPSS_INITIAL_CHAL;
237 chap_state *cstate = (chap_state *) arg;
241 if (cstate->serverstate != CHAPSS_INITIAL_CHAL &&
242 cstate->serverstate != CHAPSS_RECHALLENGE)
245 if (cstate->chal_transmits >= cstate->max_transmits) {
248 cstate->serverstate = CHAPSS_BADAUTH;
249 auth_peer_fail(cstate->unit, PPP_CHAP);
253 ChapSendChallenge(cstate); /* Re-send challenge */
264 chap_state *cstate = (chap_state *) arg;
267 if (cstate->clientstate != CHAPCS_RESPONSE)
270 ChapSendResponse(cstate); /* re-send response */
281 chap_state *cstate = (chap_state *) arg;
284 if (cstate->serverstate != CHAPSS_OPEN)
287 ChapGenChallenge(cstate);
288 ChapSendChallenge(cstate);
289 cstate->serverstate = CHAPSS_RECHALLENGE;
302 chap_state *cstate = &chap[unit];
304 if (cstate->clientstate == CHAPCS_INITIAL)
305 cstate->clientstate = CHAPCS_CLOSED;
306 else if (cstate->clientstate == CHAPCS_PENDING)
307 cstate->clientstate = CHAPCS_LISTEN;
309 if (cstate->serverstate == CHAPSS_INITIAL)
310 cstate->serverstate = CHAPSS_CLOSED;
311 else if (cstate->serverstate == CHAPSS_PENDING) {
312 ChapGenChallenge(cstate);
313 ChapSendChallenge(cstate);
314 cstate->serverstate = CHAPSS_INITIAL_CHAL;
328 chap_state *cstate = &chap[unit];
331 if (cstate->serverstate == CHAPSS_INITIAL_CHAL ||
332 cstate->serverstate == CHAPSS_RECHALLENGE)
333 UNTIMEOUT(ChapChallengeTimeout, cstate);
334 else if (cstate->serverstate == CHAPSS_OPEN
335 && cstate->chal_interval != 0)
336 UNTIMEOUT(ChapRechallenge, cstate);
337 if (cstate->clientstate == CHAPCS_RESPONSE)
338 UNTIMEOUT(ChapResponseTimeout, cstate);
340 cstate->clientstate = CHAPCS_INITIAL;
341 cstate->serverstate = CHAPSS_INITIAL;
352 chap_state *cstate = &chap[unit];
354 if (cstate->serverstate != CHAPSS_INITIAL &&
355 cstate->serverstate != CHAPSS_CLOSED)
357 if (cstate->clientstate != CHAPCS_INITIAL &&
358 cstate->clientstate != CHAPCS_CLOSED)
373 chap_state *cstate = &chap[unit];
403 ChapReceiveChallenge(cstate, inp, id, len);
407 ChapReceiveResponse(cstate, inp, id, len);
411 ChapReceiveFailure(cstate, inp, id, len);
415 ChapReceiveSuccess(cstate, inp, id, len);
430 ChapReceiveChallenge(cstate, inp, id, len)
431 chap_state *cstate;
445 if (cstate->clientstate == CHAPCS_CLOSED ||
446 cstate->clientstate == CHAPCS_PENDING) {
449 chap_cstate(cstate->clientstate));
493 if (cstate->peercname[0] == '\0') {
494 (void) strlcpy(cstate->peercname, rhostname,
495 sizeof (cstate->peercname));
496 } else if (strcmp(rhostname, cstate->peercname) != 0) {
497 if (++cstate->rename_count == 1) {
499 cstate->peercname, rhostname);
500 (void) strlcpy(cstate->peercname, rhostname,
501 sizeof (cstate->peercname));
504 if (cstate->rename_count == 2)
511 if (!get_secret(cstate->unit, cstate->resp_name, rhostname,
515 cstate->resp_name, rhostname);
519 if (cstate->clientstate == CHAPCS_RESPONSE)
520 UNTIMEOUT(ChapResponseTimeout, cstate);
522 cstate->resp_id = id;
523 cstate->resp_transmits = 0;
526 switch (cstate->resp_type) {
530 MD5Update(&mdContext, &cstate->resp_id, 1);
536 cstate->response[len] = (char) (drand48() * 0xff);
538 BCOPY(hash, cstate->response, MD5_SIGNATURE_SIZE);
540 cstate->resp_length = MD5_SIGNATURE_SIZE;
545 ChapMS(cstate, rchallenge, rchallenge_len, secret, secret_len);
551 ChapMSv2(cstate, rchallenge, rchallenge_len, secret, secret_len);
556 error("CHAP: unknown digest type %d", cstate->resp_type);
561 ChapSendResponse(cstate);
569 ChapReceiveResponse(cstate, inp, id, len)
570 chap_state *cstate;
583 if (cstate->serverstate == CHAPSS_CLOSED ||
584 cstate->serverstate == CHAPSS_PENDING) {
587 chap_sstate(cstate->serverstate));
591 if (id != cstate->chal_id) {
594 cstate->chal_id);
603 if (cstate->serverstate == CHAPSS_OPEN) {
606 ChapSendStatus(cstate, CHAP_SUCCESS);
609 if (cstate->serverstate == CHAPSS_BADAUTH) {
612 ChapSendStatus(cstate, CHAP_FAILURE);
630 UNTIMEOUT(ChapChallengeTimeout, cstate);
643 if (cstate->serverstate == CHAPSS_RECHALLENGE &&
647 } else if (!get_secret(cstate->unit, rhn, cstate->chal_name, secret,
650 rhn, cstate->chal_name);
654 switch (cstate->chal_type) {
660 MD5Update(&mdContext, &cstate->chal_id, 1);
662 MD5Update(&mdContext, cstate->challenge, cstate->chal_len);
672 if (ChapMSValidate(cstate, remmd, remmd_len, secret,
680 if (ChapMSv2Validate(cstate, rhostname, remmd, remmd_len,
687 error("CHAP: unknown digest type %d", cstate->chal_type);
692 ChapSendStatus(cstate, code);
695 old_state = cstate->serverstate;
696 cstate->serverstate = CHAPSS_OPEN;
698 auth_peer_success(cstate->unit, PPP_CHAP, rhostname, len);
700 if (cstate->chal_interval != 0)
701 TIMEOUT(ChapRechallenge, cstate, cstate->chal_interval);
708 (cstate->serverstate == CHAPSS_INITIAL_CHAL ? "" : "re"),
710 cstate->serverstate = CHAPSS_BADAUTH;
711 auth_peer_fail(cstate->unit, PPP_CHAP);
720 ChapReceiveSuccess(cstate, inp, id, len)
721 chap_state *cstate;
727 if (cstate->clientstate == CHAPCS_OPEN) {
734 if (cstate->clientstate != CHAPCS_RESPONSE) {
738 chap_cstate(cstate->clientstate));
742 UNTIMEOUT(ChapResponseTimeout, cstate);
750 cstate->clientstate = CHAPCS_OPEN;
752 auth_withpeer_success(cstate->unit, PPP_CHAP);
761 ChapReceiveFailure(cstate, inp, id, len)
762 chap_state *cstate;
767 if (cstate->clientstate != CHAPCS_RESPONSE) {
771 chap_cstate(cstate->clientstate));
775 UNTIMEOUT(ChapResponseTimeout, cstate);
784 auth_withpeer_fail(cstate->unit, PPP_CHAP);
792 ChapSendChallenge(cstate)
793 chap_state *cstate;
799 chal_len = cstate->chal_len;
800 name_len = strlen(cstate->chal_name);
807 PUTCHAR(cstate->chal_id, outp);
811 BCOPY(cstate->challenge, outp, chal_len);
814 BCOPY(cstate->chal_name, outp, name_len); /* append hostname */
816 output(cstate->unit, outpacket_buf, outlen + PPP_HDRLEN);
818 TIMEOUT(ChapChallengeTimeout, cstate, cstate->timeouttime);
819 ++cstate->chal_transmits;
827 ChapSendStatus(cstate, code)
828 chap_state *cstate;
835 if ((msgp = cstate->stat_message) != NULL) {
836 msglen = cstate->stat_length;
852 PUTCHAR(cstate->chal_id, outp);
855 output(cstate->unit, outpacket_buf, outlen + PPP_HDRLEN);
861 * string and its length are stored in *cstate, and various other fields of
862 * *cstate are initialized.
866 ChapGenChallenge(cstate)
867 chap_state *cstate;
870 u_char *ptr = cstate->challenge;
878 cstate->chal_len = chal_len;
879 cstate->chal_id = ++cstate->id;
880 cstate->chal_transmits = 0;
891 * in *cstate.
895 ChapSendResponse(cstate)
896 chap_state *cstate;
901 md_len = cstate->resp_length;
902 name_len = strlen(cstate->resp_name);
909 PUTCHAR(cstate->resp_id, outp); /* copy id from challenge packet */
913 BCOPY(cstate->response, outp, md_len); /* copy MD to buffer */
916 BCOPY(cstate->resp_name, outp, name_len); /* append our name */
919 output(cstate->unit, outpacket_buf, outlen + PPP_HDRLEN);
921 cstate->clientstate = CHAPCS_RESPONSE;
922 TIMEOUT(ChapResponseTimeout, cstate, cstate->timeouttime);
923 ++cstate->resp_transmits;