Esempio n. 1
0
void ProtoTree::expand(const QModelIndex & index) {
    field_info *fi;

    fi = index.data(Qt::UserRole).value<field_info *>();
    g_assert(fi);

    if(prefs.gui_auto_scroll_on_expand) {
        ScrollHint scroll_hint = PositionAtTop;
        if (prefs.gui_auto_scroll_percentage > 66) {
            scroll_hint = PositionAtBottom;
        } else if (prefs.gui_auto_scroll_percentage >= 33) {
            scroll_hint = PositionAtCenter;
        }
        scrollTo(index, scroll_hint);
    }

    /*
     * Nodes with "finfo->tree_type" of -1 have no ett_ value, and
     * are thus presumably leaf nodes and cannot be expanded.
     */
    if (fi->tree_type != -1) {
        g_assert(fi->tree_type >= 0 &&
                 fi->tree_type < num_tree_types);
        tree_expanded_set(fi->tree_type, TRUE);
    }
}
Esempio n. 2
0
static void
expand_tree(GtkTreeView *tree_view, GtkTreeIter *iter,
            GtkTreePath *path, gpointer user_data _U_)
{
    field_info   *finfo;
    GtkTreeModel *model;

    model = gtk_tree_view_get_model(tree_view);
    gtk_tree_model_get(model, iter, 1, &finfo, -1);
    g_assert(finfo);

    /* scroll the expanded item to reduce the need to do a manual scroll down
     * and provide faster navigation of deeper trees */

    if(prefs.gui_auto_scroll_on_expand)
        gtk_tree_view_scroll_to_cell(tree_view, path, NULL, TRUE, (prefs.gui_auto_scroll_percentage/100.0f), 0.0f);

    /*
     * Nodes with "finfo->tree_type" of -1 have no ett_ value, and
     * are thus presumably leaf nodes and cannot be expanded.
     */
    if (finfo->tree_type != -1)
        tree_expanded_set(finfo->tree_type, TRUE);

    if (finfo->tree_type != -1 && path) {
        /* Expand any subtrees that the user had left open */
        g_signal_handlers_block_by_func(tree_view, expand_tree, NULL);
        check_expand_trees(tree_view, model, path, iter, FALSE, FALSE);
        g_signal_handlers_unblock_by_func(tree_view, expand_tree, NULL);
    }
}
Esempio n. 3
0
void ProtoTree::collapseAll()
{
    int i;
    for(i=0; i < num_tree_types; i++) {
        tree_expanded_set(i, FALSE);
    }
    QTreeWidget::collapseAll();
}
Esempio n. 4
0
void ProtoTree::expandAll()
{
    int i;
    for(i=0; i < num_tree_types; i++) {
        tree_expanded_set(i, TRUE);
    }
    QTreeWidget::expandAll();
}
Esempio n. 5
0
void ProtoTree::collapse(const QModelIndex & index) {
    field_info *fi;

    fi = index.data(Qt::UserRole).value<field_info *>();
    g_assert(fi);

    /*
     * Nodes with "finfo->tree_type" of -1 have no ett_ value, and
     * are thus presumably leaf nodes and cannot be collapsed.
     */
    if (fi->tree_type != -1) {
        g_assert(fi->tree_type >= 0 &&
                 fi->tree_type < num_tree_types);
        tree_expanded_set(fi->tree_type, FALSE);
    }
}
Esempio n. 6
0
static int
dissect_mint_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
	guint32 offset, guint32 packet_length, guint received_via)
{
	proto_item *ti;
	proto_tree *mint_tree = NULL;
	proto_tree *mint_header_tree = NULL;
	proto_tree *mint_data_tree = NULL;
	proto_tree *mint_ctrl_tree = NULL;
	guint16 bytes_remaining;
	guint16 packet_type;
	guint8 type, length, header_length;
	guint32 message_type;
	guint8 element_length;
	static header_field_info *display_hfi_tlv_vals;

	packet_type = tvb_get_ntohs(tvb, offset + 12);

	col_set_str(pinfo->cinfo, COL_PROTOCOL, PROTO_SHORT_NAME);
	col_add_str(pinfo->cinfo, COL_INFO, val_to_str(packet_type,
		mint_packettype_vals, "Type 0x%02x"));

	ti = proto_tree_add_item(tree, hfi_mint, tvb,
		offset, packet_length, ENC_NA);
	mint_tree = proto_item_add_subtree(ti, ett_mint);

	ti = proto_tree_add_item(mint_tree, &hfi_mint_header, tvb,
		offset, 16, ENC_NA);
	mint_header_tree = proto_item_add_subtree(ti, ett_mint_header);

	/* MiNT header */
	proto_tree_add_item(mint_header_tree, &hfi_mint_header_unknown1, tvb,
		offset, 4, ENC_NA);
	offset += 4;
	proto_tree_add_item(mint_header_tree, &hfi_mint_header_dstid, tvb,
		offset, 4, ENC_NA);
	offset += 4;
	proto_tree_add_item(mint_header_tree, &hfi_mint_header_srcid, tvb,
		offset, 4, ENC_NA);
	offset += 4;
	proto_tree_add_item(mint_header_tree, &hfi_mint_header_dstdatatype, tvb,
		offset, 2, ENC_BIG_ENDIAN);
	offset += 2;
	proto_tree_add_item(mint_header_tree, &hfi_mint_header_srcdatatype, tvb,
		offset, 2, ENC_BIG_ENDIAN);
	offset += 2;
	/* FIXME: This is probably not the right way to determine the packet type.
	 *	  It's more likely something in mint_header_unknown1 but I haven't
	 *        found out what. */
	switch(packet_type) {
	case MINT_TYPE_DATA_UC:
		ti = proto_tree_add_item(mint_tree, &hfi_mint_data, tvb,
			offset, packet_length - 16, ENC_NA);
		mint_data_tree = proto_item_add_subtree(ti, ett_mint_data);
		proto_tree_add_item(mint_data_tree, &hfi_mint_data_unknown1, tvb,
			offset, 2, ENC_NA);
		offset += 2;
		/* Transported user frame */
		if (offset < packet_length)
			offset += dissect_eth_frame(tvb, pinfo, tree,
				offset, packet_length - offset);
		break;
	case MINT_TYPE_DATA_BCMC:
		ti = proto_tree_add_item(mint_tree, &hfi_mint_data, tvb,
			offset, packet_length - 16, ENC_NA);
		mint_data_tree = proto_item_add_subtree(ti, ett_mint_data);
		/* Decode as vlan only for now. To be verified against a capture
		 * with CoS != 0 */
		proto_tree_add_item(mint_data_tree, &hfi_mint_data_vlan, tvb,
			offset, 2, ENC_BIG_ENDIAN);
		offset += 2;
		proto_tree_add_item(mint_data_tree, &hfi_mint_data_seqno, tvb,
			offset, 4, ENC_NA);
		offset += 4;
		proto_tree_add_item(mint_data_tree, &hfi_mint_data_unknown1, tvb,
			offset, 4, ENC_NA);
		offset += 4;
		/* Transported user frame */
		if (offset < packet_length)
			offset += dissect_eth_frame(tvb, pinfo, tree,
				offset, packet_length - offset);
		break;
	case MINT_TYPE_CTRL_0x0c:
		ti = proto_tree_add_item(mint_tree, &hfi_mint_control, tvb,
			offset, packet_length - 16, ENC_NA);
		mint_ctrl_tree = proto_item_add_subtree(ti, ett_mint_ctrl);
		proto_tree_add_item(mint_ctrl_tree, &hfi_mint_control_32zerobytes, tvb,
			offset, 32, ENC_NA);
		offset += 32;

		proto_tree_add_item(mint_ctrl_tree, &hfi_mint_control_0x0c_unknown1, tvb,
			offset, 1, ENC_NA);
		offset += 1;
		proto_tree_add_item(mint_ctrl_tree, &hfi_mint_control_0x0c_unknown2, tvb,
			offset, 1, ENC_NA);
		offset += 1;
		proto_tree_add_item(mint_ctrl_tree, &hfi_mint_control_0x0c_unknown3, tvb,
			offset, 1, ENC_NA);
		offset += 1;
		header_length = tvb_get_guint8(tvb, offset);
		proto_tree_add_item(mint_ctrl_tree, &hfi_mint_control_0x0c_header_length, tvb,
			offset, 1, ENC_NA);
		offset += 1;
		message_type = tvb_get_ntohl(tvb, offset);
		proto_tree_add_item(mint_ctrl_tree, &hfi_mint_control_0x0c_message_type, tvb,
			offset, 4, ENC_NA);
		offset += 4;
		proto_tree_add_item(mint_ctrl_tree, &hfi_mint_control_0x0c_header_sender, tvb,
			offset, 4, ENC_NA);
		offset += 4;
		switch (message_type) {
			case 0x43534E50: /* CSNP */
				element_length = 12;
				display_hfi_tlv_vals = &hfi_mint_control_0x0c_type_csnp;
				break;
			case 0x48454C4F: /* HELO */
				element_length = 0;
				display_hfi_tlv_vals = &hfi_mint_control_0x0c_type_helo;
				break;
			case 0x4C535000: /* LSP */
				element_length = 8;
				display_hfi_tlv_vals = &hfi_mint_control_0x0c_type_lsp;
				break;
			case 0x50534E50: /* PSNP */
				element_length = 4;
				display_hfi_tlv_vals = &hfi_mint_control_0x0c_type_psnp;
				break;
			default:
				element_length = 0;
				display_hfi_tlv_vals = &hfi_mint_control_0x0c_type_unknown;
		}
		/* FIXME: This should go into the per message_type switch above */
		if (header_length > 12) {
			proto_tree_add_item(mint_ctrl_tree, &hfi_mint_control_0x0c_header_unknown, tvb,
				offset, header_length - 12, ENC_NA);
			offset += header_length - 12;
		}
		while (offset < packet_length - 2) {
			type = tvb_get_guint8(tvb, offset);
			proto_tree_add_item(mint_ctrl_tree, display_hfi_tlv_vals, tvb,
				offset, 1, ENC_NA);
			offset += 1;
			length = tvb_get_guint8(tvb, offset);
			/* FIXME: This is a hack - reliable array detection missing */
			if (type == 1 && length == 128) {
				proto_tree_add_item(mint_ctrl_tree, &hfi_mint_control_0x0c_array, tvb,
					offset, 1, ENC_NA);
				offset += 1;
				length = tvb_get_guint8(tvb, offset);
			}
			proto_tree_add_item(mint_ctrl_tree, &hfi_mint_control_0x0c_length, tvb,
				offset, 1, ENC_NA);
			offset += 1;
			if (offset + length > packet_length) {
				/* FIXME: print expert information */
				break;
			}
			if (type == 1 && element_length) {
				guint32 end_offset = offset + length;
				for (; offset < end_offset; offset += element_length) {
					proto_tree_add_item(mint_ctrl_tree, &hfi_mint_control_0x0c_element, tvb,
						offset, element_length, ENC_NA);
				}
			} else {
				proto_tree_add_item(mint_ctrl_tree, &hfi_mint_control_0x0c_value, tvb,
					offset, length, ENC_NA);
				offset += length;
			}
		}
		break;
	case MINT_TYPE_CTRL_0x1e:
		ti = proto_tree_add_item(mint_tree, &hfi_mint_control, tvb,
			offset, packet_length - 16, ENC_NA);
		mint_ctrl_tree = proto_item_add_subtree(ti, ett_mint_ctrl);
		proto_tree_add_item(mint_ctrl_tree, &hfi_mint_control_32zerobytes, tvb,
			offset, 32, ENC_NA);
		offset += 32;
		bytes_remaining = packet_length - offset;
		proto_tree_add_item(mint_ctrl_tree, &hfi_mint_control_0x1e_unknown, tvb,
			offset, bytes_remaining, ENC_NA);
		offset += bytes_remaining;
		break;
	case MINT_TYPE_ETH_0x22:
		ti = proto_tree_add_item(mint_tree, &hfi_mint_control, tvb,
			offset, packet_length - 16, ENC_NA);
		mint_ctrl_tree = proto_item_add_subtree(ti, ett_mint_ctrl);
		proto_tree_add_item(mint_ctrl_tree, &hfi_mint_control_32zerobytes, tvb,
			offset, 32, ENC_NA);
		offset += 32;
		proto_tree_add_item(mint_ctrl_tree, &hfi_mint_control_0x22_message, tvb,
			offset, 2, ENC_BIG_ENDIAN);
		offset += 2;
		while (offset < packet_length - 2) {
			proto_tree_add_item(mint_ctrl_tree, &hfi_mint_control_0x22_type, tvb,
				offset, 1, ENC_NA);
			offset += 1;
			length = tvb_get_guint8(tvb, offset);
			proto_tree_add_item(mint_ctrl_tree, &hfi_mint_control_0x22_length, tvb,
				offset, 1, ENC_NA);
			offset += 1;
			if (offset + length > packet_length) {
				/* print expert information */
				break;
			}
			proto_tree_add_item(mint_ctrl_tree, &hfi_mint_control_0x22_value, tvb,
				offset, length, ENC_NA);
			offset += length;
		}
		break;
	default:
		bytes_remaining = packet_length - offset;
		switch(received_via) {
		case PORT_MINT_CONTROL_TUNNEL:
		case ETHERTYPE_MINT:
			proto_tree_add_item(mint_tree, &hfi_mint_control_unknown1, tvb,
				offset, bytes_remaining, ENC_NA);
			break;
		case PORT_MINT_DATA_TUNNEL:
			proto_tree_add_item(mint_tree, &hfi_mint_data_unknown1, tvb,
				offset, bytes_remaining, ENC_NA);
			break;
		default:
			DISSECTOR_ASSERT_NOT_REACHED();
		}
		offset += bytes_remaining;
		break;
	}
#if defined MINT_DEVELOPMENT
	tree_expanded_set(ett_mint, TRUE);
	tree_expanded_set(ett_mint_ethshim, TRUE);
	tree_expanded_set(ett_mint_header, TRUE);
	tree_expanded_set(ett_mint_ctrl, TRUE);
	tree_expanded_set(ett_mint_data, TRUE);
#endif
	return offset;
}