// L2TPNS PPP Stuff
-char const *cvs_id_ppp = "$Id: ppp.c,v 1.72 2005-08-12 08:18:46 bodea Exp $";
+char const *cvs_id_ppp = "$Id: ppp.c,v 1.76 2005-08-29 03:21:14 bodea Exp $";
#include <stdio.h>
#include <string.h>
CSTAT(processchap);
LOG_HEX(5, "CHAP", p, l);
- r = sess_local[s].radius;
- if (!r)
- {
- LOG(1, s, t, "Unexpected CHAP message\n");
- STAT(tunnel_rx_errors);
- return;
- }
if (l < 4)
{
return;
}
+ r = sess_local[s].radius;
+ if (!r)
+ {
+ LOG(3, s, t, "Unexpected CHAP message\n");
+ return;
+ }
+
if (session[s].ppp.phase != Authenticate)
{
LOG(2, s, t, "CHAP ignored in %s phase\n", ppp_phase(session[s].ppp.phase));
if (!queued)
return 0;
- *nak_sent++;
+ (*nak_sent)++;
*queued = ConfigNak;
queued += 4;
}
}
else if (*p == ProtocolRej)
{
- if (*(uint16_t *) (p+4) == htons(PPPIPV6CP))
+ uint16_t proto = 0;
+
+ if (l > 4)
+ {
+ proto = *(p+4);
+ if (l > 5 && !(proto & 1))
+ {
+ proto <<= 8;
+ proto |= *(p+5);
+ }
+ }
+
+ if (proto == PPPIPV6CP)
{
LOG(3, s, t, "IPv6 rejected\n");
change_state(s, ipv6cp, Closed);
}
else
{
- LOG(1, s, t, "Unexpected LCP protocol reject 0x%X\n",
- ntohs(*(uint16_t *) (p+4)));
- STAT(tunnel_rx_errors);
+ LOG(3, s, t, "LCP protocol reject: 0x%04X\n", proto);
}
}
else if (*p == EchoReq)
addr = htonl(session[s].ip);
if (memcmp(o + 2, &addr, (sizeof addr)))
{
+ uint8_t *oq = q;
q = ppp_nak(s, b, sizeof(b), PPPIPCP, &response, q, p, o, (uint8_t *) &addr, sizeof(addr));
- if (!q || *response == ConfigRej)
+ if (!q || (q != oq && *response == ConfigRej))
{
sessionshutdown(s, "Can't negotiate IPCP.", 3, 0);
return;