// Copyright (c) 2002 FireBrick (Andrews & Arnold Ltd / Watchfront Ltd) - GPL licenced
// vim: sw=8 ts=8
-char const *cvs_id_l2tpns = "$Id: l2tpns.c,v 1.86 2005-03-10 05:47:24 bodea Exp $";
+char const *cvs_id_l2tpns = "$Id: l2tpns.c,v 1.89 2005-04-01 06:39:00 bodea Exp $";
#include <arpa/inet.h>
#include <assert.h>
}
// start tidy shutdown of session
-void sessionshutdown(sessionidt s, char *reason)
+void sessionshutdown(sessionidt s, char *reason, int result, int error)
{
int walled_garden = session[s].walled_garden;
run_plugins(PLUGIN_KILL_SESSION, &data);
}
- if (!walled_garden && !session[s].die)
+ if (session[s].ip && !walled_garden && !session[s].die)
{
// RADIUS Stop message
uint16_t r = session[s].radius;
if (session[s].throttle_in || session[s].throttle_out) // Unthrottle if throttled.
throttle_session(s, 0, 0);
+ if (result)
{ // Send CDN
controlt *c = controlnew(14); // sending CDN
- control16(c, 1, 3, 1); // result code (admin reasons - TBA make error, general error, add message
+ if (error)
+ {
+ char buf[4];
+ *(uint16_t *) buf = htons(result);
+ *(uint16_t *) (buf+2) = htons(error);
+ controlb(c, 1, buf, 4, 1);
+ }
+ else
+ control16(c, 1, result, 1);
+
control16(c, 14, s, 1); // assigned session (our end)
controladd(c, session[s].tunnel, s); // send the message
}
if (radius[r].try > 10)
{
radiusclear(r, s); // Clear radius session.
- sessionshutdown(s, "No reply on IPCP");
+ sessionshutdown(s, "No reply on IPCP", 3, 0);
return;
}
}
session[s].die = TIME;
- sessionshutdown(s, reason); // close radius/routes, etc.
+ sessionshutdown(s, reason, 3, 0); // close radius/routes, etc.
if (session[s].radius)
radiusclear(session[s].radius, s); // cant send clean accounting data, session is killed
// close session
for (s = 1; s <= config->cluster_highest_sessionid ; ++s)
if (session[s].tunnel == t)
- sessionshutdown(s, reason);
+ sessionshutdown(s, reason, 3, 0);
tunnel[t].state = TUNNELDIE;
tunnel[t].die = TIME + 700; // Clean up in 70 seconds
break;
case 14: // CDN
controlnull(t); // ack
- sessionshutdown(s, "Closed (Received CDN)");
+ sessionshutdown(s, "Closed (Received CDN)", 0, 0);
break;
case 0xFFFF:
LOG(1, s, t, "Missing message type\n");
// Drop sessions who have not responded within IDLE_TIMEOUT seconds
if (session[s].last_packet && (time_now - session[s].last_packet >= IDLE_TIMEOUT))
{
- sessionshutdown(s, "No response to LCP ECHO requests");
+ sessionshutdown(s, "No response to LCP ECHO requests", 3, 0);
STAT(session_timeout);
if (++count >= MAX_ACTIONS) break;
continue;
}
- // No data in IDLE_TIMEOUT seconds, send LCP ECHO
+ // No data in ECHO_TIMEOUT seconds, send LCP ECHO
if (session[s].user[0] && (time_now - session[s].last_packet >= ECHO_TIMEOUT))
{
uint8_t b[MAXCONTROL] = {0};
if (a & CLI_SESS_KILL)
{
LOG(2, s, session[s].tunnel, "Dropping session by CLI\n");
- sessionshutdown(s, "Requested by administrator");
+ sessionshutdown(s, "Requested by administrator", 3, 0);
a = 0; // dead, no need to check for other actions
}
if (!session[s].ip)
{
LOG(0, s, t, " No IP allocated. The IP address pool is FULL!\n");
- sessionshutdown(s, "No IP addresses available");
+ sessionshutdown(s, "No IP addresses available", 2, 7);
return 0;
}
LOG(3, s, t, " No IP allocated. Assigned %s from pool\n",