Package: xl2tpd
Version: 1.2.5+dfsg-1
Severity: wishlist

The attached patch adds rx and tx speed options to the configuration file.  
This helps in situations where
the lns uses the speed information (for example to scale graphs, or for load 
balancing).

The patch is fairly simple as most of the code was already there, just 
hardcoded.

Tony

-- System Information:
Debian Release: squeeze/sid
  APT prefers testing
  APT policy: (500, 'testing'), (50, 'unstable')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.32-trunk-amd64 (SMP w/1 CPU core)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages xl2tpd depends on:
ii  libc6                      2.10.2-2      GNU C Library: Shared libraries
ii  libpcap0.8                 1.0.0-6       system interface for user-level pa
ii  ppp                        2.4.4rel-10.1 Point-to-Point Protocol (PPP) - da

xl2tpd recommends no packages.

xl2tpd suggests no packages.

-- no debconf information
diff -rubN xl2tpd-1.2.5+dfsg/control.c xl2tpd-1.2.5+dfsg.1/control.c
--- xl2tpd-1.2.5+dfsg/control.c	2009-12-12 18:32:57.000000000 +0000
+++ xl2tpd-1.2.5+dfsg.1/control.c	2010-04-16 13:35:02.606516672 +0100
@@ -204,11 +204,15 @@
             {
                 t->ourrws = t->lns->tun_rws;
                 t->hbit = t->lns->hbit;
+		t->rxspeed = t->lns->rxspeed;
+		t->txspeed = t->lns->txspeed;
             }
             else if (t->lac)
             {
                 t->ourrws = t->lac->tun_rws;
                 t->hbit = t->lac->hbit;
+		t->rxspeed = t->lac->rxspeed;
+		t->txspeed = t->lac->txspeed;
             }
             /* This is an attempt to bring up the tunnel */
             t->state = SCCRQ;
@@ -800,14 +804,14 @@
             mk_challenge (t->chal_them.vector, VECTOR_SIZE);
             add_randvect_avp (buf, t->chal_them.vector, VECTOR_SIZE);
         }
-        add_txspeed_avp (buf, DEFAULT_TX_BPS);
+        add_txspeed_avp (buf, t->txspeed);
         add_frame_avp (buf, c->frame);
 /*		if (c->ourrws >= 0)
 			add_avp_rws(buf, c->ourrws); */
         /* FIXME: Packet Processing Delay */
         /* We don't need any kind of proxy PPP stuff */
         /* Can we proxy authenticate ourselves??? */
-        add_rxspeed_avp (buf, DEFAULT_RX_BPS);
+        add_rxspeed_avp (buf, t->rxspeed);
 /* add_seqreqd_avp (buf); *//* We don't have sequencing code, so
  * don't ask for sequencing */
         add_control_hdr (t, c, buf);
diff -rubN xl2tpd-1.2.5+dfsg/doc/l2tpd.conf.sample xl2tpd-1.2.5+dfsg.1/doc/l2tpd.conf.sample
--- xl2tpd-1.2.5+dfsg/doc/l2tpd.conf.sample	2009-12-12 18:32:57.000000000 +0000
+++ xl2tpd-1.2.5+dfsg.1/doc/l2tpd.conf.sample	2010-04-16 13:53:35.027270715 +0100
@@ -43,7 +43,10 @@
 ; tunnel rws = 4						; * RWS for tunnel (must be > 0)
 ; flow bit = yes						; * Include sequence numbers
 ; challenge = yes						; * Challenge authenticate peer ; 
-;
+; rx bps = 10000000				; Receive tunnel speed
+; tx bps = 10000000				; Transmit tunnel speed
+; bps = 100000					; Define both receive and transmit speed in one option
+
 ; [lac marko]							; Example VPN LAC definition
 ; lns = lns.marko.net					; * Who is our LNS?
 ; lns = lns2.marko.net					; * A backup LNS (not yet used)
diff -rubN xl2tpd-1.2.5+dfsg/file.c xl2tpd-1.2.5+dfsg.1/file.c
--- xl2tpd-1.2.5+dfsg/file.c	2009-12-12 18:32:57.000000000 +0000
+++ xl2tpd-1.2.5+dfsg.1/file.c	2010-04-16 13:33:14.782518750 +0100
@@ -91,6 +91,8 @@
     tmp->localaddr = 0;
     tmp->tun_rws = DEFAULT_RWS_SIZE;
     tmp->call_rws = DEFAULT_RWS_SIZE;
+    tmp->rxspeed = DEFAULT_RX_BPS;
+    tmp->txspeed = DEFAULT_TX_BPS;
     tmp->hbit = 0;
     tmp->lbit = 0;
     tmp->authpeer = 0;
