blob: 523d434b7c0b0995d8bbd62ec5ac1c6b84a268e5 [file] [log] [blame]
Andrew Geisslerd25ed322020-06-27 00:28:28 -05001From eb04ef31571f6c707eacaba6846feeebfab518e6 Mon Sep 17 00:00:00 2001
2From: Bernd Eckenfels <net-tools@lina.inka.de>
3Date: Thu, 29 May 2003 02:09:14 +0000
4Subject: [PATCH] added 'ull' prefix to unsigned long long constants to make
5 gcc 3.3 happy
6
7Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
8Upstream-Status: Backport [https://sourceforge.net/p/net-tools/code/ci/eb04ef31571f6c707eacaba6846feeebfab518e6]
9---
10 lib/interface.c | 299 ++++++++++++++++++++++++++----------------------
11 1 file changed, 161 insertions(+), 138 deletions(-)
12
13diff -uNr net-tools-1.60.orig/lib/interface.c net-tools-1.60/lib/interface.c
14--- net-tools-1.60.orig/lib/interface.c 2020-06-16 10:04:16.308411879 +0000
15+++ net-tools-1.60/lib/interface.c 2020-06-16 10:05:15.697264291 +0000
16@@ -23,7 +23,6 @@
17 #include <string.h>
18 #include <unistd.h>
19 #include <ctype.h>
20-#include <string.h>
21
22 #if HAVE_AFIPX
23 #if (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1)
24@@ -654,6 +653,8 @@
25 const char *Rext = "B";
26 const char *Text = "B";
27
28+ static char flags[200];
29+
30 #if HAVE_AFIPX
31 static struct aftype *ipxtype = NULL;
32 #endif
33@@ -685,32 +686,68 @@
34 if (hw == NULL)
35 hw = get_hwntype(-1);
36
37- printf(_("%-9s Link encap:%s "), ptr->name, hw->title);
38- /* For some hardware types (eg Ash, ATM) we don't print the
39- hardware address if it's null. */
40- if (hw->print != NULL && (! (hw_null_address(hw, ptr->hwaddr) &&
41- hw->suppress_null_addr)))
42- printf(_("HWaddr %s "), hw->print(ptr->hwaddr));
43-#ifdef IFF_PORTSEL
44- if (ptr->flags & IFF_PORTSEL) {
45- printf(_("Media:%s"), if_port_text[ptr->map.port][0]);
46- if (ptr->flags & IFF_AUTOMEDIA)
47- printf(_("(auto)"));
48- }
49+ sprintf(flags, "flags=%d<", ptr->flags);
50+ /* DONT FORGET TO ADD THE FLAGS IN ife_print_short, too */
51+ if (ptr->flags == 0)
52+ strcat(flags,">");
53+ if (ptr->flags & IFF_UP)
54+ strcat(flags,_("UP,"));
55+ if (ptr->flags & IFF_BROADCAST)
56+ strcat(flags,_("BROADCAST,"));
57+ if (ptr->flags & IFF_DEBUG)
58+ strcat(flags,_("DEBUG,"));
59+ if (ptr->flags & IFF_LOOPBACK)
60+ strcat(flags,_("LOOPBACK,"));
61+ if (ptr->flags & IFF_POINTOPOINT)
62+ strcat(flags,_("POINTOPOINT,"));
63+ if (ptr->flags & IFF_NOTRAILERS)
64+ strcat(flags,_("NOTRAILERS,"));
65+ if (ptr->flags & IFF_RUNNING)
66+ strcat(flags,_("RUNNING,"));
67+ if (ptr->flags & IFF_NOARP)
68+ strcat(flags,_("NOARP,"));
69+ if (ptr->flags & IFF_PROMISC)
70+ strcat(flags,_("PROMISC,"));
71+ if (ptr->flags & IFF_ALLMULTI)
72+ strcat(flags,_("ALLMULTI,"));
73+ if (ptr->flags & IFF_SLAVE)
74+ strcat(flags,_("SLAVE,"));
75+ if (ptr->flags & IFF_MASTER)
76+ strcat(flags,_("MASTER,"));
77+ if (ptr->flags & IFF_MULTICAST)
78+ strcat(flags,_("MULTICAST,"));
79+#ifdef HAVE_DYNAMIC
80+ if (ptr->flags & IFF_DYNAMIC)
81+ strcat(flags,_("DYNAMIC,"));
82+#endif
83+ /* DONT FORGET TO ADD THE FLAGS IN ife_print_short */
84+ if (flags[strlen(flags)-1] == ',')
85+ flags[strlen(flags)-1] = '>';
86+ else
87+ flags[strlen(flags)-1] = 0;
88+
89+
90+ printf(_("%s: %s mtu %d metric %d"),
91+ ptr->name, flags, ptr->mtu, ptr->metric ? ptr->metric : 1);
92+#ifdef SIOCSKEEPALIVE
93+ if (ptr->outfill || ptr->keepalive)
94+ printf(_(" outfill %d keepalive %d"),
95+ ptr->outfill, ptr->keepalive);
96 #endif
97 printf("\n");
98
99 #if HAVE_AFINET
100 if (ptr->has_ip) {
101- printf(_(" %s addr:%s "), ap->name,
102+ printf(_(" %s %s"), ap->name,
103 ap->sprint(&ptr->addr, 1));
104- if (ptr->flags & IFF_POINTOPOINT) {
105- printf(_(" P-t-P:%s "), ap->sprint(&ptr->dstaddr, 1));
106- }
107+ printf(_(" netmask %s"), ap->sprint(&ptr->netmask, 1));
108 if (ptr->flags & IFF_BROADCAST) {
109- printf(_(" Bcast:%s "), ap->sprint(&ptr->broadaddr, 1));
110+ printf(_(" broadcast %s"), ap->sprint(&ptr->broadaddr, 1));
111 }
112- printf(_(" Mask:%s\n"), ap->sprint(&ptr->netmask, 1));
113+ if (ptr->flags & IFF_POINTOPOINT) {
114+ printf(_(" destination %s"), ap->sprint(&ptr->dstaddr, 1));
115+ }
116+ printf("\n");
117 }
118 #endif
119
120@@ -727,29 +764,30 @@
121 addr6p[0], addr6p[1], addr6p[2], addr6p[3],
122 addr6p[4], addr6p[5], addr6p[6], addr6p[7]);
123 inet6_aftype.input(1, addr6, (struct sockaddr *) &sap);
124- printf(_(" inet6 addr: %s/%d"),
125- inet6_aftype.sprint((struct sockaddr *) &sap, 1), plen);
126- printf(_(" Scope:"));
127- switch (scope) {
128- case 0:
129- printf(_("Global"));
130- break;
131- case IPV6_ADDR_LINKLOCAL:
132- printf(_("Link"));
133- break;
134- case IPV6_ADDR_SITELOCAL:
135- printf(_("Site"));
136- break;
137- case IPV6_ADDR_COMPATv4:
138- printf(_("Compat"));
139- break;
140- case IPV6_ADDR_LOOPBACK:
141- printf(_("Host"));
142- break;
143- default:
144- printf(_("Unknown"));
145+ printf(_(" %s %s prefixlen %d"),
146+ inet6_aftype.name,
147+ inet6_aftype.sprint((struct sockaddr *) &sap, 1),
148+ plen);
149+ printf(_(" scopeid 0x%x"), scope);
150+
151+ flags[0] = '<'; flags[1] = 0;
152+ if (scope & IPV6_ADDR_COMPATv4) {
153+ strcat(flags, _("compat,"));
154+ scope -= IPV6_ADDR_COMPATv4;
155 }
156- printf("\n");
157+ if (scope == 0)
158+ strcat(flags, _("global,"));
159+ if (scope & IPV6_ADDR_LINKLOCAL)
160+ strcat(flags, _("link,"));
161+ if (scope & IPV6_ADDR_SITELOCAL)
162+ strcat(flags, _("site,"));
163+ if (scope & IPV6_ADDR_LOOPBACK)
164+ strcat(flags, _("host,"));
165+ if (flags[strlen(flags)-1] == ',')
166+ flags[strlen(flags)-1] = '>';
167+ else
168+ flags[strlen(flags)-1] = 0;
169+ printf("%s\n", flags);
170 }
171 }
172 fclose(f);
173@@ -762,17 +800,17 @@
174
175 if (ipxtype != NULL) {
176 if (ptr->has_ipx_bb)
177- printf(_(" IPX/Ethernet II addr:%s\n"),
178- ipxtype->sprint(&ptr->ipxaddr_bb, 1));
179+ printf(_(" %s Ethernet-II %s\n"),
180+ ipxtype->name, ipxtype->sprint(&ptr->ipxaddr_bb, 1));
181 if (ptr->has_ipx_sn)
182- printf(_(" IPX/Ethernet SNAP addr:%s\n"),
183- ipxtype->sprint(&ptr->ipxaddr_sn, 1));
184+ printf(_(" %s Ethernet-SNAP %s\n"),
185+ ipxtype->name, ipxtype->sprint(&ptr->ipxaddr_sn, 1));
186 if (ptr->has_ipx_e2)
187- printf(_(" IPX/Ethernet 802.2 addr:%s\n"),
188- ipxtype->sprint(&ptr->ipxaddr_e2, 1));
189+ printf(_(" %s Ethernet802.2 %s\n"),
190+ ipxtype->name, ipxtype->sprint(&ptr->ipxaddr_e2, 1));
191 if (ptr->has_ipx_e3)
192- printf(_(" IPX/Ethernet 802.3 addr:%s\n"),
193- ipxtype->sprint(&ptr->ipxaddr_e3, 1));
194+ printf(_(" %s Ethernet802.3 %s\n"),
195+ ipxtype->name, ipxtype->sprint(&ptr->ipxaddr_e3, 1));
196 }
197 #endif
198
199@@ -781,7 +819,7 @@
200 ddptype = get_afntype(AF_APPLETALK);
201 if (ddptype != NULL) {
202 if (ptr->has_ddp)
203- printf(_(" EtherTalk Phase 2 addr:%s\n"), ddptype->sprint(&ptr->ddpaddr, 1));
204+ printf(_(" %s %s\n"), ddptype->name, ddptype->sprint(&ptr->ddpaddr, 1));
205 }
206 #endif
207
208@@ -790,53 +828,30 @@
209 ectype = get_afntype(AF_ECONET);
210 if (ectype != NULL) {
211 if (ptr->has_econet)
212- printf(_(" econet addr:%s\n"), ectype->sprint(&ptr->ecaddr, 1));
213+ printf(_(" %s %s\n"), ectype->name, ectype->sprint(&ptr->ecaddr, 1));
214 }
215 #endif
216
217- printf(" ");
218- /* DONT FORGET TO ADD THE FLAGS IN ife_print_short, too */
219- if (ptr->flags == 0)
220- printf(_("[NO FLAGS] "));
221- if (ptr->flags & IFF_UP)
222- printf(_("UP "));
223- if (ptr->flags & IFF_BROADCAST)
224- printf(_("BROADCAST "));
225- if (ptr->flags & IFF_DEBUG)
226- printf(_("DEBUG "));
227- if (ptr->flags & IFF_LOOPBACK)
228- printf(_("LOOPBACK "));
229- if (ptr->flags & IFF_POINTOPOINT)
230- printf(_("POINTOPOINT "));
231- if (ptr->flags & IFF_NOTRAILERS)
232- printf(_("NOTRAILERS "));
233- if (ptr->flags & IFF_RUNNING)
234- printf(_("RUNNING "));
235- if (ptr->flags & IFF_NOARP)
236- printf(_("NOARP "));
237- if (ptr->flags & IFF_PROMISC)
238- printf(_("PROMISC "));
239- if (ptr->flags & IFF_ALLMULTI)
240- printf(_("ALLMULTI "));
241- if (ptr->flags & IFF_SLAVE)
242- printf(_("SLAVE "));
243- if (ptr->flags & IFF_MASTER)
244- printf(_("MASTER "));
245- if (ptr->flags & IFF_MULTICAST)
246- printf(_("MULTICAST "));
247-#ifdef HAVE_DYNAMIC
248- if (ptr->flags & IFF_DYNAMIC)
249- printf(_("DYNAMIC "));
250-#endif
251- /* DONT FORGET TO ADD THE FLAGS IN ife_print_short */
252- printf(_(" MTU:%d Metric:%d"),
253- ptr->mtu, ptr->metric ? ptr->metric : 1);
254-#ifdef SIOCSKEEPALIVE
255- if (ptr->outfill || ptr->keepalive)
256- printf(_(" Outfill:%d Keepalive:%d"),
257- ptr->outfill, ptr->keepalive);
258+ /* For some hardware types (eg Ash, ATM) we don't print the
259+ hardware address if it's null. */
260+ if (hw->print != NULL && (! (hw_null_address(hw, ptr->hwaddr) &&
261+ hw->suppress_null_addr)))
262+ printf(_(" %s %s"), hw->name, hw->print(ptr->hwaddr));
263+ else
264+ printf(_(" %s"), hw->name);
265+ if (ptr->tx_queue_len != -1)
266+ printf(_(" txqueuelen %d"), ptr->tx_queue_len);
267+ printf(" (%s)\n", hw->title);
268+
269+#ifdef IFF_PORTSEL
270+ if (ptr->flags & IFF_PORTSEL) {
271+ printf(_(" media %s"), if_port_text[ptr->map.port][0]);
272+ if (ptr->flags & IFF_AUTOMEDIA)
273+ printf(_("autoselect"));
274+ printf("\n");
275+ }
276 #endif
277- printf("\n");
278+
279
280 /* If needed, display the interface statistics. */
281
282@@ -845,19 +860,9 @@
283 * not for the aliases, although strictly speaking they're shared
284 * by all addresses.
285 */
286- printf(" ");
287-
288- printf(_("RX packets:%llu errors:%lu dropped:%lu overruns:%lu frame:%lu\n"),
289- ptr->stats.rx_packets, ptr->stats.rx_errors,
290- ptr->stats.rx_dropped, ptr->stats.rx_fifo_errors,
291- ptr->stats.rx_frame_errors);
292- if (can_compress)
293- printf(_(" compressed:%lu\n"), ptr->stats.rx_compressed);
294
295 rx = ptr->stats.rx_bytes;
296- tx = ptr->stats.tx_bytes;
297 short_rx = rx * 10;
298- short_tx = tx * 10;
299 if (rx > 1125899906842624ull) {
300 short_rx /= 1125899906842624ull;
301 Rext = "PiB";
302@@ -874,6 +879,8 @@
303 short_rx /= 1024;
304 Rext = "KiB";
305 }
306+ tx = ptr->stats.tx_bytes;
307+ short_tx = tx * 10;
308 if (tx > 1125899906842624ull) {
309 short_tx /= 1125899906842624ull;
310 Text = "PiB";
311@@ -891,37 +898,50 @@
312 Text = "KiB";
313 }
314
315- printf(" ");
316- printf(_("TX packets:%llu errors:%lu dropped:%lu overruns:%lu carrier:%lu\n"),
317- ptr->stats.tx_packets, ptr->stats.tx_errors,
318- ptr->stats.tx_dropped, ptr->stats.tx_fifo_errors,
319- ptr->stats.tx_carrier_errors);
320- printf(_(" collisions:%lu "), ptr->stats.collisions);
321- if (can_compress)
322- printf(_("compressed:%lu "), ptr->stats.tx_compressed);
323- if (ptr->tx_queue_len != -1)
324- printf(_("txqueuelen:%d "), ptr->tx_queue_len);
325- printf("\n ");
326- printf(_("RX bytes:%llu (%lu.%lu %s) TX bytes:%llu (%lu.%lu %s)\n"),
327+ printf(" ");
328+ printf(_("RX packets %llu bytes %llu (%lu.%lu %s)\n"),
329+ ptr->stats.rx_packets,
330 rx, (unsigned long)(short_rx / 10),
331- (unsigned long)(short_rx % 10), Rext,
332- tx, (unsigned long)(short_tx / 10),
333- (unsigned long)(short_tx % 10), Text);
334+ (unsigned long)(short_rx % 10), Rext);
335+ if (can_compress) {
336+ printf(" ");
337+ printf(_("RX compressed:%lu\n"), ptr->stats.rx_compressed);
338+ }
339+ printf(" ");
340+ printf(_("RX errors %lu dropped %lu overruns %lu frame %lu\n"),
341+ ptr->stats.rx_errors, ptr->stats.rx_dropped,
342+ ptr->stats.rx_fifo_errors, ptr->stats.rx_frame_errors);
343+
344+
345+ printf(" ");
346+ printf(_("TX packets %llu bytes %llu (%lu.%lu %s)\n"),
347+ ptr->stats.tx_packets,
348+ tx, (unsigned long)(short_tx / 10),
349+ (unsigned long)(short_tx % 10), Text);
350+ if (can_compress) {
351+ printf(" ");
352+ printf(_("TX compressed %lu\n"), ptr->stats.tx_compressed);
353+ }
354+ printf(" ");
355+ printf(_("TX errors %lu dropped %lu overruns %lu carrier %lu collisions %lu\n"),
356+ ptr->stats.tx_errors,
357+ ptr->stats.tx_dropped, ptr->stats.tx_fifo_errors,
358+ ptr->stats.tx_carrier_errors, ptr->stats.collisions);
359 }
360
361 if ((ptr->map.irq || ptr->map.mem_start || ptr->map.dma ||
362 ptr->map.base_addr >= 0x100)) {
363- printf(" ");
364+ printf(" device ");
365 if (ptr->map.irq)
366- printf(_("Interrupt:%d "), ptr->map.irq);
367+ printf(_("interrupt %d "), ptr->map.irq);
368 if (ptr->map.base_addr >= 0x100) /* Only print devices using it for
369 I/O maps */
370- printf(_("Base address:0x%x "), ptr->map.base_addr);
371+ printf(_("base 0x%x "), ptr->map.base_addr);
372 if (ptr->map.mem_start) {
373- printf(_("Memory:%lx-%lx "), ptr->map.mem_start, ptr->map.mem_end);
374+ printf(_("memory 0x%lx-%lx "), ptr->map.mem_start, ptr->map.mem_end);
375 }
376 if (ptr->map.dma)
377- printf(_("DMA chan:%x "), ptr->map.dma);
378+ printf(_(" dma 0x%x"), ptr->map.dma);
379 printf("\n");
380 }
381 printf("\n");