Merge remote-tracking branch 'new-upstream/master' into common-cvs-git-upstream

Choose the git version when conflicts happen.
This commit is contained in:
Benjamin Cama 2012-02-02 00:34:35 +01:00
commit 6b36bc85b2
30 changed files with 123 additions and 224 deletions

View file

@ -1,8 +1,13 @@
* Thu Jan 20 2011 Brendan O'Dea <bod@optus.net> 2.2.x * Sun Sep 11 2011 Brendan O'Dea <bod@optus.net> 2.2.x
- Apply MLPPP patch from Muhammad Tayseer Alquoatli. - Apply MLPPP patch from Muhammad Tayseer Alquoatli.
- Apply patch from Michael O to avoid sending multiple CDNs. - Apply patch from Michael O to avoid sending multiple CDNs.
- Apply patch from Cyril Elkaim to fix an issue with MacOS. - Apply patch from Cyril Elkaim to fix an issue with MacOS.
- Apply patch from Geoffrey D. Bennett to fix retry of control packets. - Apply patch from Geoffrey D. Bennett to fix retry of control packets.
- Apply patch from Geoffrey D. Bennett to handle RADIUS Class attribute.
- Bump heartbeat version to handle Class entry in session (v6).
- Re-arrange session struct to remove padding.
- Update cluster code to handle v6 packets. Drop compatability for pre-v5.
- Clean up some compiler errors.
* Mon Dec 18 2006 Brendan O'Dea <bod@optus.net> 2.2.0 * Mon Dec 18 2006 Brendan O'Dea <bod@optus.net> 2.2.0
- Only poll clifd if successfully bound. - Only poll clifd if successfully bound.

View file

@ -2,7 +2,7 @@
.de Id .de Id
.ds Dt \\$4 \\$5 .ds Dt \\$4 \\$5
.. ..
.Id $Id: l2tpns.8,v 1.4 2005/06/12 06:09:35 bodea Exp $ .Id $Id: l2tpns.8,v 1.4 2005-06-12 06:09:35 bodea Exp $
.TH L2TPNS 8 "\*(Dt" L2TPNS "System Management Commands" .TH L2TPNS 8 "\*(Dt" L2TPNS "System Management Commands"
.SH NAME .SH NAME
l2tpns \- Layer 2 tunneling protocol network server (LNS) l2tpns \- Layer 2 tunneling protocol network server (LNS)

View file

@ -2,7 +2,7 @@
.de Id .de Id
.ds Dt \\$4 \\$5 .ds Dt \\$4 \\$5
.. ..
.Id $Id: nsctl.8,v 1.2 2004/11/17 15:08:19 bodea Exp $ .Id $Id: nsctl.8,v 1.2 2004-11-17 15:08:19 bodea Exp $
.TH NSCTL 8 "\*(Dt" L2TPNS "System Management Commands" .TH NSCTL 8 "\*(Dt" L2TPNS "System Management Commands"
.SH NAME .SH NAME
nsctl \- manage running l2tpns instance nsctl \- manage running l2tpns instance

View file

@ -2,7 +2,7 @@
.de Id .de Id
.ds Dt \\$4 \\$5 .ds Dt \\$4 \\$5
.. ..
.Id $Id: startup-config.5,v 1.18 2006/07/01 12:40:17 bodea Exp $ .Id $Id: startup-config.5,v 1.18 2006-07-01 12:40:17 bodea Exp $
.TH STARTUP-CONFIG 5 "\*(Dt" L2TPNS "File Formats and Conventions" .TH STARTUP-CONFIG 5 "\*(Dt" L2TPNS "File Formats and Conventions"
.SH NAME .SH NAME
startup\-config \- configuration file for l2tpns startup\-config \- configuration file for l2tpns

1
THANKS
View file

@ -31,3 +31,4 @@ Graham Maltby <gmaltby+l2tpns@iig.com.au>
Rhys Kidd <rhys.kidd@staff.westnet.com.au> Rhys Kidd <rhys.kidd@staff.westnet.com.au>
Muhammad Tayseer Alquoatli <idoit.ief@gmail.com> Muhammad Tayseer Alquoatli <idoit.ief@gmail.com>
Cyril Elkaim <cyrelk@users.sourceforge.net> Cyril Elkaim <cyrelk@users.sourceforge.net>
Geoffry D. Bennett <g_bennett@users.sourceforge.net>

2
arp.c
View file

@ -1,7 +1,5 @@
// L2TPNS: arp // L2TPNS: arp
char const *cvs_id_arp = "$Id: arp.c,v 1.7 2005/07/31 10:04:09 bodea Exp $";
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include <net/ethernet.h> #include <net/ethernet.h>

View file

@ -4,8 +4,6 @@
/* set up intercept based on RADIUS reply */ /* set up intercept based on RADIUS reply */
char const *cvs_id = "$Id: autosnoop.c,v 1.12 2005/10/11 09:04:53 bodea Exp $";
int plugin_api_version = PLUGIN_API_VERSION; int plugin_api_version = PLUGIN_API_VERSION;
static struct pluginfuncs *f = 0; static struct pluginfuncs *f = 0;

View file

@ -13,8 +13,6 @@
* throttle=no * throttle=no
*/ */
char const *cvs_id = "$Id: autothrottle.c,v 1.17 2006/05/18 14:40:31 bodea Exp $";
int plugin_api_version = PLUGIN_API_VERSION; int plugin_api_version = PLUGIN_API_VERSION;
static struct pluginfuncs *f = 0; static struct pluginfuncs *f = 0;

