From: Guy Harris Date: Fri, 27 Mar 2015 20:02:36 +0000 (-0700) Subject: For -L, print the DLTs in order, not reverse order. X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/ba9350fb64379812dc49ff04de567e4c7a4a430d?ds=sidebyside For -L, print the DLTs in order, not reverse order. Reverse order puts the default DLT last, which is a bit weird. --- diff --git a/tcpdump.c b/tcpdump.c index 2b71d27d..5a735a55 100644 --- a/tcpdump.c +++ b/tcpdump.c @@ -513,7 +513,7 @@ show_tstamp_types_and_exit(const char *device, pcap_t *pd) static void show_dlts_and_exit(const char *device, pcap_t *pd) { - int n_dlts; + int n_dlts, i; int *dlts = 0; const char *dlt_name; @@ -539,22 +539,22 @@ show_dlts_and_exit(const char *device, pcap_t *pd) (void) fprintf(stderr, "Data link types for %s (use option -y to set):\n", device); - while (--n_dlts >= 0) { - dlt_name = pcap_datalink_val_to_name(dlts[n_dlts]); + for (i = 0; i < n_dlts; i++) { + dlt_name = pcap_datalink_val_to_name(dlts[i]); if (dlt_name != NULL) { (void) fprintf(stderr, " %s (%s)", dlt_name, - pcap_datalink_val_to_description(dlts[n_dlts])); + pcap_datalink_val_to_description(dlts[i])); /* * OK, does tcpdump handle that type? */ - if (lookup_printer(dlts[n_dlts]) == NULL - && lookup_ndo_printer(dlts[n_dlts]) == NULL) + if (lookup_printer(dlts[i]) == NULL + && lookup_ndo_printer(dlts[i]) == NULL) (void) fprintf(stderr, " (printing not supported)"); fprintf(stderr, "\n"); } else { (void) fprintf(stderr, " DLT %d (printing not supported)\n", - dlts[n_dlts]); + dlts[i]); } } #ifdef HAVE_PCAP_FREE_DATALINKS