/* XXX - yes, I know, I should move cppmagic.h to a generic location. */
#include "tools/lemon/cppmagic.h"
-#ifdef NEED_G_ASCII_STRCASECMP_H
-#include "g_ascii_strcasecmp.h"
-#endif
-
-
#define MAX_WIN_IF_NAME_LEN 511
static struct pcap_samp* (*p_pcap_setsampling)(pcap_t *);
#endif
+#ifdef HAVE_PCAP_LIST_DATALINKS
+static int (*p_pcap_list_datalinks)(pcap_t *, int **);
+#endif
+
+#ifdef HAVE_PCAP_SET_DATALINK
+static int (*p_pcap_set_datalink)(pcap_t *, int);
+#endif
+
+#ifdef HAVE_FREE_DATALINKS
+static int (*p_pcap_free_datalinks)(int *);
+#endif
+
typedef struct {
const char *name;
gpointer *ptr;
SYM(pcap_lib_version, TRUE),
SYM(pcap_setbuff, TRUE),
SYM(pcap_next_ex, TRUE),
+#ifdef HAVE_PCAP_LIST_DATALINKS
+ SYM(pcap_list_datalinks, FALSE),
+#endif
+#ifdef HAVE_PCAP_SET_DATALINK
+ SYM(pcap_set_datalink, FALSE),
+#endif
+#ifdef HAVE_PCAP_FREE_DATALINKS
+ SYM(pcap_free_datalinks, TRUE),
+#endif
{ NULL, NULL, FALSE }
};
return p_pcap_datalink(a);
}
+#ifdef HAVE_PCAP_SET_DATALINK
+int
+pcap_set_datalink(pcap_t *p, int dlt)
+{
+ g_assert(has_wpcap);
+ return p_pcap_set_datalink(p, dlt);
+}
+#endif
+
int
pcap_setfilter(pcap_t *a, struct bpf_program *b)
{
}
#endif
+#ifdef HAVE_PCAP_LIST_DATALINKS
+int
+pcap_list_datalinks(pcap_t *p, int **ddlt)
+{
+ g_assert(has_wpcap);
+ return p_pcap_list_datalinks(p, ddlt);
+}
+#endif
+
+#ifdef HAVE_PCAP_FREE_DATALINKS
+void
+pcap_free_datalinks(int *ddlt)
+{
+ g_assert(has_wpcap);
+
+ /*
+ * If we don't have pcap_free_datalinks() in WinPcap,
+ * we don't free the memory - we can't use free(), as
+ * we might not have been built with the same version
+ * of the C runtime library as WinPcap was, and, if we're
+ * not, free() isn't guaranteed to work on something
+ * allocated by WinPcap.
+ */
+ if (p_pcap_free_datalinks != NULL)
+ p_pcap_free_datalinks(ddlt);
+}
+#endif
+
#ifdef HAVE_PCAP_DATALINK_VAL_TO_NAME
const char *
pcap_datalink_val_to_name(int dlt)
GList *
get_interface_list(int *err, char **err_str)
{
-#ifdef HAVE_PCAP_REMOTE
- char source[PCAP_BUF_SIZE];
-#else
GList *il = NULL;
wchar_t *names;
char *win95names;
char ascii_name[MAX_WIN_IF_NAME_LEN + 1];
char ascii_desc[MAX_WIN_IF_NAME_LEN + 1];
int i, j;
-#endif
char errbuf[PCAP_ERRBUF_SIZE];
-#ifdef HAVE_PCAP_REMOTE
- if (p_pcap_createsrcstr(source, PCAP_SRC_IFLOCAL, NULL, NULL,
- NULL, errbuf) == -1) {
- *err = CANT_GET_INTERFACE_LIST;
- if (err_str != NULL)
- *err_str = cant_get_if_list_error_message(errbuf);
- return NULL;
- }
- return get_interface_list_findalldevs_ex(source, NULL, err, err_str);
-#else
-
#ifdef HAVE_PCAP_FINDALLDEVS
if (p_pcap_findalldevs != NULL)
return get_interface_list_findalldevs(err, err_str);
}
return il;
-#endif /* HAVE_PCAP_REMOTE */
}
/*
gchar *blankp;
if (has_wpcap) {
- g_string_sprintfa(str, "with ");
+ g_string_append_printf(str, "with ");
if (p_pcap_lib_version != NULL)
- g_string_sprintfa(str, p_pcap_lib_version());
+ g_string_append_printf(str, p_pcap_lib_version());
else {
/*
* An alternative method of obtaining the version
g_module_close(handle);
}
}
- g_string_sprintfa(str, "WinPcap (%s)", packetVer);
+ g_string_append_printf(str, "WinPcap (%s)", packetVer);
}
} else
g_string_append(str, "without WinPcap");