Use the WinPcap version of pcap_datalink_val_to_description if it's
authorgerald <gerald@f5534014-38df-0310-8fa8-9805f1628bb7>
Fri, 18 Dec 2009 20:36:36 +0000 (20:36 +0000)
committergerald <gerald@f5534014-38df-0310-8fa8-9805f1628bb7>
Fri, 18 Dec 2009 20:36:36 +0000 (20:36 +0000)
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

Makefile.nmake
capture-wpcap.c
config.h.win32
config.nmake

index dc361f06a77a87450dc0a3935fb01b179d181ea3..920b87b87754fe51b6e8f5af908d0a782766eef7 100644 (file)
@@ -352,6 +352,7 @@ config.h    : config.h.win32 config.nmake
            -e "s/@HAVE_PCAP_FINDALLDEVS@/$(PCAP_FINDALLDEVS_CONFIG)/" \
            -e "s/@HAVE_PCAP_DATALINK_NAME_TO_VAL@/$(PCAP_DATALINK_NAME_TO_VAL_CONFIG)/" \
            -e "s/@HAVE_PCAP_DATALINK_VAL_TO_NAME@/$(PCAP_DATALINK_VAL_TO_NAME_CONFIG)/" \
+           -e "s/@HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION@/$(PCAP_DATALINK_VAL_TO_DESCRIPTION_CONFIG)/" \
            -e "s/@HAVE_PCAP_BREAKLOOP@/$(PCAP_BREAKLOOP_CONFIG)/" \
            -e "s/@HAVE_REMOTE@/$(PCAP_HAVE_REMOTE_CONFIG)/" \
            -e "s/@HAVE_PCAP_REMOTE@/$(PCAP_REMOTE_CONFIG)/" \
index 584e989cdf8fc505498a839265c6f59ea0a98f1a..4d5deb7f0e4b15244bbe0e19fb3679dd6a52f4af 100644 (file)
@@ -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)
 {
index 73de28204a4ec22e8b9fe7905fbfbdf210bdaf4b..73607cb6fd304cde702dee7fd2c621a72e57a3cd 100644 (file)
@@ -53,6 +53,7 @@
 @HAVE_PCAP_FINDALLDEVS@
 @HAVE_PCAP_DATALINK_NAME_TO_VAL@
 @HAVE_PCAP_DATALINK_VAL_TO_NAME@
+@HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION@
 @HAVE_LIBWIRESHARKDLL@
 
 @HAVE_PCAP_LIST_DATALINKS@
index 49994d69223e4bb7e7f498706d1dfb3df7a6f246..46b8c38cbd94c5f9145e4ae8bafc2b64e2d41a5c 100644 (file)
@@ -938,6 +938,7 @@ WINPCAP_CONFIG=^#define HAVE_LIBPCAP 1
 PCAP_FINDALLDEVS_CONFIG=^#define HAVE_PCAP_FINDALLDEVS 1
 PCAP_DATALINK_NAME_TO_VAL_CONFIG=^#define HAVE_PCAP_DATALINK_NAME_TO_VAL 1
 PCAP_DATALINK_VAL_TO_NAME_CONFIG=^#define HAVE_PCAP_DATALINK_VAL_TO_NAME 1
+PCAP_DATALINK_VAL_TO_DESCRIPTION_CONFIG=^#define HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION 1
 # PCAP_BREAKLOOP won't have any benefit on Win32, but breaks compatibility with 3.0
 PCAP_BREAKLOOP_CONFIG=
 !ELSE
@@ -946,6 +947,7 @@ WINPCAP_CONFIG=
 PCAP_FINDALLDEVS_CONFIG=
 PCAP_DATALINK_NAME_TO_VAL_CONFIG=
 PCAP_DATALINK_VAL_TO_NAME_CONFIG=
+PCAP_DATALINK_VAL_TO_DESCRIPTION_CONFIG=
 PCAP_BREAKLOOP_CONFIG=
 !ENDIF