#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 },
};
.next = { &device_attr_list },
};
+static struct device_type vlan8021q_device_type;
+
struct vlandev_device {
struct device dev;
struct device_user parent;
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);
}
return dev;
}
-struct device_type vlandev_device_type = {
- .name = "VLANDEV",
+static struct device_type vlan8021ad_device_type = {
+ .name = "8021ad",
+ .config_params = &vlandev_attr_list,
+ .create = vlandev_create,
+ .config_init = vlandev_config_init,
+ .reload = vlandev_reload,
+ .free = vlandev_free,
+ .dump_info = vlandev_dump_info,
+};
+
+static struct device_type vlan8021q_device_type = {
+ .name = "8021q",
.config_params = &vlandev_attr_list,
.create = vlandev_create,
.config_init = vlandev_config_init,
.free = vlandev_free,
.dump_info = vlandev_dump_info,
};
+
+static void __init vlandev_device_type_init(void)
+{
+ device_type_add(&vlan8021ad_device_type);
+ device_type_add(&vlan8021q_device_type);
+}