use random_data() to set radius[].auth
-char const *cvs_id_ppp = "$Id: ppp.c,v 1.39 2004-12-16 08:49:53 bodea Exp $";
+char const *cvs_id_ppp = "$Id: ppp.c,v 1.40 2005-01-05 13:50:30 bodea Exp $";
#include <stdio.h>
#include <string.h>
#include <stdio.h>
#include <string.h>
char pass[129];
uint16_t hl;
char pass[129];
uint16_t hl;
- CSTAT(call_processpap);
LOG_HEX(5, "PAP", p, l);
if (l < 4)
LOG_HEX(5, "PAP", p, l);
if (l < 4)
- CSTAT(call_processchap);
LOG_HEX(5, "CHAP", p, l);
r = session[s].radius;
LOG_HEX(5, "CHAP", p, l);
r = session[s].radius;
radiussend(r, RADIUSAUTH);
}
radiussend(r, RADIUSAUTH);
}
-static char *ppp_lcp_types[] = {
- NULL,
- "ConfigReq",
- "ConfigAck",
- "ConfigNak",
- "ConfigRej",
- "TerminateReq",
- "TerminateAck",
- "CodeRej",
- "ProtocolRej",
- "EchoReq",
- "EchoReply",
- "DiscardRequest",
- "IdentRequest",
-};
-
static void dumplcp(uint8_t *p, int l)
{
int x = l - 4;
uint8_t *o = (p + 4);
LOG_HEX(5, "PPP LCP Packet", p, l);
static void dumplcp(uint8_t *p, int l)
{
int x = l - 4;
uint8_t *o = (p + 4);
LOG_HEX(5, "PPP LCP Packet", p, l);
- LOG(4, 0, 0, "PPP LCP Packet type %d (%s len %d)\n", *p, ppp_lcp_types[(int)*p], ntohs( ((uint16_t *) p)[1]) );
+ LOG(4, 0, 0, "PPP LCP Packet type %d (%s len %d)\n", *p, ppp_lcp_type((int)*p), ntohs( ((uint16_t *) p)[1]) );
LOG(4, 0, 0, "Length: %d\n", l);
if (*p != ConfigReq && *p != ConfigRej && *p != ConfigAck)
return;
LOG(4, 0, 0, "Length: %d\n", l);
if (*p != ConfigReq && *p != ConfigRej && *p != ConfigAck)
return;
{
case 1: // Maximum-Receive-Unit
if (length == 4)
{
case 1: // Maximum-Receive-Unit
if (length == 4)
- LOG(4, 0, 0, " %s %d\n", lcp_types[type], ntohs(*(uint16_t *)(o + 2)));
+ LOG(4, 0, 0, " %s %d\n", lcp_type(type), ntohs(*(uint16_t *)(o + 2)));
- LOG(4, 0, 0, " %s odd length %d\n", lcp_types[type], length);
+ LOG(4, 0, 0, " %s odd length %d\n", lcp_type(type), length);
break;
case 2: // Async-Control-Character-Map
if (length == 6)
{
uint32_t asyncmap = ntohl(*(uint32_t *)(o + 2));
break;
case 2: // Async-Control-Character-Map
if (length == 6)
{
uint32_t asyncmap = ntohl(*(uint32_t *)(o + 2));
- LOG(4, 0, 0, " %s %x\n", lcp_types[type], asyncmap);
+ LOG(4, 0, 0, " %s %x\n", lcp_type(type), asyncmap);
- LOG(4, 0, 0, " %s odd length %d\n", lcp_types[type], length);
+ LOG(4, 0, 0, " %s odd length %d\n", lcp_type(type), length);
break;
case 3: // Authentication-Protocol
if (length == 4)
{
int proto = ntohs(*(uint16_t *)(o + 2));
break;
case 3: // Authentication-Protocol
if (length == 4)
{
int proto = ntohs(*(uint16_t *)(o + 2));
- LOG(4, 0, 0, " %s 0x%x (%s)\n", lcp_types[type], proto,
+ LOG(4, 0, 0, " %s 0x%x (%s)\n", lcp_type(type), proto,
proto == PPPCHAP ? "CHAP" :
proto == PPPPAP ? "PAP" : "UNKNOWN");
}
else
proto == PPPCHAP ? "CHAP" :
proto == PPPPAP ? "PAP" : "UNKNOWN");
}
else
- LOG(4, 0, 0, " %s odd length %d\n", lcp_types[type], length);
+ LOG(4, 0, 0, " %s odd length %d\n", lcp_type(type), length);
break;
case 4: // Quality-Protocol
{
uint32_t qp = ntohl(*(uint32_t *)(o + 2));
break;
case 4: // Quality-Protocol
{
uint32_t qp = ntohl(*(uint32_t *)(o + 2));
- LOG(4, 0, 0, " %s %x\n", lcp_types[type], qp);
+ LOG(4, 0, 0, " %s %x\n", lcp_type(type), qp);
}
break;
case 5: // Magic-Number
if (length == 6)
{
uint32_t magicno = ntohl(*(uint32_t *)(o + 2));
}
break;
case 5: // Magic-Number
if (length == 6)
{
uint32_t magicno = ntohl(*(uint32_t *)(o + 2));
- LOG(4, 0, 0, " %s %x\n", lcp_types[type], magicno);
+ LOG(4, 0, 0, " %s %x\n", lcp_type(type), magicno);
- LOG(4, 0, 0, " %s odd length %d\n", lcp_types[type], length);
+ LOG(4, 0, 0, " %s odd length %d\n", lcp_type(type), length);
break;
case 7: // Protocol-Field-Compression
case 8: // Address-And-Control-Field-Compression
break;
case 7: // Protocol-Field-Compression
case 8: // Address-And-Control-Field-Compression
- LOG(4, 0, 0, " %s\n", lcp_types[type]);
+ LOG(4, 0, 0, " %s\n", lcp_type(type));
break;
default:
LOG(2, 0, 0, " Unknown PPP LCP Option type %d\n", type);
break;
default:
LOG(2, 0, 0, " Unknown PPP LCP Option type %d\n", type);
uint32_t magicno = 0;
uint16_t hl;
uint32_t magicno = 0;
uint16_t hl;
- CSTAT(call_processlcp);
LOG_HEX(5, "LCP", p, l);
if (l < 4)
LOG_HEX(5, "LCP", p, l);
if (l < 4)
- LOG(3, s, t, "Sending %s\n", ppp_lcp_types[*response]);
+ LOG(3, s, t, "Sending %s\n", ppp_lcp_type(*response));
tunnelsend(b, l + (q - b), t);
if (!(session[s].flags & SF_LCP_ACKED))
tunnelsend(b, l + (q - b), t);
if (!(session[s].flags & SF_LCP_ACKED))
- CSTAT(call_processipcp);
LOG_HEX(5, "IPCP", p, l);
if (l < 5)
LOG_HEX(5, "IPCP", p, l);
if (l < 5)
- CSTAT(call_processipin);
uint8_t b[MAXCONTROL];
uint8_t *q;
uint8_t b[MAXCONTROL];
uint8_t *q;
- CSTAT(call_processccp);
LOG_HEX(5, "CCP", p, l);
switch (l > 1 ? *p : 0)
LOG_HEX(5, "CCP", p, l);
switch (l > 1 ? *p : 0)
uint16_t r = session[s].radius;
uint8_t *q;
uint16_t r = session[s].radius;
uint8_t *q;
if (!r)
{
LOG(1, s, t, "No RADIUS to send challenge\n");
STAT(tunnel_tx_errors);
if (!r)
{
LOG(1, s, t, "No RADIUS to send challenge\n");
STAT(tunnel_tx_errors);
LOG(1, s, t, "Send CHAP challenge\n");
LOG(1, s, t, "Send CHAP challenge\n");
- {
- // new challenge
- int n;
- for (n = 0; n < 15; n++)
- radius[r].auth[n] = rand();
- }
+
+ // new challenge
+ random_data(radius[r].auth, sizeof(radius[r].auth));
radius[r].chap = 1; // CHAP not PAP
radius[r].id++;
if (radius[r].state != RADIUSCHAP)
radius[r].try = 0;
radius[r].chap = 1; // CHAP not PAP
radius[r].id++;
if (radius[r].state != RADIUSCHAP)
radius[r].try = 0;
radius[r].state = RADIUSCHAP;
radius[r].retry = backoff(radius[r].try++);
if (radius[r].try > 5)
radius[r].state = RADIUSCHAP;
radius[r].retry = backoff(radius[r].try++);
if (radius[r].try > 5)