@@ -306,6 +308,46 @@
     return 0;
 }
 
+int set_speed (char *word, char *value, int context, void *item)
+{
+    if (atoi (value) < 1 )
+    {
+        snprintf (filerr, sizeof (filerr),
+                  "bps must be greater than zero\n");
+        return -1;
+    }
+    switch (context & ~CONTEXT_DEFAULT)
+    {
+    case CONTEXT_LAC:
+        if (word[0] == 't')
+            set_int (word, value, &(((struct lac *) item)->txspeed));
+        else if (word[0] == 'r')
+            set_int (word, value, &(((struct lac *) item)->rxspeed));
+        else
+	{
+            set_int (word, value, &(((struct lac *) item)->rxspeed));
+            set_int (word, value, &(((struct lac *) item)->txspeed));
+	}
+        break;
+    case CONTEXT_LNS:
+        if (word[0] == 't')
+            set_int (word, value, &(((struct lns *) item)->txspeed));
+        else if (word[0] == 'r')
+            set_int (word, value, &(((struct lns *) item)->rxspeed));
+        else
+	{
+            set_int (word, value, &(((struct lns *) item)->rxspeed));
+            set_int (word, value, &(((struct lns *) item)->txspeed));
+	}
+        break;
+    default:
+        snprintf (filerr, sizeof (filerr), "'%s' not valid in this context\n",
+                  word);
+        return -1;
+    }
+    return 0;
+}
+
 int set_rmax (char *word, char *value, int context, void *item)
 {
     if (atoi (value) < 1)
@@ -1416,5 +1458,8 @@
     {"tunnel rws", &set_rws},
     {"flow bit", &set_flow},
     {"challenge", &set_challenge},
+    {"tx bps", &set_speed},
+    {"rx bps", &set_speed},
+    {"bps", &set_speed},
     {NULL, NULL}
 };
diff -rubN xl2tpd-1.2.5+dfsg/file.h xl2tpd-1.2.5+dfsg.1/file.h
--- xl2tpd-1.2.5+dfsg/file.h	2009-12-12 18:32:57.000000000 +0000
+++ xl2tpd-1.2.5+dfsg.1/file.h	2010-04-16 13:33:43.746517891 +0100
@@ -68,6 +68,8 @@
     unsigned int localaddr;     /* Local IP for PPP connections */
     int tun_rws;                /* Receive window size (tunnel) */
     int call_rws;               /* Call rws */
+    int rxspeed;		/* Tunnel rx speed */
+    int txspeed;		/* Tunnel tx speed */
     int hbit;                   /* Permit hidden AVP's? */
     int lbit;                   /* Use the length field? */
     int challenge;              /* Challenge authenticate the peer? */
@@ -104,6 +106,8 @@
     struct schedule_entry *rsched;
     int tun_rws;                /* Receive window size (tunnel) */
     int call_rws;               /* Call rws */
+    int rxspeed;		/* Tunnel rx speed */
+    int txspeed;		/* Tunnel tx speed */
     int active;                 /* Is this connection in active use? */
     int hbit;                   /* Permit hidden AVP's? */
     int lbit;                   /* Use the length field? */
diff -rubN xl2tpd-1.2.5+dfsg/l2tp.h xl2tpd-1.2.5+dfsg.1/l2tp.h
--- xl2tpd-1.2.5+dfsg/l2tp.h	2009-12-12 18:32:57.000000000 +0000
+++ xl2tpd-1.2.5+dfsg.1/l2tp.h	2010-04-16 13:35:59.336728674 +0100
@@ -164,6 +164,8 @@
 #endif
     int rws;                    /* Peer's Receive Window Size */
     int ourrws;                 /* Receive Window Size */
+    int rxspeed;		/* Receive bps */
+    int txspeed;		/* Transmit bps */
     struct call *self;
     struct lns *lns;            /* LNS that owns us */
     struct lac *lac;            /* LAC that owns us */
diff -rubN xl2tpd-1.2.5+dfsg/xl2tpd.c xl2tpd-1.2.5+dfsg.1/xl2tpd.c
--- xl2tpd-1.2.5+dfsg/xl2tpd.c	2009-12-12 18:32:57.000000000 +0000
+++ xl2tpd-1.2.5+dfsg.1/xl2tpd.c	2010-04-16 13:37:09.238542766 +0100
@@ -824,6 +824,8 @@
     };
     tmp->ourrws = DEFAULT_RWS_SIZE;
     tmp->self->ourfbit = FBIT;
+    tmp->rxspeed = DEFAULT_RX_BPS;
+    tmp->txspeed = DEFAULT_TX_BPS;
     tmp->lac = NULL;
     tmp->lns = NULL;
     tmp->chal_us.state = 0;

Reply via email to