diff options
author | John Crispin <blogic@openwrt.org> | 2015-12-23 19:24:45 +0000 |
---|---|---|
committer | John Crispin <blogic@openwrt.org> | 2015-12-23 19:24:45 +0000 |
commit | 3752e143da9a62e1792bc3b4c383b6b4a73a2775 (patch) | |
tree | 2fe2f9611a1cd97db0d2a5d21690b403bccff657 /package/network/config/swconfig/src/cli.c | |
parent | f9013beb5865bc5caef9291cff109755675681ce (diff) | |
download | master-187ad058-3752e143da9a62e1792bc3b4c383b6b4a73a2775.tar.gz master-187ad058-3752e143da9a62e1792bc3b4c383b6b4a73a2775.tar.bz2 master-187ad058-3752e143da9a62e1792bc3b4c383b6b4a73a2775.zip |
swconfig: support receiving SWITCH_TYPE_LINK from kernel
When using cli, print link state the same way kernel used to do it.
This will allow kernel switching PORT_LINK from SWITCH_TYPE_STRING.
Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@47998 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/network/config/swconfig/src/cli.c')
-rw-r--r-- | package/network/config/swconfig/src/cli.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/package/network/config/swconfig/src/cli.c b/package/network/config/swconfig/src/cli.c index d472086781..90554143e1 100644 --- a/package/network/config/swconfig/src/cli.c +++ b/package/network/config/swconfig/src/cli.c @@ -84,9 +84,27 @@ list_attributes(struct switch_dev *dev) print_attrs(dev->port_ops); } +static const char * +speed_str(int speed) +{ + switch (speed) { + case 10: + return "10baseT"; + case 100: + return "100baseT"; + case 1000: + return "1000baseT"; + default: + break; + } + + return "unknown"; +} + static void print_attr_val(const struct switch_attr *attr, const struct switch_val *val) { + struct switch_port_link *link; int i; switch (attr->type) { @@ -104,6 +122,21 @@ print_attr_val(const struct switch_attr *attr, const struct switch_val *val) SWLIB_PORT_FLAG_TAGGED) ? "t" : ""); } break; + case SWITCH_TYPE_LINK: + link = val->value.link; + if (link->link) + printf("port:%d link:up speed:%s %s-duplex %s%s%s%s%s", + val->port_vlan, + speed_str(link->speed), + link->duplex ? "full" : "half", + link->tx_flow ? "txflow " : "", + link->rx_flow ? "rxflow " : "", + link->eee & SWLIB_LINK_FLAG_EEE_100BASET ? "eee100 " : "", + link->eee & SWLIB_LINK_FLAG_EEE_1000BASET ? "eee1000 " : "", + link->aneg ? "auto" : ""); + else + printf("port:%d link:down", val->port_vlan); + break; default: printf("?unknown-type?"); } |