Package: net-tools
Version: 1.60-19
Severity: wishlist
[EMAIL PROTECTED] submitted this patch to add a -W (wide) flag to netstat
just like FreeBSD. otherwise there is no way to get the full hostname
from netstat for local/remote hostnames.
diff --git a/man/en_US/netstat.8 b/man/en_US/netstat.8
index e6be46b..9a3ff44 100644
--- a/man/en_US/netstat.8
+++ b/man/en_US/netstat.8
@@ -24,6 +24,7 @@ netstat \- Print network connections, routing tables,
interface statistics, masq
.RB [ \-\-all | \-a ]
.RB [ \-\-numeric | \-n ]
.RB [ \-\-numeric-hosts "] [" \-\-numeric-ports "] [" \-\-numeric-users ]
+.RB [ \-\-wide | \-W]
.RB [ \-\-symbolic | \-N ]
.RB [ \-\-extend | \-e [ \-\-extend | \-e] ]
.RB [ \-\-timers | \-o ]
@@ -130,6 +131,8 @@ host or user names.
.SS "\-\-numeric-users"
shows numerical user IDs but does not affect the resolution of host or
port names.
+.SS "\-\-wide , \-W"
+Don't truncate host names.
.SS "\-\-protocol=\fIfamily \fR, \fB\-A"
Specifies the address families (perhaps better described as low level
diff --git a/netstat.c b/netstat.c
index 843c06b..78bf551 100644
--- a/netstat.c
+++ b/netstat.c
@@ -150,6 +150,7 @@ int flag_exp = 1;
int flag_prg = 0;
int flag_arg = 0;
int flag_ver = 0;
+int flag_wid = 0;
FILE *procinfo;
@@ -780,7 +781,7 @@ 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)
+ if (!flag_wid && ((strlen(local_addr) + strlen(buffer)) > 22))
local_addr[22 - strlen(buffer)] = '\0';
strcat(local_addr, ":");
@@ -789,7 +790,7 @@ static void tcp_do_one(int lnr, const char *line)
snprintf(buffer, sizeof(buffer), "%s",
get_sname(htons(rem_port), "tcp", flag_not & FLAG_NUM_PORT));
- if ((strlen(rem_addr) + strlen(buffer)) > 22)
+ if (!flag_wid && ((strlen(rem_addr) + strlen(buffer)) > 22))
rem_addr[22 - strlen(buffer)] = '\0';
strcat(rem_addr, ":");
@@ -935,7 +936,7 @@ static void udp_do_one(int lnr, const char *line)
snprintf(buffer, sizeof(buffer), "%s",
get_sname(htons(local_port), "udp",
flag_not & FLAG_NUM_PORT));
- if ((strlen(local_addr) + strlen(buffer)) > 22)
+ if (!flag_wid && ((strlen(local_addr) + strlen(buffer)) > 22))
local_addr[22 - strlen(buffer)] = '\0';
strcat(local_addr, ":");
strncat(local_addr, buffer, sizeof(local_addr));
@@ -945,7 +946,7 @@ static void udp_do_one(int lnr, const char *line)
get_sname(htons(rem_port), "udp", flag_not & FLAG_NUM_PORT));
safe_strncpy(rem_addr, ap->sprint((struct sockaddr *) &remaddr,
flag_not & FLAG_NUM_HOST),
sizeof(rem_addr));
- if ((strlen(rem_addr) + strlen(buffer)) > 22)
+ if (!flag_wid && ((strlen(rem_addr) + strlen(buffer)) > 22))
rem_addr[22 - strlen(buffer)] = '\0';
strcat(rem_addr, ":");
strncat(rem_addr, buffer, sizeof(rem_addr));
@@ -1059,7 +1060,7 @@ static void raw_do_one(int lnr, const char *line)
flag_not & FLAG_NUM_PORT));
safe_strncpy(local_addr, ap->sprint((struct sockaddr *) &localaddr,
flag_not & FLAG_NUM_HOST),
sizeof(local_addr));
- if ((strlen(local_addr) + strlen(buffer)) > 22)
+ if (!flag_wid && ((strlen(local_addr) + strlen(buffer)) > 22))
local_addr[22 - strlen(buffer)] = '\0';
strcat(local_addr, ":");
strncat(local_addr, buffer, sizeof(local_addr));
@@ -1069,7 +1070,7 @@ static void raw_do_one(int lnr, const char *line)
get_sname(htons(rem_port), "raw", flag_not & FLAG_NUM_PORT));
safe_strncpy(rem_addr, ap->sprint((struct sockaddr *) &remaddr,
flag_not & FLAG_NUM_HOST),
sizeof(rem_addr));
- if ((strlen(rem_addr) + strlen(buffer)) > 22)
+ if (!flag_wid && ((strlen(rem_addr) + strlen(buffer)) > 22))
rem_addr[22 - strlen(buffer)] = '\0';
strcat(rem_addr, ":");
strncat(rem_addr, buffer, sizeof(rem_addr));
@@ -1531,6 +1532,7 @@ static void usage(void)
fprintf(stderr, _(" --numeric-hosts don't resolve host
names\n"));
fprintf(stderr, _(" --numeric-ports don't resolve port
names\n"));
fprintf(stderr, _(" --numeric-users don't resolve user
names\n"));
+ fprintf(stderr, _(" -W, --wide don't truncate host
names\n"));
fprintf(stderr, _(" -N, --symbolic resolve hardware
names\n"));
fprintf(stderr, _(" -e, --extend display other/more
information\n"));
fprintf(stderr, _(" -p, --programs display PID/Program
name for sockets\n"));
@@ -1580,6 +1582,7 @@ int main
{"numeric-hosts", 0, 0, '!'},
{"numeric-ports", 0, 0, '@'},
{"numeric-users", 0, 0, '#'},
+ {"wide", 0, 0, 'W'},
{"symbolic", 0, 0, 'N'},
{"cache", 0, 0, 'C'},
{"fib", 0, 0, 'F'},
@@ -1595,7 +1598,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:acdegphinWNorstuVv?wxl64",
longopts, &lop)) != EOF)
switch (i) {
case -1:
break;
@@ -1651,6 +1654,9 @@ int main
case '#':
flag_not |= FLAG_NUM_USER;
break;
+ case 'W':
+ flag_wid++;
+ break;
case 'N':
flag_not |= FLAG_SYM;
break;
--
1.5.5
-- System Information:
Debian Release: lenny/sid
APT prefers unstable
APT policy: (990, 'unstable')
Architecture: i386 (i686)
Kernel: Linux 2.6.24.4 (SMP w/2 CPU cores; PREEMPT)
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Shell: /bin/sh linked to /bin/bash
Versions of packages net-tools depends on:
ii libc6 2.7-8 GNU C Library: Shared libraries
net-tools recommends no packages.
-- no debconf information
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]