X-Git-Url: https://git.tcpdump.org/libpcap/blobdiff_plain/d6998249084df8dc1131b8dd3cbce0d65a075b4f..4e145de1143f597ef8277b51c5524af1e994f277:/pcap-dbus.c diff --git a/pcap-dbus.c b/pcap-dbus.c index 30daba8e..b1fb548f 100644 --- a/pcap-dbus.c +++ b/pcap-dbus.c @@ -29,7 +29,7 @@ */ #ifdef HAVE_CONFIG_H -#include "config.h" +#include #endif #include @@ -163,7 +163,7 @@ dbus_activate(pcap_t *handle) const char *dev = handle->opt.device; DBusError error = DBUS_ERROR_INIT; - int i; + u_int i; if (strcmp(dev, "dbus-system") == 0) { if (!(handlep->conn = dbus_bus_get(DBUS_BUS_SYSTEM, &error))) { @@ -211,6 +211,7 @@ dbus_activate(pcap_t *handle) handle->getnonblock_op = pcap_getnonblock_fd; handle->setnonblock_op = pcap_setnonblock_fd; handle->stats_op = dbus_stats; + handle->cleanup_op = dbus_cleanup; handle->selectable_fd = handle->fd = -1; @@ -222,6 +223,14 @@ dbus_activate(pcap_t *handle) return PCAP_ERROR_RFMON_NOTSUP; } + /* + * Turn a negative snapshot value (invalid), a snapshot value of + * 0 (unspecified), or a value bigger than the normal maximum + * value, into the maximum message length for D-Bus (128MB). + */ + if (handle->snapshot <= 0 || handle->snapshot > 134217728) + handle->snapshot = 134217728; + /* dbus_connection_set_max_message_size(handlep->conn, handle->snapshot); */ if (handle->opt.buffer_size != 0) dbus_connection_set_max_received_size(handlep->conn, handle->opt.buffer_size); @@ -259,7 +268,7 @@ dbus_create(const char *device, char *ebuf, int *is_ours) } *is_ours = 1; - p = pcap_create_common(device, ebuf, sizeof (struct pcap_dbus)); + p = pcap_create_common(ebuf, sizeof (struct pcap_dbus)); if (p == NULL) return (NULL); @@ -268,11 +277,11 @@ dbus_create(const char *device, char *ebuf, int *is_ours) } int -dbus_findalldevs(pcap_if_t **alldevsp, char *err_str) +dbus_findalldevs(pcap_if_list_t *devlistp, char *err_str) { - if (pcap_add_if(alldevsp, "dbus-system", 0, "D-Bus system bus", err_str) < 0) + if (add_dev(devlistp, "dbus-system", 0, "D-Bus system bus", err_str) == NULL) return -1; - if (pcap_add_if(alldevsp, "dbus-session", 0, "D-Bus session bus", err_str) < 0) + if (add_dev(devlistp, "dbus-session", 0, "D-Bus session bus", err_str) == NULL) return -1; return 0; }