From e2dfdffad514acf4f6a55f4608802421b55be236 Mon Sep 17 00:00:00 2001 From: Hans Dedecker Date: Fri, 23 Sep 2016 15:08:22 +0200 Subject: vlandev: Rework 8021ad/8021q detection based on vlandevice type Signed-off-by: Hans Dedecker --- vlandev.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/vlandev.c b/vlandev.c index b065c27..7e46251 100644 --- a/vlandev.c +++ b/vlandev.c @@ -20,14 +20,12 @@ #include "system.h" enum { - VLANDEV_ATTR_TYPE, VLANDEV_ATTR_IFNAME, VLANDEV_ATTR_VID, __VLANDEV_ATTR_MAX }; static const struct blobmsg_policy vlandev_attrs[__VLANDEV_ATTR_MAX] = { - [VLANDEV_ATTR_TYPE] = { "type", BLOBMSG_TYPE_STRING }, [VLANDEV_ATTR_IFNAME] = { "ifname", BLOBMSG_TYPE_STRING }, [VLANDEV_ATTR_VID] = { "vid", BLOBMSG_TYPE_INT32 }, }; @@ -40,6 +38,8 @@ static const struct uci_blob_param_list vlandev_attr_list = { .next = { &device_attr_list }, }; +static struct device_type vlan8021q_device_type; + struct vlandev_device { struct device dev; struct device_user parent; @@ -158,15 +158,10 @@ vlandev_apply_settings(struct vlandev_device *mvdev, struct blob_attr **tb) struct vlandev_config *cfg = &mvdev->config; struct blob_attr *cur; - cfg->proto = VLAN_PROTO_8021Q; + cfg->proto = (mvdev->dev.type == &vlan8021q_device_type) ? + VLAN_PROTO_8021Q : VLAN_PROTO_8021AD; cfg->vid = 1; - if ((cur = tb[VLANDEV_ATTR_TYPE])) - { - if(!strcmp(blobmsg_data(cur), "8021ad")) - cfg->proto = VLAN_PROTO_8021AD; - } - if ((cur = tb[VLANDEV_ATTR_VID])) cfg->vid = (uint16_t) blobmsg_get_u32(cur); } -- cgit v1.2.3