1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
comabug@gmail.com writes:
net-tools' netstat should have a -W flag like FreeBSD.
There is currently no way to get the full hostname from netstat
for local/remote hostnames.
http://bugs.gentoo.org/show_bug.cgi?id=53731
diff -ru net-tools-1.60.orig/man/en_US/netstat.8 net-tools-1.60/man/en_US/netstat.8
--- net-tools-1.60.orig/man/en_US/netstat.8 2001-01-07 13:43:57.000000000 +0100
+++ net-tools-1.60/man/en_US/netstat.8 2004-06-12 19:30:55.566822928 +0200
@@ -24,6 +24,7 @@
.RB [ \-\-all | \-a ]
.RB [ \-\-numeric | \-n ]
.RB [ \-\-numeric-hosts ] [ \-\-numeric-ports ] [ \-\-numeric-ports ]
+.RB [ \-\-wide | \-W]
.RB [ \-\-symbolic | \-N ]
.RB [ \-\-extend | \-e [ \-\-extend | \-e] ]
.RB [ \-\-timers | \-o ]
@@ -55,6 +56,7 @@
.RB { \-\-groups | \-g }
.RB [ \-\-numeric | \-n ]
.RB [ \-\-numeric-hosts ] [ \-\-numeric-ports ] [ \-\-numeric-ports ]
+.RB [ \-\-wide | \-W]
.RB [ \-\-continuous | \-c]
.P
.B netstat
@@ -124,6 +126,8 @@
.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 -ru net-tools-1.60.orig/netstat.c net-tools-1.60/netstat.c
--- net-tools-1.60.orig/netstat.c 2001-04-15 16:41:17.000000000 +0200
+++ net-tools-1.60/netstat.c 2004-06-12 19:50:23.459276288 +0200
@@ -149,6 +149,7 @@
int flag_prg = 0;
int flag_arg = 0;
int flag_ver = 0;
+int flag_wid = 0;
FILE *procinfo;
@@ -772,7 +773,7 @@
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, ":");
@@ -780,7 +781,7 @@
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, ":");
@@ -922,7 +923,7 @@
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, ":");
strcat(local_addr, buffer);
@@ -931,7 +932,7 @@
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, ":");
strcat(rem_addr, buffer);
@@ -1041,7 +1042,7 @@
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, ":");
strcat(local_addr, buffer);
@@ -1050,7 +1051,7 @@
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, ":");
strcat(rem_addr, buffer);
@@ -1492,6 +1493,7 @@
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"));
@@ -1541,6 +1543,7 @@
{"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'},
@@ -1556,7 +1559,7 @@
getroute_init(); /* Set up AF routing support */
afname[0] = '\0';
- while ((i = getopt_long(argc, argv, "MCFA:acdegphinNorstuVv?wxl", longopts, &lop)) != EOF)
+ while ((i = getopt_long(argc, argv, "MCFA:acdegphinWNorstuVv?wxl", longopts, &lop)) != EOF)
switch (i) {
case -1:
break;
@@ -1612,6 +1615,9 @@
case '#':
flag_not |= FLAG_NUM_USER;
break;
+ case 'W':
+ flag_wid++;
+ break;
case 'N':
flag_not |= FLAG_SYM;
break;
|