diff options
author | Bill Fenner <fenner@gmail.com> | 2019-04-15 06:25:28 -0700 |
---|---|---|
committer | Bill Fenner <fenner@gmail.com> | 2019-04-15 12:38:02 -0700 |
commit | 6e95542894f084d831a2da039a1da85d86dc2604 (patch) | |
tree | 1d286226e805ee69d0223cbea85c3eba8bef7098 /pcap.c | |
parent | 8795ed44290a462bcd1129a4b85fccb5d2094d76 (diff) | |
download | libpcap-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.c | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -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; |