summaryrefslogtreecommitdiff
blob: 756d638f1343c0d64cb8f4c65e2b74b81859a1f0 (plain)
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
From 2eed7d25830422bf6d61c48f911111acb56e5b06 Mon Sep 17 00:00:00 2001
From: Mike Frysinger <vapier@gentoo.org>
Date: Sat, 19 Apr 2008 03:07:09 -0400
Subject: [PATCH] revert 621a2f376334f8097604b9fee5783e0f1141e66d for ifconfig output format

---
 lib/interface.c |  293 +++++++++++++++++++++++++-----------------------------
 1 files changed, 136 insertions(+), 157 deletions(-)

diff --git a/lib/interface.c b/lib/interface.c
index be7017e..368e677 100644
--- a/lib/interface.c
+++ b/lib/interface.c
@@ -101,7 +101,6 @@ static struct interface *if_cache_add(char *name)
     if (!int_list)
     	int_last = NULL;
 
-    /* the cache is sorted, so if we hit a smaller if, exit */
     for (ife = int_last; ife; ife = ife->prev) {
 	    int n = nstrcmp(ife->name, name); 
 	    if (n == 0) 
@@ -111,7 +110,7 @@ static struct interface *if_cache_add(char *name)
     }
     new(new); 
     safe_strncpy(new->name, name, IFNAMSIZ); 
-    nextp = ife ? &ife->next : &int_list; // keep sorting
+    nextp = ife ? &ife->next : &int_list;
     new->prev = ife;
     new->next = *nextp; 
     if (new->next) 
@@ -686,70 +685,32 @@ void ife_print_long(struct interface *ptr)
     if (hw == NULL)
 	hw = get_hwntype(-1);
 
-    sprintf(flags, "flags=%d<", ptr->flags);
-    /* DONT FORGET TO ADD THE FLAGS IN ife_print_short, too */
-    if (ptr->flags == 0)
-	strcat(flags,">");
-    if (ptr->flags & IFF_UP)
-	strcat(flags,_("UP,"));
-    if (ptr->flags & IFF_BROADCAST)
-	strcat(flags,_("BROADCAST,"));
-    if (ptr->flags & IFF_DEBUG)
-	strcat(flags,_("DEBUG,"));
-    if (ptr->flags & IFF_LOOPBACK)
-	strcat(flags,_("LOOPBACK,"));
-    if (ptr->flags & IFF_POINTOPOINT)
-	strcat(flags,_("POINTOPOINT,"));
-    if (ptr->flags & IFF_NOTRAILERS)
-	strcat(flags,_("NOTRAILERS,"));
-    if (ptr->flags & IFF_RUNNING)
-	strcat(flags,_("RUNNING,"));
-    if (ptr->flags & IFF_NOARP)
-	strcat(flags,_("NOARP,"));
-    if (ptr->flags & IFF_PROMISC)
-	strcat(flags,_("PROMISC,"));
-    if (ptr->flags & IFF_ALLMULTI)
-	strcat(flags,_("ALLMULTI,"));
-    if (ptr->flags & IFF_SLAVE)
-	strcat(flags,_("SLAVE,"));
-    if (ptr->flags & IFF_MASTER)
-	strcat(flags,_("MASTER,"));
-    if (ptr->flags & IFF_MULTICAST)
-	strcat(flags,_("MULTICAST,"));
-#ifdef HAVE_DYNAMIC
-    if (ptr->flags & IFF_DYNAMIC)
-	strcat(flags,_("DYNAMIC,"));
-#endif
-    /* DONT FORGET TO ADD THE FLAGS IN ife_print_short */
-    if (flags[strlen(flags)-1] == ',')
-      flags[strlen(flags)-1] = '>';
-    else
-      flags[strlen(flags)-1] = 0;
-      
-
-    printf(_("%s: %s  mtu %d  metric %d"),
-	   ptr->name, flags, ptr->mtu, ptr->metric ? ptr->metric : 1);
-#ifdef SIOCSKEEPALIVE
-    if (ptr->outfill || ptr->keepalive)
-	printf(_("  outfill %d  keepalive %d"),
-	       ptr->outfill, ptr->keepalive);
+    printf(_("%-9.9s Link encap:%s  "), ptr->name, hw->title);
+    /* For some hardware types (eg Ash, ATM) we don't print the 
+       hardware address if it's null.  */
+    if (hw->print != NULL && (! (hw_null_address(hw, ptr->hwaddr) &&
+				  hw->suppress_null_addr)))
+	printf(_("HWaddr %s  "), hw->print(ptr->hwaddr));
+#ifdef IFF_PORTSEL
+    if (ptr->flags & IFF_PORTSEL) {
+	printf(_("Media:%s"), if_port_text[ptr->map.port][0]);
+	if (ptr->flags & IFF_AUTOMEDIA)
+	    printf(_("(auto)"));
+    }
 #endif
     printf("\n");
 