2
bgp.c
View file

@ -10,8 +10,6 @@
* nor RFC2385 (which requires a kernel patch on 2.4 kernels). * nor RFC2385 (which requires a kernel patch on 2.4 kernels).
*/ */
char const *cvs_id_bgp = "$Id: bgp.c,v 1.12 2005/09/02 23:39:36 bodea Exp $";
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <string.h> #include <string.h>

4
bgp.h
View file

@ -1,5 +1,5 @@
/* BGPv4 (RFC1771) */ /* BGPv4 (RFC1771) */
/* $Id: bgp.h,v 1.5 2005/06/04 15:42:35 bodea Exp $ */ /* $Id: bgp.h,v 1.5 2005-06-04 15:42:35 bodea Exp $ */
#ifndef __BGP_H__ #ifndef __BGP_H__
#define __BGP_H__ #define __BGP_H__
@ -200,6 +200,4 @@ int bgp_set_poll(void);
int bgp_process(uint32_t events[]); int bgp_process(uint32_t events[]);
char const *bgp_state_str(enum bgp_state state); char const *bgp_state_str(enum bgp_state state);
extern char const *cvs_id_bgp;
#endif /* __BGP_H__ */ #endif /* __BGP_H__ */

67
cli.c
View file

@ -1,9 +1,6 @@
// L2TPNS Command Line Interface // L2TPNS Command Line Interface
// vim: sw=8 ts=8 // vim: sw=8 ts=8
char const *cvs_name = "$Name: $";
char const *cvs_id_cli = "$Id: cli.c,v 1.76 2006/12/18 12:08:28 bodea Exp $";
#include <stdio.h> #include <stdio.h>
#include <stddef.h> #include <stddef.h>
#include <stdarg.h> #include <stdarg.h>
@ -794,72 +791,10 @@ static int cmd_clear_counters(struct cli_def *cli, char *command, char **argv, i
static int cmd_show_version(struct cli_def *cli, char *command, char **argv, int argc) static int cmd_show_version(struct cli_def *cli, char *command, char **argv, int argc)
{ {
int tag = 0;
int file = 0;
int i = 0;
if (CLI_HELP_REQUESTED) if (CLI_HELP_REQUESTED)
return cli_arg_help(cli, 1, return CLI_HELP_NO_ARGS;
"tag", "Include CVS release tag",
"file", "Include file versions",
NULL);
for (i = 0; i < argc; i++)
if (!strcmp(argv[i], "tag"))
tag++;
else if (!strcmp(argv[i], "file"))
file++;
cli_print(cli, "L2TPNS %s", VERSION); cli_print(cli, "L2TPNS %s", VERSION);
if (tag)
{
char const *p = strchr(cvs_name, ':');
char const *e;
if (p)
{
p++;
while (isspace(*p))
p++;
}
if (!p || *p == '$')
p = "HEAD";
e = strpbrk(p, " \t$");
cli_print(cli, "Tag: %.*s", (int) (e ? e - p + 1 : strlen(p)), p);
}
if (file)
{
extern linked_list *loaded_plugins;
void *p;
cli_print(cli, "Files:");
cli_print(cli, " %s", cvs_id_arp);
#ifdef BGP
cli_print(cli, " %s", cvs_id_bgp);
#endif /* BGP */
cli_print(cli, " %s", cvs_id_cli);
cli_print(cli, " %s", cvs_id_cluster);
cli_print(cli, " %s", cvs_id_constants);
cli_print(cli, " %s", cvs_id_control);
cli_print(cli, " %s", cvs_id_icmp);
cli_print(cli, " %s", cvs_id_l2tpns);
cli_print(cli, " %s", cvs_id_ll);
cli_print(cli, " %s", cvs_id_ppp);
cli_print(cli, " %s", cvs_id_radius);
cli_print(cli, " %s", cvs_id_tbf);
cli_print(cli, " %s", cvs_id_util);
ll_reset(loaded_plugins);
while ((p = ll_next(loaded_plugins)))
{
char const **id = dlsym(p, "cvs_id");
if (id)
cli_print(cli, " %s", *id);
}
}
return CLI_OK; return CLI_OK;
} }

141
cluster.c
View file

@ -1,7 +1,5 @@
// L2TPNS Clustering Stuff // L2TPNS Clustering Stuff
char const *cvs_id_cluster = "$Id: cluster.c,v 1.55 2009/12/08 14:49:28 bodea Exp $";
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdarg.h> #include <stdarg.h>
@ -428,12 +426,6 @@ void master_update_counts(void)
if (!config->cluster_master_address) // If we don't have a master, skip it for a while. if (!config->cluster_master_address) // If we don't have a master, skip it for a while.
return; return;
// C_BYTES format changed in 2.1.0 (cluster version 5)
// during upgrade from previous versions, hang onto our counters
// for a bit until the new master comes up
if (config->cluster_last_hb_ver < 5)
return;
i = MAX_B_RECS * 5; // Examine max 3000 sessions; i = MAX_B_RECS * 5; // Examine max 3000 sessions;
if (config->cluster_highest_sessionid > i) if (config->cluster_highest_sessionid > i)
i = config->cluster_highest_sessionid; i = config->cluster_highest_sessionid;
@ -522,7 +514,7 @@ void cluster_check_slaves(void)
// //
void cluster_check_master(void) void cluster_check_master(void)
{ {
int i, count, tcount, bcount, high_unique_id = 0; int i, count, high_unique_id = 0;
int last_free = 0; int last_free = 0;
clockt t = TIME; clockt t = TIME;
static int probed = 0; static int probed = 0;
@ -608,7 +600,7 @@ void cluster_check_master(void)
// Count the highest used tunnel number as well. // Count the highest used tunnel number as well.
// //
config->cluster_highest_tunnelid = 0; config->cluster_highest_tunnelid = 0;
for (i = 0, tcount = 0; i < MAXTUNNEL; ++i) { for (i = 0; i < MAXTUNNEL; ++i) {
if (tunnel[i].state == TUNNELUNDEF) if (tunnel[i].state == TUNNELUNDEF)
tunnel[i].state = TUNNELFREE; tunnel[i].state = TUNNELFREE;
@ -621,7 +613,7 @@ void cluster_check_master(void)
// Count the highest used bundle number as well. // Count the highest used bundle number as well.
// //
config->cluster_highest_bundleid = 0; config->cluster_highest_bundleid = 0;
for (i = 0, bcount = 0; i < MAXBUNDLE; ++i) { for (i = 0; i < MAXBUNDLE; ++i) {
if (bundle[i].state == BUNDLEUNDEF) if (bundle[i].state == BUNDLEUNDEF)
bundle[i].state = BUNDLEFREE; bundle[i].state = BUNDLEFREE;
@ -1313,54 +1305,62 @@ static int cluster_recv_tunnel(int more, uint8_t *p)
} }
// pre v5 heartbeat session structure // pre v6 heartbeat session structure
struct oldsession { struct oldsession {
sessionidt next; sessionidt next;
sessionidt far; sessionidt far;
tunnelidt tunnel; tunnelidt tunnel;
uint8_t flags;
struct {
uint8_t phase;
uint8_t lcp:4;
uint8_t ipcp:4;
uint8_t ipv6cp:4;
uint8_t ccp:4;
} ppp;
char reserved_1[2];
in_addr_t ip; in_addr_t ip;
int ip_pool_index; int ip_pool_index;
unsigned long unique_id; uint32_t unique_id;
uint16_t nr; char reserved_2[4];
uint16_t ns;
uint32_t magic; uint32_t magic;
uint32_t cin, cout;
uint32_t pin, pout; uint32_t pin, pout;
uint32_t total_cin; uint32_t cin, cout;
uint32_t total_cout; uint32_t cin_wrap, cout_wrap;
uint32_t id; uint32_t cin_delta, cout_delta;
uint16_t throttle_in; uint16_t throttle_in;
uint16_t throttle_out; uint16_t throttle_out;
uint8_t filter_in;
uint8_t filter_out;
uint16_t mru;
clockt opened; clockt opened;
clockt die; clockt die;
uint32_t session_timeout;
uint32_t idle_timeout;
time_t last_packet; time_t last_packet;
time_t last_data;
in_addr_t dns1, dns2; in_addr_t dns1, dns2;
routet route[MAXROUTE]; routet route[MAXROUTE];
uint16_t radius;
uint16_t mru;
uint16_t tbf_in; uint16_t tbf_in;
uint16_t tbf_out; uint16_t tbf_out;
uint8_t l2tp_flags;
uint8_t reserved_old_snoop;
uint8_t walled_garden;
uint8_t flags1;
char random_vector[MAXTEL];
int random_vector_length; int random_vector_length;
char user[129]; uint8_t random_vector[MAXTEL];
char user[MAXUSER];
char called[MAXTEL]; char called[MAXTEL];
char calling[MAXTEL]; char calling[MAXTEL];
uint32_t tx_connect_speed; uint32_t tx_connect_speed;
uint32_t rx_connect_speed; uint32_t rx_connect_speed;
uint32_t flags; clockt timeout;
#define SF_IPCP_ACKED 1 // Has this session seen an IPCP Ack? uint32_t mrru;
#define SF_LCP_ACKED 2 // LCP negotiated uint8_t mssf;
#define SF_CCP_ACKED 4 // CCP negotiated epdist epdis;
bundleidt bundle;
in_addr_t snoop_ip; in_addr_t snoop_ip;
uint16_t snoop_port; uint16_t snoop_port;
uint16_t sid; uint8_t walled_garden;
uint8_t filter_in; uint8_t ipv6prefixlen;
uint8_t filter_out; struct in6_addr ipv6route;
char reserved[18]; char reserved_3[11];
}; };
static uint8_t *convert_session(struct oldsession *old) static uint8_t *convert_session(struct oldsession *old)
@ -1373,17 +1373,24 @@ static uint8_t *convert_session(struct oldsession *old)
new.next = old->next; new.next = old->next;
new.far = old->far; new.far = old->far;
new.tunnel = old->tunnel; new.tunnel = old->tunnel;
new.flags = old->l2tp_flags; new.flags = old->flags;
new.ppp.phase = old->ppp.phase;
new.ppp.lcp = old->ppp.lcp;
new.ppp.ipcp = old->ppp.ipcp;
new.ppp.ipv6cp = old->ppp.ipv6cp;
new.ppp.ccp = old->ppp.ccp;
new.ip = old->ip; new.ip = old->ip;
new.ip_pool_index = old->ip_pool_index; new.ip_pool_index = old->ip_pool_index;
new.unique_id = old->unique_id; new.unique_id = old->unique_id;
new.magic = old->magic; new.magic = old->magic;
new.pin = old->pin; new.pin = old->pin;
new.pout = old->pout; new.pout = old->pout;
new.cin = old->total_cin; new.cin = old->cin;
new.cout = old->total_cout; new.cout = old->cout;
new.cin_delta = old->cin; new.cin_wrap = old->cin_wrap;
new.cout_delta = old->cout; new.cout_wrap = old->cout_wrap;
new.cin_delta = old->cin_delta;
new.cout_delta = old->cout_delta;
new.throttle_in = old->throttle_in; new.throttle_in = old->throttle_in;
new.throttle_out = old->throttle_out; new.throttle_out = old->throttle_out;
new.filter_in = old->filter_in; new.filter_in = old->filter_in;
@ -1391,7 +1398,10 @@ static uint8_t *convert_session(struct oldsession *old)
new.mru = old->mru; new.mru = old->mru;
new.opened = old->opened; new.opened = old->opened;
new.die = old->die; new.die = old->die;
new.session_timeout = old->session_timeout;
new.idle_timeout = old->idle_timeout;
new.last_packet = old->last_packet; new.last_packet = old->last_packet;
new.last_data = old->last_data;
new.dns1 = old->dns1; new.dns1 = old->dns1;
new.dns2 = old->dns2; new.dns2 = old->dns2;
new.tbf_in = old->tbf_in; new.tbf_in = old->tbf_in;
@ -1399,9 +1409,16 @@ static uint8_t *convert_session(struct oldsession *old)
new.random_vector_length = old->random_vector_length; new.random_vector_length = old->random_vector_length;
new.tx_connect_speed = old->tx_connect_speed; new.tx_connect_speed = old->tx_connect_speed;
new.rx_connect_speed = old->rx_connect_speed; new.rx_connect_speed = old->rx_connect_speed;
new.timeout = old->timeout;
new.mrru = old->mrru;
new.mssf = old->mssf;
new.epdis = old->epdis;
new.bundle = old->bundle;
new.snoop_ip = old->snoop_ip; new.snoop_ip = old->snoop_ip;
new.snoop_port = old->snoop_port; new.snoop_port = old->snoop_port;
new.walled_garden = old->walled_garden; new.walled_garden = old->walled_garden;
new.ipv6prefixlen = old->ipv6prefixlen;
new.ipv6route = old->ipv6route;
memcpy(new.random_vector, old->random_vector, sizeof(new.random_vector)); memcpy(new.random_vector, old->random_vector, sizeof(new.random_vector));
memcpy(new.user, old->user, sizeof(new.user)); memcpy(new.user, old->user, sizeof(new.user));
@ -1411,30 +1428,13 @@ static uint8_t *convert_session(struct oldsession *old)
for (i = 0; i < MAXROUTE; i++) for (i = 0; i < MAXROUTE; i++)
memcpy(&new.route[i], &old->route[i], sizeof(new.route[i])); memcpy(&new.route[i], &old->route[i], sizeof(new.route[i]));
if (new.opened)
{
new.ppp.phase = Establish;
if (old->flags & (SF_IPCP_ACKED|SF_LCP_ACKED))
{
new.ppp.phase = Network;
new.ppp.lcp = Opened;
new.ppp.ipcp = (old->flags & SF_IPCP_ACKED) ? Opened : Starting;
new.ppp.ccp = (old->flags & SF_CCP_ACKED) ? Opened : Stopped;
}
// no PPPv6 in old session
new.ppp.ipv6cp = Stopped;
}
return (uint8_t *) &new; return (uint8_t *) &new;
} }
// //
// Process a heartbeat.. // Process a heartbeat..
// //
// v3: added interval, timeout // v6: added RADIUS class attribute, re-ordered session structure
// v4: added table_version
// v5: added ipv6, re-ordered session structure
static int cluster_process_heartbeat(uint8_t *data, int size, int more, uint8_t *p, in_addr_t addr) static int cluster_process_heartbeat(uint8_t *data, int size, int more, uint8_t *p, in_addr_t addr)
{ {
heartt *h; heartt *h;
@ -1442,12 +1442,12 @@ static int cluster_process_heartbeat(uint8_t *data, int size, int more, uint8_t
int i, type; int i, type;
int hb_ver = more; int hb_ver = more;
#if HB_VERSION != 5 #if HB_VERSION != 6
# error "need to update cluster_process_heartbeat()" # error "need to update cluster_process_heartbeat()"
#endif #endif
// we handle versions 3 through 5 // we handle versions 5 through 6
if (hb_ver < 3 || hb_ver > HB_VERSION) { if (hb_ver < 5 || hb_ver > HB_VERSION) {
LOG(0, 0, 0, "Received a heartbeat version that I don't support (%d)!\n", hb_ver); LOG(0, 0, 0, "Received a heartbeat version that I don't support (%d)!\n", hb_ver);
return -1; // Ignore it?? return -1; // Ignore it??
} }
@ -1476,18 +1476,17 @@ static int cluster_process_heartbeat(uint8_t *data, int size, int more, uint8_t
return -1; // Skip it. return -1; // Skip it.
} }
if (hb_ver >= 4) { if (h->table_version > config->cluster_table_version) {
if (h->table_version > config->cluster_table_version) { LOG(0, 0, 0, "They've seen more state changes (%" PRIu64 " vs my %" PRIu64 ") so I'm gone!\n",
LOG(0, 0, 0, "They've seen more state changes (%" PRIu64 " vs my %" PRIu64 ") so I'm gone!\n",
h->table_version, config->cluster_table_version); h->table_version, config->cluster_table_version);
kill(0, SIGTERM); kill(0, SIGTERM);
exit(1); exit(1);
}
if (h->table_version < config->cluster_table_version)
return -1;
} }
if (h->table_version < config->cluster_table_version)
return -1;
if (basetime > h->basetime) { if (basetime > h->basetime) {
LOG(0, 0, 0, "They're an older master than me so I'm gone!\n"); LOG(0, 0, 0, "They're an older master than me so I'm gone!\n");
kill(0, SIGTERM); kill(0, SIGTERM);
@ -1609,7 +1608,7 @@ static int cluster_process_heartbeat(uint8_t *data, int size, int more, uint8_t
s -= (p - orig_p); s -= (p - orig_p);
// session struct changed with v5 // session struct changed with v5
if (hb_ver < 5) if (hb_ver < 6)
{ {
if (size != sizeof(struct oldsession)) { if (size != sizeof(struct oldsession)) {
LOG(0, 0, 0, "DANGER: Received a v%d CSESSION that didn't decompress correctly!\n", hb_ver); LOG(0, 0, 0, "DANGER: Received a v%d CSESSION that didn't decompress correctly!\n", hb_ver);
@ -1630,7 +1629,7 @@ static int cluster_process_heartbeat(uint8_t *data, int size, int more, uint8_t
break; break;
} }
case C_SESSION: case C_SESSION:
if (hb_ver < 5) if (hb_ver < 6)
{ {
if (s < sizeof(struct oldsession)) if (s < sizeof(struct oldsession))
goto shortpacket; goto shortpacket;

View file

@ -1,5 +1,5 @@
// L2TPNS Clustering Stuff // L2TPNS Clustering Stuff
// $Id: cluster.h,v 1.16 2006/12/04 20:54:51 bodea Exp $ // $Id: cluster.h,v 1.16 2006-12-04 20:54:51 bodea Exp $
#ifndef __CLUSTER_H__ #ifndef __CLUSTER_H__
#define __CLUSTER_H__ #define __CLUSTER_H__
@ -24,7 +24,7 @@
#define C_BUNDLE 17 // Bundle structure. #define C_BUNDLE 17 // Bundle structure.
#define C_CBUNDLE 18 // Compressed bundle structure. #define C_CBUNDLE 18 // Compressed bundle structure.
#define HB_VERSION 5 // Protocol version number.. #define HB_VERSION 6 // Protocol version number..
#define HB_MAX_SEQ (1<<30) // Maximum sequence number. (MUST BE A POWER OF 2!) #define HB_MAX_SEQ (1<<30) // Maximum sequence number. (MUST BE A POWER OF 2!)
#define HB_HISTORY_SIZE 64 // How many old heartbeats we remember?? (Must be a factor of HB_MAX_SEQ) #define HB_HISTORY_SIZE 64 // How many old heartbeats we remember?? (Must be a factor of HB_MAX_SEQ)

View file

@ -1,7 +1,5 @@
// L2TPNS: constants // L2TPNS: constants
char const *cvs_id_constants = "$Id: constants.c,v 1.8 2009/12/08 14:49:28 bodea Exp $";
#include <stdio.h> #include <stdio.h>
#include "constants.h" #include "constants.h"

View file

@ -1,7 +1,5 @@
// L2TPNS: control // L2TPNS: control
char const *cvs_id_control = "$Id: control.c,v 1.5 2005/07/31 10:04:10 bodea Exp $";
#include <string.h> #include <string.h>
#include "l2tpns.h" #include "l2tpns.h"
#include "control.h" #include "control.h"

View file

@ -1,5 +1,5 @@
/* kludge up some limited epoll semantics using select for 2.4 kernels */ /* kludge up some limited epoll semantics using select for 2.4 kernels */
/* $Id: fake_epoll.h,v 1.2 2007/06/28 07:22:50 bodea Exp $ */ /* $Id: fake_epoll.h,v 1.2 2007-06-28 07:22:50 bodea Exp $ */
#ifndef __FAKE_EPOLL_H__ #ifndef __FAKE_EPOLL_H__
#define __FAKE_EPOLL_H__ #define __FAKE_EPOLL_H__

View file

@ -9,8 +9,6 @@
/* walled garden */ /* walled garden */
char const *cvs_id = "$Id: garden.c,v 1.25 2006/02/23 01:07:23 bodea Exp $";
int plugin_api_version = PLUGIN_API_VERSION; int plugin_api_version = PLUGIN_API_VERSION;
static struct pluginfuncs *f = 0; static struct pluginfuncs *f = 0;

2
icmp.c
View file

@ -1,7 +1,5 @@
// L2TPNS: icmp // L2TPNS: icmp
char const *cvs_id_icmp = "$Id: icmp.c,v 1.11 2006/04/27 09:53:49 bodea Exp $";
#include <arpa/inet.h> #include <arpa/inet.h>
#include <netdb.h> #include <netdb.h>
#include <netinet/in.h> #include <netinet/in.h>

View file

@ -4,8 +4,6 @@
// Copyright (c) 2002 FireBrick (Andrews & Arnold Ltd / Watchfront Ltd) - GPL licenced // Copyright (c) 2002 FireBrick (Andrews & Arnold Ltd / Watchfront Ltd) - GPL licenced
// vim: sw=8 ts=8 // vim: sw=8 ts=8
char const *cvs_id_l2tpns = "$Id: l2tpns.c,v 1.176 2011/01/20 12:48:40 bodea Exp $";
#include <arpa/inet.h> #include <arpa/inet.h>
#include <assert.h> #include <assert.h>
#include <errno.h> #include <errno.h>
@ -1278,7 +1276,7 @@ static void processipout(uint8_t *buf, int len)
if(session[s].bundle != 0 && bundle[session[s].bundle].num_of_links > 1) if(session[s].bundle != 0 && bundle[session[s].bundle].num_of_links > 1)
{ {
bid = session[s].bundle; bid = session[s].bundle;
s = bundle[bid].members[bundle[bid].current_ses = ++bundle[bid].current_ses % bundle[bid].num_of_links]; s = bundle[bid].members[bundle[bid].current_ses = (bundle[bid].current_ses + 1) % bundle[bid].num_of_links];
t = session[s].tunnel; t = session[s].tunnel;
sp = &session[s]; sp = &session[s];
LOG(4, s, t, "MPPP: (1)Session number becomes: %d\n", s); LOG(4, s, t, "MPPP: (1)Session number becomes: %d\n", s);
@ -1302,7 +1300,7 @@ static void processipout(uint8_t *buf, int len)
remain -= fraglen; remain -= fraglen;
while (remain > last_fraglen) while (remain > last_fraglen)
{ {
s = b->members[b->current_ses = ++b->current_ses % num_of_links]; s = b->members[b->current_ses = (b->current_ses + 1) % num_of_links];
t = session[s].tunnel; t = session[s].tunnel;
sp = &session[s]; sp = &session[s];
LOG(4, s, t, "MPPP: (2)Session number becomes: %d\n", s); LOG(4, s, t, "MPPP: (2)Session number becomes: %d\n", s);
@ -1313,7 +1311,7 @@ static void processipout(uint8_t *buf, int len)
remain -= fraglen; remain -= fraglen;
} }
// send the last fragment // send the last fragment
s = b->members[b->current_ses = ++b->current_ses % num_of_links]; s = b->members[b->current_ses = (b->current_ses + 1) % num_of_links];
t = session[s].tunnel; t = session[s].tunnel;
sp = &session[s]; sp = &session[s];
LOG(4, s, t, "MPPP: (2)Session number becomes: %d\n", s); LOG(4, s, t, "MPPP: (2)Session number becomes: %d\n", s);
@ -1420,7 +1418,7 @@ static void processipv6out(uint8_t * buf, int len)
if (session[s].bundle && bundle[session[s].bundle].num_of_links > 1) if (session[s].bundle && bundle[session[s].bundle].num_of_links > 1)
{ {
bundleidt bid = session[s].bundle; bundleidt bid = session[s].bundle;
s = bundle[bid].members[bundle[bid].current_ses = ++bundle[bid].current_ses % bundle[bid].num_of_links]; s = bundle[bid].members[bundle[bid].current_ses = (bundle[bid].current_ses + 1) % bundle[bid].num_of_links];
LOG(3, s, session[s].tunnel, "MPPP: Session number becomes: %u\n", s); LOG(3, s, session[s].tunnel, "MPPP: Session number becomes: %u\n", s);
} }
t = session[s].tunnel; t = session[s].tunnel;
@ -1475,7 +1473,6 @@ static void send_ipout(sessionidt s, uint8_t *buf, int len)
{ {
sessiont *sp; sessiont *sp;
tunnelidt t; tunnelidt t;
in_addr_t ip;
uint8_t b[MAXETHER + 20]; uint8_t b[MAXETHER + 20];
@ -1489,8 +1486,6 @@ static void send_ipout(sessionidt s, uint8_t *buf, int len)
buf += 4; buf += 4;
len -= 4; len -= 4;
ip = *(in_addr_t *)(buf + 16);
if (!session[s].ip) if (!session[s].ip)
return; return;

View file

@ -1,5 +1,5 @@
// L2TPNS Global Stuff // L2TPNS Global Stuff
// $Id: l2tpns.h,v 1.121 2009/12/08 14:49:28 bodea Exp $ // $Id: l2tpns.h,v 1.121 2009-12-08 14:49:28 bodea Exp $
#ifndef __L2TPNS_H__ #ifndef __L2TPNS_H__
#define __L2TPNS_H__ #define __L2TPNS_H__
@ -14,7 +14,7 @@
#include <sys/types.h> #include <sys/types.h>
#include <libcli.h> #include <libcli.h>
#define VERSION "2.2.0" #define VERSION "2.2.1"
// Limits // Limits
#define MAXTUNNEL 500 // could be up to 65535 #define MAXTUNNEL 500 // could be up to 65535
@ -40,6 +40,7 @@
#define MAXTEL 96 // telephone number #define MAXTEL 96 // telephone number
#define MAXUSER 128 // username #define MAXUSER 128 // username
#define MAXPASS 128 // password #define MAXPASS 128 // password
#define MAXCLASS 128 // radius class attribute size
#define MAXPLUGINS 20 // maximum number of plugins to load #define MAXPLUGINS 20 // maximum number of plugins to load
#define MAXRADSERVER 10 // max radius servers #define MAXRADSERVER 10 // max radius servers
#define MAXROUTE 10 // max static routes per session #define MAXROUTE 10 // max static routes per session
@ -272,11 +273,10 @@ typedef struct
uint8_t ipv6cp:4; // IPV6CP state uint8_t ipv6cp:4; // IPV6CP state
uint8_t ccp:4; // CCP state uint8_t ccp:4; // CCP state
} ppp; } ppp;
char reserved_1[2]; // unused: padding uint16_t mru; // maximum receive unit
in_addr_t ip; // IP of session set by RADIUS response (host byte order). in_addr_t ip; // IP of session set by RADIUS response (host byte order).
int ip_pool_index; // index to IP pool int ip_pool_index; // index to IP pool
uint32_t unique_id; // unique session id uint32_t unique_id; // unique session id
char reserved_2[4]; // unused: was ns/nr
uint32_t magic; // ppp magic number uint32_t magic; // ppp magic number
uint32_t pin, pout; // packet counts uint32_t pin, pout; // packet counts
uint32_t cin, cout; // byte counts uint32_t cin, cout; // byte counts
@ -286,35 +286,36 @@ typedef struct
uint16_t throttle_out; // downstream throttle rate uint16_t throttle_out; // downstream throttle rate
uint8_t filter_in; // input filter index (to ip_filters[N-1]; 0 if none) uint8_t filter_in; // input filter index (to ip_filters[N-1]; 0 if none)
uint8_t filter_out; // output filter index uint8_t filter_out; // output filter index
uint16_t mru; // maximum receive unit uint16_t snoop_port; // Interception destination port
in_addr_t snoop_ip; // Interception destination IP
clockt opened; // when started clockt opened; // when started
clockt die; // being closed, when to finally free clockt die; // being closed, when to finally free
uint32_t session_timeout; // Maximum session time in seconds uint32_t session_timeout; // Maximum session time in seconds
uint32_t idle_timeout; // Maximum idle time in seconds uint32_t idle_timeout; // Maximum idle time in seconds
time_t last_packet; // Last packet from the user (used for idle timeouts) time_t last_packet; // Last packet from the user (used for idle timeouts)
time_t last_data; // Last data packet to/from the user (used for idle timeouts) time_t last_data; // Last data packet to/from the user (used for idle timeouts)
in_addr_t dns1, dns2; // DNS servers in_addr_t dns1, dns2; // DNS servers
routet route[MAXROUTE]; // static routes routet route[MAXROUTE]; // static routes
uint16_t tbf_in; // filter bucket for throttling in from the user. uint16_t tbf_in; // filter bucket for throttling in from the user.
uint16_t tbf_out; // filter bucket for throttling out to the user. uint16_t tbf_out; // filter bucket for throttling out to the user.
int random_vector_length; int random_vector_length;
uint8_t random_vector[MAXTEL]; uint8_t random_vector[MAXTEL];
char user[MAXUSER]; // user (needed in seesion for radius stop messages) char user[MAXUSER]; // user (needed in session for radius stop messages)
char called[MAXTEL]; // called number char called[MAXTEL]; // called number
char calling[MAXTEL]; // calling number char calling[MAXTEL]; // calling number
uint32_t tx_connect_speed; uint32_t tx_connect_speed;
uint32_t rx_connect_speed; uint32_t rx_connect_speed;
clockt timeout; // Session timeout clockt timeout; // Session timeout
uint32_t mrru; // Multilink Max-Receive-Reconstructed-Unit uint32_t mrru; // Multilink Max-Receive-Reconstructed-Unit
uint8_t mssf; // Multilink Short Sequence Number Header Format epdist epdis; // Multilink Endpoint Discriminator
epdist epdis; // Multilink Endpoint Discriminator bundleidt bundle; // Multilink Bundle Identifier
bundleidt bundle; // Multilink Bundle Identifier uint8_t mssf; // Multilink Short Sequence Number Header Format
in_addr_t snoop_ip; // Interception destination IP
uint16_t snoop_port; // Interception destination port
uint8_t walled_garden; // is this session gardened? uint8_t walled_garden; // is this session gardened?
uint8_t classlen; // class (needed for radius accounting messages)
char class[MAXCLASS];
uint8_t ipv6prefixlen; // IPv6 route prefix length uint8_t ipv6prefixlen; // IPv6 route prefix length
struct in6_addr ipv6route; // Static IPv6 route struct in6_addr ipv6route; // Static IPv6 route
char reserved_3[11]; // Space to expand structure without changing HB_VERSION char reserved[12]; // Space to expand structure without changing HB_VERSION
} }
sessiont; sessiont;
@ -948,19 +949,4 @@ extern uint16_t MSS;
#define CLI_HELP_REQUESTED (argc > 0 && argv[argc-1][strlen(argv[argc-1])-1] == '?') #define CLI_HELP_REQUESTED (argc > 0 && argv[argc-1][strlen(argv[argc-1])-1] == '?')
#define CLI_HELP_NO_ARGS (argc > 1 || argv[0][1]) ? CLI_OK : cli_arg_help(cli, 1, NULL) #define CLI_HELP_NO_ARGS (argc > 1 || argv[0][1]) ? CLI_OK : cli_arg_help(cli, 1, NULL)
// CVS identifiers (for "show version file")
extern char const *cvs_id_arp;
extern char const *cvs_id_cli;
extern char const *cvs_id_cluster;
extern char const *cvs_id_constants;
extern char const *cvs_id_control;
extern char const *cvs_id_icmp;
extern char const *cvs_id_l2tpns;
extern char const *cvs_id_ll;
extern char const *cvs_id_md5;
extern char const *cvs_id_ppp;
extern char const *cvs_id_radius;
extern char const *cvs_id_tbf;
extern char const *cvs_id_util;
#endif /* __L2TPNS_H__ */ #endif /* __L2TPNS_H__ */

2
ll.c
View file

@ -1,7 +1,5 @@
// L2TPNS Linked List Stuff // L2TPNS Linked List Stuff
char const *cvs_id_ll = "$Id: ll.c,v 1.6 2004/11/18 08:12:55 bodea Exp $";
#include <stdio.h> #include <stdio.h>
#include <sys/file.h> #include <sys/file.h>
#include <sys/stat.h> #include <sys/stat.h>

4
ppp.c
View file

@ -1,7 +1,5 @@
// L2TPNS PPP Stuff // L2TPNS PPP Stuff
char const *cvs_id_ppp = "$Id: ppp.c,v 1.104 2009/12/08 14:49:28 bodea Exp $";
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
@ -2371,7 +2369,7 @@ uint8_t *makeppp(uint8_t *b, int size, uint8_t *p, int l, sessionidt s, tunnelid
if ((b - start) + l > size) if ((b - start) + l > size)
{ {
LOG(2, s, t, "makeppp would overflow buffer (size=%d, header+payload=%d)\n", size, (b - start) + l); LOG(2, s, t, "makeppp would overflow buffer (size=%d, header+payload=%ld)\n", size, (b - start) + l);
return NULL; return NULL;
} }

View file

@ -1,7 +1,5 @@
// L2TPNS Radius Stuff // L2TPNS Radius Stuff
char const *cvs_id_radius = "$Id: radius.c,v 1.56 2009/12/08 14:49:28 bodea Exp $";
#include <time.h> #include <time.h>
#include <stdio.h> #include <stdio.h>
#include <sys/types.h> #include <sys/types.h>
@ -365,6 +363,13 @@ void radiussend(uint16_t r, uint8_t state)
} }
} }
if (session[s].classlen) {
*p = 25; // class
p[1] = session[s].classlen + 2;
memcpy(p + 2, session[s].class, session[s].classlen);
p += p[1];
}
{ {
struct param_radius_account acct = { &tunnel[session[s].tunnel], &session[s], &p }; struct param_radius_account acct = { &tunnel[session[s].tunnel], &session[s], &p };
run_plugins(PLUGIN_RADIUS_ACCOUNT, &acct); run_plugins(PLUGIN_RADIUS_ACCOUNT, &acct);
@ -820,6 +825,15 @@ void processrad(uint8_t *buf, int len, char socket_index)
session[s].ipv6prefixlen = prefixlen; session[s].ipv6prefixlen = prefixlen;
} }
} }
else if (*p == 25)
{
// Class
if (p[1] < 3) continue;
session[s].classlen = p[1] - 2;
if (session[s].classlen > MAXCLASS)
session[s].classlen = MAXCLASS;
memcpy(session[s].class, p + 2, session[s].classlen);
}
} }
} }
else if (r_code == AccessReject) else if (r_code == AccessReject)

View file

@ -5,8 +5,6 @@
/* session control */ /* session control */
char const *cvs_id = "$Id: sessionctl.c,v 1.5 2006/04/13 11:14:35 bodea Exp $";
int plugin_api_version = PLUGIN_API_VERSION; int plugin_api_version = PLUGIN_API_VERSION;
static struct pluginfuncs *f = 0; static struct pluginfuncs *f = 0;

View file

@ -4,8 +4,6 @@
/* fudge up session rx speed if not set */ /* fudge up session rx speed if not set */
char const *cvs_id = "$Id: setrxspeed.c,v 1.4 2005/10/11 09:04:53 bodea Exp $";
int plugin_api_version = PLUGIN_API_VERSION; int plugin_api_version = PLUGIN_API_VERSION;
static struct pluginfuncs *f = 0; static struct pluginfuncs *f = 0;

View file

@ -5,8 +5,6 @@
/* snoop control */ /* snoop control */
char const *cvs_id = "$Id: snoopctl.c,v 1.7 2005/10/11 09:04:53 bodea Exp $";
int plugin_api_version = PLUGIN_API_VERSION; int plugin_api_version = PLUGIN_API_VERSION;
static struct pluginfuncs *f = 0; static struct pluginfuncs *f = 0;

View file

@ -4,8 +4,6 @@
/* strip domain part of username before sending RADIUS requests */ /* strip domain part of username before sending RADIUS requests */
char const *cvs_id = "$Id: stripdomain.c,v 1.8 2005/10/11 09:04:53 bodea Exp $";
int plugin_api_version = PLUGIN_API_VERSION; int plugin_api_version = PLUGIN_API_VERSION;
static struct pluginfuncs *f = 0; static struct pluginfuncs *f = 0;

2
tbf.c
View file

@ -1,7 +1,5 @@
// L2TPNS: token bucket filters // L2TPNS: token bucket filters
char const *cvs_id_tbf = "$Id: tbf.c,v 1.13 2005/07/31 10:04:10 bodea Exp $";
#include <string.h> #include <string.h>
#include "l2tpns.h" #include "l2tpns.h"
#include "util.h" #include "util.h"

View file

@ -5,8 +5,6 @@
/* throttle control */ /* throttle control */
char const *cvs_id = "$Id: throttlectl.c,v 1.9 2005/10/11 09:04:53 bodea Exp $";
int plugin_api_version = PLUGIN_API_VERSION; int plugin_api_version = PLUGIN_API_VERSION;
static struct pluginfuncs *f = 0; static struct pluginfuncs *f = 0;

2
util.c
View file

@ -1,7 +1,5 @@
/* Misc util functions */ /* Misc util functions */
char const *cvs_id_util = "$Id: util.c,v 1.14 2006/04/05 01:45:57 bodea Exp $";
#include <unistd.h> #include <unistd.h>
#include <errno.h> #include <errno.h>
#include <sched.h> #include <sched.h>