static void upap_lowerup (void) { #ifdef AUTH_CFG_CLIENT if (client_state == PAP_CS_INIT) client_state = PAP_CS_CLOSED; else if (client_state == PAP_CS_PENDING) upap_sauthreq(); #endif /* of #ifdef AUTH_CFG_CLIENT */ #ifdef AUTH_CFG_SERVER if (server_state == PAP_SS_INIT) server_state = PAP_SS_CLOSED; else if (server_state == PAP_SS_PENDING) { server_state = PAP_SS_LISTEN; #if defined(DEF_PAP_REQTIME) timeout((FP)upap_reqtimeout, NULL, DEF_PAP_REQTIME); #endif /* of #if defined(DEF_PAP_REQTIME) */ } #endif /* of #ifdef AUTH_CFG_SERVER */ }
/* * upap_authwithpeer - Authenticate us with our peer (start client). * * Set new state and send authenticate's. */ void upap_authwithpeer(int unit, char *user, char *password) { upap_state *u = &upap[unit]; UPAPDEBUG(LOG_INFO, ("upap_authwithpeer: %d user=%s password=%s s=%d\r\n", unit, user, password, u->us_clientstate)); /* Save the username and password we're given */ u->us_user = user; u->us_userlen = (int)strlen(user); u->us_passwd = password; u->us_passwdlen = (int)strlen(password); u->us_transmits = 0; /* Lower layer up yet? */ if (u->us_clientstate == UPAPCS_INITIAL || u->us_clientstate == UPAPCS_PENDING) { u->us_clientstate = UPAPCS_PENDING; return; } upap_sauthreq(u); /* Start protocol */ }
static void upap_timeout (void *arg) { if (client_state != PAP_CS_AUTHREQ) return; if (client_rexmt >= MAX_PAP_REXMT) { syslog(LOG_WARNING, "[PPP/PAP] no reply auth-req."); client_state = PAP_CS_BADAUTH; return; } upap_sauthreq(); }
/* * upap_timeout - Retransmission timer for sending auth-reqs expired. */ static void upap_timeout(void *arg) { ppp_pcb *pcb = (ppp_pcb*)arg; if (pcb->upap.us_clientstate != UPAPCS_AUTHREQ) return; if (pcb->upap.us_transmits >= pcb->settings.pap_max_transmits) { /* give up in disgust */ ppp_error("No response to PAP authenticate-requests"); pcb->upap.us_clientstate = UPAPCS_BADAUTH; auth_withpeer_fail(pcb, PPP_PAP); return; } upap_sauthreq(pcb); /* Send Authenticate-Request */ }
void upap_auth_client (void) { #if defined(DEF_PAP_TIMEOUT) client_rexmt = 0; #endif /* of #if defined(DEF_PAP_TIMEOUT) */ if (client_state == PAP_CS_INIT || client_state == PAP_CS_PENDING) { client_state = PAP_CS_PENDING; return; } upap_sauthreq(); }
/* * upap_lowerup - The lower layer is up. * * Start authenticating if pending. */ static void upap_lowerup(ppp_pcb *pcb) { if (pcb->upap.us_clientstate == UPAPCS_INITIAL) pcb->upap.us_clientstate = UPAPCS_CLOSED; else if (pcb->upap.us_clientstate == UPAPCS_PENDING) { upap_sauthreq(pcb); /* send an auth-request */ } #if PPP_SERVER if (pcb->upap.us_serverstate == UPAPSS_INITIAL) pcb->upap.us_serverstate = UPAPSS_CLOSED; else if (pcb->upap.us_serverstate == UPAPSS_PENDING) { pcb->upap.us_serverstate = UPAPSS_LISTEN; if (pcb->settings.pap_req_timeout > 0) TIMEOUT(upap_reqtimeout, pcb, pcb->settings.pap_req_timeout); } #endif /* PPP_SERVER */ }
/* * upap_authwithpeer - Authenticate us with our peer (start client). * * Set new state and send authenticate's. */ void upap_authwithpeer(int unit, char *user, char *password) { upap_state *u = &upap[unit]; UPAPDEBUG((LOG_INFO, "upap_authwithpeer: %d user=%s password=%s s=%d\n", unit, user, password, u->us_clientstate)); upap_setloginpasswd(unit, user, password); u->us_transmits = 0; /* Lower layer up yet? */ if (u->us_clientstate == UPAPCS_INITIAL || u->us_clientstate == UPAPCS_PENDING) { u->us_clientstate = UPAPCS_PENDING; return; } upap_sauthreq(u); /* Start protocol */ }
/* * upap_authwithpeer - Authenticate us with our peer (start client). * * Set new state and send authenticate's. */ void upap_authwithpeer(ppp_pcb *pcb, const char *user, const char *password) { if(!user || !password) return; /* Save the username and password we're given */ pcb->upap.us_user = user; pcb->upap.us_userlen = LWIP_MIN(strlen(user), 0xff); pcb->upap.us_passwd = password; pcb->upap.us_passwdlen = LWIP_MIN(strlen(password), 0xff); pcb->upap.us_transmits = 0; /* Lower layer up yet? */ if (pcb->upap.us_clientstate == UPAPCS_INITIAL || pcb->upap.us_clientstate == UPAPCS_PENDING) { pcb->upap.us_clientstate = UPAPCS_PENDING; return; } upap_sauthreq(pcb); /* Start protocol */ }
/* * upap_lowerup - The lower layer is up. * * Start authenticating if pending. */ static void upap_lowerup(int unit) { upap_state *u = &upap[unit]; UPAPDEBUG((LOG_INFO, "upap_lowerup: %d s=%d\n", unit, u->us_clientstate)); if (u->us_clientstate == UPAPCS_INITIAL) { u->us_clientstate = UPAPCS_CLOSED; } else if (u->us_clientstate == UPAPCS_PENDING) { upap_sauthreq(u); /* send an auth-request */ } if (u->us_serverstate == UPAPSS_INITIAL) { u->us_serverstate = UPAPSS_CLOSED; } else if (u->us_serverstate == UPAPSS_PENDING) { u->us_serverstate = UPAPSS_LISTEN; if (u->us_reqtimeout > 0) { TIMEOUT(upap_reqtimeout, u, u->us_reqtimeout); } } }
/* * upap_timeout - Retransmission timer for sending auth-reqs expired. */ static void upap_timeout(void *arg) { upap_state *u = (upap_state *) arg; UPAPDEBUG((LOG_INFO, "upap_timeout: %d timeout %d expired s=%d\n", u->us_unit, u->us_timeouttime, u->us_clientstate)); if (u->us_clientstate != UPAPCS_AUTHREQ) { return; } if (u->us_transmits >= u->us_maxtransmits) { /* give up in disgust */ UPAPDEBUG((LOG_ERR, "No response to PAP authenticate-requests\n")); u->us_clientstate = UPAPCS_BADAUTH; auth_withpeer_fail(u->us_unit, PPP_PAP); return; } upap_sauthreq(u); /* Send Authenticate-Request */ }