-
-
 #if HAVE_AFINET
     if (ptr->has_ip) {
-	printf(_("        %s %s"), ap->name,
+	printf(_("          %s addr:%s "), ap->name,
 	       ap->sprint(&ptr->addr, 1));
-	printf(_("  netmask %s"), ap->sprint(&ptr->netmask, 1));
-	if (ptr->flags & IFF_BROADCAST) {
-	    printf(_("  broadcast %s"), ap->sprint(&ptr->broadaddr, 1));
-	}
 	if (ptr->flags & IFF_POINTOPOINT) {
-	    printf(_("  destination %s"), ap->sprint(&ptr->dstaddr, 1));
+	    printf(_(" P-t-P:%s "), ap->sprint(&ptr->dstaddr, 1));
 	}
-	printf("\n");
+	if (ptr->flags & IFF_BROADCAST) {
+	    printf(_(" Bcast:%s "), ap->sprint(&ptr->broadaddr, 1));
+	}
+	printf(_(" Mask:%s\n"), ap->sprint(&ptr->netmask, 1));
     }
 #endif
 
@@ -766,30 +727,29 @@ void ife_print_long(struct interface *ptr)
 			addr6p[0], addr6p[1], addr6p[2], addr6p[3],
 			addr6p[4], addr6p[5], addr6p[6], addr6p[7]);
 		inet6_aftype.input(1, addr6, (struct sockaddr *) &sap);
-		printf(_("        %s %s  prefixlen %d"),
-			inet6_aftype.name, 
-			inet6_aftype.sprint((struct sockaddr *) &sap, 1), 
-			plen);
-		printf(_("  scopeid 0x%x"), scope);
-
-		flags[0] = '<'; flags[1] = 0;
-		if (scope & IPV6_ADDR_COMPATv4) {
-		    	strcat(flags, _("compat,"));
-		    	scope -= IPV6_ADDR_COMPATv4;
+		printf(_("          inet6 addr: %s/%d"),
+		 inet6_aftype.sprint((struct sockaddr *) &sap, 1), plen);
+		printf(_(" Scope:"));
+		switch (scope) {
+		case 0:
+		    printf(_("Global"));
+		    break;
+		case IPV6_ADDR_LINKLOCAL:
+		    printf(_("Link"));
+		    break;
+		case IPV6_ADDR_SITELOCAL:
+		    printf(_("Site"));
+		    break;
+		case IPV6_ADDR_COMPATv4:
+		    printf(_("Compat"));
+		    break;
+		case IPV6_ADDR_LOOPBACK:
+		    printf(_("Host"));
+		    break;
+		default:
+		    printf(_("Unknown"));
 		}
-		if (scope == 0)
-			strcat(flags, _("global,"));
-		if (scope & IPV6_ADDR_LINKLOCAL)
-			strcat(flags, _("link,"));
-		if (scope & IPV6_ADDR_SITELOCAL)
-			strcat(flags, _("site,"));
-		if (scope & IPV6_ADDR_LOOPBACK)
-			strcat(flags, _("host,"));
-		if (flags[strlen(flags)-1] == ',')
-			flags[strlen(flags)-1] = '>';
-		else
-			flags[strlen(flags)-1] = 0;
-		printf("%s\n", flags);
+		printf("\n");
 	    }
 	}
 	fclose(f);
@@ -802,17 +762,17 @@ void ife_print_long(struct interface *ptr)
 
     if (ipxtype != NULL) {
 	if (ptr->has_ipx_bb)
-	    printf(_("        %s Ethernet-II   %s\n"),
-		   ipxtype->name, ipxtype->sprint(&ptr->ipxaddr_bb, 1));
+	    printf(_("          IPX/Ethernet II addr:%s\n"),
+		   ipxtype->sprint(&ptr->ipxaddr_bb, 1));
 	if (ptr->has_ipx_sn)
-	    printf(_("        %s Ethernet-SNAP %s\n"),
-		   ipxtype->name, ipxtype->sprint(&ptr->ipxaddr_sn, 1));
+	    printf(_("          IPX/Ethernet SNAP addr:%s\n"),
+		   ipxtype->sprint(&ptr->ipxaddr_sn, 1));
 	if (ptr->has_ipx_e2)
-	    printf(_("        %s Ethernet802.2 %s\n"),
-		   ipxtype->name, ipxtype->sprint(&ptr->ipxaddr_e2, 1));
+	    printf(_("          IPX/Ethernet 802.2 addr:%s\n"),
+		   ipxtype->sprint(&ptr->ipxaddr_e2, 1));
 	if (ptr->has_ipx_e3)
-	    printf(_("        %s Ethernet802.3 %s\n"),
-		   ipxtype->name, ipxtype->sprint(&ptr->ipxaddr_e3, 1));
+	    printf(_("          IPX/Ethernet 802.3 addr:%s\n"),
+		   ipxtype->sprint(&ptr->ipxaddr_e3, 1));
     }
 #endif
 
@@ -821,7 +781,7 @@ void ife_print_long(struct interface *ptr)
 	ddptype = get_afntype(AF_APPLETALK);
     if (ddptype != NULL) {
 	if (ptr->has_ddp)
-	    printf(_("        %s %s\n"), ddptype->name, ddptype->sprint(&ptr->ddpaddr, 1));
+	    printf(_("          EtherTalk Phase 2 addr:%s\n"), ddptype->sprint(&ptr->ddpaddr, 1));
     }
 #endif
 
@@ -830,30 +790,53 @@ void ife_print_long(struct interface *ptr)
 	ectype = get_afntype(AF_ECONET);
     if (ectype != NULL) {
 	if (ptr->has_econet)
-	    printf(_("        %s %s\n"), ectype->name, ectype->sprint(&ptr->ecaddr, 1));
+	    printf(_("          econet addr:%s\n"), ectype->sprint(&ptr->ecaddr, 1));
     }
 #endif
 
-    /* For some hardware types (eg Ash, ATM) we don't print the 
-       hardware address if it's null.  */
-    if (hw->print != NULL && (! (hw_null_address(hw, ptr->hwaddr) &&
-				  hw->suppress_null_addr)))
-	printf(_("        %s %s"), hw->name, hw->print(ptr->hwaddr));
-    else
-	printf(_("        %s"), hw->name);
-    if (ptr->tx_queue_len != -1)
-    	printf(_("  txqueuelen %d"), ptr->tx_queue_len);
-    printf("  (%s)\n", hw->title);
-
-#ifdef IFF_PORTSEL
-    if (ptr->flags & IFF_PORTSEL) {
-	printf(_("        media %s"), if_port_text[ptr->map.port][0]);
-	if (ptr->flags & IFF_AUTOMEDIA)
-	    printf(_("autoselect"));
-    	printf("\n");
-    }
+    printf("          ");
+    /* DONT FORGET TO ADD THE FLAGS IN ife_print_short, too */
+    if (ptr->flags == 0)
+	printf(_("[NO FLAGS] "));
+    if (ptr->flags & IFF_UP)
+	printf(_("UP "));
+    if (ptr->flags & IFF_BROADCAST)
+	printf(_("BROADCAST "));
+    if (ptr->flags & IFF_DEBUG)
+	printf(_("DEBUG "));
+    if (ptr->flags & IFF_LOOPBACK)
+	printf(_("LOOPBACK "));
+    if (ptr->flags & IFF_POINTOPOINT)
+	printf(_("POINTOPOINT "));
+    if (ptr->flags & IFF_NOTRAILERS)
+	printf(_("NOTRAILERS "));
+    if (ptr->flags & IFF_RUNNING)
+	printf(_("RUNNING "));
+    if (ptr->flags & IFF_NOARP)
+	printf(_("NOARP "));
+    if (ptr->flags & IFF_PROMISC)
+	printf(_("PROMISC "));
+    if (ptr->flags & IFF_ALLMULTI)
+	printf(_("ALLMULTI "));
+    if (ptr->flags & IFF_SLAVE)
+	printf(_("SLAVE "));
+    if (ptr->flags & IFF_MASTER)
+	printf(_("MASTER "));
+    if (ptr->flags & IFF_MULTICAST)
+	printf(_("MULTICAST "));
+#ifdef HAVE_DYNAMIC
+    if (ptr->flags & IFF_DYNAMIC)
+	printf(_("DYNAMIC "));
 #endif
