Esempio n. 1
0
extern stats_tree*
stats_tree_new(stats_tree_cfg *cfg, tree_pres *pr, const char *filter)
{
	stats_tree *st = (stats_tree *)g_malloc(sizeof(stats_tree));

	st->cfg = cfg;
	st->pr = pr;

	st->names = g_hash_table_new(g_str_hash,g_str_equal);
	st->parents = g_ptr_array_new();
	st->filter = g_strdup(filter);

	st->start = -1.0;
	st->elapsed = 0.0;

	st->root.counter = 0;
	st->root.total = 0;
	st->root.minvalue = G_MAXINT;
	st->root.maxvalue = G_MININT;
	st->root.st_flags = 0;

	st->root.bh = (burst_bucket*)g_malloc0(sizeof(burst_bucket));
	st->root.bt = st->root.bh;
	st->root.bcount = 0;
	st->root.max_burst = 0;
	st->root.burst_time = -1.0;

	st->root.name = stats_tree_get_displayname(cfg->name);
	st->root.st = st;
	st->root.parent = NULL;
	st->root.children = NULL;
	st->root.next = NULL;
	st->root.hash = NULL;
	st->root.pr = NULL;

	st->st_flags = st->cfg->st_flags;

	if (!(st->st_flags&ST_FLG_SRTCOL_MASK)) {
		/* No default sort specified - use preferences */
		st->st_flags |= prefs.st_sort_defcolflag<<ST_FLG_SRTCOL_SHIFT;
		if (prefs.st_sort_defdescending) {
			st->st_flags |= ST_FLG_SORT_DESC;
		}
	}
	st->num_columns = N_COLUMNS;
	st->display_name= stats_tree_get_displayname(st->cfg->name);

	g_ptr_array_add(st->parents,&st->root);

	return st;
}
Esempio n. 2
0
extern guint
stats_tree_branch_max_namelen(const stat_node *node, guint indent)
{
	stat_node *child;
	guint maxlen = 0;
	guint len;

	indent = indent > INDENT_MAX ? INDENT_MAX : indent;

	if (node->children) {
		for (child = node->children; child; child = child->next ) {
			len = stats_tree_branch_max_namelen(child,indent+1);
			maxlen = len > maxlen ? len : maxlen;
		}
	}

	if (node->st_flags&ST_FLG_ROOTCHILD) {
		gchar *display_name= stats_tree_get_displayname(node->name);
		len = (guint) strlen(display_name) + indent;
		g_free(display_name);
	}
	else {
	len = (guint) strlen(node->name) + indent;
	}
	maxlen = len > maxlen ? len : maxlen;

	return maxlen;
}
void StatsTreeDialog::fillTree()
{
    GString *error_string;
    if (!st_cfg_ || file_closed_) return;

    gchar* display_name_temp = stats_tree_get_displayname(st_cfg_->name);
    QString display_name(display_name_temp);
    g_free(display_name_temp);

    // The GTK+ UI appends "Stats Tree" to the window title. If we do the same
    // here we should expand the name completely, e.g. to "Statistics Tree".
    setWindowSubtitle(display_name);

    st_cfg_->pr = &cfg_pr_;
    cfg_pr_.st_dlg = this;

    if (st_) {
        stats_tree_free(st_);
    }
    st_ = stats_tree_new(st_cfg_, NULL, ui->displayFilterLineEdit->text().toUtf8().constData());

    // Add number of columns for this stats_tree
    QStringList headerLabels;
    for (int count = 0; count<st_->num_columns; count++) {
        headerLabels.push_back(stats_tree_get_column_name(count));
    }
    ui->statsTreeWidget->setColumnCount(headerLabels.count());
    ui->statsTreeWidget->setHeaderLabels(headerLabels);
    resize(st_->num_columns*80+80, height());
    for (int count = 0; count<st_->num_columns; count++) {
        headerLabels.push_back(stats_tree_get_column_name(count));
    }
    ui->statsTreeWidget->setSortingEnabled(false);

    error_string = register_tap_listener(st_cfg_->tapname,
                          st_,
                          st_->filter,
                          st_cfg_->flags,
                          resetTap,
                          stats_tree_packet,
                          drawTreeItems);
    if (error_string) {
        QMessageBox::critical(this, tr("%1 failed to attach to tap").arg(display_name),
                             error_string->str);
        g_string_free(error_string, TRUE);
        reject();
    }

    cf_retap_packets(cap_file_.capFile());
    drawTreeItems(st_);

    ui->statsTreeWidget->setSortingEnabled(true);
    remove_tap_listener(st_);

    st_cfg_->pr = NULL;
}
void StatsTreeDialog::fillTree()
{
    if (!st_cfg_ || file_closed_) return;

    QString display_name = gchar_free_to_qstring(stats_tree_get_displayname(st_cfg_->name));

    // The GTK+ UI appends "Stats Tree" to the window title. If we do the same
    // here we should expand the name completely, e.g. to "Statistics Tree".
    setWindowSubtitle(display_name);

    st_cfg_->pr = &cfg_pr_;
    cfg_pr_.st_dlg = this;

    if (st_) {
        stats_tree_free(st_);
    }
    QString display_filter = displayFilter();
    st_ = stats_tree_new(st_cfg_, NULL, display_filter.toUtf8().constData());

    // Add number of columns for this stats_tree
    QStringList header_labels;
    for (int count = 0; count<st_->num_columns; count++) {
        header_labels.push_back(stats_tree_get_column_name(count));
    }
    statsTreeWidget()->setColumnCount(header_labels.count());
    statsTreeWidget()->setHeaderLabels(header_labels);
    statsTreeWidget()->setSortingEnabled(false);

    if (!registerTapListener(st_cfg_->tapname,
                             st_,
                             st_->filter,
                             st_cfg_->flags,
                             resetTap,
                             stats_tree_packet,
                             drawTreeItems)) {
        reject(); // XXX Stay open instead?
        return;
    }

    cap_file_.retapPackets();
    drawTreeItems(st_);

    statsTreeWidget()->setSortingEnabled(true);
    removeTapListeners();

    st_cfg_->pr = NULL;
}
Esempio n. 5
0
extern void
stats_tree_reinit(void *p)
{
	stats_tree *st = (stats_tree *)p;
	stat_node *child;
	stat_node *next;

	for (child = st->root.children; child; child = next) {
		/* child->next will be gone after free_stat_node, so cache it here */
		next = child->next;
		free_stat_node(child);
	}

	st->root.children = NULL;
	st->root.counter = 0;
	st->root.total = 0;
	st->root.minvalue = G_MAXINT;
	st->root.maxvalue = G_MININT;
	st->root.st_flags = 0;

	st->root.bh = (burst_bucket*)g_malloc0(sizeof(burst_bucket));
	st->root.bt = st->root.bh;
	st->root.bcount = 0;
	st->root.max_burst = 0;
	st->root.burst_time = -1.0;

	/* No more stat_nodes left in tree - clean out hash, array */
	g_hash_table_remove_all(st->names);
	if (st->parents->len>1) {
		g_ptr_array_remove_range(st->parents, 1, st->parents->len-1);
	}

	/* Do not update st_flags for the tree (sorting) - leave as was */
	st->num_columns = N_COLUMNS;
	g_free(st->display_name);
	st->display_name= stats_tree_get_displayname(st->cfg->name);

	if (st->cfg->init) {
		st->cfg->init(st);
	}
}
Esempio n. 6
0
void StatsTreeDialog::fillTree()
{
    GString *error_string;
    if (!st_cfg_) return;

    gchar* display_name_temp = stats_tree_get_displayname(st_cfg_->name);
    QString display_name(display_name_temp);
    g_free(display_name_temp);

    setWindowTitle(display_name + tr(" Stats Tree"));

    if (!cap_file_) return;

    if (st_cfg_->in_use) {
        QMessageBox::warning(this, tr("%1 already open").arg(display_name),
                             tr("Each type of tree can only be generated one at at time."));
        reject();
    }

    st_cfg_->in_use = TRUE;
    st_cfg_->pr = &cfg_pr_;
    cfg_pr_.st_dlg = this;

    if (st_) {
        stats_tree_free(st_);
    }
    st_ = stats_tree_new(st_cfg_, NULL, ui->displayFilterLineEdit->text().toUtf8().constData());

    // Add number of columns for this stats_tree
    QStringList headerLabels;
    for (int count = 0; count<st_->num_columns; count++) {
        headerLabels.push_back(stats_tree_get_column_name(count));
    }
    ui->statsTreeWidget->setColumnCount(headerLabels.count());
    ui->statsTreeWidget->setHeaderLabels(headerLabels);
    resize(st_->num_columns*80+80, height());
    for (int count = 0; count<st_->num_columns; count++) {
        headerLabels.push_back(stats_tree_get_column_name(count));
    }
    ui->statsTreeWidget->setSortingEnabled(false);

    error_string = register_tap_listener(st_cfg_->tapname,
                          st_,
                          st_->filter,
                          st_cfg_->flags,
                          resetTap,
                          stats_tree_packet,
                          drawTreeItems);
    if (error_string) {
        QMessageBox::critical(this, tr("%1 failed to attach to tap").arg(display_name),
                             error_string->str);
        g_string_free(error_string, TRUE);
        reject();
    }

    cf_retap_packets(cap_file_);
    drawTreeItems(st_);

    ui->statsTreeWidget->setSortingEnabled(true);
    remove_tap_listener(st_);

    st_cfg_->in_use = FALSE;
    st_cfg_->pr = NULL;
}