summaryrefslogtreecommitdiff
path: root/pcap.c
diff options
context:
space:
mode:
authorBill Fenner <fenner@gmail.com>2019-04-15 06:25:28 -0700
committerBill Fenner <fenner@gmail.com>2019-04-15 12:38:02 -0700
commit6e95542894f084d831a2da039a1da85d86dc2604 (patch)
tree1d286226e805ee69d0223cbea85c3eba8bef7098 /pcap.c
parent8795ed44290a462bcd1129a4b85fccb5d2094d76 (diff)
downloadlibpcap-6e95542894f084d831a2da039a1da85d86dc2604.tar.gz
Report the DLT description in error messages
Introduce pcap_datalink_val_to_description_or_dlt, and use that when reporting an error. This was inspired by seeing "tcpdump: no VLAN support for data link type 113". The new equivalent message is "tcpdump: no VLAN support for Linux cooked".
Diffstat (limited to 'pcap.c')
-rw-r--r--pcap.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/pcap.c b/pcap.c
index 36a118bc..d25e569c 100644
--- a/pcap.c
+++ b/pcap.c
@@ -3152,6 +3152,21 @@ pcap_datalink_val_to_description(int dlt)
return (NULL);
}
+const char *
+pcap_datalink_val_to_description_or_dlt(int dlt)
+{
+ static char unkbuf[40];
+ const char *description;
+
+ description = pcap_datalink_val_to_description(dlt);
+ if (description != NULL) {
+ return description;
+ } else {
+ (void)pcap_snprintf(unkbuf, sizeof(unkbuf), "DLT %u", dlt);
+ return unkbuf;
+ }
+}
+
struct tstamp_type_choice {
const char *name;
const char *description;