summaryrefslogtreecommitdiff
path: root/accel-pppd
diff options
context:
space:
mode:
Diffstat (limited to 'accel-pppd')
-rw-r--r--accel-pppd/accel-ppp.conf1
-rw-r--r--accel-pppd/accel-ppp.conf.511
-rw-r--r--accel-pppd/ctrl/ipoe/ipoe.c38
3 files changed, 47 insertions, 3 deletions
diff --git a/accel-pppd/accel-ppp.conf b/accel-pppd/accel-ppp.conf
index 707287f3..00e08c5c 100644
--- a/accel-pppd/accel-ppp.conf
+++ b/accel-pppd/accel-ppp.conf
@@ -118,6 +118,7 @@ start=dhcpv4
#offer-delay=0,100:100,200:200,-1:1000
#vlan-mon=eth0,10-200
#vlan-timeout=60
+#vlan-name=%I.%N
#ip-pool=ipoe
interface=eth0
diff --git a/accel-pppd/accel-ppp.conf.5 b/accel-pppd/accel-ppp.conf.5
index fd9db87c..73a3233c 100644
--- a/accel-pppd/accel-ppp.conf.5
+++ b/accel-pppd/accel-ppp.conf.5
@@ -347,6 +347,17 @@ vlan-mon=eth1,2,5,10,20-30
.TP
.BI "vlan-timeout=" n
Specifies time of vlan inactivity before it will be removed (seconds).
+.TP
+.BI "vlan-name=" pattern
+Specifies pattern of vlan interface name. Pattern may contain following macros:
+.br
+.B %I
+- name of patern interface.
+.br
+.B %N
+- number of vlan.
+.br
+By default vlan-name=%I.%N.
.SH [dns]
.TP
.BI "dns1=" x.x.x.x
diff --git a/accel-pppd/ctrl/ipoe/ipoe.c b/accel-pppd/ctrl/ipoe/ipoe.c
index 5baf3d85..36ba4e36 100644
--- a/accel-pppd/ctrl/ipoe/ipoe.c
+++ b/accel-pppd/ctrl/ipoe/ipoe.c
@@ -132,6 +132,7 @@ static int conf_verbose;
static const char *conf_agent_remote_id;
static int conf_proto;
static LIST_HEAD(conf_offer_delay);
+static const char *conf_vlan_name;
static unsigned int stat_starting;
static unsigned int stat_active;
@@ -1827,6 +1828,32 @@ static int get_offer_delay()
return 0;
}
+static int make_vlan_name(const char *parent, int vid, char *name)
+{
+ char *ptr1 = name, *endptr = name + IFNAMSIZ - 1;
+ const char *ptr2 = conf_vlan_name;
+ char num[5], *ptr3 = num;
+
+ sprintf(num, "%i", vid);
+
+ while (ptr1 < endptr && *ptr2) {
+ if (ptr2[0] == '%' && ptr2[1] == 'I') {
+ while (ptr1 < endptr && *parent)
+ *ptr1++ = *parent++;
+ ptr2 += 2;
+ } else if (ptr2[0] == '%' && ptr2[1] == 'N') {
+ while (ptr1 < endptr && *ptr3)
+ *ptr1++ = *ptr3++;
+ ptr2 += 2;
+ } else
+ *ptr1++ = *ptr2++;
+ }
+
+ *ptr1 = 0;
+
+ return ptr1 == endptr;
+}
+
void ipoe_vlan_notify(int ifindex, int vid)
{
struct conf_sect_t *sect = conf_get_section("ipoe");
@@ -1838,6 +1865,7 @@ void ipoe_vlan_notify(int ifindex, int vid)
const char *pcre_err;
char *pattern;
int pcre_offset;
+ char ifname[IFNAMSIZ];
if (!sect)
return;
@@ -1849,12 +1877,12 @@ void ipoe_vlan_notify(int ifindex, int vid)
return;
}
- if (strlen(ifr.ifr_name) + 5 >= sizeof(ifr.ifr_name)) {
+ if (make_vlan_name(ifr.ifr_name, vid, ifname)) {
log_error("ipoe: vlan-mon: %s.%i: interface name is too long\n", ifr.ifr_name, vid);
return;
}
-
- sprintf(ifr.ifr_name + strlen(ifr.ifr_name), ".%i", vid);
+
+ strcpy(ifr.ifr_name, ifname);
len = strlen(ifr.ifr_name);
log_info2("ipoe: create vlan %s\n", ifr.ifr_name);
@@ -2838,6 +2866,10 @@ static void load_config(void)
conf_offer_timeout = 10;
conf_ip_pool = conf_get_opt("ipoe", "ip-pool");
+
+ conf_vlan_name = conf_get_opt("ipoe", "vlan-name");
+ if (!conf_vlan_name)
+ conf_vlan_name = "%I.%N";
#ifdef RADIUS
if (triton_module_loaded("radius"))