-
+    /* DONT FORGET TO ADD THE FLAGS IN ife_print_short */
+    printf(_(" MTU:%d  Metric:%d"),
+	   ptr->mtu, ptr->metric ? ptr->metric : 1);
+#ifdef SIOCSKEEPALIVE
+    if (ptr->outfill || ptr->keepalive)
+	printf(_("  Outfill:%d  Keepalive:%d"),
+	       ptr->outfill, ptr->keepalive);
+#endif
+    printf("\n");
 
     /* If needed, display the interface statistics. */
 
@@ -862,16 +845,27 @@ void ife_print_long(struct interface *ptr)
 	 *      not for the aliases, although strictly speaking they're shared
 	 *      by all addresses.
 	 */
+	printf("          ");
+
+	printf(_("RX packets:%llu errors:%lu dropped:%lu overruns:%lu frame:%lu\n"),
+	       ptr->stats.rx_packets, ptr->stats.rx_errors,
+	       ptr->stats.rx_dropped, ptr->stats.rx_fifo_errors,
+	       ptr->stats.rx_frame_errors);
+	if (can_compress)
+	    printf(_("             compressed:%lu\n"), ptr->stats.rx_compressed);
+
 	rx = ptr->stats.rx_bytes;  
+	tx = ptr->stats.tx_bytes;
 	short_rx = rx * 10;  
-	if (rx > 1125899906842624ull) {
-	    short_rx /= 1125899906842624ull;
+	short_tx = tx * 10;
+	if (rx > 1125899906842624) {
+	    short_rx /= 1125899906842624;
 	    Rext = "PiB";
-	} else if (rx > 1099511627776ull) {
-	    short_rx /= 1099511627776ull;
+	} else if (rx > 1099511627776) {
+	    short_rx /= 1099511627776;
 	    Rext = "TiB";
-	} else if (rx > 1073741824ull) {
-	    short_rx /= 1073741824ull;
+	} else if (rx > 1073741824) {
+	    short_rx /= 1073741824;
 	    Rext = "GiB";
 	} else if (rx > 1048576) {
 	    short_rx /= 1048576;
@@ -880,16 +874,14 @@ void ife_print_long(struct interface *ptr)
 	    short_rx /= 1024;
 	    Rext = "KiB";
 	}
-	tx = ptr->stats.tx_bytes;
-	short_tx = tx * 10;
-	if (tx > 1125899906842624ull) {
-	    short_tx /= 1125899906842624ull;
+	if (tx > 1125899906842624) {
+	    short_tx /= 1125899906842624;
 	    Text = "PiB";
-	} else 	if (tx > 1099511627776ull) {
-	    short_tx /= 1099511627776ull;
+	} else 	if (tx > 1099511627776) {
+	    short_tx /= 1099511627776;
 	    Text = "TiB";
-	} else if (tx > 1073741824ull) {
-	    short_tx /= 1073741824ull;
+	} else if (tx > 1073741824) {
+	    short_tx /= 1073741824;
 	    Text = "GiB";
 	} else if (tx > 1048576) {
 	    short_tx /= 1048576;
@@ -899,50 +891,37 @@ void ife_print_long(struct interface *ptr)
 	    Text = "KiB";
 	}
 
-	printf("        ");
-	printf(_("RX packets %llu  bytes %llu (%lu.%lu %s)\n"), 
-		ptr->stats.rx_packets, 
-	       rx, (unsigned long)(short_rx / 10), 
-	       (unsigned long)(short_rx % 10), Rext);
-	if (can_compress) {
-  	    printf("        ");
-	    printf(_("RX compressed:%lu\n"), ptr->stats.rx_compressed);
-	}
-	printf("        ");
-	printf(_("RX errors %lu  dropped %lu  overruns %lu  frame %lu\n"),
-	       ptr->stats.rx_errors, ptr->stats.rx_dropped, 
-	       ptr->stats.rx_fifo_errors, ptr->stats.rx_frame_errors);
-
-
-	printf("        ");
-	printf(_("TX packets %llu  bytes %llu (%lu.%lu %s)\n"),
-		ptr->stats.tx_packets, 
-	        tx, (unsigned long)(short_tx / 10), 
-	        (unsigned long)(short_tx % 10), Text);
-	if (can_compress) {
-  	    printf("        ");
-	    printf(_("TX compressed %lu\n"), ptr->stats.tx_compressed);
-	}
-	printf("        ");
-	printf(_("TX errors %lu  dropped %lu overruns %lu  carrier %lu  collisions %lu\n"),
-	       ptr->stats.tx_errors,
+	printf("          ");
+	printf(_("TX packets:%llu errors:%lu dropped:%lu overruns:%lu carrier:%lu\n"),
+	       ptr->stats.tx_packets, ptr->stats.tx_errors,
 	       ptr->stats.tx_dropped, ptr->stats.tx_fifo_errors,
-	       ptr->stats.tx_carrier_errors, ptr->stats.collisions);
+	       ptr->stats.tx_carrier_errors);
+	printf(_("          collisions:%lu "), ptr->stats.collisions);
+	if (can_compress)
+	    printf(_("compressed:%lu "), ptr->stats.tx_compressed);
+	if (ptr->tx_queue_len != -1)
+	    printf(_("txqueuelen:%d "), ptr->tx_queue_len);
+	printf("\n          ");
+	printf(_("RX bytes:%llu (%lu.%lu %s)  TX bytes:%llu (%lu.%lu %s)\n"),
+	       rx, (unsigned long)(short_rx / 10), 
+	       (unsigned long)(short_rx % 10), Rext, 
+	       tx, (unsigned long)(short_tx / 10), 
+	       (unsigned long)(short_tx % 10), Text);
     }
 
     if ((ptr->map.irq || ptr->map.mem_start || ptr->map.dma ||
 	 ptr->map.base_addr >= 0x100)) {
-	printf("        device ");
+	printf("          ");
 	if (ptr->map.irq)
-	    printf(_("interrupt %d  "), ptr->map.irq);
+	    printf(_("Interrupt:%d "), ptr->map.irq);
 	if (ptr->map.base_addr >= 0x100)	/* Only print devices using it for 
 						   I/O maps */
-	    printf(_("base 0x%x  "), ptr->map.base_addr);
+	    printf(_("Base address:0x%x "), ptr->map.base_addr);
 	if (ptr->map.mem_start) {
-	    printf(_("memory 0x%lx-%lx  "), ptr->map.mem_start, ptr->map.mem_end);
+	    printf(_("Memory:%lx-%lx "), ptr->map.mem_start, ptr->map.mem_end);
 	}
 	if (ptr->map.dma)
-	    printf(_("  dma 0x%x"), ptr->map.dma);
+	    printf(_("DMA chan:%x "), ptr->map.dma);
 	printf("\n");
     }
     printf("\n");
-- 
1.5.5.3