#include "epan/ex-opt.h"
#include "capture_ifinfo.h"
#include "capture_ui_utils.h"
-#include "ui/simple_dialog.h"
#include "wiretap/wtap.h"
#include "epan/to_str.h"
/* Allocate enough space to return the string,
which runs from p2 to p, plus a terminating
'\0'. */
- descr = g_malloc(p - p2 + 1);
+ descr = (char *)g_malloc(p - p2 + 1);
memcpy(descr, p2, p - p2);
descr[p - p2] = '\0';
return descr;
return (gint)linktype;
}
+#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
+gint
+capture_dev_user_buffersize_find(const gchar *if_name)
+{
+ gchar *p, *next;
+ gint buffersize;
+
+ if ((prefs.capture_devices_buffersize == NULL) ||
+ (*prefs.capture_devices_buffersize == '\0')) {
+ /* There are no buffersizes defined */
+ return -1;
+ }
+
+ if ((p = strstr(prefs.capture_devices_buffersize, if_name)) == NULL) {
+ /* There are, but there isn't one for this interface. */
+ return -1;
+ }
+
+ p += strlen(if_name) + 1;
+ buffersize = (gint)strtol(p, &next, 10);
+ if (next == p || *next != ')' || buffersize < 0) {
+ /* Syntax error */
+ return -1;
+ }
+ if (buffersize > G_MAXINT) {
+ /* Value doesn't fit in a gint */
+ return -1;
+ }
+
+ return (gint)buffersize;
+}
+#endif
+
+gint
+capture_dev_user_snaplen_find(const gchar *if_name)
+{
+ gchar *p, *next;
+ gint snaplen;
+
+ if ((prefs.capture_devices_snaplen == NULL) ||
+ (*prefs.capture_devices_snaplen == '\0')) {
+ /* There is no snap length defined */
+ return -1;
+ }
+
+ if ((p = strstr(prefs.capture_devices_snaplen, if_name)) == NULL) {
+ /* There are, but there isn't one for this interface. */
+ return -1;
+ }
+
+ p += strlen(if_name) + 3;
+ snaplen = (gint)strtol(p, &next, 10);
+ if (next == p || *next != ')' || snaplen < 0) {
+ /* Syntax error */
+ return -1;
+ }
+ if (snaplen > WTAP_MAX_PACKET_SIZE) {
+ /* Value doesn't fit in a gint */
+ return -1;
+ }
+
+ return (gint)snaplen;
+}
+
+gboolean
+capture_dev_user_hassnap_find(const gchar *if_name)
+{
+ gchar *p, *next;
+ gboolean hassnap;
+
+ if ((prefs.capture_devices_snaplen == NULL) ||
+ (*prefs.capture_devices_snaplen == '\0')) {
+ /* There is no snap length defined */
+ return -1;
+ }
+
+ if ((p = strstr(prefs.capture_devices_snaplen, if_name)) == NULL) {
+ /* There are, but there isn't one for this interface. */
+ return -1;
+ }
+
+ p += strlen(if_name) + 1;
+ hassnap = (gboolean)strtol(p, &next, 10);
+ if (next == p || *next != '(') {
+ /* Syntax error */
+ return -1;
+ }
+
+ return (gboolean)hassnap;
+}
+
+gboolean
+capture_dev_user_pmode_find(const gchar *if_name)
+{
+ gchar *p, *next;
+ gboolean pmode;
+
+ if ((prefs.capture_devices_pmode == NULL) ||
+ (*prefs.capture_devices_pmode == '\0')) {
+ /* There is no promiscuous mode defined */
+ return -1;
+ }
+
+ if ((p = strstr(prefs.capture_devices_pmode, if_name)) == NULL) {
+ /* There are, but there isn't one for this interface. */
+ return -1;
+ }
+
+ p += strlen(if_name) + 1;
+ pmode = (gboolean)strtol(p, &next, 10);
+ if (next == p || *next != ')') {
+ /* Syntax error */
+ return -1;
+ }
+ return (gboolean)pmode;
+}
+
/*
* Return as descriptive a name for an interface as we can get.
* If the user has specified a comment, use that. Otherwise,
/* No, we don't have a user-supplied description; did we get
one from the OS or libpcap? */
descr = NULL;
- if_list = capture_interface_list(&err, NULL);
+ if_list = capture_interface_list(&err, NULL, NULL);
if (if_list != NULL) {
if_entry = if_list;
do {
- if_info = if_entry->data;
+ if_info = (if_info_t *)if_entry->data;
if (strcmp(if_info->name, if_name) == 0) {
- if (if_info->friendly_name!= NULL) {
- /* use the friendly name */
+ if (if_info->friendly_name != NULL) {
+ /* We have a "friendly name"; return a copy of that
+ as the description - when we free the interface
+ list, that'll also free up the strings to which
+ it refers. */
descr = g_strdup(if_info->friendly_name);
- }else if (if_info->description != NULL) {
- /* Return a copy of that - when we free the interface
- list, that'll also free up the strings to which
- it refers. */
- descr = g_strdup(if_info->description);
+ } else if (if_info->vendor_description != NULL) {
+ /* We have no "friendly name", but we have a vendor
+ description; return a copy of that - when we free
+ the interface list, that'll also free up the strings
+ to which it refers. */
+ descr = g_strdup(if_info->vendor_description);
}
break;
}
for (if_entry = if_list; if_entry != NULL; if_entry = g_list_next(if_entry)) {
- if_info = if_entry->data;
+ if_info = (if_info_t *)if_entry->data;
if(strcmp(if_name, if_info->name) == 0) {
return if_info;
/* No, we don't have a user-supplied description; did we get
one from the OS or libpcap? */
if_info = search_info(if_list, if_name);
- if (if_info != NULL && if_info->description != NULL) {
+ if (if_info != NULL && if_info->vendor_description != NULL) {
/* Yes - use it. */
- if_string = g_strdup_printf("%s: %s", if_info->description,
+ if_string = g_strdup_printf("%s: %s", if_info->vendor_description,
if_info->name);
} else {
/* No. */
/* Scan through the list and build a list of strings to display. */
for (if_entry = if_list; if_entry != NULL;
if_entry = g_list_next(if_entry)) {
- if_info = if_entry->data;
+ if_info = (if_info_t *)if_entry->data;
/* Is this interface hidden and, if so, should we include it
anyway? */
} else {
/* No, we don't have a user-supplied description; did we get
one from the OS or libpcap? */
- if (if_info->description != NULL) {
+ if (if_info->vendor_description != NULL) {
/* Yes - use it. */
- if_string = g_strdup_printf("%s: %s", if_info->description,
+ if_string = g_strdup_printf("%s: %s",
+ if_info->vendor_description,
if_info->name);
} else {
/* No. */