-capture_stat_start(GList *if_list) {
- int stat_fd, fork_child;
- gchar *msg;
- if_stat_cache_t *sc = NULL;
- GList *if_entry;
- if_info_t *if_info;
- if_stat_cache_item_t *sc_item;
-
- /* Fire up dumpcap. */
- /*
- * XXX - on systems with BPF, the number of BPF devices limits the
- * number of devices on which you can capture simultaneously.
- *
- * This means that
- *
- * 1) this might fail if you run out of BPF devices
- *
- * and
- *
- * 2) opening every interface could leave too few BPF devices
- * for *other* programs.
- *
- * It also means the system could end up getting a lot of traffic
- * that it has to pass through the networking stack and capture
- * mechanism, so opening all the devices and presenting packet
- * counts might not always be a good idea.
- */
- if (sync_interface_stats_open(&stat_fd, &fork_child, &msg) == 0) {
- sc = g_malloc(sizeof(if_stat_cache_t));
- sc->stat_fd = stat_fd;
- sc->fork_child = fork_child;
- sc->cache_list = NULL;
-
- /* Initialize the cache */
- for (if_entry = if_list; if_entry != NULL; if_entry = g_list_next(if_entry)) {
- if_info = if_entry->data;
- sc_item = g_malloc0(sizeof(if_stat_cache_item_t));
- sc_item->name = g_strdup(if_info->name);
- sc->cache_list = g_list_append(sc->cache_list, sc_item);
- }
+capture_stat_start(capture_options *capture_opts) {
+ int stat_fd, fork_child;
+ gchar *msg;
+ if_stat_cache_t *sc = NULL;
+ if_stat_cache_item_t *sc_item;
+ guint i;
+ interface_t device;
+
+ /* Fire up dumpcap. */
+ /*
+ * XXX - on systems with BPF, the number of BPF devices limits the
+ * number of devices on which you can capture simultaneously.
+ *
+ * This means that
+ *
+ * 1) this might fail if you run out of BPF devices
+ *
+ * and
+ *
+ * 2) opening every interface could leave too few BPF devices
+ * for *other* programs.
+ *
+ * It also means the system could end up getting a lot of traffic
+ * that it has to pass through the networking stack and capture
+ * mechanism, so opening all the devices and presenting packet
+ * counts might not always be a good idea.
+ */
+ if (sync_interface_stats_open(&stat_fd, &fork_child, &msg, NULL) == 0) {
+ sc = (if_stat_cache_t *)g_malloc(sizeof(if_stat_cache_t));
+ sc->stat_fd = stat_fd;
+ sc->fork_child = fork_child;
+ sc->cache_list = NULL;
+
+ /* Initialize the cache */
+ for (i = 0; i < capture_opts->all_ifaces->len; i++) {
+ device = g_array_index(capture_opts->all_ifaces, interface_t, i);
+ if (device.type != IF_PIPE && &(device.if_info)) {
+ sc_item = (if_stat_cache_item_t *)g_malloc0(sizeof(if_stat_cache_item_t));
+ sc_item->name = g_strdup(device.if_info.name);
+ sc->cache_list = g_list_append(sc->cache_list, sc_item);
+ }