コード例 #1
0
ファイル: packet-rtitcp.c プロジェクト: CharaD7/wireshark
    { 0, NULL }
};

static void rtitcp_util_add_error_attribute(proto_tree *attribute, tvbuff_t* tvb,
                             gint offset, guint size) {
    proto_tree_add_item(attribute, hf_rtitcp_control_attribute_error_code_value, tvb, offset, 4, ENC_BIG_ENDIAN);
    proto_tree_add_item(attribute, hf_rtitcp_control_attribute_error_code_description, tvb, offset + 4,
            size - 4, ENC_ASCII|ENC_NA);
}

static void rtitcp_util_add_locator_t(proto_tree *tree, packet_info *pinfo _U_, tvbuff_t * tvb,
                             gint offset, gboolean little_endian,
                             proto_item * rtitcp_message, gboolean * first_attribute) {
    gint32  kind;
    guint16 port;
    kind = tvb_get_guint16(tvb, offset+8, little_endian ? ENC_LITTLE_ENDIAN : ENC_BIG_ENDIAN);

    if (kind == 0xFFFF) {
        kind = LOCATOR_KIND_IPV4;
    } else {
        kind = LOCATOR_KIND_IPV6;
    }
    proto_tree_add_uint(tree, hf_rtitcp_locator_kind, tvb, offset+8, 2, kind);

    if (kind == LOCATOR_KIND_IPV4) {
        proto_tree_add_item(tree, hf_rtitcp_locator_port, tvb, offset+10, 2, ENC_BIG_ENDIAN);
        proto_tree_add_item(tree, hf_rtitcp_locator_ipv4, tvb, offset+12, 4, ENC_BIG_ENDIAN);

        port = tvb_get_guint16(tvb, offset+10, little_endian ? ENC_LITTLE_ENDIAN : ENC_BIG_ENDIAN);
        if (*first_attribute) {
            proto_item_append_text(rtitcp_message," (");
コード例 #2
0
ファイル: packet-gsm_cbsp.c プロジェクト: ssyram/wireshark
static gint
dissect_cbsp_tlvs(tvbuff_t *tvb, int base_offs, int length, packet_info *pinfo, proto_tree *tree)
{
	guint8 sms_encoding = SMS_ENCODING_7BIT;
	int offset = base_offs;

	while (offset - base_offs < length) {
		guint8 tag;		 /* Information Element Identifier */
		unsigned int len;	 /* Length of payload */
		unsigned int len_len = 0;/* Length of "length" field (may be 0) */
		proto_item *ti;
		proto_tree *att_tree, *subtree;
		guint32 tmp_u;
		int secs;

		tag = tvb_get_guint8(tvb, offset);
		offset++;

		switch (cbsp_att_tlvdef.def[tag].type) {
		case TLV_TYPE_TV:
			len = 1;
			len_len = 0;
			break;
		case TLV_TYPE_FIXED:
			len = cbsp_att_tlvdef.def[tag].fixed_len;
			len_len = 0;
			break;
		case TLV_TYPE_TLV:
			len = tvb_get_guint8(tvb, offset);
			break;
		case TLV_TYPE_TL16V:
			len = tvb_get_guint16(tvb, offset, ENC_BIG_ENDIAN);
			len_len = 2;
			break;
		default:
			return length;
		}

		att_tree = proto_tree_add_subtree_format(tree, tvb, offset-1, 1+len_len+len,
						ett_cbsp_ie, &ti, "IE: %s",
						val_to_str(tag, cbsp_iei_names, "Unknown 0x%02x"));
		proto_tree_add_item(att_tree, hf_cbsp_iei, tvb, offset-1, 1, ENC_NA);
		if (len_len)
			proto_tree_add_uint(att_tree, hf_cbsp_ie_len, tvb, offset, len_len, len);

		offset += len_len;

		switch (tag) {
		case CBSP_IEI_MSG_CONTENT:
			dissect_cbsp_content_ie(tvb, pinfo, offset, len, att_tree, sms_encoding, ti);
			break;
		case CBSP_IEI_OLD_SERIAL_NR:
			proto_tree_add_item_ret_uint(att_tree, hf_cbsp_old_serial_nr, tvb, offset, len, ENC_BIG_ENDIAN, &tmp_u);
			proto_item_append_text(ti, ": 0x%04x", tmp_u);
			break;
		case CBSP_IEI_NEW_SERIAL_NR:
			proto_tree_add_item_ret_uint(att_tree, hf_cbsp_new_serial_nr, tvb, offset, len, ENC_BIG_ENDIAN, &tmp_u);
			proto_item_append_text(ti, ": 0x%04x", tmp_u);
			break;
		case CBSP_IEI_CATEGORY:
			proto_tree_add_item_ret_uint(att_tree, hf_cbsp_category, tvb, offset, len, ENC_NA,&tmp_u);
			proto_item_append_text(ti, ": %s", val_to_str_const(tmp_u, cbsp_category_names, ""));
			break;
		case CBSP_IEI_REP_PERIOD:
			proto_tree_add_item_ret_uint(att_tree, hf_cbsp_rep_period, tvb, offset, len, ENC_BIG_ENDIAN, &tmp_u);
			proto_item_append_text(ti, ": %u", tmp_u);
			break;
		case CBSP_IEI_NUM_BCAST_REQ:
			proto_tree_add_item_ret_uint(att_tree, hf_cbsp_num_bcast_req, tvb, offset, len, ENC_BIG_ENDIAN, &tmp_u);
			proto_item_append_text(ti, ": %u", tmp_u);
			break;
		case CBSP_IEI_CAUSE:
			proto_tree_add_item_ret_uint(att_tree, hf_cbsp_cause, tvb, offset, len, ENC_NA, &tmp_u);
			proto_item_append_text(ti, ": %s", val_to_str_const(tmp_u, cbsp_cause_vals, ""));
			break;
		case CBSP_IEI_DCS:
			proto_tree_add_item_ret_uint(att_tree, hf_cbsp_dcs, tvb, offset, len, ENC_NA, &tmp_u);
			subtree = proto_item_add_subtree(att_tree, ett_cbsp_cbs_data_coding);
			sms_encoding = dissect_cbs_data_coding_scheme(tvb, pinfo, subtree, offset);
			proto_item_append_text(ti, ": 0x%02x", tmp_u);
			break;
		case CBSP_IEI_RECOVERY_IND:
			proto_tree_add_item(att_tree, hf_cbsp_recovery_ind, tvb, offset, len, ENC_NA);
			break;
		case CBSP_IEI_MSG_ID:
			proto_tree_add_item_ret_uint(att_tree, hf_cbsp_msg_id, tvb, offset, len, ENC_BIG_ENDIAN, &tmp_u);
			proto_item_append_text(ti, ": 0x%04x", tmp_u);
			break;
		case CBSP_IEI_EMERG_IND:
			proto_tree_add_item_ret_uint(att_tree, hf_cbsp_emerg_ind, tvb, offset, len, ENC_NA, &tmp_u);
			proto_item_append_text(ti, ": %s", val_to_str_const(tmp_u, cbsp_emerg_ind_vals, ""));
			break;
		case CBSP_IEI_WARN_TYPE:
			proto_tree_add_item(att_tree, hf_cbsp_warn_type, tvb, offset, len, ENC_NA);
			break;
		case CBSP_IEI_CHANNEL_IND:
			proto_tree_add_item_ret_uint(att_tree, hf_cbsp_channel_ind, tvb, offset, len, ENC_NA, &tmp_u);
			proto_item_append_text(ti, ": %s", val_to_str_const(tmp_u, cbsp_chan_ind_vals, ""));
			break;
		case CBSP_IEI_NUM_OF_PAGES:
			proto_tree_add_item_ret_uint(att_tree, hf_cbsp_num_of_pages, tvb, offset, len, ENC_NA, &tmp_u);
			proto_item_append_text(ti, ": %u", tmp_u);
			break;
		case CBSP_IEI_SCHEDULE_PERIOD:
			proto_tree_add_item(att_tree, hf_cbsp_sched_period, tvb, offset, len, ENC_NA);
			break;
		case CBSP_IEI_NUM_OF_RES_SLOTS:
			proto_tree_add_item(att_tree, hf_cbsp_num_of_res_slots, tvb, offset, len, ENC_NA);
			break;
		case CBSP_IEI_BCAST_MSG_TYPE:
			proto_tree_add_item_ret_uint(att_tree, hf_cbsp_bcast_msg_type, tvb, offset, len, ENC_NA, &tmp_u);
			proto_item_append_text(ti, ": %s", val_to_str_const(tmp_u, cbsp_bcast_msg_type_vals, ""));
			break;
		case CBSP_IEI_WARNING_PERIOD:
			secs = cbsp_warn_period_to_secs(tvb_get_guint8(tvb, offset));
			proto_tree_add_uint(att_tree, hf_cbsp_warning_period, tvb, offset, len, secs);
			proto_item_append_text(ti, ": %u (s)", secs);
			break;
		case CBSP_IEI_KEEP_ALIVE_REP_PERIOD:
			secs = cbsp_warn_period_to_secs(tvb_get_guint8(tvb, offset));
			proto_tree_add_uint(att_tree, hf_cbsp_keepalive_period, tvb, offset, len, secs);
			proto_item_append_text(ti, ": %u (s)", secs);
			break;
		case CBSP_IEI_CELL_LIST:
			dissect_cell_id_list_ie(tvb, pinfo, offset, len, att_tree, ti);
			break;
		case CBSP_IEI_NUM_BCAST_COMPL_LIST:
			dissect_bc_compl_list_ie(tvb, pinfo, offset, len, att_tree, ti);
			break;
		case CBSP_IEI_FAILURE_LIST:
			dissect_failure_list_ie(tvb, pinfo, offset, len, att_tree, ti);
			break;
		case CBSP_IEI_RR_LOADING_LIST:
			dissect_rr_load_list_ie(tvb, pinfo, offset, len, att_tree, ti);
			break;
		case CBSP_IEI_WARN_SEC_INFO:
			/* this element is bogus / not used anyway, no need for a dissector */
		default:
			/* Unknown/unsupported IE: Print raw payload in addition to IEI + Length printed above */
			proto_tree_add_item(att_tree, hf_cbsp_ie_payload, tvb, offset, len, ENC_NA);
			break;
		}

		offset += len;
	}

	return offset;
}