mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-08-25 07:33:11 +00:00
global variables removed from chap support
This commit is contained in:
parent
2deb13df43
commit
19238a910c
@ -1348,8 +1348,8 @@ auth_check_options()
|
||||
#endif /* EAP_SUPPORT */
|
||||
) {
|
||||
#if CHAP_SUPPORT
|
||||
wo->neg_chap = chap_mdtype_all != MDTYPE_NONE;
|
||||
wo->chap_mdtype = chap_mdtype_all;
|
||||
wo->neg_chap = pcb->chap_mdtype_all != MDTYPE_NONE;
|
||||
wo->chap_mdtype = pcb->chap_mdtype_all;
|
||||
#endif /* CHAP_SUPPORT */
|
||||
#if PAP_SUPPORT
|
||||
wo->neg_upap = 1;
|
||||
|
@ -52,21 +52,12 @@
|
||||
#define MDTYPE_ALL (MDTYPE_MD5)
|
||||
#endif
|
||||
|
||||
int chap_mdtype_all = MDTYPE_ALL;
|
||||
|
||||
/* Hook for a plugin to validate CHAP challenge */
|
||||
int (*chap_verify_hook)(char *name, char *ourname, int id,
|
||||
struct chap_digest_type *digest,
|
||||
unsigned char *challenge, unsigned char *response,
|
||||
char *message, int message_space) = NULL;
|
||||
|
||||
/*
|
||||
* Option variables.
|
||||
*/
|
||||
int chap_timeout_time = 3;
|
||||
int chap_max_transmits = 10;
|
||||
int chap_rechallenge_time = 0;
|
||||
|
||||
#if PPP_OPTIONS
|
||||
/*
|
||||
* Command-line options.
|
||||
@ -74,9 +65,9 @@ int chap_rechallenge_time = 0;
|
||||
static option_t chap_option_list[] = {
|
||||
{ "chap-restart", o_int, &chap_timeout_time,
|
||||
"Set timeout for CHAP", OPT_PRIO },
|
||||
{ "chap-max-challenge", o_int, &chap_max_transmits,
|
||||
{ "chap-max-challenge", o_int, &pcb->settings.chap_max_transmits,
|
||||
"Set max #xmits for challenge", OPT_PRIO },
|
||||
{ "chap-interval", o_int, &chap_rechallenge_time,
|
||||
{ "chap-interval", o_int, &pcb->settings.chap_rechallenge_time,
|
||||
"Set interval for rechallenge", OPT_PRIO },
|
||||
{ NULL }
|
||||
};
|
||||
@ -138,6 +129,8 @@ static void chap_init(int unit) {
|
||||
memset(&pcb->chap_server, 0, sizeof(chap_server_state));
|
||||
#endif /* PPP_SERVER */
|
||||
|
||||
pcb->chap_mdtype_all = MDTYPE_ALL;
|
||||
|
||||
chap_md5_init();
|
||||
#if MSCHAP_SUPPORT
|
||||
chapms_init();
|
||||
@ -245,7 +238,7 @@ static void chap_timeout(void *arg) {
|
||||
pcb->chap_server.challenge_xmits = 0;
|
||||
chap_generate_challenge(pcb);
|
||||
pcb->chap_server.flags |= CHALLENGE_VALID;
|
||||
} else if (pcb->chap_server.challenge_xmits >= chap_max_transmits) {
|
||||
} else if (pcb->chap_server.challenge_xmits >= pcb->settings.chap_max_transmits) {
|
||||
pcb->chap_server.flags &= ~CHALLENGE_VALID;
|
||||
pcb->chap_server.flags |= AUTH_DONE | AUTH_FAILED;
|
||||
auth_peer_fail(pcb, PPP_CHAP);
|
||||
@ -255,7 +248,7 @@ static void chap_timeout(void *arg) {
|
||||
ppp_write(pcb, pcb->chap_server.challenge, pcb->chap_server.challenge_pktlen);
|
||||
++pcb->chap_server.challenge_xmits;
|
||||
pcb->chap_server.flags |= TIMEOUT_PENDING;
|
||||
TIMEOUT(chap_timeout, arg, chap_timeout_time);
|
||||
TIMEOUT(chap_timeout, arg, pcb->settings.chap_timeout_time);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -380,10 +373,10 @@ static void chap_handle_response(ppp_pcb *pcb, int id,
|
||||
auth_peer_success(pcb, PPP_CHAP,
|
||||
pcb->chap_server.digest->code,
|
||||
name, strlen(name));
|
||||
if (chap_rechallenge_time) {
|
||||
if (pcb->settings.chap_rechallenge_time) {
|
||||
pcb->chap_server.flags |= TIMEOUT_PENDING;
|
||||
TIMEOUT(chap_timeout, pcb,
|
||||
chap_rechallenge_time);
|
||||
pcb->settings.chap_rechallenge_time);
|
||||
}
|
||||
}
|
||||
pcb->chap_server.flags |= AUTH_DONE;
|
||||
|
@ -67,9 +67,6 @@
|
||||
#define MDTYPE_MD5 0x4
|
||||
#define MDTYPE_NONE 0
|
||||
|
||||
/* hashes supported by this instance of pppd */
|
||||
extern int chap_mdtype_all;
|
||||
|
||||
#if MSCHAP_SUPPORT
|
||||
/* Return the digest alg. ID for the most preferred digest type. */
|
||||
#define CHAP_DIGEST(mdtype) \
|
||||
|
@ -378,6 +378,7 @@ static void
|
||||
lcp_init(unit)
|
||||
int unit;
|
||||
{
|
||||
ppp_pcb *pcb = &ppp_pcb_list[unit];
|
||||
fsm *f = &lcp_fsm[unit];
|
||||
lcp_options *wo = &lcp_wantoptions[unit];
|
||||
lcp_options *ao = &lcp_allowoptions[unit];
|
||||
@ -402,7 +403,7 @@ lcp_init(unit)
|
||||
ao->neg_asyncmap = 1;
|
||||
#if CHAP_SUPPORT
|
||||
ao->neg_chap = 1;
|
||||
ao->chap_mdtype = chap_mdtype_all;
|
||||
ao->chap_mdtype = pcb->chap_mdtype_all;
|
||||
#endif /* CHAP_SUPPORT */
|
||||
#if PAP_SUPPORT
|
||||
ao->neg_upap = 1;
|
||||
|
@ -255,8 +255,13 @@ ppp_pcb *ppp_new(void) {
|
||||
pcb->status = EXIT_OK;
|
||||
new_phase(pcb, PHASE_INITIALIZE);
|
||||
|
||||
/* default configuration */
|
||||
pcb->settings.usepeerdns = 1;
|
||||
pcb->settings.persist = 1;
|
||||
#if CHAP_SUPPORT
|
||||
pcb->settings.chap_timeout_time = 3;
|
||||
pcb->settings.chap_max_transmits = 10;
|
||||
#endif /* CHAP_SUPPPORT */
|
||||
|
||||
/*
|
||||
* Initialize each protocol.
|
||||
|
@ -169,6 +169,12 @@ typedef struct ppp_settings_s {
|
||||
#endif /* PPP_SERVER */
|
||||
/* FIXME: make it a compile time option */
|
||||
char remote_name[MAXNAMELEN + 1]; /* Peer's name for authentication */
|
||||
|
||||
#if CHAP_SUPPORT
|
||||
int chap_timeout_time;
|
||||
int chap_max_transmits;
|
||||
int chap_rechallenge_time;
|
||||
#endif /* CHAP_SUPPPORT */
|
||||
} ppp_settings;
|
||||
|
||||
struct ppp_addrs {
|
||||
@ -374,6 +380,8 @@ typedef struct ppp_pcb_s {
|
||||
#endif /* PAP_SUPPORT */
|
||||
|
||||
#if CHAP_SUPPORT
|
||||
/* FIXME: we can probably remove this entry */
|
||||
int chap_mdtype_all; /* hashes supported by this instance of pppd */
|
||||
chap_client_state chap_client;
|
||||
#if PPP_SERVER
|
||||
chap_server_state chap_server;
|
||||
|
Loading…
Reference in New Issue
Block a user