summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Kozlov <xeb@mail.ru>2015-11-21 15:57:49 +0300
committerDmitry Kozlov <xeb@mail.ru>2015-11-21 15:57:49 +0300
commit4a41fc593e56691172a58b511a1d9ade63982c32 (patch)
tree535c8a5a53b737998d85ff097a059de4d582c3aa
parent9190fe47e0ce57e8f0b3360f2fe0404169b44263 (diff)
downloadaccel-ppp-4a41fc593e56691172a58b511a1d9ade63982c32.tar.gz
accel-ppp-4a41fc593e56691172a58b511a1d9ade63982c32.zip
move parse_vlan_mon function to vlan-mon module
-rw-r--r--accel-pppd/ctrl/ipoe/ipoe.c53
-rw-r--r--accel-pppd/include/vlan_mon.h2
-rw-r--r--accel-pppd/vlan-mon/vlan_mon.c53
3 files changed, 54 insertions, 54 deletions
diff --git a/accel-pppd/ctrl/ipoe/ipoe.c b/accel-pppd/ctrl/ipoe/ipoe.c
index d77da31f..46ab130d 100644
--- a/accel-pppd/ctrl/ipoe/ipoe.c
+++ b/accel-pppd/ctrl/ipoe/ipoe.c
@@ -2881,59 +2881,6 @@ out_err:
return -1;
}
-static int parse_vlan_mon(const char *opt, long *mask)
-{
- char *ptr, *ptr2;
- int vid, vid2;
-
- ptr = strchr(opt, ',');
- if (!ptr)
- ptr = strchr(opt, 0);
-
- if (*ptr == ',')
- memset(mask, 0xff, 4096/8);
- else if (*ptr == 0) {
- memset(mask, 0, 4096/8);
- return 0;
- } else
- goto out_err;
-
- while (1) {
- vid = strtol(ptr + 1, &ptr2, 10);
- if (vid <= 0 || vid >= 4096) {
- log_error("ipoe: vlan-mon=%s: invalid vlan %i\n", opt, vid);
- return -1;
- }
-
- if (*ptr2 == '-') {
- vid2 = strtol(ptr2 + 1, &ptr2, 10);
- if (vid2 <= 0 || vid2 >= 4096) {
- log_error("ipoe: vlan-mon=%s: invalid vlan %i\n", opt, vid2);
- return -1;
- }
-
- for (; vid < vid2; vid++)
- mask[vid / (8*sizeof(long))] &= ~(1lu << (vid % (8*sizeof(long))));
- }
-
- mask[vid / (8*sizeof(long))] &= ~(1lu << (vid % (8*sizeof(long))));
-
- if (*ptr2 == 0)
- break;
-
- if (*ptr2 != ',')
- goto out_err;
-
- ptr = ptr2;
- }
-
- return 0;
-
-out_err:
- log_error("ipoe: vlan-mon=%s: failed to parse\n", opt);
- return -1;
-}
-
static void add_vlan_mon(const char *opt, long *mask)
{
const char *ptr;
diff --git a/accel-pppd/include/vlan_mon.h b/accel-pppd/include/vlan_mon.h
index 928c732e..c6b2db76 100644
--- a/accel-pppd/include/vlan_mon.h
+++ b/accel-pppd/include/vlan_mon.h
@@ -10,6 +10,6 @@ int vlan_mon_add_vid(int ifindex, int proto, int vid);
int vlan_mon_del(int ifindex, int proto);
int make_vlan_name(const char *pattern, const char *parent, int svid, int cvid, char *name);
-
+int parse_vlan_mon(const char *opt, long *mask);
#endif
diff --git a/accel-pppd/vlan-mon/vlan_mon.c b/accel-pppd/vlan-mon/vlan_mon.c
index 898d7dcd..7f15aa06 100644
--- a/accel-pppd/vlan-mon/vlan_mon.c
+++ b/accel-pppd/vlan-mon/vlan_mon.c
@@ -305,6 +305,59 @@ int __export make_vlan_name(const char *pattern, const char *parent, int svid, i
return 0;
}
+int __export parse_vlan_mon(const char *opt, long *mask)
+{
+ char *ptr, *ptr2;
+ int vid, vid2;
+
+ ptr = strchr(opt, ',');
+ if (!ptr)
+ ptr = strchr(opt, 0);
+
+ if (*ptr == ',')
+ memset(mask, 0xff, 4096/8);
+ else if (*ptr == 0) {
+ memset(mask, 0, 4096/8);
+ return 0;
+ } else
+ goto out_err;
+
+ while (1) {
+ vid = strtol(ptr + 1, &ptr2, 10);
+ if (vid <= 0 || vid >= 4096) {
+ log_error("vlan-mon=%s: invalid vlan %i\n", opt, vid);
+ return -1;
+ }
+
+ if (*ptr2 == '-') {
+ vid2 = strtol(ptr2 + 1, &ptr2, 10);
+ if (vid2 <= 0 || vid2 >= 4096) {
+ log_error("vlan-mon=%s: invalid vlan %i\n", opt, vid2);
+ return -1;
+ }
+
+ for (; vid < vid2; vid++)
+ mask[vid / (8*sizeof(long))] &= ~(1lu << (vid % (8*sizeof(long))));
+ }
+
+ mask[vid / (8*sizeof(long))] &= ~(1lu << (vid % (8*sizeof(long))));
+
+ if (*ptr2 == 0)
+ break;
+
+ if (*ptr2 != ',')
+ goto out_err;
+
+ ptr = ptr2;
+ }
+
+ return 0;
+
+out_err:
+ log_error("vlan-mon=%s: failed to parse\n", opt);
+ return -1;
+}
+
static void vlan_mon_mc_close(struct triton_context_t *ctx)
{