l2tplac: move forward session creation to lac_create_session function
Which will be useful to fasten session creation after tunnel is created.
This commit is contained in:
parent
b48dfb2697
commit
b409fb7b9d
2 changed files with 45 additions and 38 deletions
62
l2tplac.c
62
l2tplac.c
|
|
@ -278,34 +278,8 @@ void lac_save_rad_tag_tunnels(sessionidt s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create Remote LNS a Tunnel or Session
|
// Create Remote LNS Session
|
||||||
static int lac_create_tunnelsession(tunnelidt t, sessionidt s, confrlnsidt i_conf, char * puser)
|
int lac_create_session(tunnelidt t, sessionidt s, char * puser)
|
||||||
{
|
|
||||||
if (t == 0)
|
|
||||||
{
|
|
||||||
if (main_quit == QUIT_SHUTDOWN) return 0;
|
|
||||||
|
|
||||||
// Start Open Tunnel
|
|
||||||
if (!(t = lac_new_tunnel()))
|
|
||||||
{
|
|
||||||
LOG(1, 0, 0, "No more tunnels\n");
|
|
||||||
STAT(tunnel_overflow);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
lac_tunnelclear(t);
|
|
||||||
tunnel[t].ip = pconfigrlns[i_conf].ip;
|
|
||||||
tunnel[t].port = pconfigrlns[i_conf].port;
|
|
||||||
tunnel[t].window = 4; // default window
|
|
||||||
tunnel[t].isremotelns = i_conf;
|
|
||||||
tunnel[t].indexudp = config->indexlacudpfd;
|
|
||||||
STAT(tunnel_created);
|
|
||||||
|
|
||||||
random_data(pconfigrlns[i_conf].auth, sizeof(pconfigrlns[i_conf].auth));
|
|
||||||
|
|
||||||
LOG(2, 0, t, "Create New tunnel to REMOTE LNS %s for user %s\n", fmtaddr(htonl(tunnel[t].ip), 0), puser);
|
|
||||||
lac_send_SCCRQ(t, pconfigrlns[i_conf].auth, sizeof(pconfigrlns[i_conf].auth));
|
|
||||||
}
|
|
||||||
else if (tunnel[t].state == TUNNELOPEN)
|
|
||||||
{
|
{
|
||||||
if (main_quit != QUIT_SHUTDOWN)
|
if (main_quit != QUIT_SHUTDOWN)
|
||||||
{
|
{
|
||||||
|
|
@ -346,6 +320,38 @@ static int lac_create_tunnelsession(tunnelidt t, sessionidt s, confrlnsidt i_con
|
||||||
lac_tunnelshutdown(t, "Shutting down", 6, 0, 0);
|
lac_tunnelshutdown(t, "Shutting down", 6, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create Remote LNS a Tunnel or Session
|
||||||
|
static int lac_create_tunnelsession(tunnelidt t, sessionidt s, confrlnsidt i_conf, char * puser)
|
||||||
|
{
|
||||||
|
if (t == 0)
|
||||||
|
{
|
||||||
|
if (main_quit == QUIT_SHUTDOWN) return 0;
|
||||||
|
|
||||||
|
// Start Open Tunnel
|
||||||
|
if (!(t = lac_new_tunnel()))
|
||||||
|
{
|
||||||
|
LOG(1, 0, 0, "No more tunnels\n");
|
||||||
|
STAT(tunnel_overflow);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
lac_tunnelclear(t);
|
||||||
|
tunnel[t].ip = pconfigrlns[i_conf].ip;
|
||||||
|
tunnel[t].port = pconfigrlns[i_conf].port;
|
||||||
|
tunnel[t].window = 4; // default window
|
||||||
|
tunnel[t].isremotelns = i_conf;
|
||||||
|
tunnel[t].indexudp = config->indexlacudpfd;
|
||||||
|
STAT(tunnel_created);
|
||||||
|
|
||||||
|
random_data(pconfigrlns[i_conf].auth, sizeof(pconfigrlns[i_conf].auth));
|
||||||
|
|
||||||
|
LOG(2, 0, t, "Create New tunnel to REMOTE LNS %s for user %s\n", fmtaddr(htonl(tunnel[t].ip), 0), puser);
|
||||||
|
lac_send_SCCRQ(t, pconfigrlns[i_conf].auth, sizeof(pconfigrlns[i_conf].auth));
|
||||||
|
}
|
||||||
|
else if (tunnel[t].state == TUNNELOPEN)
|
||||||
|
{
|
||||||
|
lac_create_session(t, s, puser);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/** TODO **/
|
/** TODO **/
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ typedef uint16_t confrlnsidt;
|
||||||
// l2tplac.c
|
// l2tplac.c
|
||||||
void lac_initremotelnsdata();
|
void lac_initremotelnsdata();
|
||||||
int lac_session_forward(uint8_t *buf, int len, sessionidt sess, uint16_t proto, in_addr_t s_addr, int sin_port, uint16_t indexudpfd);
|
int lac_session_forward(uint8_t *buf, int len, sessionidt sess, uint16_t proto, in_addr_t s_addr, int sin_port, uint16_t indexudpfd);
|
||||||
|
int lac_create_session(tunnelidt t, sessionidt s, char * puser);
|
||||||
int lac_conf_forwardtoremotelns(sessionidt s, char * puser);
|
int lac_conf_forwardtoremotelns(sessionidt s, char * puser);
|
||||||
void lac_calc_rlns_auth(tunnelidt t, uint8_t id, uint8_t *out);
|
void lac_calc_rlns_auth(tunnelidt t, uint8_t id, uint8_t *out);
|
||||||
void lac_calc_our_auth(tunnelidt t, uint8_t *challenge, uint8_t id, uint16_t challenge_length, uint8_t *out);
|
void lac_calc_our_auth(tunnelidt t, uint8_t *challenge, uint8_t id, uint16_t challenge_length, uint8_t *out);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue