diff options
author | Rafał Miłecki <zajec5@gmail.com> | 2016-01-06 18:32:13 +0000 |
---|---|---|
committer | Rafał Miłecki <zajec5@gmail.com> | 2016-01-06 18:32:13 +0000 |
commit | bab5b7547cd15ca71f72c4aacbb1b723a669d89d (patch) | |
tree | 0925cf0d469d81d1ed828fe6b062043bf2b4fdae /package/network/config/swconfig/src | |
parent | 0efd7e707fd665db0872b886c4c7a58a859bcf0d (diff) | |
download | master-187ad058-bab5b7547cd15ca71f72c4aacbb1b723a669d89d.tar.gz master-187ad058-bab5b7547cd15ca71f72c4aacbb1b723a669d89d.tar.bz2 master-187ad058-bab5b7547cd15ca71f72c4aacbb1b723a669d89d.zip |
swconfig: support sending SWITCH_TYPE_LINK to kernel
Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@48141 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/network/config/swconfig/src')
-rw-r--r-- | package/network/config/swconfig/src/swlib.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/package/network/config/swconfig/src/swlib.c b/package/network/config/swconfig/src/swlib.c index 908e0fb496..eeabbf14e9 100644 --- a/package/network/config/swconfig/src/swlib.c +++ b/package/network/config/swconfig/src/swlib.c @@ -337,6 +337,30 @@ nla_put_failure: } static int +send_attr_link(struct nl_msg *msg, struct switch_val *val) +{ + struct switch_port_link *link = val->value.link; + struct nlattr *n; + + n = nla_nest_start(msg, SWITCH_ATTR_OP_VALUE_LINK); + if (!n) + goto nla_put_failure; + + if (link->duplex) + NLA_PUT_FLAG(msg, SWITCH_LINK_FLAG_DUPLEX); + if (link->aneg) + NLA_PUT_FLAG(msg, SWITCH_LINK_FLAG_ANEG); + NLA_PUT_U32(msg, SWITCH_LINK_SPEED, link->speed); + + nla_nest_end(msg, n); + + return 0; + +nla_put_failure: + return -1; +} + +static int send_attr_val(struct nl_msg *msg, void *arg) { struct switch_val *val = arg; @@ -360,6 +384,10 @@ send_attr_val(struct nl_msg *msg, void *arg) if (send_attr_ports(msg, val) < 0) goto nla_put_failure; break; + case SWITCH_TYPE_LINK: + if (send_attr_link(msg, val)) + goto nla_put_failure; + break; default: goto nla_put_failure; } |