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
82
l2tplac.c
82
l2tplac.c
|
|
@ -278,6 +278,49 @@ void lac_save_rad_tag_tunnels(sessionidt s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create Remote LNS Session
|
||||||
|
int lac_create_session(tunnelidt t, sessionidt s, char * puser)
|
||||||
|
{
|
||||||
|
if (main_quit != QUIT_SHUTDOWN)
|
||||||
|
{
|
||||||
|
|
||||||
|
/**********************/
|
||||||
|
/** Open New session **/
|
||||||
|
/**********************/
|
||||||
|
sessionidt new_sess = sessionfree;
|
||||||
|
|
||||||
|
sessionfree = session[new_sess].next;
|
||||||
|
memset(&session[new_sess], 0, sizeof(session[new_sess]));
|
||||||
|
|
||||||
|
if (new_sess > config->cluster_highest_sessionid)
|
||||||
|
config->cluster_highest_sessionid = new_sess;
|
||||||
|
|
||||||
|
session[new_sess].opened = time_now;
|
||||||
|
session[new_sess].tunnel = t;
|
||||||
|
session[new_sess].last_packet = session[s].last_data = time_now;
|
||||||
|
|
||||||
|
session[new_sess].ppp.phase = Establish;
|
||||||
|
session[new_sess].ppp.lcp = Starting;
|
||||||
|
session[s].ppp.phase = Establish;
|
||||||
|
|
||||||
|
LOG(2, 0, t, "Open New session to REMOTE LNS %s for user: %s\n", fmtaddr(htonl(tunnel[t].ip), 0), puser);
|
||||||
|
// Sent ICRQ Incoming-call-request
|
||||||
|
lac_send_ICRQ(t, new_sess);
|
||||||
|
|
||||||
|
// Set session to forward to another LNS
|
||||||
|
session[s].forwardtosession = new_sess;
|
||||||
|
session[new_sess].forwardtosession = s;
|
||||||
|
strncpy(session[s].user, puser, sizeof(session[s].user) - 1);
|
||||||
|
strncpy(session[new_sess].user, puser, sizeof(session[new_sess].user) - 1);
|
||||||
|
|
||||||
|
STAT(session_created);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lac_tunnelshutdown(t, "Shutting down", 6, 0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 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)
|
||||||
{
|
{
|
||||||
|
|
@ -307,44 +350,7 @@ static int lac_create_tunnelsession(tunnelidt t, sessionidt s, confrlnsidt i_con
|
||||||
}
|
}
|
||||||
else if (tunnel[t].state == TUNNELOPEN)
|
else if (tunnel[t].state == TUNNELOPEN)
|
||||||
{
|
{
|
||||||
if (main_quit != QUIT_SHUTDOWN)
|
lac_create_session(t, s, puser);
|
||||||
{
|
|
||||||
|
|
||||||
/**********************/
|
|
||||||
/** Open New session **/
|
|
||||||
/**********************/
|
|
||||||
sessionidt new_sess = sessionfree;
|
|
||||||
|
|
||||||
sessionfree = session[new_sess].next;
|
|
||||||
memset(&session[new_sess], 0, sizeof(session[new_sess]));
|
|
||||||
|
|
||||||
if (new_sess > config->cluster_highest_sessionid)
|
|
||||||
config->cluster_highest_sessionid = new_sess;
|
|
||||||
|
|
||||||
session[new_sess].opened = time_now;
|
|
||||||
session[new_sess].tunnel = t;
|
|
||||||
session[new_sess].last_packet = session[s].last_data = time_now;
|
|
||||||
|
|
||||||
session[new_sess].ppp.phase = Establish;
|
|
||||||
session[new_sess].ppp.lcp = Starting;
|
|
||||||
session[s].ppp.phase = Establish;
|
|
||||||
|
|
||||||
LOG(2, 0, t, "Open New session to REMOTE LNS %s for user: %s\n", fmtaddr(htonl(tunnel[t].ip), 0), puser);
|
|
||||||
// Sent ICRQ Incoming-call-request
|
|
||||||
lac_send_ICRQ(t, new_sess);
|
|
||||||
|
|
||||||
// Set session to forward to another LNS
|
|
||||||
session[s].forwardtosession = new_sess;
|
|
||||||
session[new_sess].forwardtosession = s;
|
|
||||||
strncpy(session[s].user, puser, sizeof(session[s].user) - 1);
|
|
||||||
strncpy(session[new_sess].user, puser, sizeof(session[new_sess].user) - 1);
|
|
||||||
|
|
||||||
STAT(session_created);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
lac_tunnelshutdown(t, "Shutting down", 6, 0, 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -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