Gentoo Archives: gentoo-commits

From: Mike Frysinger <vapier@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/net-tools:gentoo commit in: lib/
Date: Mon, 21 Nov 2011 01:38:56
Message-Id: 1735e2c711c1838757eb8732c6eccf11b38854ef.vapier@gentoo
1 commit: 1735e2c711c1838757eb8732c6eccf11b38854ef
2 Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
3 AuthorDate: Sat Apr 19 07:07:09 2008 +0000
4 Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org>
5 CommitDate: Mon Nov 21 01:38:29 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/net-tools.git;a=commit;h=1735e2c7
7
8 revert 621a2f376334f8097604b9fee5783e0f1141e66d for ifconfig output format to avoid breaking scripts
9
10 this isn't a complete revert, just the display portions
11
12 ---
13 lib/interface.c | 262 +++++++++++++++++++++++++-----------------------------
14 1 files changed, 121 insertions(+), 141 deletions(-)
15
16 diff --git a/lib/interface.c b/lib/interface.c
17 index 0e5e454..ead6a8d 100644
18 --- a/lib/interface.c
19 +++ b/lib/interface.c
20 @@ -691,70 +691,32 @@ void ife_print_long(struct interface *ptr)
21 if (hw == NULL)
22 hw = get_hwntype(-1);
23
24 - sprintf(flags, "flags=%d<", ptr->flags);
25 - /* DONT FORGET TO ADD THE FLAGS IN ife_print_short, too */
26 - if (ptr->flags == 0)
27 - strcat(flags,">");
28 - if (ptr->flags & IFF_UP)
29 - strcat(flags,_("UP,"));
30 - if (ptr->flags & IFF_BROADCAST)
31 - strcat(flags,_("BROADCAST,"));
32 - if (ptr->flags & IFF_DEBUG)
33 - strcat(flags,_("DEBUG,"));
34 - if (ptr->flags & IFF_LOOPBACK)
35 - strcat(flags,_("LOOPBACK,"));
36 - if (ptr->flags & IFF_POINTOPOINT)
37 - strcat(flags,_("POINTOPOINT,"));
38 - if (ptr->flags & IFF_NOTRAILERS)
39 - strcat(flags,_("NOTRAILERS,"));
40 - if (ptr->flags & IFF_RUNNING)
41 - strcat(flags,_("RUNNING,"));
42 - if (ptr->flags & IFF_NOARP)
43 - strcat(flags,_("NOARP,"));
44 - if (ptr->flags & IFF_PROMISC)
45 - strcat(flags,_("PROMISC,"));
46 - if (ptr->flags & IFF_ALLMULTI)
47 - strcat(flags,_("ALLMULTI,"));
48 - if (ptr->flags & IFF_SLAVE)
49 - strcat(flags,_("SLAVE,"));
50 - if (ptr->flags & IFF_MASTER)
51 - strcat(flags,_("MASTER,"));
52 - if (ptr->flags & IFF_MULTICAST)
53 - strcat(flags,_("MULTICAST,"));
54 -#ifdef HAVE_DYNAMIC
55 - if (ptr->flags & IFF_DYNAMIC)
56 - strcat(flags,_("DYNAMIC,"));
57 -#endif
58 - /* DONT FORGET TO ADD THE FLAGS IN ife_print_short */
59 - if (flags[strlen(flags)-1] == ',')
60 - flags[strlen(flags)-1] = '>';
61 - else
62 - flags[strlen(flags)-1] = 0;
63 -
64 -
65 - printf(_("%s: %s mtu %d metric %d"),
66 - ptr->name, flags, ptr->mtu, ptr->metric ? ptr->metric : 1);
67 -#ifdef SIOCSKEEPALIVE
68 - if (ptr->outfill || ptr->keepalive)
69 - printf(_(" outfill %d keepalive %d"),
70 - ptr->outfill, ptr->keepalive);
71 + printf(_("%-9.9s Link encap:%s "), ptr->name, hw->title);
72 + /* For some hardware types (eg Ash, ATM) we don't print the
73 + hardware address if it's null. */
74 + if (hw->print != NULL && (! (hw_null_address(hw, ptr->hwaddr) &&
75 + hw->suppress_null_addr)))
76 + printf(_("HWaddr %s "), hw->print(ptr->hwaddr));
77 +#ifdef IFF_PORTSEL
78 + if (ptr->flags & IFF_PORTSEL) {
79 + printf(_("Media:%s"), if_port_text[ptr->map.port][0]);
80 + if (ptr->flags & IFF_AUTOMEDIA)
81 + printf(_("(auto)"));
82 + }
83 #endif
84 printf("\n");
85
86 -
87 -
88 #if HAVE_AFINET
89 if (ptr->has_ip) {
90 - printf(_(" %s %s"), ap->name,
91 + printf(_(" %s addr:%s "), ap->name,
92 ap->sprint(&ptr->addr, 1));
93 - printf(_(" netmask %s"), ap->sprint(&ptr->netmask, 1));
94 - if (ptr->flags & IFF_BROADCAST) {
95 - printf(_(" broadcast %s"), ap->sprint(&ptr->broadaddr, 1));
96 - }
97 if (ptr->flags & IFF_POINTOPOINT) {
98 - printf(_(" destination %s"), ap->sprint(&ptr->dstaddr, 1));
99 + printf(_(" P-t-P:%s "), ap->sprint(&ptr->dstaddr, 1));
100 }
101 - printf("\n");
102 + if (ptr->flags & IFF_BROADCAST) {
103 + printf(_(" Bcast:%s "), ap->sprint(&ptr->broadaddr, 1));
104 + }
105 + printf(_(" Mask:%s\n"), ap->sprint(&ptr->netmask, 1));
106 }
107 #endif
108
109 @@ -771,30 +733,29 @@ void ife_print_long(struct interface *ptr)
110 addr6p[0], addr6p[1], addr6p[2], addr6p[3],
111 addr6p[4], addr6p[5], addr6p[6], addr6p[7]);
112 inet6_aftype.input(1, addr6, (struct sockaddr *) &sap);
113 - printf(_(" %s %s prefixlen %d"),
114 - inet6_aftype.name,
115 - inet6_aftype.sprint((struct sockaddr *) &sap, 1),
116 - plen);
117 - printf(_(" scopeid 0x%x"), scope);
118 -
119 - flags[0] = '<'; flags[1] = 0;
120 - if (scope & IPV6_ADDR_COMPATv4) {
121 - strcat(flags, _("compat,"));
122 - scope -= IPV6_ADDR_COMPATv4;
123 + printf(_(" inet6 addr: %s/%d"),
124 + inet6_aftype.sprint((struct sockaddr *) &sap, 1), plen);
125 + printf(_(" Scope:"));
126 + switch (scope) {
127 + case 0:
128 + printf(_("Global"));
129 + break;
130 + case IPV6_ADDR_LINKLOCAL:
131 + printf(_("Link"));
132 + break;
133 + case IPV6_ADDR_SITELOCAL:
134 + printf(_("Site"));
135 + break;
136 + case IPV6_ADDR_COMPATv4:
137 + printf(_("Compat"));
138 + break;
139 + case IPV6_ADDR_LOOPBACK:
140 + printf(_("Host"));
141 + break;
142 + default:
143 + printf(_("Unknown"));
144 }
145 - if (scope == 0)
146 - strcat(flags, _("global,"));
147 - if (scope & IPV6_ADDR_LINKLOCAL)
148 - strcat(flags, _("link,"));
149 - if (scope & IPV6_ADDR_SITELOCAL)
150 - strcat(flags, _("site,"));
151 - if (scope & IPV6_ADDR_LOOPBACK)
152 - strcat(flags, _("host,"));
153 - if (flags[strlen(flags)-1] == ',')
154 - flags[strlen(flags)-1] = '>';
155 - else
156 - flags[strlen(flags)-1] = 0;
157 - printf("%s\n", flags);
158 + printf("\n");
159 }
160 }
161 fclose(f);
162 @@ -807,17 +768,17 @@ void ife_print_long(struct interface *ptr)
163
164 if (ipxtype != NULL) {
165 if (ptr->has_ipx_bb)
166 - printf(_(" %s Ethernet-II %s\n"),
167 - ipxtype->name, ipxtype->sprint(&ptr->ipxaddr_bb, 1));
168 + printf(_(" IPX/Ethernet II addr:%s\n"),
169 + ipxtype->sprint(&ptr->ipxaddr_bb, 1));
170 if (ptr->has_ipx_sn)
171 - printf(_(" %s Ethernet-SNAP %s\n"),
172 - ipxtype->name, ipxtype->sprint(&ptr->ipxaddr_sn, 1));
173 + printf(_(" IPX/Ethernet SNAP addr:%s\n"),
174 + ipxtype->sprint(&ptr->ipxaddr_sn, 1));
175 if (ptr->has_ipx_e2)
176 - printf(_(" %s Ethernet802.2 %s\n"),
177 - ipxtype->name, ipxtype->sprint(&ptr->ipxaddr_e2, 1));
178 + printf(_(" IPX/Ethernet 802.2 addr:%s\n"),
179 + ipxtype->sprint(&ptr->ipxaddr_e2, 1));
180 if (ptr->has_ipx_e3)
181 - printf(_(" %s Ethernet802.3 %s\n"),
182 - ipxtype->name, ipxtype->sprint(&ptr->ipxaddr_e3, 1));
183 + printf(_(" IPX/Ethernet 802.3 addr:%s\n"),
184 + ipxtype->sprint(&ptr->ipxaddr_e3, 1));
185 }
186 #endif
187
188 @@ -826,7 +787,7 @@ void ife_print_long(struct interface *ptr)
189 ddptype = get_afntype(AF_APPLETALK);
190 if (ddptype != NULL) {
191 if (ptr->has_ddp)
192 - printf(_(" %s %s\n"), ddptype->name, ddptype->sprint(&ptr->ddpaddr, 1));
193 + printf(_(" EtherTalk Phase 2 addr:%s\n"), ddptype->sprint(&ptr->ddpaddr, 1));
194 }
195 #endif
196
197 @@ -835,30 +796,53 @@ void ife_print_long(struct interface *ptr)
198 ectype = get_afntype(AF_ECONET);
199 if (ectype != NULL) {
200 if (ptr->has_econet)
201 - printf(_(" %s %s\n"), ectype->name, ectype->sprint(&ptr->ecaddr, 1));
202 + printf(_(" econet addr:%s\n"), ectype->sprint(&ptr->ecaddr, 1));
203 }
204 #endif
205
206 - /* For some hardware types (eg Ash, ATM) we don't print the
207 - hardware address if it's null. */
208 - if (hw->print != NULL && (! (hw_null_address(hw, ptr->hwaddr) &&
209 - hw->suppress_null_addr)))
210 - printf(_(" %s %s"), hw->name, hw->print(ptr->hwaddr));
211 - else
212 - printf(_(" %s"), hw->name);
213 - if (ptr->tx_queue_len != -1)
214 - printf(_(" txqueuelen %d"), ptr->tx_queue_len);
215 - printf(" (%s)\n", hw->title);
216 -
217 -#ifdef IFF_PORTSEL
218 - if (ptr->flags & IFF_PORTSEL) {
219 - printf(_(" media %s"), if_port_text[ptr->map.port][0]);
220 - if (ptr->flags & IFF_AUTOMEDIA)
221 - printf(_("autoselect"));
222 - printf("\n");
223 - }
224 + printf(" ");
225 + /* DONT FORGET TO ADD THE FLAGS IN ife_print_short, too */
226 + if (ptr->flags == 0)
227 + printf(_("[NO FLAGS] "));
228 + if (ptr->flags & IFF_UP)
229 + printf(_("UP "));
230 + if (ptr->flags & IFF_BROADCAST)
231 + printf(_("BROADCAST "));
232 + if (ptr->flags & IFF_DEBUG)
233 + printf(_("DEBUG "));
234 + if (ptr->flags & IFF_LOOPBACK)
235 + printf(_("LOOPBACK "));
236 + if (ptr->flags & IFF_POINTOPOINT)
237 + printf(_("POINTOPOINT "));
238 + if (ptr->flags & IFF_NOTRAILERS)
239 + printf(_("NOTRAILERS "));
240 + if (ptr->flags & IFF_RUNNING)
241 + printf(_("RUNNING "));
242 + if (ptr->flags & IFF_NOARP)
243 + printf(_("NOARP "));
244 + if (ptr->flags & IFF_PROMISC)
245 + printf(_("PROMISC "));
246 + if (ptr->flags & IFF_ALLMULTI)
247 + printf(_("ALLMULTI "));
248 + if (ptr->flags & IFF_SLAVE)
249 + printf(_("SLAVE "));
250 + if (ptr->flags & IFF_MASTER)
251 + printf(_("MASTER "));
252 + if (ptr->flags & IFF_MULTICAST)
253 + printf(_("MULTICAST "));
254 +#ifdef HAVE_DYNAMIC
255 + if (ptr->flags & IFF_DYNAMIC)
256 + printf(_("DYNAMIC "));
257 #endif
258 -
259 + /* DONT FORGET TO ADD THE FLAGS IN ife_print_short */
260 + printf(_(" MTU:%d Metric:%d"),
261 + ptr->mtu, ptr->metric ? ptr->metric : 1);
262 +#ifdef SIOCSKEEPALIVE
263 + if (ptr->outfill || ptr->keepalive)
264 + printf(_(" Outfill:%d Keepalive:%d"),
265 + ptr->outfill, ptr->keepalive);
266 +#endif
267 + printf("\n");
268
269 /* If needed, display the interface statistics. */
270
271 @@ -867,6 +851,15 @@ void ife_print_long(struct interface *ptr)
272 * not for the aliases, although strictly speaking they're shared
273 * by all addresses.
274 */
275 + printf(" ");
276 +
277 + printf(_("RX packets:%llu errors:%lu dropped:%lu overruns:%lu frame:%lu\n"),
278 + ptr->stats.rx_packets, ptr->stats.rx_errors,
279 + ptr->stats.rx_dropped, ptr->stats.rx_fifo_errors,
280 + ptr->stats.rx_frame_errors);
281 + if (can_compress)
282 + printf(_(" compressed:%lu\n"), ptr->stats.rx_compressed);
283 +
284 rx = ptr->stats.rx_bytes;
285 short_rx = rx * 10;
286 if (rx > 1125899906842624ull) {
287 @@ -904,50 +897,37 @@ void ife_print_long(struct interface *ptr)
288 Text = "KiB";
289 }
290
291 - printf(" ");
292 - printf(_("RX packets %llu bytes %llu (%lu.%lu %s)\n"),
293 - ptr->stats.rx_packets,
294 - rx, (unsigned long)(short_rx / 10),
295 - (unsigned long)(short_rx % 10), Rext);
296 - if (can_compress) {
297 - printf(" ");
298 - printf(_("RX compressed:%lu\n"), ptr->stats.rx_compressed);
299 - }
300 - printf(" ");
301 - printf(_("RX errors %lu dropped %lu overruns %lu frame %lu\n"),
302 - ptr->stats.rx_errors, ptr->stats.rx_dropped,
303 - ptr->stats.rx_fifo_errors, ptr->stats.rx_frame_errors);
304 -
305 -
306 - printf(" ");
307 - printf(_("TX packets %llu bytes %llu (%lu.%lu %s)\n"),
308 - ptr->stats.tx_packets,
309 - tx, (unsigned long)(short_tx / 10),
310 - (unsigned long)(short_tx % 10), Text);
311 - if (can_compress) {
312 - printf(" ");
313 - printf(_("TX compressed %lu\n"), ptr->stats.tx_compressed);
314 - }
315 - printf(" ");
316 - printf(_("TX errors %lu dropped %lu overruns %lu carrier %lu collisions %lu\n"),
317 - ptr->stats.tx_errors,
318 + printf(" ");
319 + printf(_("TX packets:%llu errors:%lu dropped:%lu overruns:%lu carrier:%lu\n"),
320 + ptr->stats.tx_packets, ptr->stats.tx_errors,
321 ptr->stats.tx_dropped, ptr->stats.tx_fifo_errors,
322 - ptr->stats.tx_carrier_errors, ptr->stats.collisions);
323 + ptr->stats.tx_carrier_errors);
324 + printf(_(" collisions:%lu "), ptr->stats.collisions);
325 + if (can_compress)
326 + printf(_("compressed:%lu "), ptr->stats.tx_compressed);
327 + if (ptr->tx_queue_len != -1)
328 + printf(_("txqueuelen:%d "), ptr->tx_queue_len);
329 + printf("\n ");
330 + printf(_("RX bytes:%llu (%lu.%lu %s) TX bytes:%llu (%lu.%lu %s)\n"),
331 + rx, (unsigned long)(short_rx / 10),
332 + (unsigned long)(short_rx % 10), Rext,
333 + tx, (unsigned long)(short_tx / 10),
334 + (unsigned long)(short_tx % 10), Text);
335 }
336
337 if ((ptr->map.irq || ptr->map.mem_start || ptr->map.dma ||
338 ptr->map.base_addr >= 0x100)) {
339 - printf(" device ");
340 + printf(" ");
341 if (ptr->map.irq)
342 - printf(_("interrupt %d "), ptr->map.irq);
343 + printf(_("Interrupt:%d "), ptr->map.irq);
344 if (ptr->map.base_addr >= 0x100) /* Only print devices using it for
345 I/O maps */
346 - printf(_("base 0x%x "), ptr->map.base_addr);
347 + printf(_("Base address:0x%x "), ptr->map.base_addr);
348 if (ptr->map.mem_start) {
349 - printf(_("memory 0x%lx-%lx "), ptr->map.mem_start, ptr->map.mem_end);
350 + printf(_("Memory:%lx-%lx "), ptr->map.mem_start, ptr->map.mem_end);
351 }
352 if (ptr->map.dma)
353 - printf(_(" dma 0x%x"), ptr->map.dma);
354 + printf(_("DMA chan:%x "), ptr->map.dma);
355 printf("\n");
356 }
357 printf("\n");