aboutsummaryrefslogtreecommitdiffstats
path: root/capture.c
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2007-07-20 21:43:07 +0000
committerGerald Combs <gerald@wireshark.org>2007-07-20 21:43:07 +0000
commitc02e0c7b4a2f23916f6bdda16bd124e3a2b83419 (patch)
treea705612afd4276c7aa9f43738667b6b8a7da2520 /capture.c
parentc1a4caf1b24b7ce38434f8963b3590013912697b (diff)
Remove the "-I" flag from dumpcap, and add a "-M" flag used to specify
that "-D" and "-L" should produce machine-readable output. Use this to move an indirect get_pcap_linktype() call from the GUI to dumpcap. svn path=/trunk/; revision=22367
Diffstat (limited to 'capture.c')
-rw-r--r--capture.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/capture.c b/capture.c
index d18b1d81cb..a09daed2a8 100644
--- a/capture.c
+++ b/capture.c
@@ -682,5 +682,62 @@ capture_interface_list(int *err, char **err_str)
return if_list;
}
+/* XXX - We parse simple text output to get our interface list. Should
+ * we use "real" data serialization instead, e.g. via XML? */
+GList *
+capture_pcap_linktype_list(gchar *ifname, char **err_str)
+{
+ GList *linktype_list = NULL;
+ int err, i;
+ gchar *msg;
+ gchar **raw_list, **lt_parts;
+ data_link_info_t *data_link_info;
+
+ g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Capture Interface List ...");
+
+ /* Try to get our interface list */
+ err = sync_linktype_list_open(ifname, &msg);
+ if (err != 0) {
+ g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Capture Interface List failed!");
+ if (err_str) {
+ *err_str = msg;
+ } else {
+ g_free(msg);
+ }
+ return NULL;
+ }
+
+ /* Split our lines */
+ raw_list = g_strsplit(msg, "\n", 0);
+ g_free(msg);
+
+ for (i = 0; raw_list[i] != NULL; i++) {
+ /* ...and what if the interface name has a tab in it, Mr. Clever Programmer? */
+ lt_parts = g_strsplit(raw_list[i], "\t", 3);
+ if (lt_parts[0] == NULL || lt_parts[1] == NULL || lt_parts[2] == NULL) {
+ g_strfreev(lt_parts);
+ continue;
+ }
+
+ data_link_info = g_malloc(sizeof (data_link_info_t));
+ data_link_info->dlt = (int) strtol(lt_parts[0], NULL, 10);
+ data_link_info->name = g_strdup(lt_parts[1]);
+ if (strcmp(lt_parts[2], "(not supported)") != NULL)
+ data_link_info->description = g_strdup(lt_parts[2]);
+ else
+ data_link_info->description = NULL;
+
+ linktype_list = g_list_append(linktype_list, data_link_info);
+ }
+ g_strfreev(raw_list);
+
+ /* Check to see if we built a list */
+ if (linktype_list == NULL) {
+ if (err_str)
+ *err_str = NULL;
+ }
+ return linktype_list;
+}
+
#endif /* HAVE_LIBPCAP */