diff options
author | Hans Dedecker <dedeckeh@gmail.com> | 2016-09-23 15:08:22 +0200 |
---|---|---|
committer | Felix Fietkau <nbd@nbd.name> | 2016-09-26 11:51:19 +0200 |
commit | e2dfdffad514acf4f6a55f4608802421b55be236 (patch) | |
tree | dd715ee7c610846467581b400caf925df6baf863 | |
parent | 824c5f4b3a041183604018e0068ccf123ee10221 (diff) |
vlandev: Rework 8021ad/8021q detection based on vlandevice type
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
-rw-r--r-- | vlandev.c | 13 |
1 files changed, 4 insertions, 9 deletions
@@ -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); } |