summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2016-02-21 14:31:51 +0100
committerLennart Poettering <lennart@poettering.net>2016-02-21 20:58:59 +0100
commitd08191a242d51f72e75d41f188b14e67dd8851c4 (patch)
treeb7a65b26ad7786a58e913f01d573ed061ee7b27f /src
parentf5207c2206061479e7eb5f3fd6213d7c508e0336 (diff)
networkctl: ellipsize long LLDP fields in table output
Diffstat (limited to 'src')
-rw-r--r--src/network/networkctl.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/network/networkctl.c b/src/network/networkctl.c
index 23d8c4555b..d1aec9a7dc 100644
--- a/src/network/networkctl.c
+++ b/src/network/networkctl.c
@@ -940,6 +940,7 @@ static int link_lldp_status(int argc, char *argv[], void *userdata) {
}
for (;;) {
+ _cleanup_free_ char *cid = NULL, *pid = NULL, *sname = NULL, *pdesc = NULL;
const char *chassis_id = NULL, *port_id = NULL, *system_name = NULL, *port_description = NULL, *capabilities = NULL;
_cleanup_(sd_lldp_neighbor_unrefp) sd_lldp_neighbor *n = NULL;
uint16_t cc;
@@ -957,6 +958,30 @@ static int link_lldp_status(int argc, char *argv[], void *userdata) {
(void) sd_lldp_neighbor_get_system_name(n, &system_name);
(void) sd_lldp_neighbor_get_port_description(n, &port_description);
+ if (chassis_id) {
+ cid = ellipsize(chassis_id, 17, 100);
+ if (cid)
+ chassis_id = cid;
+ }
+
+ if (port_id) {
+ pid = ellipsize(port_id, 17, 100);
+ if (pid)
+ port_id = pid;
+ }
+
+ if (system_name) {
+ sname = ellipsize(system_name, 16, 100);
+ if (sname)
+ system_name = sname;
+ }
+
+ if (port_description) {
+ pdesc = ellipsize(port_description, 16, 100);
+ if (pdesc)
+ port_description = pdesc;
+ }
+
if (sd_lldp_neighbor_get_enabled_capabilities(n, &cc) >= 0)
capabilities = lldp_capabilities_to_string(cc);