X-Git-Url: http://git.sameswireless.fr/l2tpns.git/blobdiff_plain/6adc660b4946e81de5f659ea4217fee43496a733..439dc534eb2edc6dfc86cc281cb920e27ccb7df2:/l2tpns.c diff --git a/l2tpns.c b/l2tpns.c index 45d652e..2e620f8 100644 --- a/l2tpns.c +++ b/l2tpns.c @@ -4,7 +4,7 @@ // 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.12 2004-07-08 16:54:35 bodea Exp $"; +char const *cvs_id_l2tpns = "$Id: l2tpns.c,v 1.17 2004-07-28 04:01:12 fred_nerk Exp $"; #include #include @@ -100,6 +100,8 @@ struct config_descriptt config_values[] = { CONFIG("save_state", save_state, BOOL), CONFIG("primary_radius", radiusserver[0], IP), CONFIG("secondary_radius", radiusserver[1], IP), + CONFIG("primary_radius_port",radiusport[0], SHORT), + CONFIG("secondary_radius_port",radiusport[1], SHORT), CONFIG("radius_accounting", radius_accounting, BOOL), CONFIG("radius_secret", radiussecret, STRING), CONFIG("bind_address", bind_address, IP), @@ -111,6 +113,7 @@ struct config_descriptt config_values[] = { CONFIG("cleanup_interval", cleanup_interval, INT), CONFIG("multi_read_count", multi_read_count, INT), CONFIG("scheduler_fifo", scheduler_fifo, BOOL), + CONFIG("lock_pages", lock_pages, BOOL), CONFIG("icmp_rate", icmp_rate, INT), CONFIG("cluster_address", cluster_address, IP), CONFIG("cluster_interface", cluster_interface, STRING), @@ -143,10 +146,10 @@ char *plugin_functions[] = { #define max_plugin_functions (sizeof(plugin_functions) / sizeof(char *)) -tunnelt *tunnel = NULL; // Array of tunnel structures. -sessiont *session = NULL; // Array of session structures. +tunnelt *tunnel = NULL; // Array of tunnel structures. +sessiont *session = NULL; // Array of session structures. sessioncountt *sess_count = NULL; // Array of partial per-session traffic counters. -radiust *radius = NULL; // Array of radius structures. +radiust *radius = NULL; // Array of radius structures. ippoolt *ip_address_pool = NULL; // Array of dynamic IP addresses. controlt *controlfree = 0; struct Tstats *_statistics = NULL; @@ -1015,7 +1018,7 @@ void sessionshutdown(sessionidt s, char *reason) return; // not a live session } - if (!session[s].die) + if (!dead) log(2, 0, s, session[s].tunnel, "Shutting down session %d: %s\n", s, reason); session[s].die = now() + 150; // Clean up in 15 seconds @@ -1122,9 +1125,10 @@ void sessionkill(sessionidt s, char *reason) CSTAT(call_sessionkill); + session[s].die = now(); sessionshutdown(s, reason); // close radius/routes, etc. if (session[s].radius) - radiusclear(session[s].radius, 0); // cant send clean accounting data, session is killed + radiusclear(session[s].radius, s); // cant send clean accounting data, session is killed log(2, 0, s, session[s].tunnel, "Kill session %d (%s): %s\n", s, session[s].user, reason); @@ -1304,9 +1308,9 @@ void processudp(u8 * buf, int len, struct sockaddr_in *addr) // Is this a duplicate of the first packet? (SCCRQ) // for ( i = 1; i <= config->cluster_highest_tunnelid ; ++i) { - if (tunnel[t].state != TUNNELOPENING || - tunnel[t].ip != ntohl(*(ipt *) & addr->sin_addr) || - tunnel[t].port != ntohs(addr->sin_port) ) + if (tunnel[i].state != TUNNELOPENING || + tunnel[i].ip != ntohl(*(ipt *) & addr->sin_addr) || + tunnel[i].port != ntohs(addr->sin_port) ) continue; t = i; break; @@ -1555,6 +1559,8 @@ void processudp(u8 * buf, int len, struct sockaddr_in *addr) memcpy(calling, b, (n >= MAXTEL) ? (MAXTEL-1) : n); log(4, ntohl(addr->sin_addr.s_addr), s, t, " Calling <%s>\n", calling); break; + case 23: // subtype + break; case 24: // tx connect speed if (n == 4) { @@ -2835,6 +2841,7 @@ void dump_acct_info() int main(int argc, char *argv[]) { int o; + int optdebug = 0; _program_name = strdup(argv[0]); @@ -2851,7 +2858,7 @@ int main(int argc, char *argv[]) if (fork()) exit(0); break; case 'v': - config->debug++; + optdebug++; break; case 'h': snprintf(hostname, sizeof(hostname), "%s", optarg); @@ -2879,6 +2886,9 @@ int main(int argc, char *argv[]) initiptables(); initplugins(); initdata(); + + config->debug = optdebug; + init_tbf(); init_cli(hostname); read_config_file(); @@ -2954,6 +2964,15 @@ int main(int argc, char *argv[]) signal(SIGQUIT, sigquit_handler); signal(SIGCHLD, sigchild_handler); + // Prevent us from getting paged out + if (config->lock_pages) + { + if (!mlockall(MCL_CURRENT)) + log(1, 0, 0, 0, "Locking pages into memory\n"); + else + log(0, 0, 0, 0, "Can't lock pages: %s\n", strerror(errno)); + } + alarm(1); // Drop privileges here @@ -3310,7 +3329,21 @@ void update_config() // Update radius config->numradiusservers = 0; for (i = 0; i < MAXRADSERVER; i++) - if (config->radiusserver[i]) config->numradiusservers++; + if (config->radiusserver[i]) + { + config->numradiusservers++; + // Set radius port: if not set, take the port from the + // first radius server. For the first radius server, + // take the #defined default value from l2tpns.h + + // test twice, In case someone works with + // a secondary radius server without defining + // a primary one, this will work even then. + if (i>0 && !config->radiusport[i]) + config->radiusport[i] = config->radiusport[i-1]; + if (!config->radiusport[i]) + config->radiusport[i] = RADPORT; + } if (!config->numradiusservers) {