示例#1
0
static void
dissect_dmx_chan(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
	col_set_str(pinfo->cinfo, COL_PROTOCOL, "DMX Channels");
	col_clear(pinfo->cinfo, COL_INFO);

	if (tree != NULL) {
		static const char *chan_format[]   = {
			"%2u%% ",
			"0x%02x ",
			"%3u "
		};
		static const char *string_format[] = {
			"0x%03x: %s",
			"%3u: %s"
		};
		emem_strbuf_t *chan_str = ep_strbuf_new_label("");
		proto_item    *item;
		guint16        length,r,c,row_count;
		guint8         v;
		unsigned       offset   = 0;

		proto_tree    *ti = proto_tree_add_item(tree, proto_dmx_chan, tvb, offset, -1, ENC_NA);
		proto_tree    *dmx_chan_tree = proto_item_add_subtree(ti, ett_dmx_chan);

		length = tvb_reported_length_remaining(tvb, offset);

		row_count = (length / global_disp_col_count) + ((length % global_disp_col_count) == 0 ? 0 : 1);
		for (r = 0; r < row_count;r++) {
			for (c = 0;(c < global_disp_col_count) && (((r * global_disp_col_count) + c) < length);c++) {
				if ((global_disp_col_count >= 2) && ((c % (global_disp_col_count / 2)) == 0)) {
					ep_strbuf_append(chan_str, " ");
				}

				v = tvb_get_guint8(tvb, (offset + (r * global_disp_col_count) + c));
				if (global_disp_chan_val_type == 0) {
					v = (v * 100) / 255;
					if (v == 100) {
						ep_strbuf_append(chan_str, "FL ");
					} else {
						ep_strbuf_append_printf(chan_str, chan_format[global_disp_chan_val_type], v);
					}
				} else {
					ep_strbuf_append_printf(chan_str, chan_format[global_disp_chan_val_type], v);
				}
			}

			proto_tree_add_none_format(dmx_chan_tree, hf_dmx_chan_output_dmx_data, tvb,
							offset+(r * global_disp_col_count), c,
							string_format[global_disp_chan_nr_type],
							(r * global_disp_col_count) + 1, chan_str->str);
		}

		/* Add the real type hidden */
		item = proto_tree_add_item(dmx_chan_tree, hf_dmx_chan_output_data_filter, tvb,
						offset, length, ENC_NA );
		PROTO_ITEM_SET_HIDDEN(item);
	}
}
示例#2
0
static int
dissect_reason(tvbuff_t *tvb, int offset, proto_tree *tree)
{
    if (tree)
    {
        guint32 reason =
            tvb_get_ntohl(tvb, offset);
        proto_item *reason_item =
            proto_tree_add_item(tree, hf_vxi11_core_reason, tvb, offset, 4, FALSE);

        if (reason_item)
        {
            proto_tree *reason_tree =
                proto_item_add_subtree(reason_item, ett_vxi11_core_reason);

            proto_tree_add_item(reason_tree, hf_vxi11_core_reason_req_cnt, tvb, offset, 4, FALSE);
            proto_tree_add_item(reason_tree, hf_vxi11_core_reason_chr, tvb, offset, 4, FALSE);
            proto_tree_add_item(reason_tree, hf_vxi11_core_reason_end, tvb, offset, 4, FALSE);

            if (reason != 0)
            {
                emem_strbuf_t *strbuf = ep_strbuf_new_label(NULL);

                if (reason & VXI11_CORE_REASON_REQCNT)
                {
                    ep_strbuf_append(strbuf, "REQ_CNT, ");
                }
                if (reason & VXI11_CORE_REASON_CHR)
                {
                    ep_strbuf_append(strbuf, "CHR, ");
                }
                if (reason & VXI11_CORE_REASON_END)
                {
                    ep_strbuf_append(strbuf, "END, ");
                }

                ep_strbuf_truncate(strbuf, strbuf->len - 2);
                proto_item_append_text(reason_item, " (%s)", strbuf->str);
            }
        }
    }

    return offset + 4;
}
示例#3
0
static int
dissect_flags(tvbuff_t *tvb, int offset, proto_tree *tree)
{
    if (tree)
    {
        guint32 flags =
            tvb_get_ntohl(tvb, offset);
        proto_item *flags_item =
            proto_tree_add_item(tree, hf_vxi11_core_flags, tvb, offset, 4, FALSE);

        if (flags_item)
        {
            proto_tree *flags_tree =
                proto_item_add_subtree(flags_item, ett_vxi11_core_flags);

            proto_tree_add_item(flags_tree, hf_vxi11_core_flag_wait_lock, tvb, offset, 4, FALSE);
            proto_tree_add_item(flags_tree, hf_vxi11_core_flag_end, tvb, offset, 4, FALSE);
            proto_tree_add_item(flags_tree, hf_vxi11_core_flag_term_chr_set, tvb, offset, 4, FALSE);

            if (flags != 0)
            {
                emem_strbuf_t *strbuf = ep_strbuf_new_label(NULL);

                if (flags & VXI11_CORE_FLAG_WAITLOCK)
                {
                    ep_strbuf_append(strbuf, "WAIT_LOCK, ");
                }
                if (flags & VXI11_CORE_FLAG_END)
                {
                    ep_strbuf_append(strbuf, "END, ");
                }
                if (flags & VXI11_CORE_FLAG_TERMCHRSET)
                {
                    ep_strbuf_append(strbuf, "TERM_CHR_SET, ");
                }

                ep_strbuf_truncate(strbuf, strbuf->len - 2);
                proto_item_append_text(flags_item, " (%s)", strbuf->str);
            }
        }
    }

    return offset + 4;
}