aboutsummaryrefslogtreecommitdiffstats
path: root/capture-pcap-util.c
diff options
context:
space:
mode:
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>2010-05-07 08:06:25 +0000
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>2010-05-07 08:06:25 +0000
commit201c0874833f535f70bc6a1e6ee4f0e47c3dd729 (patch)
tree211917813f771c8c7799bf5cc322e7a61f7bac39 /capture-pcap-util.c
parent322dd1f8cba46346b6fd97a1daedd7405b402da2 (diff)
For TShark and Wireshark, get the list of link-layer types for an
interface by running dumpcap, so that if you need privileges to open an interface, and dumpcap has those privileges, neither TShark nor Wireshark need them. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@32710 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'capture-pcap-util.c')
-rw-r--r--capture-pcap-util.c105
1 files changed, 0 insertions, 105 deletions
diff --git a/capture-pcap-util.c b/capture-pcap-util.c
index ef2588042e..1c7815fa4e 100644
--- a/capture-pcap-util.c
+++ b/capture-pcap-util.c
@@ -438,111 +438,6 @@ pcap_datalink_val_to_description(int dlt)
#endif /* !defined(HAVE_PCAP_DATALINK_VAL_TO_NAME) || !defined(HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION) */
-/*
- * Get the data-link types available for a libpcap device.
- */
-static data_link_info_t *
-create_data_link_info(int dlt)
-{
- data_link_info_t *data_link_info;
- const char *text;
-
- data_link_info = (data_link_info_t *)g_malloc(sizeof (data_link_info_t));
- data_link_info->dlt = dlt;
- text = pcap_datalink_val_to_name(dlt);
- if (text != NULL)
- data_link_info->name = g_strdup(text);
- else
- data_link_info->name = g_strdup_printf("DLT %d", dlt);
- text = pcap_datalink_val_to_description(dlt);
- if (text != NULL)
- data_link_info->description = g_strdup(text);
- else
- data_link_info->description = NULL;
- return data_link_info;
-}
-
-GList *
-get_pcap_linktype_list(const char *devname, char **err_str)
-{
- GList *linktype_list = NULL;
- pcap_t *pch;
- int deflt;
- char errbuf[PCAP_ERRBUF_SIZE];
-#ifdef HAVE_PCAP_LIST_DATALINKS
- int *linktypes;
- int i, nlt;
-#endif
- data_link_info_t *data_link_info;
-
-#ifdef HAVE_PCAP_OPEN
- pch = pcap_open(devname, MIN_PACKET_SIZE, 0, 0, NULL, errbuf);
-#else
- pch = pcap_open_live(devname, MIN_PACKET_SIZE, 0, 0, errbuf);
-#endif
- if (pch == NULL) {
- if (err_str != NULL)
- *err_str = g_strdup(errbuf);
- return NULL;
- }
- deflt = get_pcap_linktype(pch, devname);
-#ifdef HAVE_PCAP_LIST_DATALINKS
- nlt = pcap_list_datalinks(pch, &linktypes);
- if (nlt == 0 || linktypes == NULL) {
- pcap_close(pch);
- if (err_str != NULL)
- *err_str = NULL; /* an empty list doesn't mean an error */
- return NULL;
- }
- for (i = 0; i < nlt; i++) {
- data_link_info = create_data_link_info(linktypes[i]);
-
- /*
- * XXX - for 802.11, make the most detailed 802.11
- * version the default, rather than the one the
- * device has as the default?
- */
- if (linktypes[i] == deflt)
- linktype_list = g_list_prepend(linktype_list,
- data_link_info);
- else
- linktype_list = g_list_append(linktype_list,
- data_link_info);
- }
-#ifdef HAVE_PCAP_FREE_DATALINKS
- pcap_free_datalinks(linktypes);
-#else
- /*
- * In Windows, there's no guarantee that if you have a library
- * built with one version of the MSVC++ run-time library, and
- * it returns a pointer to allocated data, you can free that
- * data from a program linked with another version of the
- * MSVC++ run-time library.
- *
- * This is not an issue on UN*X.
- *
- * See the mail threads starting at
- *
- * http://www.winpcap.org/pipermail/winpcap-users/2006-September/001421.html
- *
- * and
- *
- * http://www.winpcap.org/pipermail/winpcap-users/2008-May/002498.html
- */
-#ifndef _WIN32
-#define xx_free free /* hack so checkAPIs doesn't complain */
- xx_free(linktypes);
-#endif /* _WIN32 */
-#endif /* HAVE_PCAP_FREE_DATALINKS */
-#else /* HAVE_PCAP_LIST_DATALINKS */
- data_link_info = create_data_link_info(deflt);
- linktype_list = g_list_append(linktype_list, data_link_info);
-#endif /* HAVE_PCAP_LIST_DATALINKS */
-
- pcap_close(pch);
- return linktype_list;
-}
-
static void
free_linktype_cb(gpointer data, gpointer user_data _U_)
{