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

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