Fix LAC functionnality
This commit is contained in:
parent
5e65215ed4
commit
bcc2c7408b
4 changed files with 31 additions and 23 deletions
21
l2tplac.c
21
l2tplac.c
|
|
@ -196,7 +196,8 @@ int lac_rad_select_assignment_id(sessionidt s, char *assignment_id)
|
||||||
if (nbtagfound > 0)
|
if (nbtagfound > 0)
|
||||||
{
|
{
|
||||||
// random between 0 and nbtagfound-1
|
// random between 0 and nbtagfound-1
|
||||||
idtag = (nbtagfound*rand()/(RAND_MAX+1.0));
|
idtag = (rand() % nbtagfound);
|
||||||
|
|
||||||
if (idtag >= nbtagfound)
|
if (idtag >= nbtagfound)
|
||||||
idtag = 0; //Sanity checks.
|
idtag = 0; //Sanity checks.
|
||||||
|
|
||||||
|
|
@ -227,6 +228,7 @@ void lac_save_rad_tag_tunnels(sessionidt s)
|
||||||
else if (strlen(ptunnelrlns[idtag].tunnel_assignment_id) <= 0)
|
else if (strlen(ptunnelrlns[idtag].tunnel_assignment_id) <= 0)
|
||||||
LOG(1, s, session[s].tunnel, "Error, No tunnel_assignment_id \n");
|
LOG(1, s, session[s].tunnel, "Error, No tunnel_assignment_id \n");
|
||||||
else
|
else
|
||||||
|
{
|
||||||
for (idrlns = 1; idrlns < MAXRLNSTUNNEL; ++idrlns)
|
for (idrlns = 1; idrlns < MAXRLNSTUNNEL; ++idrlns)
|
||||||
{
|
{
|
||||||
if (pconfigrlns[idrlns].state == CONFRLNSFREE)
|
if (pconfigrlns[idrlns].state == CONFRLNSFREE)
|
||||||
|
|
@ -247,7 +249,6 @@ void lac_save_rad_tag_tunnels(sessionidt s)
|
||||||
if ( (pconfigrlns[idrlns].ip == ptunnelrlns[idtag].tunnel_server_endpoint) &&
|
if ( (pconfigrlns[idrlns].ip == ptunnelrlns[idtag].tunnel_server_endpoint) &&
|
||||||
(strcmp(pconfigrlns[idrlns].tunnel_assignment_id, ptunnelrlns[idtag].tunnel_assignment_id) == 0) )
|
(strcmp(pconfigrlns[idrlns].tunnel_assignment_id, ptunnelrlns[idtag].tunnel_assignment_id) == 0) )
|
||||||
{
|
{
|
||||||
LOG(3, s, session[s].tunnel, "Tunnel IP %s already defined\n", fmtaddr(htonl(pconfigrlns[idrlns].ip), 0));
|
|
||||||
// l2tp_secret may be changed
|
// l2tp_secret may be changed
|
||||||
strcpy(pconfigrlns[idrlns].l2tp_secret, ptunnelrlns[idtag].tunnel_password);
|
strcpy(pconfigrlns[idrlns].l2tp_secret, ptunnelrlns[idtag].tunnel_password);
|
||||||
pconfigrlns[idrlns].port = L2TPPORT; //Default L2TP poart
|
pconfigrlns[idrlns].port = L2TPPORT; //Default L2TP poart
|
||||||
|
|
@ -266,6 +267,7 @@ void lac_save_rad_tag_tunnels(sessionidt s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Create Remote LNS a Tunnel or Session
|
// Create Remote LNS a Tunnel or Session
|
||||||
static int lac_create_tunnelsession(tunnelidt t, sessionidt s, confrlnsidt i_conf, char * puser)
|
static int lac_create_tunnelsession(tunnelidt t, sessionidt s, confrlnsidt i_conf, char * puser)
|
||||||
|
|
@ -569,8 +571,9 @@ int lac_cli_show_remotelns(confrlnsidt idrlns, char *strout)
|
||||||
|
|
||||||
if (idrlns == 0)
|
if (idrlns == 0)
|
||||||
// Show Summary
|
// Show Summary
|
||||||
sprintf(strout, "%15s %-32s %-32s %11s %7s %10s",
|
sprintf(strout, "%15s %3s %-32s %-32s %11s %7s %10s",
|
||||||
"IP Remote LNS",
|
"IP Remote LNS",
|
||||||
|
"TID",
|
||||||
"l2tp secret",
|
"l2tp secret",
|
||||||
"assignment Id",
|
"assignment Id",
|
||||||
"File/Radius",
|
"File/Radius",
|
||||||
|
|
@ -578,7 +581,7 @@ int lac_cli_show_remotelns(confrlnsidt idrlns, char *strout)
|
||||||
"Count Sess");
|
"Count Sess");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
tunnelidt t;
|
tunnelidt t, tfound = 0;
|
||||||
sessionidt s;
|
sessionidt s;
|
||||||
int countsess = 0;
|
int countsess = 0;
|
||||||
char state[20];
|
char state[20];
|
||||||
|
|
@ -586,12 +589,10 @@ int lac_cli_show_remotelns(confrlnsidt idrlns, char *strout)
|
||||||
strcpy(state, "Close");
|
strcpy(state, "Close");
|
||||||
for (t = 0; t <= config->cluster_highest_tunnelid ; ++t)
|
for (t = 0; t <= config->cluster_highest_tunnelid ; ++t)
|
||||||
{
|
{
|
||||||
if ((tunnel[t].isremotelns) &&
|
if ((tunnel[t].isremotelns == idrlns) &&
|
||||||
(tunnel[t].ip == pconfigrlns[idrlns].ip) &&
|
(tunnel[t].ip == pconfigrlns[idrlns].ip) &&
|
||||||
(tunnel[t].port == pconfigrlns[idrlns].port) &&
|
(tunnel[t].port == pconfigrlns[idrlns].port) &&
|
||||||
(tunnel[t].state != TUNNELDIE))
|
(tunnel[t].state != TUNNELDIE))
|
||||||
{
|
|
||||||
if (tunnel[t].isremotelns)
|
|
||||||
{
|
{
|
||||||
if (tunnel[t].state == TUNNELOPENING)
|
if (tunnel[t].state == TUNNELOPENING)
|
||||||
strcpy(state, "Opening");
|
strcpy(state, "Opening");
|
||||||
|
|
@ -601,14 +602,14 @@ int lac_cli_show_remotelns(confrlnsidt idrlns, char *strout)
|
||||||
for (s = 1; s <= config->cluster_highest_sessionid ; ++s)
|
for (s = 1; s <= config->cluster_highest_sessionid ; ++s)
|
||||||
if (session[s].tunnel == t)
|
if (session[s].tunnel == t)
|
||||||
countsess++;
|
countsess++;
|
||||||
|
tfound = t;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
sprintf(strout, "%15s %-32s %-32s %11s %7s %10u",
|
sprintf(strout, "%15s %3u %-32s %-32s %11s %7s %10u",
|
||||||
fmtaddr(htonl(pconfigrlns[idrlns].ip), 0),
|
fmtaddr(htonl(pconfigrlns[idrlns].ip), 0),
|
||||||
|
tfound,
|
||||||
pconfigrlns[idrlns].l2tp_secret,
|
pconfigrlns[idrlns].l2tp_secret,
|
||||||
pconfigrlns[idrlns].tunnel_assignment_id,
|
pconfigrlns[idrlns].tunnel_assignment_id,
|
||||||
(pconfigrlns[idrlns].state == CONFRLNSSET?"File":(pconfigrlns[idrlns].state == CONFRLNSSETBYRADIUS?"Radius":"Free")),
|
(pconfigrlns[idrlns].state == CONFRLNSSET?"File":(pconfigrlns[idrlns].state == CONFRLNSSETBYRADIUS?"Radius":"Free")),
|
||||||
|
|
|
||||||
1
l2tpns.h
1
l2tpns.h
|
|
@ -874,6 +874,7 @@ void sendarp(int ifr_idx, const unsigned char* mac, in_addr_t ip);
|
||||||
void processpap(sessionidt s, tunnelidt t, uint8_t *p, uint16_t l);
|
void processpap(sessionidt s, tunnelidt t, uint8_t *p, uint16_t l);
|
||||||
void processchap(sessionidt s, tunnelidt t, uint8_t *p, uint16_t l);
|
void processchap(sessionidt s, tunnelidt t, uint8_t *p, uint16_t l);
|
||||||
void lcp_open(sessionidt s, tunnelidt t);
|
void lcp_open(sessionidt s, tunnelidt t);
|
||||||
|
void lcp_restart(sessionidt s);
|
||||||
void processlcp(sessionidt s, tunnelidt t, uint8_t *p, uint16_t l);
|
void processlcp(sessionidt s, tunnelidt t, uint8_t *p, uint16_t l);
|
||||||
void processipcp(sessionidt s, tunnelidt t, uint8_t *p, uint16_t l);
|
void processipcp(sessionidt s, tunnelidt t, uint8_t *p, uint16_t l);
|
||||||
void processipv6cp(sessionidt s, tunnelidt t, uint8_t *p, uint16_t l);
|
void processipv6cp(sessionidt s, tunnelidt t, uint8_t *p, uint16_t l);
|
||||||
|
|
|
||||||
2
ppp.c
2
ppp.c
|
|
@ -425,7 +425,7 @@ void lcp_open(sessionidt s, tunnelidt t)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void lcp_restart(sessionidt s)
|
void lcp_restart(sessionidt s)
|
||||||
{
|
{
|
||||||
session[s].ppp.phase = Establish;
|
session[s].ppp.phase = Establish;
|
||||||
// This-Layer-Down
|
// This-Layer-Down
|
||||||
|
|
|
||||||
6
radius.c
6
radius.c
|
|
@ -947,6 +947,8 @@ void processrad(uint8_t *buf, int len, char socket_index)
|
||||||
if (!lac_rad_select_assignment_id(s, assignment_id))
|
if (!lac_rad_select_assignment_id(s, assignment_id))
|
||||||
break; // Error no assignment_id
|
break; // Error no assignment_id
|
||||||
|
|
||||||
|
LOG(3, s, session[s].tunnel, "Select Tunnel Remote LNS for assignment_id == %s\n", assignment_id);
|
||||||
|
|
||||||
if (lac_rad_forwardtoremotelns(s, assignment_id, session[s].user))
|
if (lac_rad_forwardtoremotelns(s, assignment_id, session[s].user))
|
||||||
{
|
{
|
||||||
int ro;
|
int ro;
|
||||||
|
|
@ -956,6 +958,10 @@ void processrad(uint8_t *buf, int len, char socket_index)
|
||||||
{
|
{
|
||||||
session[s].route[ro].ip = 0;
|
session[s].route[ro].ip = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Restart LCP auth...
|
||||||
|
lcp_restart(s);
|
||||||
|
sendlcp(s, t);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue