46 |
|
exit(1); |
47 |
|
} |
48 |
|
|
49 |
+ |
if (argc != 1) { |
50 |
+ |
/* If an argument is given, use bsearch to find just that |
51 |
+ |
* interface. */ |
52 |
+ |
sg_network_iface_stats key; |
53 |
+ |
|
54 |
+ |
key.interface_name = argv[1]; |
55 |
+ |
network_iface_stats = bsearch(&key, network_iface_stats, |
56 |
+ |
iface_count, |
57 |
+ |
sizeof *network_iface_stats, |
58 |
+ |
sg_network_iface_compare_name); |
59 |
+ |
if (network_iface_stats == NULL) { |
60 |
+ |
fprintf(stderr, "Interface %s not found\n", argv[1]); |
61 |
+ |
exit(1); |
62 |
+ |
} |
63 |
+ |
iface_count = 1; |
64 |
+ |
} |
65 |
+ |
|
66 |
|
printf("Name\tSpeed\tDuplex\n"); |
67 |
|
for(i = 0; i < iface_count; i++) { |
68 |
|
printf("%s\t%d\t", network_iface_stats->interface_name, network_iface_stats->speed); |
69 |
< |
switch (network_iface_stats->dup) { |
69 |
> |
switch (network_iface_stats->duplex) { |
70 |
|
case SG_IFACE_DUPLEX_FULL: |
71 |
|
printf("full\n"); |
72 |
|
break; |