You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

59 lines
2.1 KiB

From 81f3991e232fd45b05ff52b5091393532e4305e5 Mon Sep 17 00:00:00 2001
From: Michael Heimpold <mhei@heimpold.de>
Date: Thu, 13 Apr 2017 20:29:10 +0200
Subject: [PATCH] dataxfer.c: adjust "Remote address" column width
In case we are connected to an IPv6 address the current column width
is too small to take the complete address and port number so adjust it.
Signed-off-by: Michael Heimpold <mhei@heimpold.de>
Signed-off-by: Corey Minyard <cminyard@mvista.com>
diff --git a/dataxfer.c b/dataxfer.c
index 75c2777..9955403 100644
--- a/dataxfer.c
+++ b/dataxfer.c
@@ -3674,6 +3674,9 @@ clear_old_port_config(int curr_config)
UNLOCK(ports_lock);
}
+#define REMOTEADDR_COLUMN_WIDTH \
+ (INET6_ADDRSTRLEN - 1 /* terminating NUL */ + 1 /* comma */ + 5 /* strlen("65535") */)
+
/* Print information about a port to the control port given in cntlr. */
static void
showshortport(struct controller_info *cntlr, port_info_t *port)
@@ -3705,14 +3708,14 @@ showshortport(struct controller_info *cntlr, port_info_t *port)
snprintf(buffer, sizeof(buffer), "*err*,%s", gai_strerror(err));
/* gai_strerror could return an elongated string which could break
our pretty formatted output below, so truncate the string nicely */
- if (strlen(buffer) > 22)
- strcpy(&buffer[22 - 3], "...");
+ if (strlen(buffer) > REMOTEADDR_COLUMN_WIDTH)
+ strcpy(&buffer[REMOTEADDR_COLUMN_WIDTH - 3], "...");
count = controller_outputf(cntlr, "%s", buffer);
} else {
count = controller_outputf(cntlr, "%s,%s", buffer, portbuff);
}
- while (count < 23) {
+ while (count < REMOTEADDR_COLUMN_WIDTH + 1) {
controller_outs(cntlr, " ");
count++;
}
@@ -3878,10 +3881,11 @@ showshortports(struct controller_info *cntlr, char *portspec)
port_info_t *port;
controller_outputf(cntlr,
- "%-22s %-6s %7s %-22s %-22s %-14s %-14s %9s %9s %9s %9s %s\r\n",
+ "%-22s %-6s %7s %-*s %-22s %-14s %-14s %9s %9s %9s %9s %s\r\n",
"Port name",
"Type",
"Timeout",
+ REMOTEADDR_COLUMN_WIDTH,
"Remote address",
"Device",
"TCP to device",
--
2.7.4