1 From eb04ef31571f6c707eacaba6846feeebfab518e6 Mon Sep 17 00:00:00 2001
2 From: Bernd Eckenfels <net-tools@lina.inka.de>
3 Date: Thu, 29 May 2003 02:09:14 +0000
4 Subject: [PATCH] added 'ull' prefix to unsigned long long constants to make
7 Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
8 Upstream-Status: Backport [https://sourceforge.net/p/net-tools/code/ci/eb04ef31571f6c707eacaba6846feeebfab518e6]
10 lib/interface.c | 299 ++++++++++++++++++++++++++----------------------
11 1 file changed, 161 insertions(+), 138 deletions(-)
13 diff -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
23 #if (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1)
25 const char *Rext = "B";
26 const char *Text = "B";
28 + static char flags[200];
31 static struct aftype *ipxtype = NULL;
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));
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)"));
49 + sprintf(flags, "flags=%d<", ptr->flags);
50 + /* DONT FORGET TO ADD THE FLAGS IN ife_print_short, too */
51 + if (ptr->flags == 0)
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,"));
80 + if (ptr->flags & IFF_DYNAMIC)
81 + strcat(flags,_("DYNAMIC,"));
83 + /* DONT FORGET TO ADD THE FLAGS IN ife_print_short */
84 + if (flags[strlen(flags)-1] == ',')
85 + flags[strlen(flags)-1] = '>';
87 + flags[strlen(flags)-1] = 0;
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);
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));
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));
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));
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:"));
129 - printf(_("Global"));
131 - case IPV6_ADDR_LINKLOCAL:
134 - case IPV6_ADDR_SITELOCAL:
137 - case IPV6_ADDR_COMPATv4:
138 - printf(_("Compat"));
140 - case IPV6_ADDR_LOOPBACK:
144 - printf(_("Unknown"));
145 + printf(_(" %s %s prefixlen %d"),
147 + inet6_aftype.sprint((struct sockaddr *) &sap, 1),
149 + printf(_(" scopeid 0x%x"), scope);
151 + flags[0] = '<'; flags[1] = 0;
152 + if (scope & IPV6_ADDR_COMPATv4) {
153 + strcat(flags, _("compat,"));
154 + scope -= IPV6_ADDR_COMPATv4;
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] = '>';
168 + flags[strlen(flags)-1] = 0;
169 + printf("%s\n", flags);
173 @@ -762,17 +800,17 @@
175 if (ipxtype != NULL) {
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));
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));
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));
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));
200 ddptype = get_afntype(AF_APPLETALK);
201 if (ddptype != NULL) {
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));
208 @@ -790,53 +828,30 @@
209 ectype = get_afntype(AF_ECONET);
210 if (ectype != NULL) {
212 - printf(_(" econet addr:%s\n"), ectype->sprint(&ptr->ecaddr, 1));
213 + printf(_(" %s %s\n"), ectype->name, ectype->sprint(&ptr->ecaddr, 1));
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)
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 "));
248 - if (ptr->flags & IFF_DYNAMIC)
249 - printf(_("DYNAMIC "));
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));
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);
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"));
280 /* If needed, display the interface statistics. */
283 * not for the aliases, although strictly speaking they're shared
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);
293 - printf(_(" compressed:%lu\n"), ptr->stats.rx_compressed);
295 rx = ptr->stats.rx_bytes;
296 - tx = ptr->stats.tx_bytes;
298 - short_tx = tx * 10;
299 if (rx > 1125899906842624ull) {
300 short_rx /= 1125899906842624ull;
306 + tx = ptr->stats.tx_bytes;
307 + short_tx = tx * 10;
308 if (tx > 1125899906842624ull) {
309 short_tx /= 1125899906842624ull;
311 @@ -891,37 +898,50 @@
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);
322 - printf(_("compressed:%lu "), ptr->stats.tx_compressed);
323 - if (ptr->tx_queue_len != -1)
324 - printf(_("txqueuelen:%d "), ptr->tx_queue_len);
326 - printf(_("RX bytes:%llu (%lu.%lu %s) TX bytes:%llu (%lu.%lu %s)\n"),
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) {
337 + printf(_("RX compressed:%lu\n"), ptr->stats.rx_compressed);
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);
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) {
352 + printf(_("TX compressed %lu\n"), ptr->stats.tx_compressed);
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);
361 if ((ptr->map.irq || ptr->map.mem_start || ptr->map.dma ||
362 ptr->map.base_addr >= 0x100)) {
364 + printf(" device ");
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
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);
377 - printf(_("DMA chan:%x "), ptr->map.dma);
378 + printf(_(" dma 0x%x"), ptr->map.dma);