summaryrefslogtreecommitdiff
path: root/accel-pppd/ctrl/pppoe
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 /accel-pppd/ctrl/pppoe
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.
Diffstat (limited to 'accel-pppd/ctrl/pppoe')
-rw-r--r--accel-pppd/ctrl/pppoe/pppoe.c42
1 files changed, 32 insertions, 10 deletions
diff --git a/accel-pppd/ctrl/pppoe/pppoe.c b/accel-pppd/ctrl/pppoe/pppoe.c
index 1dc21a3..07019d8 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)