ipcp: try to re-send CHAP ack on timeout
If it was lost, some clients (e.g. pppd) may not try to re-send their CHAP reply.
This commit is contained in:
parent
b3b052a483
commit
366faaea76
3 changed files with 24 additions and 10 deletions
24
ppp.c
24
ppp.c
|
|
@ -170,6 +170,19 @@ void processpap(sessionidt s, tunnelidt t, uint8_t *p, uint16_t l)
|
|||
}
|
||||
}
|
||||
|
||||
// Re-send a CHAP ack, in case it was previously lost
|
||||
void resendchapack(sessionidt s, tunnelidt t, uint16_t auth_id)
|
||||
{
|
||||
uint8_t b[MAXETHER];
|
||||
uint8_t *p;
|
||||
p = makeppp(b, sizeof(b), 0, 0, s, t, PPPCHAP, 0, 0, 0);
|
||||
if (!p) return;
|
||||
*p = 3; // ack
|
||||
p[1] = auth_id;
|
||||
*(uint16_t *) (p + 2) = ntohs(4); // no message
|
||||
tunnelsend(b, (p - b) + 4, t); // send it
|
||||
}
|
||||
|
||||
// Process CHAP messages
|
||||
void processchap(sessionidt s, tunnelidt t, uint8_t *p, uint16_t l)
|
||||
{
|
||||
|
|
@ -209,15 +222,8 @@ void processchap(sessionidt s, tunnelidt t, uint8_t *p, uint16_t l)
|
|||
{
|
||||
if (session[s].ppp.phase == Network)
|
||||
{
|
||||
uint8_t b[MAXETHER];
|
||||
uint8_t *p2;
|
||||
LOG(2, s, t, "CHAP in Network phase, peer probably missed our ack, confirming it\n");
|
||||
p2 = makeppp(b, sizeof(b), 0, 0, s, t, PPPCHAP, 0, 0, 0);
|
||||
if (!p2) return;
|
||||
*p2 = 3; // ack
|
||||
p2[1] = p[1];
|
||||
*(uint16_t *) (p2 + 2) = ntohs(4); // no message
|
||||
tunnelsend(b, (p2 - b) + 4, t); // send it
|
||||
resendchapack(s, t, p[1]);
|
||||
}
|
||||
else
|
||||
LOG(2, s, t, "CHAP ignored in %s phase\n", ppp_phase(session[s].ppp.phase));
|
||||
|
|
@ -405,7 +411,7 @@ static void dumplcp(uint8_t *p, int l)
|
|||
void lcp_open(sessionidt s, tunnelidt t)
|
||||
{
|
||||
// transition to Authentication or Network phase:
|
||||
session[s].ppp.phase = sess_local[s].lcp_authtype ? Authenticate : Network;
|
||||
session[s].ppp.phase = sess_local[s].lcp_authtype && !sess_local[s].lcp_authdone ? Authenticate : Network;
|
||||
|
||||
LOG(3, s, t, "LCP: Opened, phase %s\n", ppp_phase(session[s].ppp.phase));
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue