summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Kozlov <xeb@mail.ru>2014-05-12 15:12:21 +0400
committerDmitry Kozlov <xeb@mail.ru>2014-05-12 15:12:21 +0400
commit48e3ff7f660efdf56b2dd53955de7e790f51e336 (patch)
treec4114c28e9c76e66566f765c2cfd5af0b4611f90
parent1c79692a883d065c4d0c185e91c16afda49d5d36 (diff)
downloadaccel-ppp-48e3ff7f660efdf56b2dd53955de7e790f51e336.tar.gz
accel-ppp-48e3ff7f660efdf56b2dd53955de7e790f51e336.zip
pppoe: introduced called-sid option.
This new option will control how to represent Called-Station-ID. Its value maybe ifname,mac or ifname:mac. By default mac is used to keep compatibility with old versions. Also old option ifname-in-sid is removed from documentation, but is still supported for compatibility.
-rw-r--r--accel-pppd/accel-ppp.conf2
-rw-r--r--accel-pppd/accel-ppp.conf.513
-rw-r--r--accel-pppd/ctrl/pppoe/pppoe.c42
3 files changed, 44 insertions, 13 deletions
diff --git a/accel-pppd/accel-ppp.conf b/accel-pppd/accel-ppp.conf
index f399361d..b833aae2 100644
--- a/accel-pppd/accel-ppp.conf
+++ b/accel-pppd/accel-ppp.conf
@@ -70,7 +70,7 @@ verbose=1
#service-name=yyy
#pado-delay=0
#pado-delay=0,100:100,200:200,-1:500
-#ifname-in-sid=called-sid
+called-sid=mac
#tr101=1
#padi-limit=0
#ip-pool=pppoe
diff --git a/accel-pppd/accel-ppp.conf.5 b/accel-pppd/accel-ppp.conf.5
index bf7b999b..d5fcb7ac 100644
--- a/accel-pppd/accel-ppp.conf.5
+++ b/accel-pppd/accel-ppp.conf.5
@@ -447,8 +447,17 @@ Specifies mac-filter filename and type, type maybe
or
.B deny
.TP
-.BI "ifname-in-sid=" called-sid|calling-sid|both
-Specifies that interface name should be present in Called-Station-ID or in Calling-Station-ID or in both attributes.
+.BI "called-sid=" ifname|mac|ifname:mac
+Specifies how to represent Called-Station-ID.
+.br
+.B ifname
+- Called-Station-ID will contain name of interface accepted request.
+.br
+.B mac
+- Called-Station-ID will contain mac address of interface accepted request.
+.br
+.B ifname:mac
+- Called-Station-Id will contain both name and mac of interface.
.TP
.BI "verbose=" n
If this option is given and
diff --git a/accel-pppd/ctrl/pppoe/pppoe.c b/accel-pppd/ctrl/pppoe/pppoe.c
index 1dc21a3d..07019d89 100644
--- a/accel-pppd/ctrl/pppoe/pppoe.c
+++ b/accel-pppd/ctrl/pppoe/pppoe.c
@@ -33,8 +33,7 @@
#include "memdebug.h"
-struct pppoe_conn_t
-{
+struct pppoe_conn_t {
struct list_head entry;
struct triton_context_t ctx;
struct pppoe_serv_t *serv;
@@ -90,6 +89,8 @@ int conf_tr101 = 1;
int conf_padi_limit = 0;
int conf_mppe = MPPE_UNSET;
static const char *conf_ip_pool;
+enum {CSID_MAC, CSID_IFNAME, CSID_IFNAME_MAC};
+static int conf_called_sid;
static mempool_t conn_pool;
static mempool_t pado_pool;
@@ -280,8 +281,23 @@ static struct pppoe_conn_t *allocate_channel(struct pppoe_serv_t *serv, const ui
conn->ctrl.name = "pppoe";
conn->ctrl.mppe = conf_mppe;
+ if (conf_called_sid == CSID_IFNAME)
+ conn->ctrl.called_station_id = _strdup(serv->ifname);
+ else if (conf_called_sid == CSID_IFNAME_MAC) {
+ conn->ctrl.called_station_id = _malloc(IFNAMSIZ + 19);
+ sprintf(conn->ctrl.called_station_id, "%s:%02x:%02x:%02x:%02x:%02x:%02x", serv->ifname,
+ serv->hwaddr[0], serv->hwaddr[1], serv->hwaddr[2], serv->hwaddr[3], serv->hwaddr[4], serv->hwaddr[5]);
+ } else {
+ conn->ctrl.called_station_id = _malloc(IFNAMSIZ + 19);
+ if (conf_ifname_in_sid == 2 || conf_ifname_in_sid == 3)
+ sprintf(conn->ctrl.called_station_id, "%s:%02x:%02x:%02x:%02x:%02x:%02x", serv->ifname,
+ serv->hwaddr[0], serv->hwaddr[1], serv->hwaddr[2], serv->hwaddr[3], serv->hwaddr[4], serv->hwaddr[5]);
+ else
+ sprintf(conn->ctrl.called_station_id, "%02x:%02x:%02x:%02x:%02x:%02x",
+ serv->hwaddr[0], serv->hwaddr[1], serv->hwaddr[2], serv->hwaddr[3], serv->hwaddr[4], serv->hwaddr[5]);
+ }
+
conn->ctrl.calling_station_id = _malloc(IFNAMSIZ + 19);
- conn->ctrl.called_station_id = _malloc(IFNAMSIZ + 19);
if (conf_ifname_in_sid == 1 || conf_ifname_in_sid == 3)
sprintf(conn->ctrl.calling_station_id, "%s:%02x:%02x:%02x:%02x:%02x:%02x", serv->ifname,
@@ -290,13 +306,6 @@ static struct pppoe_conn_t *allocate_channel(struct pppoe_serv_t *serv, const ui
sprintf(conn->ctrl.calling_station_id, "%02x:%02x:%02x:%02x:%02x:%02x",
addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
- if (conf_ifname_in_sid == 2 || conf_ifname_in_sid == 3)
- sprintf(conn->ctrl.called_station_id, "%s:%02x:%02x:%02x:%02x:%02x:%02x", serv->ifname,
- serv->hwaddr[0], serv->hwaddr[1], serv->hwaddr[2], serv->hwaddr[3], serv->hwaddr[4], serv->hwaddr[5]);
- else
- sprintf(conn->ctrl.called_station_id, "%02x:%02x:%02x:%02x:%02x:%02x",
- serv->hwaddr[0], serv->hwaddr[1], serv->hwaddr[2], serv->hwaddr[3], serv->hwaddr[4], serv->hwaddr[5]);
-
ppp_init(&conn->ppp);
conn->ppp.ses.ctrl = &conn->ctrl;
@@ -1508,6 +1517,19 @@ static void load_config(void)
}
conf_ip_pool = conf_get_opt("pppoe", "ip-pool");
+
+ conf_called_sid = CSID_MAC;
+ opt = conf_get_opt("pppoe", "called-sid");
+ if (opt) {
+ if (!strcmp(opt, "mac"))
+ conf_called_sid = CSID_MAC;
+ else if (!strcmp(opt, "ifname"))
+ conf_called_sid = CSID_IFNAME;
+ else if (!strcmp(opt, "ifname:mac"))
+ conf_called_sid = CSID_IFNAME_MAC;
+ else
+ log_error("pppoe: unknown called-sid type\n");
+ }
}
static void pppoe_init(void)