From ca5a7ce28f4e5a0537b8d1dabd9fdb9ef4417556 Mon Sep 17 00:00:00 2001 From: gerald Date: Fri, 18 Dec 2009 20:36:36 +0000 Subject: Use the WinPcap version of pcap_datalink_val_to_description if it's present. Add an entry for DLT_PPI in case it's not. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@31316 f5534014-38df-0310-8fa8-9805f1628bb7 --- capture-wpcap.c | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) (limited to 'capture-wpcap.c') diff --git a/capture-wpcap.c b/capture-wpcap.c index 584e989cdf..4d5deb7f0e 100644 --- a/capture-wpcap.c +++ b/capture-wpcap.c @@ -79,6 +79,9 @@ static int (*p_pcap_datalink_name_to_val) (const char *); #ifdef HAVE_PCAP_DATALINK_VAL_TO_NAME static const char *(*p_pcap_datalink_val_to_name) (int); #endif +#ifdef HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION +static const char *(*p_pcap_datalink_val_to_description) (int); +#endif #ifdef HAVE_PCAP_BREAKLOOP static void (*p_pcap_breakloop) (pcap_t *); #endif @@ -155,6 +158,9 @@ load_wpcap(void) #ifdef HAVE_PCAP_DATALINK_VAL_TO_NAME SYM(pcap_datalink_val_to_name, TRUE), #endif +#ifdef HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION + SYM(pcap_datalink_val_to_description, TRUE), +#endif #ifdef HAVE_PCAP_BREAKLOOP /* * We don't try to work around the lack of this at @@ -371,7 +377,7 @@ pcap_freealldevs(pcap_if_t *a) } #endif -#if defined(HAVE_PCAP_DATALINK_NAME_TO_VAL) || defined(HAVE_PCAP_DATALINK_VAL_TO_NAME) +#if defined(HAVE_PCAP_DATALINK_NAME_TO_VAL) || defined(HAVE_PCAP_DATALINK_VAL_TO_NAME) || defined(HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION) /* * Table of DLT_ types, names, and descriptions, for use if the version * of WinPcap we have installed lacks "pcap_datalink_name_to_val()" @@ -464,10 +470,13 @@ static struct dlt_choice dlt_choices[] = { #endif #ifdef DLT_HDLC DLT_CHOICE(DLT_HDLC, "Cisco HDLC"), +#endif +#ifdef DLT_PPI + DLT_CHOICE(DLT_PPI, "Per-Packet Information"), #endif DLT_CHOICE_SENTINEL }; -#endif /* defined(HAVE_PCAP_DATALINK_NAME_TO_VAL) || defined(HAVE_PCAP_DATALINK_VAL_TO_NAME) */ +#endif /* defined(HAVE_PCAP_DATALINK_NAME_TO_VAL) || defined(HAVE_PCAP_DATALINK_VAL_TO_NAME) || defined(HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION */ #ifdef HAVE_PCAP_DATALINK_NAME_TO_VAL int @@ -544,6 +553,29 @@ pcap_datalink_val_to_name(int dlt) } #endif +#ifdef HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION +const char * +pcap_datalink_val_to_description(int dlt) +{ + int i; + + g_assert(has_wpcap); + + if (p_pcap_datalink_val_to_description != NULL) + return p_pcap_datalink_val_to_description(dlt); + else { + /* + * We don't have it in WinPcap; do it ourselves. + */ + for (i = 0; dlt_choices[i].name != NULL; i++) { + if (dlt_choices[i].dlt == dlt) + return (dlt_choices[i].description); + } + return NULL; + } +} +#endif + #ifdef HAVE_PCAP_BREAKLOOP void pcap_breakloop(pcap_t *a) { -- cgit v1.2.3