aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuk Claes <luk@debian.org>2008-11-16 16:45:08 +0000
committerLuk Claes <luk@debian.org>2008-11-16 16:45:08 +0000
commit38720e894744e883c2b37c92c16c793f790346ed (patch)
treeabd0b17d75f17a1eb90d12fc456cb6243d4c5e97
parentmoved H suport for Infiniband to the right section (diff)
downloadnet-tools-38720e894744e883c2b37c92c16c793f790346ed.tar.gz
net-tools-38720e894744e883c2b37c92c16c793f790346ed.tar.bz2
net-tools-38720e894744e883c2b37c92c16c793f790346ed.zip
Add wide option to prevent truncating IPv6 addresses
-rw-r--r--man/en_US/netstat.85
-rw-r--r--netstat.c28
2 files changed, 23 insertions, 10 deletions
diff --git a/man/en_US/netstat.8 b/man/en_US/netstat.8
index dabe2a5..f93996b 100644
--- a/man/en_US/netstat.8
+++ b/man/en_US/netstat.8
@@ -8,7 +8,7 @@
.\" Modified: Tuan Hoang tqhoang@bigfoot.com
.\"
.\"
-.TH NETSTAT 8 "2008\-10\-03" "net\-tools" "Linux System Administrator's Manual"
+.TH NETSTAT 8 "2008\-11\-16" "net\-tools" "Linux System Administrator's Manual"
.SH NAME
netstat \- Print network connections, routing tables, interface statistics, masquerade connections, and multicast memberships
@@ -118,6 +118,9 @@ Display summary statistics for each protocol.
.SS "\-\-verbose , \-v"
Tell the user what is going on by being verbose. Especially print some
useful information about unconfigured address families.
+.SS "\-\-wide , \-W"
+Do not truncate IP addresses by using output as wide as needed. This is
+optional for now to not break existing scripts.
.SS "\-\-numeric , \-n"
Show numerical addresses instead of trying to determine symbolic host, port
or user names.
diff --git a/netstat.c b/netstat.c
index 182e601..c8460bf 100644
--- a/netstat.c
+++ b/netstat.c
@@ -6,7 +6,7 @@
* NET-3 Networking Distribution for the LINUX operating
* system.
*
- * Version: $Id: netstat.c,v 1.59 2008/10/03 01:39:06 ecki Exp $
+ * Version: $Id: netstat.c,v 1.60 2008/11/16 16:45:08 luk Exp $
*
* Authors: Fred Baumgarten, <dc6iq@insu1.etec.uni-karlsruhe.de>
* Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
@@ -149,6 +149,7 @@ int flag_udp = 0;
int flag_igmp= 0;
int flag_rom = 0;
int flag_exp = 1;
+int flag_wide= 0;
int flag_prg = 0;
int flag_arg = 0;
int flag_ver = 0;
@@ -770,16 +771,20 @@ static void tcp_do_one(int lnr, const char *line)
get_sname(htons(local_port), "tcp",
flag_not & FLAG_NUM_PORT));
- if ((strlen(local_addr) + strlen(buffer)) > 22)
- local_addr[22 - strlen(buffer)] = '\0';
+ if (!flag_wide) {
+ if ((strlen(local_addr) + strlen(buffer)) > 22)
+ local_addr[22 - strlen(buffer)] = '\0';
+ }
strcat(local_addr, ":");
strcat(local_addr, buffer);
snprintf(buffer, sizeof(buffer), "%s",
get_sname(htons(rem_port), "tcp", flag_not & FLAG_NUM_PORT));
- if ((strlen(rem_addr) + strlen(buffer)) > 22)
- rem_addr[22 - strlen(buffer)] = '\0';
+ if (!flag_wide) {
+ if ((strlen(rem_addr) + strlen(buffer)) > 22)
+ rem_addr[22 - strlen(buffer)] = '\0';
+ }
strcat(rem_addr, ":");
strcat(rem_addr, buffer);
@@ -1500,9 +1505,9 @@ static void version(void)
static void usage(void)
{
- fprintf(stderr, _("usage: netstat [-veenNcCF] [<Af>] -r netstat {-V|--version|-h|--help}\n"));
- fprintf(stderr, _(" netstat [-vnNcaeol] [<Socket> ...]\n"));
- fprintf(stderr, _(" netstat { [-veenNac] -i | [-cnNe] -M | -s [-6tuw] }\n\n"));
+ fprintf(stderr, _("usage: netstat [-vWeenNcCF] [<Af>] -r netstat {-V|--version|-h|--help}\n"));
+ fprintf(stderr, _(" netstat [-vWnNcaeol] [<Socket> ...]\n"));
+ fprintf(stderr, _(" netstat { [-vWeenNac] -i | [-cnNe] -M | -s [-6tuw] }\n\n"));
fprintf(stderr, _(" -r, --route display routing table\n"));
fprintf(stderr, _(" -i, --interfaces display interface table\n"));
@@ -1512,6 +1517,7 @@ static void usage(void)
fprintf(stderr, _(" -M, --masquerade display masqueraded connections\n\n"));
#endif
fprintf(stderr, _(" -v, --verbose be verbose\n"));
+ fprintf(stderr, _(" -W, --wide don't truncate IP addresses\n"));
fprintf(stderr, _(" -n, --numeric don't resolve names\n"));
fprintf(stderr, _(" --numeric-hosts don't resolve host names\n"));
fprintf(stderr, _(" --numeric-ports don't resolve port names\n"));
@@ -1561,6 +1567,7 @@ int main
{"programs", 0, 0, 'p'},
{"verbose", 0, 0, 'v'},
{"statistics", 0, 0, 's'},
+ {"wide", 0, 0, 'W'},
{"numeric", 0, 0, 'n'},
{"numeric-hosts", 0, 0, '!'},
{"numeric-ports", 0, 0, '@'},
@@ -1580,7 +1587,7 @@ int main
getroute_init(); /* Set up AF routing support */
afname[0] = '\0';
- while ((i = getopt_long(argc, argv, "MCFA:acdegphinNorstuVv?wxl64", longopts, &lop)) != EOF)
+ while ((i = getopt_long(argc, argv, "MCFA:acdegphinNorstuWVv?wxl64", longopts, &lop)) != EOF)
switch (i) {
case -1:
break;
@@ -1624,6 +1631,9 @@ int main
case 'i':
flag_int++;
break;
+ case 'W':
+ flag_wide++;
+ break;
case 'n':
flag_not |= FLAG_NUM;
break;