static int
dissect_rs_pgo_query_result_t (tvbuff_t * tvb, int offset,
			       packet_info * pinfo, proto_tree * parent_tree,
			       guint8 * drep)
{
  proto_item *item = NULL;
  proto_tree *tree = NULL;
  int old_offset = offset;
  guint32 st;
  dcerpc_info *di;
  const char *status;
#define error_status_ok 0

  /*
     typedef union switch (signed32 status) tagged_union {
     case error_status_ok:
     rs_pgo_result_t     result;

     default:
     ;                      * empty branch of union *

     } rs_pgo_query_result_t;
   */

  di = (dcerpc_info *)pinfo->private_data;
  if (di->conformant_run)
    {
      return offset;
    }

  if (parent_tree)
    {
      item = proto_tree_add_text (parent_tree, tvb, offset, -1,
				  "rs_pgo_query_result_t");
      tree = proto_item_add_subtree (item, ett_rs_pgo_query_result_t);
    }

  offset =
    dissect_ndr_uint32 (tvb, offset, pinfo, tree, drep,
			hf_rs_pgo_query_result_t, &st);
  status = val_to_str_ext (st, &dce_error_vals_ext, "%u");

  if (check_col (pinfo->cinfo, COL_INFO))
    col_append_fstr (pinfo->cinfo, COL_INFO, " status:%s ", status);

  offset += 4;			/* XXX */

  switch (st)
    {
    case error_status_ok:
      offset = dissect_rs_pgo_result_t (tvb, offset, pinfo, tree, drep);
      break;
    default:
      ;

    }

  proto_item_set_len (item, offset - old_offset);
  return offset;
}
/* Code to actually dissect the packets */
static guint dissect_one_tlv(tvbuff_t *tvb, proto_tree *tree,
                guint offset)
{
    proto_item *ti;
    proto_tree *tlv_tree = proto_tree_add_subtree(tree, tvb, offset, 0, ett_pp_tlv, &ti, "Property");

    guint len;
    guint pad_len;

    guint type = tvb_get_ntohs(tvb, offset);
    const char *name = val_to_str_ext(type, &pp_pid_vals_ext, TYPE_UNKNOWN);
    proto_item_append_text(ti, " : %s", name);

    proto_tree_add_item(tlv_tree, hf_pp_pid_type, tvb, offset, 2, ENC_BIG_ENDIAN);
    offset += 2;

    len = tvb_get_ntohs(tvb, offset);
    proto_item_set_len(ti, 4 + len);

    proto_tree_add_item(tlv_tree, hf_pp_pid_len, tvb, offset, 2, ENC_BIG_ENDIAN);
    offset += 2;

    proto_tree_add_item(tlv_tree, hf_pp_pid_value, tvb, offset, len, ENC_NA);
    offset += len;

    pad_len = ~(offset-1) & 3;
    if(pad_len)
    {
        proto_tree_add_item(tlv_tree, hf_pp_pid_pad_bytes, tvb, offset, pad_len, ENC_NA);
        offset += pad_len;
    }
    return offset;
}
static int
dissect_error_status_t (tvbuff_t * tvb, int offset,
                        packet_info * pinfo, proto_tree * parent_tree,
                        dcerpc_info *di, guint8 * drep)
{
  proto_item *item;
  proto_tree *tree;
  int old_offset = offset;
  guint32 st;
  const char *st_str;

  if (di->conformant_run)
  {
    return offset;
  }

  item = proto_tree_add_text (parent_tree, tvb, offset, -1, "error_status_t");
  tree = proto_item_add_subtree (item, ett_error_status_t);

  offset =
    dissect_ndr_uint32 (tvb, offset, pinfo, tree, di, drep, hf_error_status_t,
                        &st);
  st_str = val_to_str_ext (st, &dce_error_vals_ext, "%u");

  col_append_fstr (pinfo->cinfo, COL_INFO, " st:%s ", st_str);

  proto_item_set_len (item, offset - old_offset);
  return offset;
}
static int
conv_dissect_who_are_you2_resp (tvbuff_t *tvb, int offset,
				packet_info *pinfo, proto_tree *tree,
				dcerpc_info *di, guint8 *drep)
{
	/*
	 *         [out]   unsigned32      *seq,
	 *         [out]   uuid_t          *cas_uuid,
	 *
	 *         [out]   unsigned32      *st
	 */
	guint32 seq, st;
	e_guid_t cas_uuid;

	offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, di, drep, hf_conv_who_are_you2_resp_seq, &seq);
	offset = dissect_ndr_uuid_t (tvb, offset, pinfo, tree, di, drep, hf_conv_who_are_you2_resp_casuuid, &cas_uuid);
	offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, di, drep, hf_conv_rc, &st);

	col_add_fstr(pinfo->cinfo, COL_INFO,
			     "conv_who_are_you2 response seq:%u st:%s cas:%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
			     seq, val_to_str_ext(st, &dce_error_vals_ext, "%u"),
			     cas_uuid.data1, cas_uuid.data2, cas_uuid.data3,
			     cas_uuid.data4[0], cas_uuid.data4[1], cas_uuid.data4[2], cas_uuid.data4[3],
			     cas_uuid.data4[4], cas_uuid.data4[5], cas_uuid.data4[6], cas_uuid.data4[7]);

	return offset;
}
/*
 * dissect lwapp control packets.  This is not fully implemented,
 * but it's a good start.
 */
static void
dissect_control(tvbuff_t *tvb, packet_info *pinfo,
                         proto_tree *tree)
{
    CNTL_Header  header;
    proto_tree  *control_tree;
    tvbuff_t    *next_tvb;

    /* Set up structures needed to add the protocol subtree and manage it */
    proto_item      *ti;
    gint             offset=0;

    /* Make entries in Protocol column and Info column on summary display */
    col_set_str(pinfo->cinfo, COL_PROTOCOL, "LWAPP");
    col_set_str(pinfo->cinfo, COL_INFO,
                    "CNTL ");

    /* Copy our header */
    tvb_memcpy(tvb, (guint8*) &header, offset, sizeof(header));

    /*
     * Fix the length (network byte ordering), and set our version &
     * slot id
     */
    header.length = g_ntohs(header.length);

    if (check_col(pinfo->cinfo, COL_INFO)) {
        col_append_str(pinfo->cinfo, COL_INFO,
            val_to_str_ext(header.type, &control_msg_vals_ext, "Bad Type: 0x%02x"));
    }

    /* In the interest of speed, if "tree" is NULL, don't do any work not
       necessary to generate protocol tree items. */
    if (tree) {
        /* create display subtree for the protocol */
        ti = proto_tree_add_item(tree, proto_lwapp_control, tvb, offset,
                                 -1, ENC_NA);
        control_tree = proto_item_add_subtree(ti, ett_lwapp_control);

        proto_tree_add_uint(control_tree, hf_lwapp_control_type,
                               tvb, offset, 1, header.type);
        offset++;

        proto_tree_add_uint(control_tree, hf_lwapp_control_seq_no,
                               tvb, offset, 1, header.seqNo);
        offset++;

        proto_tree_add_uint(control_tree, hf_lwapp_control_length,
                               tvb, offset, 2, header.length);
        offset += 2;

        /* Dissect rest of packet as data */
        next_tvb = tvb_new_subset_remaining(tvb, offset);
        call_dissector(data_handle,next_tvb, pinfo, tree);
    }

} /* dissect_control */
static gint
dissect_om2k_attr_unkn(tvbuff_t *tvb, gint offset, gint len, gint iei, proto_tree *tree)
{
	proto_tree_add_bytes_format(tree, hf_om2k_unknown_val, tvb,
				    offset, len, NULL,
				    "%s: %s",
				    val_to_str_ext(iei, &om2k_attr_vals_ext, "0x%02x"),
				    tvb_bytes_to_str(wmem_packet_scope(), tvb, offset, len));
	return len;
}
Exemple #7
0
static void
dissect_trmac(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
	proto_tree	*mac_tree = NULL;
	proto_item	*ti;
	int		mv_length, sv_offset, sv_additional;
	guint8		mv_val;

	col_set_str(pinfo->cinfo, COL_PROTOCOL, "TR MAC");
	col_clear(pinfo->cinfo, COL_INFO);

	mv_val = tvb_get_guint8(tvb, 3);

	/* Interpret the major vector */
	col_add_str(pinfo->cinfo, COL_INFO,
		    val_to_str_ext(mv_val, &major_vector_vs_ext, "Unknown Major Vector: %u"));

	if (tree) {
		mv_length = tvb_get_ntohs(tvb, 0);
		ti = proto_tree_add_item(tree, proto_trmac, tvb, 0, mv_length, ENC_NA);
		mac_tree = proto_item_add_subtree(ti, ett_tr_mac);

		proto_tree_add_uint(mac_tree, hf_trmac_mv, tvb, 3, 1, mv_val);
		proto_tree_add_uint_format_value(mac_tree, hf_trmac_length, tvb, 0, 2, mv_length,
				"%d bytes", mv_length);
		proto_tree_add_uint(mac_tree, hf_trmac_srcclass, tvb, 2, 1, tvb_get_guint8(tvb, 2) & 0x0f);
		proto_tree_add_uint(mac_tree, hf_trmac_dstclass, tvb, 2, 1, tvb_get_guint8(tvb, 2) >> 4 );

		/* interpret the subvectors */
		sv_offset = 4;
		while (sv_offset < mv_length) {
			sv_additional = sv_text(tvb, sv_offset, pinfo, mac_tree);

			/* if this is a bad packet, we could get a 0-length added here,
			 * looping forever */
			if (sv_additional > 0)
				sv_offset += sv_additional;
			else
				break;
		}
	}
}
static int
conv_dissect_who_are_you_resp (tvbuff_t *tvb, int offset,
			       packet_info *pinfo, proto_tree *tree,
			       dcerpc_info *di, guint8 *drep)
{
	/*
	 *         [out]   unsigned32      *seq,
	 *         [out]   unsigned32      *st
	 */
	guint32 seq, st;

	offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, di, drep, hf_conv_who_are_you_resp_seq, &seq);
	offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, di, drep, hf_conv_rc, &st);


	col_add_fstr(pinfo->cinfo, COL_INFO, "conv_who_are_you response seq:%u st:%s",
			     seq, val_to_str_ext(st, &dce_error_vals_ext, "%u"));

	return offset;
}
Exemple #9
0
static void
dissect_amr_wb_if2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
    int    offset = 0;
    guint8 octet;

    proto_tree_add_item(tree, hf_amr_wb_if2_ft, tvb, offset, 1, ENC_BIG_ENDIAN);
    octet = (tvb_get_guint8(tvb,offset) & 0xf0) >> 4;

    if (octet == AMR_WB_SID) {
        proto_tree_add_text(tree, tvb, offset+1, 4, "Speech data");
        proto_tree_add_item(tree, hf_amr_if2_sti, tvb, offset+5, 1, ENC_BIG_ENDIAN);
        proto_tree_add_item(tree, hf_amr_wb_if2_sti_mode_ind, tvb, offset+5, 1, ENC_BIG_ENDIAN);
        return;
    }
    if (octet == AMR_NO_TRANS)
        return;
    proto_tree_add_text(tree, tvb, offset+1, -1, "Speech data");

    col_append_fstr(pinfo->cinfo, COL_INFO, "%s ",
            val_to_str_ext(octet, &amr_wb_codec_mode_request_vals_ext, "Unknown (%d)" ));
}
static void
dissect_abis_om2000(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
	proto_item *ti;
	proto_tree *om2k_tree;
	guint16     msg_code;
	guint8      tmp;

	int offset;

	if ((tree == NULL) && (pinfo->cinfo == NULL))
		return;   /* no dissection required */

	col_set_str(pinfo->cinfo, COL_PROTOCOL, "OM2000");
	/* Don't do col_clear() so this dissector can append to COL_INFO*/

	offset = 0;

	ti = proto_tree_add_item(tree, proto_abis_om2000,
				 tvb, 0, -1, ENC_NA);
	om2k_tree = proto_item_add_subtree(ti, ett_om2000);

	msg_code = tvb_get_ntohs(tvb, offset);
	proto_tree_add_item(om2k_tree, hf_om2k_msg_code, tvb, offset,
			    2, ENC_BIG_ENDIAN);
	offset += 2;

	offset += dissect_om2k_mo(tvb, offset, pinfo, om2k_tree);  /* appends to COL_INFO */

	col_append_fstr(pinfo->cinfo, COL_INFO, " %s ",
			val_to_str_ext(msg_code, &om2k_msgcode_vals_ext,
				   "unknown 0x%04x"));

	if (tree == NULL)
		return;   /* No refs to COL_...  beyond this point */

	proto_item_append_text(ti, " %s ",
			       val_to_str_ext(msg_code, &om2k_msgcode_vals_ext,
					  "unknown 0x%04x"));

	switch (msg_code) {
	case 0x74: /* Operational Info */
		tmp = tvb_get_guint8(tvb, offset+1);
		proto_item_append_text(ti, ": %s",
				       val_to_str(tmp, om2k_oip_vals,
						  "unknown 0x%02x"));
		break;
	case 0x1A: /* CON Configuration Result */
	case 0x66: /* IS Configuration Result */
	case 0x82: /* RX Configuration Result */
	case 0xA6: /* TF Configuration Result */
	case 0xAE: /* TS Configuration Result */
	case 0xB6: /* TX Configuration Result */
	case 0xE2: /* DP Configuration Result */
	case 0xF6: /* DP Configuration Result */
		tmp = tvb_get_guint8(tvb, offset+1);
		proto_item_append_text(ti, ": %s",
				       val_to_str(tmp, om2k_aip_vals,
						  "unknown 0x%02x"));
		break;
	default:
		break;
	}
	dissect_om2k_attrs(tvb, offset, om2k_tree);
}
Exemple #11
0

	col_set_str(pinfo->cinfo, COL_PROTOCOL, "DSI");
	col_clear(pinfo->cinfo, COL_INFO);

	dsi_flags = tvb_get_guint8(tvb, 0);
	dsi_command = tvb_get_guint8(tvb, 1);
	dsi_requestid = tvb_get_ntohs(tvb, 2);
	dsi_code = tvb_get_ntohl(tvb, 4);
	dsi_length = tvb_get_ntohl(tvb, 8);
	dsi_reserved = tvb_get_ntohl(tvb, 12);

	col_add_fstr(pinfo->cinfo, COL_INFO, "%s %s (%u)",
			val_to_str(dsi_flags, flag_vals,
				   "Unknown flag (0x%02x)"),
			val_to_str_ext(dsi_command, &func_vals_ext,
				   "Unknown function (0x%02x)"),
			dsi_requestid);

	dsi_ti = proto_tree_add_item(tree, proto_dsi, tvb, 0, -1, ENC_NA);
	dsi_tree = proto_item_add_subtree(dsi_ti, ett_dsi);

	if (tree) {
		proto_tree_add_uint(dsi_tree, hf_dsi_flags, tvb,
			0, 1, dsi_flags);
		proto_tree_add_uint(dsi_tree, hf_dsi_command, tvb,
			1, 1, dsi_command);
		proto_tree_add_uint(dsi_tree, hf_dsi_requestid, tvb,
			2, 2, dsi_requestid);
		switch (dsi_flags) {

		case DSIFL_REQUEST:
Exemple #12
0
static gint
dissect_hid_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
        gint offset, guint report_type)
{
    gboolean     shortcut_helper = FALSE;
    unsigned int protocol_code;
    unsigned int modifier;
    unsigned int keycode;
    unsigned int leds;
    unsigned int buttons;

    proto_tree_add_item(tree, hf_bthid_protocol_code, tvb, offset, 1, ENC_BIG_ENDIAN);
    protocol_code = tvb_get_guint8(tvb, offset);
    col_append_fstr(pinfo->cinfo, COL_INFO, " - %s", val_to_str_const(protocol_code, protocol_code_vals, "unknown type"));
    offset += 1;

    switch (protocol_code) {
        case 0x01: /* Keyboard */
            if (report_type == 0x02) { /* Output - LEDs */
                proto_tree_add_item(tree, hf_bthid_data_keyboard_leds_constants, tvb, offset, 1, ENC_BIG_ENDIAN);
                proto_tree_add_item(tree, hf_bthid_data_keyboard_leds_kana, tvb, offset, 1, ENC_BIG_ENDIAN);
                proto_tree_add_item(tree, hf_bthid_data_keyboard_leds_compose, tvb, offset, 1, ENC_BIG_ENDIAN);
                proto_tree_add_item(tree, hf_bthid_data_keyboard_leds_scroll_lock, tvb, offset, 1, ENC_BIG_ENDIAN);
                proto_tree_add_item(tree, hf_bthid_data_keyboard_leds_caps_lock, tvb, offset, 1, ENC_BIG_ENDIAN);
                proto_tree_add_item(tree, hf_bthid_data_keyboard_leds_num_lock, tvb, offset, 1, ENC_BIG_ENDIAN);
                leds = tvb_get_guint8(tvb, offset);

            col_append_str(pinfo->cinfo, COL_INFO, " - LEDs: ");
            if (leds & 0x01) {
                col_append_str(pinfo->cinfo, COL_INFO, "NumLock");
                shortcut_helper = TRUE;
            }
            if (leds & 0x02) {
                if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, ", ");
                col_append_str(pinfo->cinfo, COL_INFO, "CapsLock");
                shortcut_helper = TRUE;
            }
            if (leds & 0x04) {
                if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, ", ");
                col_append_str(pinfo->cinfo, COL_INFO, "ScrollLock");
                shortcut_helper = TRUE;
            }
            if (leds & 0x08) {
                if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, ", ");
                col_append_str(pinfo->cinfo, COL_INFO, "Compose");
                shortcut_helper = TRUE;
            }
            if (leds & 0x10) {
                if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, ", ");
                col_append_str(pinfo->cinfo, COL_INFO, "Kana");
                shortcut_helper = TRUE;
            }
            if (leds & 0x20) {
                if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, ", ");
                col_append_str(pinfo->cinfo, COL_INFO, "Constant1");
                shortcut_helper = TRUE;
            }
            if (leds & 0x40) {
                if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, ", ");
                col_append_str(pinfo->cinfo, COL_INFO, "Constant2");
                shortcut_helper = TRUE;
            }
            if (leds & 0x80) {
                if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, ", ");
                col_append_str(pinfo->cinfo, COL_INFO, "Constant3");
                /*shortcut_helper = TRUE;*/
            }
            if (!leds) {
                col_append_str(pinfo->cinfo, COL_INFO, "none");
            }

                offset += 1;
                break;
            } else if (report_type != 0x01) {/* is not Input (Keys) */
                break;
            }

            proto_tree_add_item(tree, hf_bthid_data_keyboard_modifier_right_gui, tvb, offset, 1, ENC_BIG_ENDIAN);
            proto_tree_add_item(tree, hf_bthid_data_keyboard_modifier_right_alt, tvb, offset, 1, ENC_BIG_ENDIAN);
            proto_tree_add_item(tree, hf_bthid_data_keyboard_modifier_right_shift, tvb, offset, 1, ENC_BIG_ENDIAN);
            proto_tree_add_item(tree, hf_bthid_data_keyboard_modifier_right_ctrl, tvb, offset, 1, ENC_BIG_ENDIAN);
            proto_tree_add_item(tree, hf_bthid_data_keyboard_modifier_left_gui, tvb, offset, 1, ENC_BIG_ENDIAN);
            proto_tree_add_item(tree, hf_bthid_data_keyboard_modifier_left_alt, tvb, offset, 1, ENC_BIG_ENDIAN);
            proto_tree_add_item(tree, hf_bthid_data_keyboard_modifier_left_shift, tvb, offset, 1, ENC_BIG_ENDIAN);
            proto_tree_add_item(tree, hf_bthid_data_keyboard_modifier_left_ctrl, tvb, offset, 1, ENC_BIG_ENDIAN);
            modifier = tvb_get_guint8(tvb, offset);

            col_append_str(pinfo->cinfo, COL_INFO, " - ");
            if (modifier & 0x80) {
                col_append_str(pinfo->cinfo, COL_INFO, "RIGHT GUI");
                shortcut_helper = TRUE;
            }
            if (modifier & 0x40) {
                if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + ");
                col_append_str(pinfo->cinfo, COL_INFO, "RIGHT ALT");
                shortcut_helper = TRUE;
            }
            if (modifier & 0x20) {
                if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + ");
                col_append_str(pinfo->cinfo, COL_INFO, "RIGHT SHIFT");
                shortcut_helper = TRUE;
            }
            if (modifier & 0x10) {
                if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + ");
                col_append_str(pinfo->cinfo, COL_INFO, "RIGHT CTRL");
                shortcut_helper = TRUE;
            }
            if (modifier & 0x08) {
                if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + ");
                col_append_str(pinfo->cinfo, COL_INFO, "LEFT GUI");
                shortcut_helper = TRUE;
            }
            if (modifier & 0x04) {
                if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + ");
                col_append_str(pinfo->cinfo, COL_INFO, "LEFT ALT");
                shortcut_helper = TRUE;
            }
            if (modifier & 0x02) {
                if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + ");
                col_append_str(pinfo->cinfo, COL_INFO, "LEFT SHIFT");
                shortcut_helper = TRUE;
            }
            if (modifier & 0x01) {
                if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + ");
                col_append_str(pinfo->cinfo, COL_INFO, "LEFT CTRL");
                shortcut_helper = TRUE;
            }
            offset += 1;

            proto_tree_add_item(tree, hf_bthid_data_keyboard_reserved, tvb, offset, 1, ENC_BIG_ENDIAN);
            offset += 1;

            proto_tree_add_item(tree, hf_bthid_data_keyboard_keycode_1, tvb, offset, 1, ENC_BIG_ENDIAN);
            keycode = tvb_get_guint8(tvb, offset);
            offset += 1;

            if (keycode) {
                if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + ");
                col_append_fstr(pinfo->cinfo, COL_INFO, "%s", val_to_str_ext(keycode, &keycode_vals_ext, "Unknown"));
                shortcut_helper = TRUE;
            }

            proto_tree_add_item(tree, hf_bthid_data_keyboard_keycode_2, tvb, offset, 1, ENC_BIG_ENDIAN);
            keycode = tvb_get_guint8(tvb, offset);
            offset += 1;

            if (keycode) {
                if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + ");
                col_append_fstr(pinfo->cinfo, COL_INFO, "%s", val_to_str_ext(keycode, &keycode_vals_ext, "Unknown"));
                shortcut_helper = TRUE;
            }

            proto_tree_add_item(tree, hf_bthid_data_keyboard_keycode_3, tvb, offset, 1, ENC_BIG_ENDIAN);
            keycode = tvb_get_guint8(tvb, offset);
            offset += 1;

            if (keycode) {
                if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + ");
                col_append_fstr(pinfo->cinfo, COL_INFO, "%s", val_to_str_ext(keycode, &keycode_vals_ext, "Unknown"));
                shortcut_helper = TRUE;
            }

            proto_tree_add_item(tree, hf_bthid_data_keyboard_keycode_4, tvb, offset, 1, ENC_BIG_ENDIAN);
            keycode = tvb_get_guint8(tvb, offset);
            offset += 1;

            if (keycode) {
                if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + ");
                col_append_fstr(pinfo->cinfo, COL_INFO, "%s", val_to_str_ext(keycode, &keycode_vals_ext, "Unknown"));
                shortcut_helper = TRUE;
            }

            proto_tree_add_item(tree, hf_bthid_data_keyboard_keycode_5, tvb, offset, 1, ENC_BIG_ENDIAN);
            keycode = tvb_get_guint8(tvb, offset);
            offset += 1;

            if (keycode) {
                if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + ");
                col_append_fstr(pinfo->cinfo, COL_INFO, "%s", val_to_str_ext(keycode, &keycode_vals_ext, "Unknown"));
                shortcut_helper = TRUE;
            }

            proto_tree_add_item(tree, hf_bthid_data_keyboard_keycode_6, tvb, offset, 1, ENC_BIG_ENDIAN);
            keycode = tvb_get_guint8(tvb, offset);
            offset += 1;

            if (keycode) {
                if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + ");
                col_append_fstr(pinfo->cinfo, COL_INFO, "%s", val_to_str_ext(keycode, &keycode_vals_ext, "Unknown"));
                shortcut_helper = TRUE;
            }

            if (shortcut_helper == FALSE) {
                col_append_str(pinfo->cinfo, COL_INFO, "<action key up>");
            }

            break;
        case 0x02: /* Mouse */
            proto_tree_add_item(tree, hf_bthid_data_mouse_button_8, tvb, offset, 1, ENC_BIG_ENDIAN);
            proto_tree_add_item(tree, hf_bthid_data_mouse_button_7, tvb, offset, 1, ENC_BIG_ENDIAN);
            proto_tree_add_item(tree, hf_bthid_data_mouse_button_6, tvb, offset, 1, ENC_BIG_ENDIAN);
            proto_tree_add_item(tree, hf_bthid_data_mouse_button_5, tvb, offset, 1, ENC_BIG_ENDIAN);
            proto_tree_add_item(tree, hf_bthid_data_mouse_button_4, tvb, offset, 1, ENC_BIG_ENDIAN);
            proto_tree_add_item(tree, hf_bthid_data_mouse_button_middle, tvb, offset, 1, ENC_BIG_ENDIAN);
            proto_tree_add_item(tree, hf_bthid_data_mouse_button_right, tvb, offset, 1, ENC_BIG_ENDIAN);
            proto_tree_add_item(tree, hf_bthid_data_mouse_button_left, tvb, offset, 1, ENC_BIG_ENDIAN);
            buttons = tvb_get_guint8(tvb, offset);
            offset += 1;

            if (buttons) col_append_str(pinfo->cinfo, COL_INFO, " - ");
            if (buttons & 0x01) {
                col_append_str(pinfo->cinfo, COL_INFO, "Button LEFT");
                shortcut_helper = TRUE;
            }
            if (buttons & 0x02) {
                if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + ");
                col_append_str(pinfo->cinfo, COL_INFO, "Button RIGHT");
                shortcut_helper = TRUE;
            }
            if (buttons & 0x04) {
                if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + ");
                col_append_str(pinfo->cinfo, COL_INFO, "Button MIDDLE");
            }
            if (buttons & 0x08) {
                if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + ");
                col_append_str(pinfo->cinfo, COL_INFO, "Button 4");
                shortcut_helper = TRUE;
            }
            if (buttons & 0x10) {
                if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + ");
                col_append_str(pinfo->cinfo, COL_INFO, "Button 5");
                shortcut_helper = TRUE;
            }
            if (buttons & 0x20) {
                if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + ");
                col_append_str(pinfo->cinfo, COL_INFO, "Button 6");
                shortcut_helper = TRUE;
            }
            if (buttons & 0x40) {
                if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + ");
                col_append_str(pinfo->cinfo, COL_INFO, "Button 7");
                shortcut_helper = TRUE;
            }
            if (buttons & 0x80) {
                if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + ");
                col_append_str(pinfo->cinfo, COL_INFO, "Button 8");
                /* Not necessary, this is the last case where it is used
                 * shortcut_helper = TRUE;
                 */
            }

            proto_tree_add_item(tree, hf_bthid_data_mouse_x_displacement, tvb, offset, 1, ENC_LITTLE_ENDIAN);
            offset += 1;

            proto_tree_add_item(tree, hf_bthid_data_mouse_y_displacement, tvb, offset, 1, ENC_LITTLE_ENDIAN);
            offset += 1;

            /* not really in HID Specification */
            if (tvb_length_remaining(tvb, offset)) {
                proto_tree_add_item(tree, hf_bthid_data_mouse_horizontal_scroll_wheel, tvb, offset, 1, ENC_BIG_ENDIAN);
                offset += 1;
            }

            /* not really in HID Specification */
            if (tvb_length_remaining(tvb, offset)) {
                proto_tree_add_item(tree, hf_bthid_data_mouse_vertical_scroll_wheel, tvb, offset, 1, ENC_BIG_ENDIAN);
                offset += 1;
            }

            if (tvb_length_remaining(tvb, offset)) {
                proto_tree_add_item(tree, hf_bthid_data, tvb, offset, -1, ENC_NA);
                offset += tvb_length_remaining(tvb, offset);
            }
            break;
    }

    return offset;
}
Exemple #13
0
static int
dissect_trmac(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
	proto_tree	*mac_tree = NULL;
	proto_item	*ti;
	int		mv_length, sv_offset, sv_additional;
	guint8		mv_val;

	col_set_str(pinfo->cinfo, COL_PROTOCOL, "TR MAC");
	col_clear(pinfo->cinfo, COL_INFO);

	mv_val = tvb_get_guint8(tvb, 3);

	/* Interpret the major vector */
	col_add_str(pinfo->cinfo, COL_INFO,
		    val_to_str_ext(mv_val, &major_vector_vs_ext, "Unknown Major Vector: %u"));

	if (tree) {
		mv_length = tvb_get_ntohs(tvb, 0);
		ti = proto_tree_add_item(tree, proto_trmac, tvb, 0, mv_length, ENC_NA);
		mac_tree = proto_item_add_subtree(ti, ett_tr_mac);

		proto_tree_add_uint(mac_tree, hf_trmac_mv, tvb, 3, 1, mv_val);
		proto_tree_add_uint_format_value(mac_tree, hf_trmac_length, tvb, 0, 2, mv_length,
				"%d bytes", mv_length);
		proto_tree_add_uint(mac_tree, hf_trmac_srcclass, tvb, 2, 1, tvb_get_guint8(tvb, 2) & 0x0f);
		proto_tree_add_uint(mac_tree, hf_trmac_dstclass, tvb, 2, 1, tvb_get_guint8(tvb, 2) >> 4 );

		/* interpret the subvectors */
		sv_offset = 4;
		while (sv_offset < mv_length) {
Exemple #14
0
/* Sub-vectors */
static int
sv_text(tvbuff_t *tvb, int svoff, packet_info *pinfo, proto_tree *tree)
{
	guint	sv_length, sv_id;
	guint16	beacon_type, ring;
	guint32	error_report_timer_value;

	proto_tree	*sv_tree, *sv_subtree;
	proto_item	*sv_item, *len_item, *ti;

	guchar		errors[6];	/* isolating or non-isolating */

	sv_tree = proto_tree_add_subtree(tree, tvb, svoff+0, 1, ett_tr_sv, &sv_item, "Subvector");

	sv_length = tvb_get_guint8(tvb, svoff+0);
	len_item = proto_tree_add_item(sv_tree, hf_trmac_sv_len, tvb, svoff+0, 1, ENC_BIG_ENDIAN);

	/* Check the SV length; it must be at least 2, to include
	   the subvector length and indicator. */
	if (sv_length < 2) {
		expert_add_info_format(pinfo, len_item, &ei_trmac_sv_len,
			"Invalid subvector: length < 2");
		return 0;	/* tells our caller to give up */
	}

	sv_id = tvb_get_guint8(tvb, svoff+1);
	proto_tree_add_item(sv_tree, hf_trmac_sv_id, tvb, svoff+1, 1, ENC_BIG_ENDIAN);
	proto_item_append_text(sv_item, " (%s)", val_to_str_ext(sv_id, &subvector_vs_ext, "Unknown subvector ID 0x%02X"));

	switch(sv_id) {
		case 0x01: /* Beacon Type */
			if (sv_length != 4) {
				expert_add_info_format(pinfo, len_item, &ei_trmac_sv_len,
				    "Subvector length is != 4");
				break;
			}
			beacon_type = tvb_get_ntohs(tvb, svoff+2);
			proto_tree_add_item(sv_tree, hf_trmac_beacon_type, tvb, svoff+2, sv_length-2, ENC_BIG_ENDIAN);
			proto_item_append_text(sv_item,
					": %s", val_to_str(beacon_type, beacon_vs, "Illegal value: %d"));
			break;

		case 0x02: /* Upstream Neighbor's Address */
			if (sv_length != 8) {
				expert_add_info_format(pinfo, len_item, &ei_trmac_sv_len,
				    "Subvector length is != 8");
				break;
			}
			proto_tree_add_item(sv_tree, hf_trmac_naun, tvb, svoff+2, sv_length-2, ENC_NA);
			proto_item_append_text(sv_item, ": %s",
					tvb_ether_to_str(tvb, svoff+2));
			break;

		case 0x03: /* Local Ring Number */
			if (sv_length != 4) {
				expert_add_info_format(pinfo, len_item, &ei_trmac_sv_len,
				    "Subvector length is != 4");
				break;
			}
			ring = tvb_get_ntohs(tvb, svoff+2);
			proto_tree_add_item(sv_tree, hf_trmac_local_ring_number, tvb, svoff+2, sv_length-2, ENC_BIG_ENDIAN);
			proto_item_append_text(sv_item,
				": 0x%04X (%d)", ring, ring);
			break;

		case 0x04: /* Assign Physical Drop Number */
			if (sv_length != 6) {
				expert_add_info_format(pinfo, len_item, &ei_trmac_sv_len,
				    "Subvector length is != 6");
				break;
			}
			proto_tree_add_item(sv_tree, hf_trmac_assign_physical_drop_number, tvb, svoff+2, sv_length-2, ENC_BIG_ENDIAN);
			proto_item_append_text(sv_item,
				": 0x%08X", tvb_get_ntohl(tvb, svoff+2) );
			break;

		case 0x05: /* Error Report Timer Value */
			if (sv_length != 4) {
				expert_add_info_format(pinfo, len_item, &ei_trmac_sv_len,
				    "Subvector length is != 4");
				break;
			}

			error_report_timer_value = 10 * tvb_get_ntohs(tvb, svoff+2);
			proto_tree_add_uint_format_value(sv_tree, hf_trmac_error_report_timer_value, tvb, svoff+2, sv_length-2,
											error_report_timer_value, "%u ms", error_report_timer_value );
			proto_item_append_text(sv_item,
				": %u ms", error_report_timer_value );
			break;

		case 0x06: /* Authorized Function Classes */
			if (sv_length != 4) {
				expert_add_info_format(pinfo, len_item, &ei_trmac_sv_len,
				    "Subvector length is != 4");
				break;
			}
			proto_tree_add_item(sv_tree, hf_trmac_authorized_function_classes, tvb, svoff+2, sv_length-2, ENC_BIG_ENDIAN);
			proto_item_append_text(sv_item,
				": %04X",  tvb_get_ntohs(tvb, svoff+2) );
			break;

		case 0x07: /* Authorized Access Priority */
			if (sv_length != 4) {
				expert_add_info_format(pinfo, len_item, &ei_trmac_sv_len,
				    "Subvector length is != 4");
				break;
			}
			proto_tree_add_item(sv_tree, hf_trmac_authorized_access_priority, tvb, svoff+2, sv_length-2, ENC_BIG_ENDIAN);
			proto_item_append_text(sv_item,
				": %04X",  tvb_get_ntohs(tvb, svoff+2) );
			break;

		case 0x09: /* Correlator */
			if (sv_length != 4) {
				expert_add_info_format(pinfo, len_item, &ei_trmac_sv_len,
				    "Subvector length is != 4");
				break;
			}
			proto_tree_add_item(sv_tree, hf_trmac_correlator, tvb, svoff+2, sv_length-2, ENC_BIG_ENDIAN);
			proto_item_append_text(sv_item,
				": %04X",  tvb_get_ntohs(tvb, svoff+2) );
			break;

		case 0x0A: /* SA of Last AMP or SMP Frame */
			if (sv_length != 8) {
				expert_add_info_format(pinfo, len_item, &ei_trmac_sv_len,
				    "Subvector length is != 8");
				break;
			}
			proto_tree_add_item(sv_tree, hf_trmac_sa_of_last_amp_or_smp_frame, tvb, svoff+2, sv_length-2, ENC_NA);
			proto_item_append_text(sv_item,
				": %s",
				tvb_ether_to_str(tvb, svoff+2));
			break;

		case 0x0B: /* Physical Drop Number */
			if (sv_length != 6) {
				expert_add_info_format(pinfo, len_item, &ei_trmac_sv_len,
				    "Subvector length is != 6");
				break;
			}
			proto_tree_add_item(sv_tree, hf_trmac_physical_drop_number, tvb, svoff+2, sv_length-2, ENC_BIG_ENDIAN);
			proto_item_append_text(sv_item,
				": 0x%08X", tvb_get_ntohl(tvb, svoff+2) );
			break;

		case 0x20: /* Response Code */
			if (sv_length != 4 && sv_length != 6) {
				expert_add_info_format(pinfo, len_item, &ei_trmac_sv_len,
				    "Subvector length is != 4 and != 6");
				break;
			}
			if (sv_length == 4) {
				proto_tree_add_uint_format_value(sv_tree, hf_trmac_response_code32, tvb, svoff+2, sv_length-2,
					tvb_get_ntohl(tvb, svoff+2), "0x%04X 0x%02X 0x%02x",
					tvb_get_ntohs(tvb, svoff+2), tvb_get_guint8(tvb, svoff+4), tvb_get_guint8(tvb, svoff+5));
				proto_item_append_text(sv_item,
					": 0x%04X 0x%02X 0x%02x",
					tvb_get_ntohs(tvb, svoff+2),
					tvb_get_guint8(tvb, svoff+4),
					tvb_get_guint8(tvb, svoff+5));
			} else {
				proto_tree_add_uint64_format_value(sv_tree, hf_trmac_response_code48, tvb, svoff+2, sv_length-2,
					tvb_get_ntoh48(tvb, svoff+2), "0x%04X 0x%02X 0x%06X",
					tvb_get_ntohs(tvb, svoff+2),
					tvb_get_guint8(tvb, svoff+4),
					tvb_get_ntoh24(tvb, svoff+5));
				proto_item_append_text(sv_item,
					": 0x%04X 0x%02X 0x%06X",
					tvb_get_ntohs(tvb, svoff+2),
					tvb_get_guint8(tvb, svoff+4),
					tvb_get_ntoh24(tvb, svoff+5));
			}
			break;

		case 0x21: /* Individual Address Count */
			if (sv_length != 4) {
				expert_add_info_format(pinfo, len_item, &ei_trmac_sv_len,
				    "Subvector length is != 4");
				break;
			}
			proto_tree_add_item(sv_tree, hf_trmac_individual_address_count, tvb, svoff+2, sv_length-2, ENC_BIG_ENDIAN);
			proto_item_append_text(sv_item,
				": %u", tvb_get_ntohs(tvb, svoff+2) );
			break;

		case 0x22: /* Product Instance ID */
			proto_tree_add_item(sv_tree, hf_trmac_product_instance_id, tvb, svoff+2, sv_length-2, ENC_NA);
			break;

		case 0x23: /* Ring Station Version Number */
			proto_tree_add_item(sv_tree, hf_trmac_ring_station_version_number, tvb, svoff+2, sv_length-2, ENC_NA);
			break;

		case 0x26: /* Wrap data */
			proto_tree_add_item(sv_tree, hf_trmac_wrap_data, tvb, svoff+2, sv_length-2, ENC_NA);
			break;

		case 0x27: /* Frame Forward */
			proto_tree_add_item(sv_tree, hf_trmac_frame_forward, tvb, svoff+2, sv_length-2, ENC_NA);
			break;

		case 0x28: /* Station Identifier */
			if (sv_length != 8) {
				expert_add_info_format(pinfo, len_item, &ei_trmac_sv_len,
				    "Subvector length is != 8");
				break;
			}
			proto_tree_add_item(sv_tree, hf_trmac_station_identifier, tvb, svoff+2, sv_length-2, ENC_NA);
			proto_item_append_text(sv_item,
				": %s",
				tvb_ether_to_str(tvb, svoff+2));
			break;

		case 0x29: /* Ring Station Status */
			proto_tree_add_item(sv_tree, hf_trmac_ring_station_status, tvb, svoff+2, sv_length-2, ENC_NA);
			break;

		case 0x2A: /* Transmit Status Code */
			if (sv_length != 4) {
				expert_add_info_format(pinfo, len_item, &ei_trmac_sv_len,
				    "Subvector length is != 4");
				break;
			}
			proto_tree_add_item(sv_tree, hf_trmac_transmit_status_code, tvb, svoff+2, sv_length-2, ENC_BIG_ENDIAN);
			proto_item_append_text(sv_item,
				": %04X", tvb_get_ntohs(tvb, svoff+2) );
			break;

		case 0x2B: /* Group Address */
			if (sv_length != 6 && sv_length != 8) {
				expert_add_info_format(pinfo, len_item, &ei_trmac_sv_len,
				    "Subvector length is != 6 and != 8");
				break;
			}
			if (sv_length == 6) {
				proto_tree_add_item(sv_tree, hf_trmac_group_address32, tvb, svoff+2, sv_length-2, ENC_BIG_ENDIAN);
				proto_item_append_text(sv_item,
					": %08X", tvb_get_ntohl(tvb, svoff+2) );
			} else {
				proto_tree_add_item(sv_tree, hf_trmac_group_address_ether, tvb, svoff+2, sv_length-2, ENC_NA);
				proto_item_append_text(sv_item,
					": %s",
					tvb_ether_to_str(tvb, svoff+2));
			}
			break;

		case 0x2C: /* Functional Addresses */
			if (sv_length != 6) {
				expert_add_info_format(pinfo, len_item, &ei_trmac_sv_len,
				    "Subvector length is != 6");
				break;
			}
			proto_tree_add_item(sv_tree, hf_trmac_functional_addresses, tvb, svoff+2, sv_length-2, ENC_BIG_ENDIAN);
			proto_item_append_text(sv_item,
				": %08X", tvb_get_ntohl(tvb, svoff+2) );
			break;

		case 0x2D: /* Isolating Error Counts */
			if (sv_length != 8) {
				expert_add_info_format(pinfo, len_item, &ei_trmac_sv_len,
				    "Subvector length is != 8");
				break;
			}
			tvb_memcpy(tvb, errors, svoff+2, 6);
			ti = proto_tree_add_uint(sv_tree, hf_trmac_errors_iso, tvb, svoff+2, sv_length-2,
				errors[0] + errors[1] + errors[2] + errors[3] + errors[4]);
			sv_subtree = proto_item_add_subtree(ti, ett_tr_ierr_cnt);

			proto_tree_add_uint(sv_subtree, hf_trmac_errors_line, tvb, svoff+2, 1, errors[0]);
			proto_tree_add_uint(sv_subtree, hf_trmac_errors_internal, tvb, svoff+3, 1, errors[1]);
			proto_tree_add_uint(sv_subtree, hf_trmac_errors_burst, tvb, svoff+4, 1, errors[2]);
			proto_tree_add_uint(sv_subtree, hf_trmac_errors_ac, tvb, svoff+5, 1, errors[3]);
			proto_tree_add_uint(sv_subtree, hf_trmac_errors_abort, tvb, svoff+6, 1, errors[4]);

			break;

		case 0x2E: /* Non-Isolating Error Counts */
			if (sv_length != 8) {
				expert_add_info_format(pinfo, len_item, &ei_trmac_sv_len,
				    "Subvector length is != 8");
				break;
			}
			tvb_memcpy(tvb, errors, svoff+2, 6);
			ti = proto_tree_add_uint(sv_tree, hf_trmac_errors_noniso, tvb, svoff+2, sv_length-2,
				errors[0] + errors[1] + errors[2] + errors[3] + errors[4]);
			sv_subtree = proto_item_add_subtree(ti, ett_tr_nerr_cnt);

			proto_tree_add_uint(sv_subtree, hf_trmac_errors_lost, tvb, svoff+2, 1, errors[0]);
			proto_tree_add_uint(sv_subtree, hf_trmac_errors_congestion, tvb, svoff+3, 1, errors[1]);
			proto_tree_add_uint(sv_subtree, hf_trmac_errors_fc, tvb, svoff+4, 1, errors[2]);
			proto_tree_add_uint(sv_subtree, hf_trmac_errors_freq, tvb, svoff+5, 1, errors[3]);
			proto_tree_add_uint(sv_subtree, hf_trmac_errors_token, tvb, svoff+6, 1, errors[4]);
			break;

		case 0x30: /* Error Code */
			if (sv_length != 4) {
				expert_add_info_format(pinfo, len_item, &ei_trmac_sv_len,
				    "Subvector length is != 4");
				break;
			}
			proto_tree_add_item(sv_tree, hf_trmac_error_code, tvb, svoff+2, sv_length-2, ENC_BIG_ENDIAN);
			proto_item_append_text(sv_item,
				": %04X", tvb_get_ntohs(tvb, svoff+2) );
			break;

		default: /* Unknown */
			proto_tree_add_item(sv_tree, hf_trmac_unknown_subvector, tvb, svoff+2, sv_length-2, ENC_NA);
			break;
	}
	return sv_length;
}
Exemple #15
0
/* UA/UDP DISSECTOR */
static void _dissect_uaudp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
                           e_ua_direction direction)
{
    gint        offset = 0;
    guint32     type, length;
    guint8      opcode;
    proto_item *uaudp_item, *tlv_item, *tlv_len_item;
    proto_tree *uaudp_tree, *connect_tree;

    col_set_str(pinfo->cinfo, COL_PROTOCOL, "UAUDP");

    /* get the identifier; it means operation code */
    opcode = tvb_get_guint8(tvb, offset);
    offset += 1;

    ua_tap_info.opcode = opcode;
    ua_tap_info.expseq = 0;
    ua_tap_info.sntseq = 0;

    /* print in "INFO" column the type of UAUDP message */
    col_add_fstr(pinfo->cinfo,
                COL_INFO,
                "%s",
                val_to_str_ext(opcode, &uaudp_opcode_str_ext, "unknown (0x%02x)"));

    uaudp_item = proto_tree_add_protocol_format(tree, proto_uaudp, tvb, 0, tvb_reported_length(tvb),
                            "Universal Alcatel/UDP Encapsulation Protocol, %s",
                            val_to_str_ext(opcode, &uaudp_opcode_str_ext, "unknown (0x%02x)"));

    uaudp_tree = proto_item_add_subtree(uaudp_item, ett_uaudp);

    /* print the identifier */
    proto_tree_add_uint(uaudp_tree, hf_uaudp_opcode, tvb, 0, 1, opcode);

    switch(opcode)
    {
    case UAUDP_CONNECT:
    {
        while(tvb_reported_length_remaining(tvb, offset) > 0)
        {
            type = tvb_get_guint8(tvb, offset+0);
            connect_tree = proto_tree_add_subtree(uaudp_tree, tvb, offset, 0, ett_uaudp_tlv, &tlv_item,
                                                    val_to_str_ext(type, &uaudp_connect_vals_ext, "Unknown %d"));
            proto_tree_add_uint(connect_tree, hf_uaudp_type, tvb, offset, 1, type);
            offset++;
            tlv_len_item = proto_tree_add_item_ret_uint(connect_tree, hf_uaudp_length, tvb, offset, 1, ENC_NA, &length);
            proto_item_set_len(tlv_item, length+2);
            offset++;

            switch(type)
            {
            case UAUDP_CONNECT_VERSION:
                if ((length >= 1) && (length <= 4))
                {
                    proto_tree_add_item(connect_tree, hf_uaudp_version, tvb, offset, length, ENC_BIG_ENDIAN);
                }
                else
                {
                    expert_add_info_format(pinfo, tlv_len_item, &ei_uaudp_tlv_length, "Invalid length %d", length);
                }
                break;
            case UAUDP_CONNECT_WINDOW_SIZE:
                if ((length >= 1) && (length <= 4))
                {
                    proto_tree_add_item(connect_tree, hf_uaudp_window_size, tvb, offset, length, ENC_BIG_ENDIAN);
                }
                else
                {
                    expert_add_info_format(pinfo, tlv_len_item, &ei_uaudp_tlv_length, "Invalid length %d", length);
                }
                break;
            case UAUDP_CONNECT_MTU:
                if ((length >= 1) && (length <= 4))
                {
                    proto_tree_add_item(connect_tree, hf_uaudp_mtu, tvb, offset, length, ENC_BIG_ENDIAN);
                }
                else
                {
                    expert_add_info_format(pinfo, tlv_len_item, &ei_uaudp_tlv_length, "Invalid length %d", length);
                }
                break;
            case UAUDP_CONNECT_UDP_LOST:
                if ((length >= 1) && (length <= 4))
                {
                    proto_tree_add_item(connect_tree, hf_uaudp_udp_lost, tvb, offset, length, ENC_BIG_ENDIAN);
                }
                else
                {
                    expert_add_info_format(pinfo, tlv_len_item, &ei_uaudp_tlv_length, "Invalid length %d", length);
                }
                break;
            case UAUDP_CONNECT_UDP_LOST_REINIT:
                if ((length >= 1) && (length <= 4))
                {
                    proto_tree_add_item(connect_tree, hf_uaudp_udp_lost_reinit, tvb, offset, length, ENC_BIG_ENDIAN);
                }
                else
                {
                    expert_add_info_format(pinfo, tlv_len_item, &ei_uaudp_tlv_length, "Invalid length %d", length);
                }
                break;
            case UAUDP_CONNECT_KEEPALIVE:
                if ((length >= 1) && (length <= 4))
                {
                    proto_tree_add_item(connect_tree, hf_uaudp_keepalive, tvb, offset, length, ENC_BIG_ENDIAN);
                }
                else
                {
                    expert_add_info_format(pinfo, tlv_len_item, &ei_uaudp_tlv_length, "Invalid length %d", length);
                }
                break;
            case UAUDP_CONNECT_QOS_IP_TOS:
                if ((length >= 1) && (length <= 4))
                {
                    proto_tree_add_item(connect_tree, hf_uaudp_qos_ip_tos, tvb, offset, length, ENC_BIG_ENDIAN);
                }
                else
                {
                    expert_add_info_format(pinfo, tlv_len_item, &ei_uaudp_tlv_length, "Invalid length %d", length);
                }
                break;
            case UAUDP_CONNECT_QOS_8021_VLID:
                if ((length >= 1) && (length <= 4))
                {
                    proto_tree_add_item(connect_tree, hf_uaudp_qos_8021_vlid, tvb, offset, length, ENC_BIG_ENDIAN);
                }
                else
                {
                    expert_add_info_format(pinfo, tlv_len_item, &ei_uaudp_tlv_length, "Invalid length %d", length);
                }
                break;
            case UAUDP_CONNECT_QOS_8021_PRI:
                if ((length >= 1) && (length <= 4))
                {
                    proto_tree_add_item(connect_tree, hf_uaudp_qos_8021_pri, tvb, offset, length, ENC_BIG_ENDIAN);
                }
                else
                {
                    expert_add_info_format(pinfo, tlv_len_item, &ei_uaudp_tlv_length, "Invalid length %d", length);
                }
                break;
            case UAUDP_CONNECT_SUPERFAST_CONNECT:
                if ((length >= 1) && (length <= 4))
                {
                    proto_tree_add_item(connect_tree, hf_uaudp_superfast_connect, tvb, offset, length, ENC_BIG_ENDIAN);
                }
                else
                {
                    expert_add_info_format(pinfo, tlv_len_item, &ei_uaudp_tlv_length, "Invalid length %d", length);
                }
                break;
            }
            offset += length;
        }
        break;
    }

    case UAUDP_NACK:
    {
        proto_tree_add_item(uaudp_tree,
                    hf_uaudp_expseq,
                    tvb,
                    offset,
                    2,
                    ENC_BIG_ENDIAN);
        break;
    }

    case UAUDP_DATA:
    {
        int datalen;

        proto_tree_add_item_ret_uint(uaudp_tree,
                    hf_uaudp_expseq,
                    tvb,
                    offset+0,
                    2,
                    ENC_BIG_ENDIAN,
                    &ua_tap_info.expseq);

        proto_tree_add_item_ret_uint(uaudp_tree,
                    hf_uaudp_sntseq,
                    tvb,
                    offset+2,
                    2,
                    ENC_BIG_ENDIAN,
                    &ua_tap_info.sntseq);

        offset  += 4;
        datalen  = tvb_reported_length(tvb) - offset;

        /* if there is remaining data, call the UA dissector */
        if (datalen > 0)
        {
            if (direction == SYS_TO_TERM)
                call_dissector(ua_sys_to_term_handle,
                           tvb_new_subset_length(tvb, offset, datalen),
                           pinfo,
                           tree);
            else if (direction == TERM_TO_SYS)
                call_dissector(ua_term_to_sys_handle,
                           tvb_new_subset_length(tvb, offset, datalen),
                           pinfo,
                           tree);
            else {
                /* XXX: expert ?? */
                col_set_str(pinfo->cinfo,
                            COL_INFO,
                            "Data - Couldn't resolve direction. Check UAUDP Preferences.");
            }
            ua_tap_info.expseq = hf_uaudp_expseq;
        }
        else {
            /* print in "INFO" column */
            col_set_str(pinfo->cinfo,
                        COL_INFO,
                        "Data ACK");
        }
        break;
    }
    default:
        break;
    }
#if 0
    tap_queue_packet(uaudp_tap, pinfo, &ua_tap_info);
#endif
}
static int
dissect_control(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
{
    proto_item  *pitem = NULL;
    guint        control_type;
    guint8       unknown_control_type;
    guint8       uuid_size;
    guint16      uuid_dst;
    guint16      uuid_src;
    guint16      response_message;
    guint        list_length;
    guint        i_item;

    proto_tree_add_item(tree, hf_btbnep_control_type, tvb, offset, 1, ENC_BIG_ENDIAN);
    control_type = tvb_get_guint8(tvb, offset);
    offset += 1;

    col_append_fstr(pinfo->cinfo, COL_INFO, " - %s", val_to_str_const(control_type, control_type_vals,  "Unknown type"));

    switch(control_type) {
        case 0x00: /* Command Not Understood */
            proto_tree_add_item(tree, hf_btbnep_unknown_control_type, tvb, offset, 1, ENC_BIG_ENDIAN);
            unknown_control_type = tvb_get_guint8(tvb, offset);
            offset += 1;

            col_append_fstr(pinfo->cinfo, COL_INFO, " - Unknown(%s)", val_to_str_const(unknown_control_type, control_type_vals,  "Unknown type"));

            break;
        case 0x01: /* Setup Connection Request */
            proto_tree_add_item(tree, hf_btbnep_uuid_size, tvb, offset, 1, ENC_BIG_ENDIAN);
            uuid_size = tvb_get_guint8(tvb, offset);
            offset += 1;

            pitem = proto_tree_add_item(tree, hf_btbnep_destination_service_uuid, tvb, offset, uuid_size, ENC_NA);
            uuid_dst = tvb_get_ntohs(tvb, offset);
            proto_item_append_text(pitem, " (%s)", val_to_str_ext(uuid_dst, &vs_service_classes_ext,  "Unknown uuid"));
            offset += uuid_size;

            pitem = proto_tree_add_item(tree, hf_btbnep_source_service_uuid, tvb, offset, uuid_size, ENC_NA);
            uuid_src = tvb_get_ntohs(tvb, offset);
            proto_item_append_text(pitem, " (%s)", val_to_str_ext(uuid_src, &vs_service_classes_ext,  "Unknown uuid"));
            offset += uuid_size;

            col_append_fstr(pinfo->cinfo, COL_INFO, " - dst: <%s>, src: <%s>",
                    val_to_str_ext(uuid_dst, &vs_service_classes_ext,  "Unknown uuid"),
                    val_to_str_ext(uuid_src, &vs_service_classes_ext,  "Unknown uuid"));
            break;
        case 0x02: /* Setup Connection Response */
            proto_tree_add_item(tree, hf_btbnep_setup_connection_response_message, tvb, offset, 2, ENC_BIG_ENDIAN);
            response_message = tvb_get_ntohs(tvb, offset);
            offset += 2;
            col_append_fstr(pinfo->cinfo, COL_INFO, " - %s",
                    val_to_str_const(response_message, setup_connection_response_message_vals,  "Unknown response message"));
            break;
        case 0x03: /* Filter Net Type Set */
            proto_tree_add_item(tree, hf_btbnep_list_length, tvb, offset, 2, ENC_BIG_ENDIAN);
            list_length = tvb_get_ntohs(tvb, offset);
            offset += 2;

            for (i_item = 0; i_item < list_length; i_item += 4) {
                proto_tree_add_item(tree, hf_btbnep_network_type_start, tvb, offset, 2, ENC_BIG_ENDIAN);
                offset += 2;

                proto_tree_add_item(tree, hf_btbnep_network_type_end, tvb, offset, 2, ENC_BIG_ENDIAN);
                offset += 2;
            }
            break;
        case 0x04: /* Filter Net Type Response */
            proto_tree_add_item(tree, hf_btbnep_filter_net_type_response_message, tvb, offset, 2, ENC_BIG_ENDIAN);
            response_message = tvb_get_ntohs(tvb, offset);
            offset += 2;
            col_append_fstr(pinfo->cinfo, COL_INFO, " - %s",
                    val_to_str_const(response_message, filter_net_type_response_message_vals,  "Unknown response message"));
            break;
        case 0x05: /*Filter Multi Addr Set*/
            proto_tree_add_item(tree, hf_btbnep_list_length, tvb, offset, 2, ENC_BIG_ENDIAN);
            list_length = tvb_get_ntohs(tvb, offset);
            offset += 2;

            for (i_item = 0; i_item < list_length; i_item += 12) {
                proto_tree_add_item(tree, hf_btbnep_multicast_address_start, tvb, offset, 6, ENC_NA);
                offset += 6;

                proto_tree_add_item(tree, hf_btbnep_multicast_address_end, tvb, offset, 6, ENC_NA);
                offset += 6;
            }
            break;
        case 0x06: /* Filter Multi Addr Response */
            proto_tree_add_item(tree, hf_btbnep_filter_multi_addr_response_message, tvb, offset, 2, ENC_BIG_ENDIAN);
            response_message = tvb_get_ntohs(tvb, offset);
            offset += 2;
            col_append_fstr(pinfo->cinfo, COL_INFO, " - %s",
                    val_to_str_const(response_message, filter_multi_addr_response_message_vals,  "Unknown response message"));
            break;

    };

    return offset;
}
Exemple #17
0
static void
dissect_UDPH1_generic(tvbuff_t *tvb, packet_info *pinfo,
		      proto_tree *adwin_tree, proto_tree *adwin_debug_tree, gchar** info_string, const gchar* packet_name)
{
	guint32 i3plus1code =  0, instructionID, seq_num;

	instructionID = tvb_get_letohl(tvb, 0);
	*info_string = ep_strdup_printf("%s: %s", packet_name,
				        val_to_str_ext(instructionID, &instruction_mapping_ext, "unknown instruction: %d"));

	if (instructionID == I_3PLUS1) {
		gchar *tmp = *info_string;

		i3plus1code = tvb_get_letohl(tvb, 20);
		*info_string = ep_strdup_printf("%s: %s", tmp, val_to_str_ext(i3plus1code, &instruction_3plus1_mapping_ext, "unknown 3+1 code: %d"));
	}

	/* Get the transaction identifier */
	seq_num = tvb_get_letohl(tvb, 4);
	adwin_request_response_handling(tvb, pinfo, adwin_tree, seq_num, ADWIN_REQUEST);

	if (! adwin_tree)
		return;

	SET_PACKET_TYPE(adwin_tree, APT_UDPH1_old);

	ADWIN_ADD_LE(adwin_tree, instruction,          0,  4);
	ADWIN_ADD_LE(adwin_tree, packet_index,         4,  4);
	ADWIN_ADD_BE(adwin_tree, password,             8, 10);
	ADWIN_ADD_LE(adwin_debug_tree, unused,        18,  2);

	switch(instructionID) {
	case I_3PLUS1:
		ADWIN_ADD_LE(adwin_tree, i3plus1,      20,  4);
		switch (i3plus1code) {
		case I_3P1_SET_PAR:
			ADWIN_ADD_LE(adwin_tree, parameter,     24,  4);
			ADWIN_ADD_LE(adwin_tree, val1,          28,  4);
			ADWIN_ADD_LE(adwin_tree, val1f,         28,  4);
			ADWIN_ADD_LE(adwin_debug_tree, unused,  32,  4);
			break;
		case I_3P1_GET_PAR:
			ADWIN_ADD_LE(adwin_tree, parameter,     24,  4);
			ADWIN_ADD_LE(adwin_debug_tree, unused,  28,  8);
			break;
		case I_3P1_GET_MEMORY_INFO:
		case I_3P1_GET_DETAILED_MEM_INFO:
			ADWIN_ADD_LE(adwin_tree, mem_type,      24,  4);
			ADWIN_ADD_LE(adwin_debug_tree, unused,  28,  8);
			break;
		case I_3P1_START:
		case I_3P1_STOP:
		case I_3P1_CLEAR_PROCESS:
			ADWIN_ADD_LE(adwin_tree, process_no,    24,  4);
			ADWIN_ADD_LE(adwin_debug_tree, unused,  28,  8);
			break;
		case I_3P1_GET_DATA_LENGTH:
			ADWIN_ADD_LE(adwin_tree, data_no32,     24,  4);
			ADWIN_ADD_LE(adwin_debug_tree, unused,  28,  8);
			break;
		case I_3P1_CLEAR_FIFO:
		case I_3P1_GET_FIFO_EMPTY:
		case I_3P1_GET_FIFO_COUNT:
			ADWIN_ADD_LE(adwin_tree, fifo_no32,     24,  4);
			ADWIN_ADD_LE(adwin_debug_tree, unused,  28,  8);
			break;
		default: ; /* should not happen */
			/* illegal values should be displayed properly
			   by 3plus1_mapping */
		}
		break;
	case I_BOOT:
		ADWIN_ADD_LE(adwin_tree, memsize,       20,  4);
		ADWIN_ADD_LE(adwin_tree, blocksize,     24,  2);
		ADWIN_ADD_LE(adwin_debug_tree, unused,  26,  2);
		ADWIN_ADD_LE(adwin_tree, processor,     28,  4);
		ADWIN_ADD_LE(adwin_tree, binfilesize,   32,  4);
		break;
	case I_LOAD_BIN_FILE:
		ADWIN_ADD_LE(adwin_debug_tree, unused,  20,  6);
		ADWIN_ADD_LE(adwin_tree, blocksize,     26,  2);
		ADWIN_ADD_LE(adwin_tree, processor,     28,  4);
		ADWIN_ADD_LE(adwin_tree, binfilesize,   32,  4);
		break;
	case I_GET_WORKLOAD:
		ADWIN_ADD_LE(adwin_tree, instruction,   20,  4);
		ADWIN_ADD_LE(adwin_debug_tree, unused,  24, 12);
		break;
	case I_GET_DATA_TYPE:
		ADWIN_ADD_LE(adwin_debug_tree, unused,  20,  4);
		ADWIN_ADD_LE(adwin_tree, data_no32,     24,  4);
		ADWIN_ADD_LE(adwin_tree, start_index,   28,  4);
		ADWIN_ADD_LE(adwin_debug_tree, unused,  32,  4);
		break;
	case I_GET_DATA:
	case I_SET_DATA:
		ADWIN_ADD_LE(adwin_tree, data_type,     20,  4);
		ADWIN_ADD_LE(adwin_tree, data_no16,     24,  2);
		ADWIN_ADD_LE(adwin_tree, blocksize,     26,  2);
		ADWIN_ADD_LE(adwin_tree, start_index,   28,  4);
		ADWIN_ADD_LE(adwin_tree, count,         32,  4);
		break;
	case I_GET_DATA_SHIFTED_HANDSHAKE:
		ADWIN_ADD_BE(adwin_tree, data_no16,     20,  2);
		ADWIN_ADD_BE(adwin_tree, blocksize,     22,  2);
		ADWIN_ADD_BE(adwin_tree, start_index,   24,  4);
		ADWIN_ADD_BE(adwin_tree, count,         28,  4);
		ADWIN_ADD_BE(adwin_debug_tree, unused,  32,  4);
		break;
	case I_GET_DATA_SMALL:
		ADWIN_ADD_LE(adwin_debug_tree, unused,  20,  4);
		ADWIN_ADD_LE(adwin_tree, data_no16,     24,  2);
		ADWIN_ADD_LE(adwin_debug_tree, unused,  26,  2);
		ADWIN_ADD_LE(adwin_tree, start_index,   28,  4);
		ADWIN_ADD_LE(adwin_tree, count,         32,  4);
		break;
	case I_GET_PAR_ALL:
		ADWIN_ADD_LE(adwin_tree, start_index,   20,  4);
		ADWIN_ADD_LE(adwin_tree, count,         24,  4);
		ADWIN_ADD_LE(adwin_debug_tree, unused,  28,  8);
		break;
	case I_SET_DATA_LAST_STATUS:
		ADWIN_ADD_LE(adwin_tree, data_packet_index, 20,  4);
		ADWIN_ADD_LE(adwin_debug_tree, unused,  24,  12);
		break;
	case I_GET_ARM_VERSION:
		ADWIN_ADD_LE(adwin_tree, armVersion,  20,  4);
		ADWIN_ADD_LE(adwin_debug_tree, unused,24, 12);
		break;
	case I_GET_FIFO:
	case I_SET_FIFO:
		ADWIN_ADD_LE(adwin_tree, data_type,     20,  4);
		ADWIN_ADD_LE(adwin_tree, fifo_no16,     24,  2);
		ADWIN_ADD_LE(adwin_debug_tree, unused,  26,  6);
		ADWIN_ADD_LE(adwin_tree, count,         32,  4);
		break;
	case I_GET_FIFO_RETRY:
	case I_SET_FIFO_RETRY:
		ADWIN_ADD_LE(adwin_tree, data_type,     20,  4);
		ADWIN_ADD_LE(adwin_tree, fifo_no16,     24,  2);
		ADWIN_ADD_LE(adwin_debug_tree, unused,  26,  2);
		ADWIN_ADD_LE(adwin_tree, retry_packet_index, 28,  4);
		ADWIN_ADD_LE(adwin_tree, count,         32,  4);
		break;
	case I_TEST_VERSION:
		ADWIN_ADD_LE(adwin_debug_tree, unused,  20,  16);
		break;
	case I_GET_MEMORY:
		ADWIN_ADD_LE(adwin_tree, address,       20,  4);
		ADWIN_ADD_LE(adwin_tree, count,         24,  4);
		ADWIN_ADD_LE(adwin_debug_tree, unused,  28,  8);
		break;
	default: ; /* should not happen */
		/* illegal values should be displayed properly by
		   instruction_mapping */
	}

	ADWIN_ADD_LE(adwin_debug_tree, link_addr,36,  4);
	ADWIN_ADD_LE(adwin_tree, timeout,        40,  4);
	ADWIN_ADD_LE(adwin_debug_tree, osys,     44,  4);
	ADWIN_ADD_LE(adwin_debug_tree, unused,   48,  4);

}
static void
rtpproxy_add_parameter(proto_tree *rtpproxy_tree, tvbuff_t *tvb, guint begin, guint realsize)
{
    proto_item *ti;
    proto_tree *another_tree = NULL;
    guint offset = 0;
    guint new_offset = 0;
    gint i;
    guint pt = 0;
    gchar** codecs = NULL;
    guint codec_len;
    guint8* rawstr = NULL;

    /* Extract the entire parameters line. */
    /* Something like "t4p1iic8,0,2,4,18,96,97,98,100,101" */
    rawstr = tvb_get_string(wmem_packet_scope(), tvb, begin, realsize);

    while(offset < realsize) {
        ti = proto_tree_add_item(rtpproxy_tree, hf_rtpproxy_command_parameter, tvb, begin + offset, 1, ENC_NA);
        offset++; /* Skip 1-byte parameter's type */
        switch (g_ascii_tolower(tvb_get_guint8(tvb, begin+offset-1)))
        {
        /* Official long parameters */
        case 'c':
            new_offset = (gint)strspn(rawstr+offset, "0123456789,");
            another_tree = proto_item_add_subtree(ti, ett_rtpproxy_command_parameters_codecs);
            codecs = g_strsplit(tvb_get_string(wmem_packet_scope(), tvb, begin+offset, new_offset), ",", 0);
            i = 0;
            while(codecs[i]) {
                /* We assume strings < 2^32-1 bytes long. :-) */
                codec_len = (guint)strlen(codecs[i]);
                ti = proto_tree_add_uint(another_tree, hf_rtpproxy_command_parameter_codec, tvb, begin+offset, codec_len,
                                         (guint16) g_ascii_strtoull((gchar*)tvb_get_string(wmem_packet_scope(), tvb, begin+offset, codec_len), NULL, 10));
                proto_item_append_text(ti, " (%s)", val_to_str_ext((guint)strtoul(tvb_format_text(tvb,begin+offset,codec_len),NULL,10), &rtp_payload_type_vals_ext, "Unknown"));
                offset += codec_len;
                if(codecs[i+1])
                    offset++; /* skip comma */
                i++;
            };
            g_strfreev(codecs);
            break;
        case 'l':
            new_offset = (gint)strspn(rawstr+offset, "0123456789.");
            another_tree = proto_item_add_subtree(ti, ett_rtpproxy_command_parameters_local);
            proto_tree_add_item(another_tree, hf_rtpproxy_command_parameter_local, tvb, begin+offset, new_offset, ENC_ASCII | ENC_NA);
            offset += new_offset;
            break;
        case 'r':
            new_offset = (gint)strspn(rawstr+offset, "0123456789.");
            another_tree = proto_item_add_subtree(ti, ett_rtpproxy_command_parameters_remote);
            proto_tree_add_item(another_tree, hf_rtpproxy_command_parameter_remote, tvb, begin+offset, new_offset, ENC_ASCII | ENC_NA);
            offset += new_offset;
            break;
        case 'z':
            new_offset = (gint)strspn(rawstr+offset, "0123456789");
            another_tree = proto_item_add_subtree(ti, ett_rtpproxy_command_parameters_repacketize);
            proto_tree_add_uint(another_tree, hf_rtpproxy_command_parameter_repacketize, tvb, begin+offset, new_offset,
                                (guint16) g_ascii_strtoull((gchar*)tvb_get_string(wmem_packet_scope(), tvb, begin+offset, new_offset), NULL, 10));
            offset += new_offset;
            break;
        /* Unofficial long parameters */
        case 'd':
            new_offset = (gint)strspn(rawstr+offset, "0123456789");
            another_tree = proto_item_add_subtree(ti, ett_rtpproxy_command_parameters_dtmf);
            proto_tree_add_uint(another_tree, hf_rtpproxy_command_parameter_dtmf, tvb, begin+offset, new_offset,
                                (guint16) g_ascii_strtoull((gchar*)tvb_get_string(wmem_packet_scope(), tvb, begin+offset, new_offset), NULL, 10));
            if(rtpproxy_establish_conversation) {
                pt = (guint)strtoul(tvb_format_text(tvb,begin+offset,new_offset),NULL,10);
                dissector_add_uint("rtp.pt", pt, rtp_events_handle);
            }
            offset += new_offset;
            break;
        case 'm':
            new_offset = (gint)strspn(rawstr+offset, "0123456789=,");
            /* TODO */
            offset += new_offset;
            break;
        case 'p':
            another_tree = proto_item_add_subtree(ti, ett_rtpproxy_command_parameters_proto);
            proto_tree_add_item(another_tree, hf_rtpproxy_command_parameter_proto, tvb, begin+offset, 1, ENC_NA);
            offset++;
            break;
        case 't':
            new_offset = (gint)strspn(rawstr+offset, "0123456789");
            another_tree = proto_item_add_subtree(ti, ett_rtpproxy_command_parameters_transcode);
            ti = proto_tree_add_uint(another_tree, hf_rtpproxy_command_parameter_transcode, tvb, begin+offset, new_offset,
                                     (guint16) g_ascii_strtoull((gchar*)tvb_get_string(wmem_packet_scope(), tvb, begin+offset, new_offset), NULL, 10));
            proto_item_append_text(ti, " (%s)", val_to_str_ext((guint)strtoul(tvb_format_text(tvb,begin+offset, new_offset),NULL,10), &rtp_payload_type_vals_ext, "Unknown"));
            offset += new_offset;
            break;
        case 'v':
            another_tree = proto_item_add_subtree(ti, ett_rtpproxy_command_parameters_acc);
            proto_tree_add_item(another_tree, hf_rtpproxy_command_parameter_acc, tvb, begin+offset, 1, ENC_NA);
            offset++;
            break;
        default:
            break;
        }
    }
}
Exemple #19
0
static void _dissect_uasip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, e_ua_direction direction)
{
    proto_item *uasip_item, *tlv_item, *tlv_len_item;
    proto_tree *uasip_tree, *connect_tree;
    guint8      opcode;
    guint32     type, length;
    gint        offset = 0;

    if (noesip_enabled)
    {
        col_append_str(pinfo->cinfo, COL_PROTOCOL, "/NOE");
    }
    else
    {
        col_append_str(pinfo->cinfo, COL_PROTOCOL, "/DL");
    }

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

    ua_tap_info.opcode = opcode;
    ua_tap_info.expseq = 0;
    ua_tap_info.sntseq = 0;

    col_add_fstr(pinfo->cinfo, COL_INFO, "%s", val_to_str_ext(opcode, &uaudp_opcode_str_ext, "unknown (0x%02x)"));

    uasip_item = proto_tree_add_protocol_format(tree, proto_uasip, tvb, 0, 5,
                                                "SIP/NOE Protocol, %s",
                                                val_to_str_ext(opcode, &uaudp_opcode_str_ext, "unknown (0x%02x)"));
    uasip_tree = proto_item_add_subtree(uasip_item, ett_uasip);
    proto_tree_add_uint(uasip_tree, hf_uasip_opcode, tvb, 0, 1, opcode);

    switch(opcode)
    {
        case UAUDP_CONNECT:
        {
            while(tvb_reported_length_remaining(tvb, offset) > 0)
            {
                type = tvb_get_guint8(tvb, offset+0);
                connect_tree = proto_tree_add_subtree(uasip_tree, tvb, offset, 0, ett_uasip_tlv, &tlv_item,
                                                      val_to_str_ext(type, &uaudp_connect_vals_ext, "Unknown %d"));
                proto_tree_add_uint(connect_tree, hf_uasip_type, tvb, offset, 1, type);
                offset++;
                tlv_len_item = proto_tree_add_item_ret_uint(connect_tree, hf_uasip_length, tvb, offset, 1, ENC_NA, &length);
                proto_item_set_len(tlv_item, length+2);
                offset++;

                switch(type)
                {
                    case UAUDP_CONNECT_VERSION:
                        if ((length >= 1) && (length <= 4))
                        {
                            proto_tree_add_item(connect_tree, hf_uasip_version, tvb, offset, length, ENC_BIG_ENDIAN);
                        }
                        else
                        {
                            expert_add_info_format(pinfo, tlv_len_item, &ei_uasip_tlv_length, "Invalid length %d", length);
                        }
                    break;

                    case UAUDP_CONNECT_WINDOW_SIZE:
                        if ((length >= 1) && (length <= 4))
                        {
                            proto_tree_add_item(connect_tree, hf_uasip_window_size, tvb, offset, length, ENC_BIG_ENDIAN);
                        }
                        else
                        {
                            expert_add_info_format(pinfo, tlv_len_item, &ei_uasip_tlv_length, "Invalid length %d", length);
                        }
                    break;

                    case UAUDP_CONNECT_MTU:
                        if ((length >= 1) && (length <= 4))
                        {
                            proto_tree_add_item(connect_tree, hf_uasip_mtu, tvb, offset, length, ENC_BIG_ENDIAN);
                        }
                        else
                        {
                            expert_add_info_format(pinfo, tlv_len_item, &ei_uasip_tlv_length, "Invalid length %d", length);
                        }
                    break;

                    case UAUDP_CONNECT_UDP_LOST:
                        if ((length >= 1) && (length <= 4))
                        {
                            proto_tree_add_item(connect_tree, hf_uasip_udp_lost, tvb, offset, length, ENC_BIG_ENDIAN);
                        }
                        else
                        {
                            expert_add_info_format(pinfo, tlv_len_item, &ei_uasip_tlv_length, "Invalid length %d", length);
                        }
                    break;

                    case UAUDP_CONNECT_UDP_LOST_REINIT:
                        if ((length >= 1) && (length <= 4))
                        {
                            proto_tree_add_item(connect_tree, hf_uasip_udp_lost_reinit, tvb, offset, length, ENC_BIG_ENDIAN);
                        }
                        else
                        {
                            expert_add_info_format(pinfo, tlv_len_item, &ei_uasip_tlv_length, "Invalid length %d", length);
                        }
                    break;

                    case UAUDP_CONNECT_KEEPALIVE:
                        if ((length >= 1) && (length <= 4))
                        {
                            proto_tree_add_item(connect_tree, hf_uasip_keepalive, tvb, offset, length, ENC_BIG_ENDIAN);
                        }
                        else
                        {
                            expert_add_info_format(pinfo, tlv_len_item, &ei_uasip_tlv_length, "Invalid length %d", length);
                        }
                    break;

                    case UAUDP_CONNECT_QOS_IP_TOS:
                        if ((length >= 1) && (length <= 4))
                        {
                            proto_tree_add_item(connect_tree, hf_uasip_qos_ip_tos, tvb, offset, length, ENC_BIG_ENDIAN);
                        }
                        else
                        {
                            expert_add_info_format(pinfo, tlv_len_item, &ei_uasip_tlv_length, "Invalid length %d", length);
                        }
                    break;

                    case UAUDP_CONNECT_QOS_8021_VLID:
                        if ((length >= 1) && (length <= 4))
                        {
                            proto_tree_add_item(connect_tree, hf_uasip_qos_8021_vlid, tvb, offset, length, ENC_BIG_ENDIAN);
                        }
                        else
                        {
                            expert_add_info_format(pinfo, tlv_len_item, &ei_uasip_tlv_length, "Invalid length %d", length);
                        }
                    break;

                    case UAUDP_CONNECT_QOS_8021_PRI:
                        if ((length >= 1) && (length <= 4))
                        {
                            proto_tree_add_item(connect_tree, hf_uasip_qos_8021_pri, tvb, offset, length, ENC_BIG_ENDIAN);
                        }
                        else
                        {
                            expert_add_info_format(pinfo, tlv_len_item, &ei_uasip_tlv_length, "Invalid length %d", length);
                        }
                    break;

                    default:
                    break;
                }
                offset += length;
            }
        }
        break;

        case UAUDP_NACK:
        {
            proto_tree_add_item_ret_uint(uasip_tree, hf_uasip_expseq, tvb, offset, 2, ENC_BIG_ENDIAN, &ua_tap_info.expseq);

            /*offset += 2;*/

            if (noesip_enabled)
            {
                col_add_fstr(pinfo->cinfo, COL_INFO, "NACK");
            }
            else
            {
                col_add_fstr(pinfo->cinfo, COL_INFO, "NACK exp:%d", ua_tap_info.expseq);
            }
        }
        break;

        case UAUDP_DATA:
        {
            int datalen;

            proto_tree_add_item_ret_uint(uasip_tree, hf_uasip_expseq, tvb, offset+0, 2, ENC_BIG_ENDIAN, &ua_tap_info.expseq);
            proto_tree_add_item_ret_uint(uasip_tree, hf_uasip_sntseq, tvb, offset+2, 2, ENC_BIG_ENDIAN, &ua_tap_info.sntseq);
            offset += 4;
            datalen = tvb_reported_length_remaining(tvb, offset);

            if (noesip_enabled)
            {
                if (datalen > 0)
                {
                    if (direction == SYS_TO_TERM)
                    {
                        call_dissector(ua_sys_to_term_handle, tvb_new_subset_length(tvb, offset, datalen), pinfo, tree);
                    }
                    else if (direction == TERM_TO_SYS)
                    {
                        call_dissector(ua_term_to_sys_handle, tvb_new_subset_length(tvb, offset, datalen), pinfo, tree);
                    }
                    else
                    {
                        col_add_str(pinfo->cinfo, COL_INFO, "DATA - Couldn't resolve direction.");
                    }
                }
                else
                {
                    col_add_str(pinfo->cinfo, COL_INFO, "ACK");
                }
            }
            else
            {
                if (datalen > 0)
                {
                    col_add_fstr(pinfo->cinfo, COL_INFO, "DATA exp:%d", ua_tap_info.expseq);
                    col_append_fstr(pinfo->cinfo, COL_INFO, " snt:%d", ua_tap_info.sntseq);
                }
                else
                {
                    col_add_fstr(pinfo->cinfo, COL_INFO, "ACK  exp:%d", ua_tap_info.expseq);
                    col_append_fstr(pinfo->cinfo, COL_INFO, " snt:%d", ua_tap_info.sntseq);
                }
            }
        }
        break;

        default:
        break;
    }
#if 0
    tap_queue_packet(uasip_tap, pinfo, &ua_tap_info);
#endif
}
/* Dissect an individual actrace CAS message */
static void dissect_actrace_cas(tvbuff_t *tvb, packet_info *pinfo, proto_tree *actrace_tree)
{
	/* Declare variables */
	gint32 value, function, trunk, bchannel, source, event, curr_state, next_state;
	gint32 par0, par1, par2;
	gchar *frame_label = NULL;
	int direction = 0;
	int offset = 0;

	col_set_str(pinfo->cinfo, COL_PROTOCOL, "AC_CAS");

	value = tvb_get_ntohl(tvb, offset);
	proto_tree_add_int(actrace_tree, hf_actrace_cas_time, tvb, offset, 4, value);
	offset += 4;

	source = tvb_get_ntohl(tvb, offset);
	proto_tree_add_int(actrace_tree, hf_actrace_cas_source, tvb, offset, 4, source);
	offset += 4;

	curr_state = tvb_get_ntohl(tvb, offset);
	proto_tree_add_int(actrace_tree, hf_actrace_cas_current_state, tvb, offset, 4, curr_state);
	offset += 4;

	event = tvb_get_ntohl(tvb, offset);
	proto_tree_add_int(actrace_tree, hf_actrace_cas_event, tvb, offset, 4, event);
	offset += 4;

	next_state = tvb_get_ntohl(tvb, offset);
	proto_tree_add_int(actrace_tree, hf_actrace_cas_next_state, tvb, offset, 4, next_state);
	offset += 4;

	function = tvb_get_ntohl(tvb, offset);
	proto_tree_add_int(actrace_tree, hf_actrace_cas_function, tvb, offset, 4, function);
	offset += 4;

	col_append_fstr(pinfo->cinfo, COL_INFO, "%s|%d|%s|%d|%s|",
			val_to_str_const(source, actrace_cas_source_vals_short, "ukn"),
			curr_state,
			val_to_str_ext(event, &actrace_cas_event_vals_ext, "%d"),
			next_state,
			val_to_str_ext(function, &actrace_cas_function_vals_ext, "%d"));

	par0 = tvb_get_ntohl(tvb, offset);
	switch (function)
	{
		case SEND_EVENT:
			proto_tree_add_text(actrace_tree, tvb, offset, 4,
				"Parameter 0: %s",  val_to_str_ext(par0,
				&actrace_cas_pstn_event_vals_ext, "Unknown (%d)"));
			col_append_fstr(pinfo->cinfo, COL_INFO, "%s|",
					val_to_str_ext(par0, &actrace_cas_pstn_event_vals_ext, "%d"));
			break;
		case CHANGE_COLLECT_TYPE:
			proto_tree_add_text(actrace_tree, tvb, offset, 4,
				"Parameter 0: %s", val_to_str(par0,
				actrace_cas_collect_type_vals, "Unknown (%d)"));
			col_append_fstr(pinfo->cinfo, COL_INFO, "%s|",
					val_to_str(par0, actrace_cas_collect_type_vals, "%d"));
			break;
		case SEND_MF:
		case SEND_DEST_NUM:
			proto_tree_add_text(actrace_tree, tvb, offset, 4,
				"Parameter 0: %s", val_to_str(par0,
				actrace_cas_send_type_vals, "Unknown (%d)"));
			col_append_fstr(pinfo->cinfo, COL_INFO, "%s|",
					val_to_str(par0, actrace_cas_send_type_vals, "%d"));
			break;
		default:
			proto_tree_add_int(actrace_tree, hf_actrace_cas_par0, tvb, offset, 4, par0);
			col_append_fstr(pinfo->cinfo, COL_INFO, "%d|", par0);
	}
	offset += 4;

	par1 = tvb_get_ntohl(tvb, offset);
	if (function == SEND_EVENT) {
		proto_tree_add_text(actrace_tree, tvb, offset, 4,
			"Parameter 1: %s", val_to_str_ext(par1, &actrace_cas_cause_vals_ext, "Unknown (%d)"));
		col_append_fstr(pinfo->cinfo, COL_INFO, "%s|",
				val_to_str_ext(par1, &actrace_cas_cause_vals_ext, "%d"));
	} else {
		proto_tree_add_int(actrace_tree, hf_actrace_cas_par1, tvb, offset, 4, par1);
		col_append_fstr(pinfo->cinfo, COL_INFO, "%d|", par1);
	}
	offset += 4;

	par2 = tvb_get_ntohl(tvb, offset);
	proto_tree_add_int(actrace_tree, hf_actrace_cas_par2, tvb, offset, 4, par2);
	col_append_fstr(pinfo->cinfo, COL_INFO, "%d|", par2);
	offset += 4;

	trunk = tvb_get_ntohl(tvb, offset);
	proto_tree_add_int(actrace_tree, hf_actrace_cas_trunk, tvb, offset, 4, trunk);
	offset += 4;

	bchannel = tvb_get_ntohl(tvb, offset);
	proto_tree_add_int(actrace_tree, hf_actrace_cas_bchannel, tvb, offset, 4, bchannel);
	offset += 4;

	col_prepend_fstr(pinfo->cinfo, COL_INFO, "t%db%d|", trunk, bchannel);

	value = tvb_get_ntohl(tvb, offset);
	proto_tree_add_int(actrace_tree, hf_actrace_cas_connection_id, tvb, offset, 4, value);

	/* Add tap info for the Voip Graph */
	if (source == ACTRACE_CAS_SOURCE_DSP) {
		direction = 1;
		if ( (event >= ACTRACE_CAS_EV_11) && (event <= ACTRACE_CAS_EV_00 ) ) {
			frame_label = ep_strdup_printf("AB: %s", val_to_str_const(event, actrace_cas_event_ab_vals, "ERROR") );
		} else if ( (event >= 32) && (event <= 46 ) ) { /* is an MF tone */
			frame_label = ep_strdup_printf("MF: %s", val_to_str_ext_const(event, &actrace_cas_mf_vals_ext, "ERROR") );
		} else if ( (event == ACTRACE_CAS_EV_DTMF ) || (event == ACTRACE_CAS_EV_FIRST_DIGIT ) ) { /* DTMF digit */
			frame_label = ep_strdup_printf("DTMF: %u", par0 );
		}
	} else if (source == ACTRACE_CAS_SOURCE_TABLE) {
		direction = 0;
		if (function == SEND_MF) {
			if (par0 == SEND_TYPE_SPECIFIC ) {
				frame_label = ep_strdup_printf("MF: %u", par1);
			} else if (par0 == SEND_TYPE_ADDRESS ) {
				frame_label = ep_strdup("MF: DNIS digit");
			} else if (par0 == SEND_TYPE_ANI  ) {
				frame_label = ep_strdup("MF: ANI digit");
			} else if (par0 == SEND_TYPE_SOURCE_CATEGORY ) {
				frame_label = ep_strdup("MF: src_category");
			} else if (par0 == SEND_TYPE_TRANSFER_CAPABILITY ) {
				frame_label = ep_strdup("MF: trf_capability");
			} else if (par0 == SEND_TYPE_INTER_EXCHANGE_SWITCH ) {
				frame_label = ep_strdup("MF: inter_exch_sw");
			}
		} else if (function == SEND_CAS) {
			frame_label = ep_strdup_printf("AB: %s", val_to_str_const(ACTRACE_CAS_EV_00-par0, actrace_cas_event_ab_vals, "ERROR"));
		} else if (function == SEND_DEST_NUM) {
			if (par0 == SEND_TYPE_ADDRESS ) {
				frame_label = ep_strdup("DTMF/MF: sending DNIS");
			} else if (par0 == SEND_TYPE_ANI ) {
				frame_label = ep_strdup("DTMF/MF: sending ANI");
			}
		}
	}

	if (frame_label != NULL) {
		/* Initialise packet info for passing to tap */
		actrace_pi = ep_new(actrace_info_t);

		actrace_pi->type = ACTRACE_CAS;
		actrace_pi->direction = direction;
		actrace_pi->trunk = trunk;
		actrace_pi->cas_bchannel = bchannel;
		actrace_pi->cas_frame_label = frame_label;
		/* Report this packet to the tap */
		tap_queue_packet(actrace_tap, pinfo, actrace_pi);
	}
}
Exemple #21
0
static void
dissect_starteam(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
  gint offset = 0;

  col_set_str(pinfo->cinfo, COL_PROTOCOL, "StarTeam");

  if(check_col(pinfo->cinfo, COL_INFO)){
    /* This is a trick to know whether this is the first PDU in this packet or not */
    if(iPreviousFrameNumber != (gint) pinfo->fd->num){
      col_clear(pinfo->cinfo, COL_INFO);
    } else {
      col_append_str(pinfo->cinfo, COL_INFO, " | ");
    }
  }
  iPreviousFrameNumber = pinfo->fd->num;
  if(tvb_length(tvb) >= 16){
    guint32 iCommand = 0;
    gboolean bRequest = FALSE;
    if(tvb_get_ntohl(tvb, offset + 0) == STARTEAM_MAGIC){
      /* This packet is a response */
      bRequest = FALSE;
      if(check_col(pinfo->cinfo, COL_INFO)){
        col_append_fstr(pinfo->cinfo, COL_INFO, "Reply: %d bytes", tvb_length(tvb));
      }
    } else if(tvb_length_remaining(tvb, offset) >= 28 && tvb_get_ntohl(tvb, offset + 20) == STARTEAM_MAGIC){
      /* This packet is a request */
      bRequest = TRUE;
      if(tvb_length_remaining(tvb, offset) >= 66){
        iCommand = tvb_get_letohl(tvb, offset + 62);
      }
      if(check_col(pinfo->cinfo, COL_INFO)){
        col_append_str(pinfo->cinfo, COL_INFO,
                       val_to_str_ext(iCommand, &starteam_opcode_vals_ext, "Unknown (0x%02x)"));
      }
    }

    if(tree){
      proto_tree *starteam_tree;
      proto_tree *starteamroot_tree;
      proto_item *ti;

      ti = proto_tree_add_item(tree, proto_starteam, tvb, offset, -1, ENC_NA);
      if (bRequest) proto_item_append_text(ti, " (%s)",
                                           val_to_str_ext(iCommand, &starteam_opcode_vals_ext, "Unknown (0x%02x)"));
      starteamroot_tree = proto_item_add_subtree(ti, ett_starteam);

      if(bRequest){
        if(tvb_length_remaining(tvb, offset) >= 20){
          ti = proto_tree_add_text(starteamroot_tree, tvb, offset, 20, STARTEAM_TEXT_MDH);
          starteam_tree = proto_item_add_subtree(ti, ett_starteam_mdh);

          proto_tree_add_item(starteam_tree, hf_starteam_mdh_session_tag, tvb, offset + 0,  4, ENC_LITTLE_ENDIAN);
          proto_tree_add_item(starteam_tree, hf_starteam_mdh_ctimestamp,  tvb, offset + 4,  4, ENC_LITTLE_ENDIAN);
          proto_tree_add_item(starteam_tree, hf_starteam_mdh_flags,       tvb, offset + 8,  4, ENC_LITTLE_ENDIAN);
          proto_tree_add_item(starteam_tree, hf_starteam_mdh_keyid,       tvb, offset + 12, 4, ENC_LITTLE_ENDIAN);
          proto_tree_add_item(starteam_tree, hf_starteam_mdh_reserved,    tvb, offset + 16, 4, ENC_LITTLE_ENDIAN);
          offset += 20;
        }
      }

      if(tvb_length_remaining(tvb, offset) >= 16){
        ti = proto_tree_add_text(starteamroot_tree, tvb, offset, 16, STARTEAM_TEXT_PH);
        starteam_tree = proto_item_add_subtree(ti, ett_starteam_ph);

        proto_tree_add_item(starteam_tree, hf_starteam_ph_signature,   tvb, offset + 0,  4,  ENC_ASCII|ENC_NA);
        proto_tree_add_item(starteam_tree, hf_starteam_ph_packet_size, tvb, offset + 4,  4,  ENC_LITTLE_ENDIAN);
        proto_tree_add_item(starteam_tree, hf_starteam_ph_data_size,   tvb, offset + 8,  4,  ENC_LITTLE_ENDIAN);
        proto_tree_add_item(starteam_tree, hf_starteam_ph_data_flags,  tvb, offset + 12, 4, ENC_LITTLE_ENDIAN);
        offset += 16;

        if(bRequest){
          if(tvb_length_remaining(tvb, offset) >= 38){
            ti = proto_tree_add_text(starteamroot_tree, tvb, offset, 38, STARTEAM_TEXT_ID);
            starteam_tree = proto_item_add_subtree(ti, ett_starteam_id);

            proto_tree_add_item(starteam_tree, hf_starteam_id_revision_level, tvb, offset + 0,  2, ENC_LITTLE_ENDIAN);
            proto_tree_add_item(starteam_tree, hf_starteam_id_client,         tvb, offset + 2, 16, ENC_ASCII|ENC_NA);
            proto_tree_add_item(starteam_tree, hf_starteam_id_connect,        tvb, offset + 18, 4, ENC_LITTLE_ENDIAN);
            proto_tree_add_item(starteam_tree, hf_starteam_id_component,      tvb, offset + 22, 4, ENC_LITTLE_ENDIAN);
            proto_tree_add_item(starteam_tree, hf_starteam_id_command,        tvb, offset + 26, 4, ENC_LITTLE_ENDIAN);
            proto_tree_add_item(starteam_tree, hf_starteam_id_command_time,   tvb, offset + 30, 4, ENC_LITTLE_ENDIAN);
            proto_tree_add_item(starteam_tree, hf_starteam_id_command_userid, tvb, offset + 34, 4, ENC_LITTLE_ENDIAN);
            offset += 38;
          }
        }
        if(tvb_length_remaining(tvb, offset) > 0){
          ti = proto_tree_add_text(starteamroot_tree, tvb, offset, -1, STARTEAM_TEXT_DATA);
          starteam_tree = proto_item_add_subtree(ti, ett_starteam_data);
          proto_tree_add_item(starteam_tree, hf_starteam_data_data, tvb, offset, tvb_length_remaining(tvb, offset), ENC_ASCII|ENC_NA);
        }
      }
    }
  }
}
	offset = 0;

	ti = proto_tree_add_item(tree, proto_abis_om2000,
				 tvb, 0, -1, ENC_NA);
	om2k_tree = proto_item_add_subtree(ti, ett_om2000);

	msg_code = tvb_get_ntohs(tvb, offset);
	proto_tree_add_item(om2k_tree, hf_om2k_msg_code, tvb, offset,
			    2, ENC_BIG_ENDIAN);
	offset += 2;

	offset += dissect_om2k_mo(tvb, offset, pinfo, om2k_tree);  /* appends to COL_INFO */

	col_append_fstr(pinfo->cinfo, COL_INFO, " %s ",
			val_to_str_ext(msg_code, &om2k_msgcode_vals_ext,
				   "unknown 0x%04x"));

	if (tree == NULL)
		return tvb_captured_length(tvb);   /* No refs to COL_...  beyond this point */

	proto_item_append_text(ti, " %s ",
			       val_to_str_ext(msg_code, &om2k_msgcode_vals_ext,
					  "unknown 0x%04x"));

	switch (msg_code) {
	case 0x74: /* Operational Info */
		tmp = tvb_get_guint8(tvb, offset+1);
		proto_item_append_text(ti, ": %s",
				       val_to_str(tmp, om2k_oip_vals,
						  "unknown 0x%02x"));
		break;
static void _dissect_uasip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, e_ua_direction direction)
{
    proto_item *uasip_item;
    proto_tree *uasip_tree;
    guint8      opcode;
    gint        offset = 0;

    if (noesip_enabled)
    {
        col_append_str(pinfo->cinfo, COL_PROTOCOL, "/NOE");
    }
    else
    {
        col_append_str(pinfo->cinfo, COL_PROTOCOL, "/DL");
    }

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

    ua_tap_info.opcode = opcode;
    ua_tap_info.expseq = 0;
    ua_tap_info.sntseq = 0;

    col_add_fstr(pinfo->cinfo, COL_INFO, "%s", val_to_str_ext(opcode, &uaudp_opcode_str_ext, "unknown (0x%02x)"));

    uasip_item = proto_tree_add_protocol_format(tree, proto_uasip, tvb, 0, 5,
                                                "SIP/NOE Protocol, %s",
                                                val_to_str_ext(opcode, &uaudp_opcode_str_ext, "unknown (0x%02x)"));
    uasip_tree = proto_item_add_subtree(uasip_item, ett_uasip);
    proto_tree_add_uint(uasip_tree, hf_uasip_opcode, tvb, 0, 1, opcode);

    switch(opcode)
    {
        case UAUDP_CONNECT:
        {
            if (!tree)
                break;
            while(tvb_offset_exists(tvb, offset))
            {
                guint8 T = tvb_get_guint8(tvb, offset+0);
                guint8 L = tvb_get_guint8(tvb, offset+1);

                switch(T)
                {
                    case UAUDP_CONNECT_VERSION:
                        rTLV(uasip_tree, &hf_uasip_version, tvb, offset, L);
                    break;

                    case UAUDP_CONNECT_WINDOW_SIZE:
                        rTLV(uasip_tree, &hf_uasip_window_size, tvb, offset, L);
                    break;

                    case UAUDP_CONNECT_MTU:
                        rTLV(uasip_tree, &hf_uasip_mtu, tvb, offset, L);
                    break;

                    case UAUDP_CONNECT_UDP_LOST:
                        rTLV(uasip_tree, &hf_uasip_udp_lost, tvb, offset, L);
                    break;

                    case UAUDP_CONNECT_UDP_LOST_REINIT:
                        rTLV(uasip_tree, &hf_uasip_udp_lost_reinit, tvb, offset, L);
                    break;

                    case UAUDP_CONNECT_KEEPALIVE:
                        rTLV(uasip_tree, &hf_uasip_keepalive, tvb, offset, L);
                    break;

                    case UAUDP_CONNECT_QOS_IP_TOS:
                        rTLV(uasip_tree, &hf_uasip_qos_ip_tos, tvb, offset, L);
                    break;

                    case UAUDP_CONNECT_QOS_8021_VLID:
                        rTLV(uasip_tree, &hf_uasip_qos_8021_vlid, tvb, offset, L);
                    break;

                    case UAUDP_CONNECT_QOS_8021_PRI:
                        rTLV(uasip_tree, &hf_uasip_qos_8021_pri, tvb, offset, L);
                    break;

                    default:
                    break;
                }
                offset += (2 + L);
            }
        }
        break;

        case UAUDP_NACK:
        {
            proto_tree_add_uint(uasip_tree, hf_uasip_expseq, tvb, offset, 2, tvb_get_ntohs(tvb, offset));
            ua_tap_info.expseq = tvb_get_ntohs(tvb, offset+0);

            /*offset += 2;*/

            if (noesip_enabled)
            {
                col_add_fstr(pinfo->cinfo, COL_INFO, "NACK");
            }
            else
            {
                col_add_fstr(pinfo->cinfo, COL_INFO, "NACK exp:%d", ua_tap_info.expseq);
            }
        }
        break;

        case UAUDP_DATA:
        {
            int datalen;

            proto_tree_add_uint(uasip_tree, hf_uasip_expseq, tvb, offset+0, 2, tvb_get_ntohs(tvb, offset+0));
            proto_tree_add_uint(uasip_tree, hf_uasip_sntseq, tvb, offset+2, 2, tvb_get_ntohs(tvb, offset+2));
            ua_tap_info.expseq = tvb_get_ntohs(tvb, offset+0);
            ua_tap_info.sntseq = tvb_get_ntohs(tvb, offset+2);
            offset += 4;
            datalen  = (tvb_length(tvb) - offset);

            if (noesip_enabled)
            {
                if (datalen > 0)
                {
                    if (direction == SYS_TO_TERM)
                    {
                        call_dissector(ua_sys_to_term_handle, tvb_new_subset(tvb, offset, datalen, datalen), pinfo, tree);
                    }
                    else if (direction == TERM_TO_SYS)
                    {
                        call_dissector(ua_term_to_sys_handle, tvb_new_subset(tvb, offset, datalen, datalen), pinfo, tree);
                    }
                    else
                    {
                        col_add_str(pinfo->cinfo, COL_INFO, "DATA - Couldn't resolve direction.");
                    }
                }
                else
                {
                    col_add_str(pinfo->cinfo, COL_INFO, "ACK");
                }
            }
            else
            {
                if (datalen > 0)
                {
                    col_add_fstr(pinfo->cinfo, COL_INFO, "DATA exp:%d", ua_tap_info.expseq);
                    col_append_fstr(pinfo->cinfo, COL_INFO, " snt:%d", ua_tap_info.sntseq);
                }
                else
                {
                    col_add_fstr(pinfo->cinfo, COL_INFO, "ACK  exp:%d", ua_tap_info.expseq);
                    col_append_fstr(pinfo->cinfo, COL_INFO, " snt:%d", ua_tap_info.sntseq);
                }
            }
        }
        break;

        default:
        break;
    }
#if 0
    tap_queue_packet(uasip_tap, pinfo, &ua_tap_info);
#endif
}
static gint
dissect_om2k_attrs(tvbuff_t *tvb, gint offset, proto_tree *tree)
{
	while (tvb_reported_length_remaining(tvb, offset) > 0) {
		guint8 iei = tvb_get_guint8(tvb, offset++);
		guint8 len, tmp;

		switch (iei) {
		case 0x00: /* Accordance Information */
			proto_tree_add_item(tree, hf_om2k_aip, tvb,
					    offset++, 1, ENC_BIG_ENDIAN);
			break;
		case 0x06: /* BCC */
			proto_tree_add_item(tree, hf_om2k_bcc, tvb,
					    offset++, 1, ENC_BIG_ENDIAN);
			break;
		case 0x07: /* BS_AG_BLKS_RES */
			proto_tree_add_item(tree, hf_om2k_bs_ag_blks_res, tvb,
					    offset++, 1, ENC_BIG_ENDIAN);
			break;
		case 0x09: /* BSIC */
			proto_tree_add_item(tree, hf_om2k_bsic, tvb,
					    offset++, 1, ENC_BIG_ENDIAN);
			break;
		case 0x0a: /* BS_PA_MFRMS */
			proto_tree_add_item(tree, hf_om2k_bs_pa_mfrms, tvb,
					    offset++, 1, ENC_BIG_ENDIAN);
			break;
		case 0x0b: /* CBCH indicator */
			proto_tree_add_item(tree, hf_om2k_cbi, tvb,
					    offset++, 1, ENC_BIG_ENDIAN);
			break;
		case 0x0c: /* CCCH Options */
			proto_tree_add_item(tree, hf_om2k_cr, tvb,
					    offset, 1, ENC_BIG_ENDIAN);
			proto_tree_add_item(tree, hf_om2k_ipt3, tvb,
					    offset, 1, ENC_BIG_ENDIAN);
			proto_tree_add_item(tree, hf_om2k_aop, tvb,
					    offset, 1, ENC_BIG_ENDIAN);
			offset++;
			break;
		case 0x0d: /* Calendar Time */
			offset += dissect_om2k_time(tvb, offset, tree);
			break;
		case 0x0f: /* Combination */
			proto_tree_add_item(tree, hf_om2k_comb, tvb,
					    offset++, 1, ENC_BIG_ENDIAN);
			break;
		case 0x10: /* CON Connection List */
			offset += dissect_om2k_con_list(tvb, offset, tree);
			break;
		case 0x12: /* DRX_DEV_MAX */
			proto_tree_add_item(tree, hf_om2k_drx_dev_max, tvb,
					    offset++, 1, ENC_BIG_ENDIAN);
			break;
		case 0x13: /* End List Number */
			proto_tree_add_item(tree, hf_om2k_list_nr_end, tvb,
					    offset++, 1, ENC_BIG_ENDIAN);
			break;
		case 0x14: /* External Condition Map Class 1 */
			/* FIXME */
		case 0x15: /* External Condition Map Class 2 */
			/* FIXME */
			offset += dissect_om2k_attr_unkn(tvb, offset, 2, iei, tree);
			break;
		case 0x16: /* File Relation Indication */
			proto_tree_add_item(tree, hf_om2k_filerel_ilr, tvb,
					    offset, 1, ENC_BIG_ENDIAN);
			proto_tree_add_item(tree, hf_om2k_filerel_cur, tvb,
					    offset, 1, ENC_BIG_ENDIAN);
			offset++;
			proto_tree_add_item(tree, hf_om2k_filerel_other, tvb,
					    offset, 1, ENC_BIG_ENDIAN);
			offset++;
			break;
		case 0x17: /* File Revision */
			proto_tree_add_item(tree, hf_om2k_file_rev, tvb,
					    offset, 8, ENC_ASCII|ENC_NA);
			offset += 8;
			break;
		case 0x1c: /* Filling Marker */
			proto_tree_add_item(tree, hf_om2k_fill_mark, tvb,
					    offset++, 1, ENC_BIG_ENDIAN);
			break;
		case 0x1d: /* FN Offset */
			proto_tree_add_item(tree, hf_om2k_fn_offs, tvb,
					    offset, 2, ENC_BIG_ENDIAN);
			offset += 2;
			break;
		case 0x1e: /* Frequency List */
			len = tvb_get_guint8(tvb, offset++);
			/* FIXME */
			offset += dissect_om2k_attr_unkn(tvb, offset, len, iei, tree);
			break;
		case 0x1f: /* Frequency Specifier Rx */
			/* FIXME */
		case 0x20: /* Frequency Specifier Rx */
			/* FIXME */
			offset += dissect_om2k_attr_unkn(tvb, offset, 2, iei, tree);
			break;
		case 0x21: /* HSN */
			proto_tree_add_item(tree, hf_om2k_hsn, tvb,
					    offset++, 1, ENC_BIG_ENDIAN);
			break;
		case 0x22: /* ICM */
			proto_tree_add_item(tree, hf_om2k_icm, tvb,
					    offset++, 1, ENC_BIG_ENDIAN);
			break;
		case 0x23: /* Internal Fault Map Class 1A */
			/* FIXME */
		case 0x24: /* Internal Fault Map Class 1B */
			/* FIXME */
		case 0x25: /* Internal Fault Map Class 2A */
			/* FIXME */
		case 0x26: /* Internal Fault Map Class 2A Ext */
			/* FIXME */
			offset += dissect_om2k_attr_unkn(tvb, offset, 6, iei, tree);
			break;
		case 0x27: /* IS Connection List */
			offset += dissect_om2k_is_list(tvb, offset, tree);
			break;
		case 0x28: /* List Number */
			proto_tree_add_item(tree, hf_om2k_list_nr, tvb,
					    offset++, 1, ENC_BIG_ENDIAN);
			break;
		case 0x2a: /* Local Access State */
			proto_tree_add_item(tree, hf_om2k_la_state, tvb,
					    offset++, 1, ENC_BIG_ENDIAN);
			break;
		case 0x2b: /* MAIO */
			proto_tree_add_item(tree, hf_om2k_maio, tvb,
					    offset++, 1, ENC_BIG_ENDIAN);
			break;
		case 0x2c: /* MO State */
			proto_tree_add_item(tree, hf_om2k_mo_state, tvb,
					    offset++, 1, ENC_BIG_ENDIAN);
			break;
		case 0x2d: /* Ny1 */
			proto_tree_add_item(tree, hf_om2k_ny1, tvb,
					    offset++, 1, ENC_BIG_ENDIAN);
			break;
		case 0x2e: /* Operational Information */
			proto_tree_add_item(tree, hf_om2k_oip, tvb,
					    offset++, 1, ENC_BIG_ENDIAN);
			break;
		case 0x2f: /* Nominal Power */
			proto_tree_add_item(tree, hf_om2k_nom_pwr, tvb,
					    offset++, 1, ENC_BIG_ENDIAN);
			break;
		case 0x33: /* Receiver Diversity */
			proto_tree_add_item(tree, hf_om2k_diversity, tvb,
					    offset++, 1, ENC_BIG_ENDIAN);
			break;
		case 0x34: /* Replacement Unit Map */
			/* FIXME */
			offset += dissect_om2k_attr_unkn(tvb, offset, 6, iei, tree);
			break;
		case 0x38: /* T3105 */
			proto_tree_add_item(tree, hf_om2k_t3105, tvb,
					    offset++, 1, ENC_BIG_ENDIAN);
			break;
		case 0x3a: /* TF Mode */
			proto_tree_add_item(tree, hf_om2k_tf_mode, tvb,
					    offset++, 1, ENC_BIG_ENDIAN);
			break;
		case 0x3c: /* TS Number */
			proto_tree_add_item(tree, hf_om2k_ts, tvb,
					    offset++, 1, ENC_BIG_ENDIAN);
			break;
		case 0x3d: /* TSC */
			proto_tree_add_item(tree, hf_om2k_tsc, tvb,
					    offset++, 1, ENC_BIG_ENDIAN);
			break;
		case 0x40: /* BTS Version */
			proto_tree_add_item(tree, hf_om2k_bts_manuf, tvb,
					    offset, 3, ENC_ASCII|ENC_NA);
			offset += 3;
			proto_tree_add_item(tree, hf_om2k_bts_gen, tvb,
					    offset, 3, ENC_ASCII|ENC_NA);
			offset += 3;
			proto_tree_add_item(tree, hf_om2k_bts_rev, tvb,
					    offset, 3, ENC_ASCII|ENC_NA);
			offset += 3;
			proto_tree_add_item(tree, hf_om2k_bts_var, tvb,
					    offset, 3, ENC_ASCII|ENC_NA);
			offset += 3;
			break;
		case 0x43: /* OML Function Map 1 */
		case 0x44: /* OML Function Map 2 */
		case 0x45: /* RSL Function Map 1 */
		case 0x46: /* RSL Function Map 2 */
			len = tvb_get_guint8(tvb, offset++);
			/* FIXME */
			offset += dissect_om2k_attr_unkn(tvb, offset, len, iei, tree);
			break;
		case 0x47: /* Ext Range */
			proto_tree_add_item(tree, hf_om2k_ext_range, tvb,
					    offset++, 1, ENC_BIG_ENDIAN);
			break;
		case 0x48: /* Request Indicators */
			proto_tree_add_item(tree, hf_om2k_brr, tvb,
					    offset, 1, ENC_BIG_ENDIAN);
			proto_tree_add_item(tree, hf_om2k_bfr, tvb,
					    offset, 1, ENC_BIG_ENDIAN);
			offset++;
			break;
		case 0x50: /* Replacement Unit Map Extension */
			/* FIXME */
			offset += dissect_om2k_attr_unkn(tvb, offset, 6, iei, tree);
			break;
		case 0x74: /* ICM Boundary */
			/* FIXME */
			offset += dissect_om2k_attr_unkn(tvb, offset, 5, iei, tree);
			break;
		case 0x79: /* Link Supervision Control */
			proto_tree_add_item(tree, hf_om2k_lsc_fm, tvb,
					    offset, 1, ENC_BIG_ENDIAN);
			proto_tree_add_item(tree, hf_om2k_lsc_lsi, tvb,
					    offset, 1, ENC_BIG_ENDIAN);
			proto_tree_add_item(tree, hf_om2k_lsc_lsa, tvb,
					    offset, 1, ENC_BIG_ENDIAN);
			offset++;
			break;
		case 0x7a: /* Link Supervision Control */
			proto_tree_add_item(tree, hf_om2k_ls_ft, tvb,
					    offset++, 1, ENC_BIG_ENDIAN);
			break;
		case 0x7b: /* Call Supervision Time */
			proto_tree_add_item(tree, hf_om2k_cst, tvb,
					    offset++, 1, ENC_BIG_ENDIAN);
			break;
		case 0x7e: /* ICM Channel Rate */
			proto_tree_add_item(tree, hf_om2k_icm_cr, tvb,
					    offset++, 1, ENC_BIG_ENDIAN);
			break;
		case 0x84: /* HW Info Signature */
			proto_tree_add_item(tree, hf_om2k_hwinfo_sig, tvb,
					    offset, 2, ENC_BIG_ENDIAN);
			offset += 2;
			break;
		case 0x87: /* TTA */
			proto_tree_add_item(tree, hf_om2k_tta, tvb,
					    offset++, 1, ENC_BIG_ENDIAN);
			break;
		case 0x8a: /* Capabilities Signature */
			proto_tree_add_item(tree, hf_om2k_capa_sig, tvb,
					    offset, 2, ENC_BIG_ENDIAN);
			offset += 2;
			break;
		case 0x90: /* Negotiation Record I */
		case 0x91: /* Negotiation Record II */
			len = tvb_get_guint8(tvb, offset++);
			/* FIXME */
			offset += dissect_om2k_attr_unkn(tvb, offset, len, iei, tree);
			break;
		case 0x92: /* Encryption Algorithm */
			proto_tree_add_item(tree, hf_om2k_ea, tvb,
					    offset++, 1, ENC_BIG_ENDIAN);
			break;
		case 0x94: /* Interference Rejection Combining */
			proto_tree_add_item(tree, hf_om2k_irc, tvb,
					    offset++, 1, ENC_BIG_ENDIAN);
			break;
		case 0x95: /* Dedication information */
			/* FIXME */
			offset += dissect_om2k_attr_unkn(tvb, offset, 3, iei, tree);
			break;
		case 0x98: /* FS Offset */
			proto_tree_add_item(tree, hf_om2k_tf_fs_offset, tvb,
					    offset, 5, ENC_BIG_ENDIAN);
			offset += 5;
			break;
		case 0x9c: /* External Condition Class 2 Extension */
			/* FIXME */
			offset += dissect_om2k_attr_unkn(tvb, offset, 4, iei, tree);
			break;
		case 0x9d: /* TSs MO State */
			offset += dissect_tss_mo_state(tvb, offset, tree);
			break;
		case 0x9e:
		case 0x9f:
		default:
			tmp = tvb_get_guint8(tvb, offset);
			proto_tree_add_uint_format(tree, hf_om2k_unknown_tag, tvb,
					    offset-1, 1, tmp, "Tag %s: 0x%02x",
					    val_to_str_ext(iei, &om2k_attr_vals_ext, "0x%02x"), tmp);
			offset++;
			break;
		}
	}

	return offset;
}
Exemple #25
0
/*
 * Name: dissect_lsp_svcs_info_clv()
 *
 * Description:
 *	Decode for a lsp packet's services information clv.
 *
 * Input:
 *	tvbuff_t * : tvbuffer for packet data
 *	proto_tree * : protocol display tree to fill out.  May be NULL
 *	int : offset into packet data where we are.
 *	int : length of clv we are decoding
 *
 * Output:
 *      void, but we will add to proto tree if !NULL.
 */
static void
dissect_lsp_svcs_info_clv(tvbuff_t *tvb, proto_tree *tree, int offset,
    int length)
{
	if (length < 1) {
		nlsp_dissect_unknown(tvb, tree, offset,
		    "Short services info entry");
		return;
	}
	if (tree) {
		proto_tree_add_text(tree, tvb, offset, 1,
		    "Hops to reach the service: %u",
		    tvb_get_guint8(tvb, offset));
	}
	offset += 1;
	length -= 1;

	if (length < 4) {
		nlsp_dissect_unknown(tvb, tree, offset,
		    "Short services info entry");
		return;
	}
	if (tree) {
		proto_tree_add_text(tree, tvb, offset, 4,
		    "Network number: 0x%08x",
		    tvb_get_ntohl(tvb, offset));
	}
	offset += 4;
	length -= 4;

	if (length < 6) {
		nlsp_dissect_unknown(tvb, tree, offset,
		    "Short services info entry");
		return;
	}
	if (tree) {
		proto_tree_add_text(tree, tvb, offset, 6,
		    "Node number: %s",
		    tvb_ether_to_str(tvb, offset));
	}
	offset += 6;
	length -= 6;

	if (length < 2) {
		nlsp_dissect_unknown(tvb, tree, offset,
		    "Short services info entry");
		return;
	}
	if (tree) {
		proto_tree_add_text(tree, tvb, offset, 2,
		    "Socket: %s",
		    val_to_str_ext(tvb_get_ntohs(tvb, offset), &ipx_socket_vals_ext,
			"Unknown (0x%04x)"));
	}
	offset += 2;
	length -= 2;

	if (length < 2) {
		nlsp_dissect_unknown(tvb, tree, offset,
		    "Short services info entry");
		return;
	}
	if (tree) {
		proto_tree_add_text(tree, tvb, offset, 2,
		    "Type: %s",
		    val_to_str_ext(tvb_get_ntohs(tvb, offset), &novell_server_vals_ext,
			"Unknown (0x%04x)"));
	}
	offset += 2;
	length -= 2;

	if (length > 0) {
		if (tree) {
			proto_tree_add_text(tree, tvb, offset, length,
			    "Service Name: %s",
			    tvb_format_text(tvb, offset, length));
		}
	}
}
Exemple #26
0
/* UA/UDP DISSECTOR */
static void _dissect_uaudp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
                           e_ua_direction direction)
{
    gint        offset = 0;
    guint8      opcode;
    proto_item *uaudp_item;
    proto_tree *uaudp_tree;

    col_set_str(pinfo->cinfo, COL_PROTOCOL, "UAUDP");

    /* get the identifier; it means operation code */
    opcode = tvb_get_guint8(tvb, offset);
    offset += 1;

    ua_tap_info.opcode = opcode;
    ua_tap_info.expseq = 0;
    ua_tap_info.sntseq = 0;

    /* print in "INFO" column the type of UAUDP message */
    col_add_fstr(pinfo->cinfo,
                COL_INFO,
                "%s",
                val_to_str_ext(opcode, &uaudp_opcode_str_ext, "unknown (0x%02x)"));

    uaudp_item = proto_tree_add_protocol_format(tree, proto_uaudp, tvb, 0, 5,
                            "Universal Alcatel/UDP Encapsulation Protocol, %s",
                            val_to_str_ext(opcode, &uaudp_opcode_str_ext, "unknown (0x%02x)"));

    uaudp_tree = proto_item_add_subtree(uaudp_item, ett_uaudp);

    /* print the identifier */
    proto_tree_add_uint(uaudp_tree, hf_uaudp_opcode, tvb, 0, 1, opcode);

    switch(opcode)
    {
    case UAUDP_CONNECT:
    {
        if (!tree)
            break;
        while (tvb_offset_exists(tvb, offset))
        {
            guint8 T = tvb_get_guint8(tvb, offset+0);
            guint8 L = tvb_get_guint8(tvb, offset+1);

            switch(T)
            {
            case UAUDP_CONNECT_VERSION:
                rV(uaudp_tree, &hf_uaudp_version        , tvb, offset, L);
                break;
            case UAUDP_CONNECT_WINDOW_SIZE:
                rV(uaudp_tree, &hf_uaudp_window_size    , tvb, offset, L);
                break;
            case UAUDP_CONNECT_MTU:
                rV(uaudp_tree, &hf_uaudp_mtu            , tvb, offset, L);
                break;
            case UAUDP_CONNECT_UDP_LOST:
                rV(uaudp_tree, &hf_uaudp_udp_lost       , tvb, offset, L);
                break;
            case UAUDP_CONNECT_UDP_LOST_REINIT:
                rV(uaudp_tree, &hf_uaudp_udp_lost_reinit, tvb, offset, L);
                break;
            case UAUDP_CONNECT_KEEPALIVE:
                rV(uaudp_tree, &hf_uaudp_keepalive      , tvb, offset, L);
                break;
            case UAUDP_CONNECT_QOS_IP_TOS:
                rV(uaudp_tree, &hf_uaudp_qos_ip_tos     , tvb, offset, L);
                break;
            case UAUDP_CONNECT_QOS_8021_VLID:
                rV(uaudp_tree, &hf_uaudp_qos_8021_vlid  , tvb, offset, L);
                break;
            case UAUDP_CONNECT_QOS_8021_PRI:
                rV(uaudp_tree, &hf_uaudp_qos_8021_pri   , tvb, offset, L);
                break;
            }
            offset += (2 + L);
        }
        break;
    }

    case UAUDP_NACK:
    {
        proto_tree_add_uint(uaudp_tree,
                    hf_uaudp_expseq,
                    tvb,
                    offset,
                    2,
                    tvb_get_ntohs(tvb, offset));
        break;
    }

    case UAUDP_DATA:
    {
        int datalen;

        proto_tree_add_uint(uaudp_tree,
                    hf_uaudp_expseq,
                    tvb,
                    offset+0,
                    2,
                    tvb_get_ntohs(tvb, offset+0));

        proto_tree_add_uint(uaudp_tree,
                    hf_uaudp_sntseq,
                    tvb,
                    offset+2,
                    2,
                    tvb_get_ntohs(tvb, offset+2));

        ua_tap_info.expseq = hf_uaudp_expseq;
        ua_tap_info.sntseq = hf_uaudp_sntseq;

        offset  += 4;
        datalen  = tvb_reported_length(tvb) - offset;

        /* if there is remaining data, call the UA dissector */
        if (datalen > 0)
        {
            if (direction == SYS_TO_TERM)
                call_dissector(ua_sys_to_term_handle,
                           tvb_new_subset(tvb, offset, datalen, datalen),
                           pinfo,
                           tree);
            else if (direction == TERM_TO_SYS)
                call_dissector(ua_term_to_sys_handle,
                           tvb_new_subset(tvb, offset, datalen, datalen),
                           pinfo,
                           tree);
            else {
                /* XXX: expert ?? */
                col_set_str(pinfo->cinfo,
                            COL_INFO,
                            "Data - Couldn't resolve direction. Check UAUDP Preferences.");
            }
            ua_tap_info.expseq = hf_uaudp_expseq;
        }
        else {
            /* print in "INFO" column */
            col_set_str(pinfo->cinfo,
                        COL_INFO,
                        "Data ACK");
        }
        break;
    }
    default:
        break;
    }
#if 0
    tap_queue_packet(uaudp_tap, pinfo, &ua_tap_info);
#endif
}
Exemple #27
0
static void
dissect_rtp_events( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree )
{
	proto_item   *ti;
	proto_tree   *rtp_events_tree;
	unsigned int  offset = 0;

	struct _rtp_conversation_info *p_conv_data;

	guint8 rtp_evt;
	guint8 octet;

	col_set_str(pinfo->cinfo, COL_PROTOCOL, "RTP EVENT");
	col_clear(pinfo->cinfo, COL_INFO);


	/* Get event fields */

	rtp_evt = tvb_get_guint8(tvb, offset );

	/* get tap info */
	rtp_event_info.info_rtp_evt = rtp_evt;

	p_conv_data = (struct _rtp_conversation_info *)p_get_proto_data(wmem_file_scope(), pinfo, proto_get_id_by_filter_name("rtp"), 0);
	if (p_conv_data)
		rtp_event_info.info_setup_frame_num = p_conv_data->frame_number;
	else
		rtp_event_info.info_setup_frame_num = 0;


	col_add_fstr( pinfo->cinfo, COL_INFO,
		"Payload type=RTP Event, %s",
		val_to_str_ext( rtp_evt, &rtp_event_type_values_ext, "Unknown (%u)" ));

	ti = proto_tree_add_item( tree, proto_rtp_events, tvb, offset, -1, ENC_NA );
	rtp_events_tree = proto_item_add_subtree( ti, ett_rtp_events );

	proto_tree_add_uint ( rtp_events_tree, hf_rtp_events_event, tvb, offset, 1, rtp_evt);
	offset++;
	octet = tvb_get_guint8(tvb, offset);
	proto_tree_add_boolean (rtp_events_tree, hf_rtp_events_end, tvb, offset, 1, octet);
	proto_tree_add_boolean (rtp_events_tree, hf_rtp_events_reserved, tvb, offset, 1, octet);
	proto_tree_add_uint ( rtp_events_tree, hf_rtp_events_volume, tvb, offset, 1, octet);
	offset++;

	/* The duration field indicates the duration of the event or segment
	 * being reported, in timestamp units.
	 */
	rtp_event_info.info_duration = tvb_get_ntohs(tvb, offset);
	proto_tree_add_item ( rtp_events_tree, hf_rtp_events_duration, tvb, offset, 2, ENC_BIG_ENDIAN);

	/* set the end info for the tap */
	if (octet & 0x80)
	{
		rtp_event_info.info_end = TRUE;
	} else
	{
		rtp_event_info.info_end = FALSE;
	}

	/* Make end-of-event packets obvious in the info column */
	if ((octet & 0x80))
	{
		col_append_str(pinfo->cinfo, COL_INFO, " (end)");
	}

	tap_queue_packet(rtp_event_tap, pinfo, &rtp_event_info);
}
Exemple #28
0
static void
dissect_dsi_packet(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
    proto_tree      *dsi_tree;
    proto_item	*ti;
    guint8		dsi_flags,dsi_command;
    guint16		dsi_requestid;
    gint32		dsi_code;
    guint32		dsi_length;
    guint32		dsi_reserved;
    struct		aspinfo aspinfo;


    col_set_str(pinfo->cinfo, COL_PROTOCOL, "DSI");
    col_clear(pinfo->cinfo, COL_INFO);

    dsi_flags = tvb_get_guint8(tvb, 0);
    dsi_command = tvb_get_guint8(tvb, 1);
    dsi_requestid = tvb_get_ntohs(tvb, 2);
    dsi_code = tvb_get_ntohl(tvb, 4);
    dsi_length = tvb_get_ntohl(tvb, 8);
    dsi_reserved = tvb_get_ntohl(tvb, 12);

    col_add_fstr(pinfo->cinfo, COL_INFO, "%s %s (%u)",
                 val_to_str(dsi_flags, flag_vals,
                            "Unknown flag (0x%02x)"),
                 val_to_str_ext(dsi_command, &func_vals_ext,
                                "Unknown function (0x%02x)"),
                 dsi_requestid);

    if (tree) {
        ti = proto_tree_add_item(tree, proto_dsi, tvb, 0, -1, ENC_NA);
        dsi_tree = proto_item_add_subtree(ti, ett_dsi);

        proto_tree_add_uint(dsi_tree, hf_dsi_flags, tvb,
                            0, 1, dsi_flags);
        proto_tree_add_uint(dsi_tree, hf_dsi_command, tvb,
                            1, 1, dsi_command);
        proto_tree_add_uint(dsi_tree, hf_dsi_requestid, tvb,
                            2, 2, dsi_requestid);
        switch (dsi_flags) {

        case DSIFL_REQUEST:
            proto_tree_add_int(dsi_tree, hf_dsi_offset, tvb,
                               4, 4, dsi_code);
            break;

        case DSIFL_REPLY:
            proto_tree_add_int(dsi_tree, hf_dsi_error, tvb,
                               4, 4, dsi_code);
            break;
        }
        proto_tree_add_uint_format_value(dsi_tree, hf_dsi_length, tvb,
                                         8, 4, dsi_length,
                                         "%u bytes", dsi_length);
        proto_tree_add_uint(dsi_tree, hf_dsi_reserved, tvb,
                            12, 4, dsi_reserved);
    }
    else
        dsi_tree = tree;
    switch (dsi_command) {
    case DSIFUNC_OPEN:
        if (tree) {
            dissect_dsi_open_session(tvb, dsi_tree, DSI_BLOCKSIZ, dsi_length);
        }
        break;
    case DSIFUNC_ATTN:
        if (tree) {
            dissect_dsi_attention(tvb, dsi_tree, DSI_BLOCKSIZ);
        }
        break;
    case DSIFUNC_STAT:
        if (tree && (dsi_flags == DSIFL_REPLY)) {
            dissect_dsi_reply_get_status(tvb, dsi_tree, DSI_BLOCKSIZ);
        }
        break;
    case DSIFUNC_CMD:
    case DSIFUNC_WRITE:
    {
        tvbuff_t   *new_tvb;
        void* pd_save;
        int len = tvb_reported_length_remaining(tvb,DSI_BLOCKSIZ);

        aspinfo.reply = (dsi_flags == DSIFL_REPLY);
        aspinfo.command = dsi_command;
        aspinfo.seq = dsi_requestid;
        aspinfo.code = dsi_code;
        pd_save = pinfo->private_data;
        pinfo->private_data = &aspinfo;
        proto_item_set_len(dsi_tree, DSI_BLOCKSIZ);

        new_tvb = tvb_new_subset(tvb, DSI_BLOCKSIZ,-1,len);
        call_dissector(afp_handle, new_tvb, pinfo, tree);
        pinfo->private_data = pd_save;
    }
    break;
    default:
        if (tree) {
            call_dissector(data_handle,
                           tvb_new_subset_remaining(tvb, DSI_BLOCKSIZ),
                           pinfo, dsi_tree);
        }
        break;
    }
}
Exemple #29
0
static void
dissect_drda(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
    gint offset = 0;

    guint16 iCommand;
    guint16 iLength;
    guint16 iCommandEnd = 0;

    guint8 iFormatFlags;
    guint8 iDSSType;
    guint8 iDSSFlags;

    guint16 iParameterCP;
    gint iLengthParam;

    col_set_str(pinfo->cinfo, COL_PROTOCOL, "DRDA");
    /* This is a trick to know whether this is the first PDU in this packet or not */
    if (iPreviousFrameNumber != pinfo->fd->num)
        col_clear(pinfo->cinfo, COL_INFO);
    else
        col_append_str(pinfo->cinfo, COL_INFO, " | ");

    iPreviousFrameNumber = pinfo->fd->num;
    /* There may be multiple DRDA commands in one frame */
    while ((guint) (offset + 10) <= tvb_length(tvb))
    {
        iCommand = tvb_get_ntohs(tvb, offset + 8);
        iLength = tvb_get_ntohs(tvb, offset + 0);
        if (iLength < 10) {
            expert_add_info_format_text(pinfo, NULL, &ei_drda_opcode_invalid_length, "Invalid length detected (%u): should be at least 10 bytes long", iLength);
            break;
        }
        /* iCommandEnd is the length of the packet up to the end of the current command */
        iCommandEnd += iLength;

        if (offset > 0)
            col_append_str(pinfo->cinfo, COL_INFO, " | ");
        col_append_str(pinfo->cinfo, COL_INFO, val_to_str_ext(iCommand, &drda_opcode_abbr_ext, "Unknown (0x%02x)"));

        if (tree)
        {
            proto_tree  *drda_tree;
            proto_tree  *drdaroot_tree;
            proto_tree  *drda_tree_sub;
            proto_item  *ti;

            ti = proto_tree_add_item(tree, proto_drda, tvb, offset, -1, ENC_NA);
            proto_item_append_text(ti, " (%s)", val_to_str_ext(iCommand, &drda_opcode_vals_ext, "Unknown (0x%02x)"));
            drdaroot_tree = proto_item_add_subtree(ti, ett_drda);

            ti = proto_tree_add_text(drdaroot_tree, tvb, offset, 10, DRDA_TEXT_DDM);
            proto_item_append_text(ti, " (%s)", val_to_str_ext(iCommand, &drda_opcode_abbr_ext, "Unknown (0x%02x)"));
            drda_tree = proto_item_add_subtree(ti, ett_drda_ddm);

            proto_tree_add_item(drda_tree, hf_drda_ddm_length, tvb, offset + 0, 2, ENC_BIG_ENDIAN);
            proto_tree_add_item(drda_tree, hf_drda_ddm_magic, tvb, offset + 2, 1, ENC_BIG_ENDIAN);

            iFormatFlags = tvb_get_guint8(tvb, offset + 3);
            iDSSType = iFormatFlags & 0x0F;
            iDSSFlags = iFormatFlags >> 4;

            ti = proto_tree_add_item(drda_tree, hf_drda_ddm_format, tvb, offset + 3, 1, ENC_BIG_ENDIAN);
            drda_tree_sub = proto_item_add_subtree(ti, ett_drda_ddm_format);

            proto_tree_add_boolean(drda_tree_sub, hf_drda_ddm_fmt_reserved, tvb, offset + 3, 1, iDSSFlags);
            proto_tree_add_boolean(drda_tree_sub, hf_drda_ddm_fmt_chained, tvb, offset + 3, 1, iDSSFlags);
            proto_tree_add_boolean(drda_tree_sub, hf_drda_ddm_fmt_errcont, tvb, offset + 3, 1, iDSSFlags);
            proto_tree_add_boolean(drda_tree_sub, hf_drda_ddm_fmt_samecorr, tvb, offset + 3, 1, iDSSFlags);
            proto_tree_add_uint(drda_tree_sub, hf_drda_ddm_fmt_dsstyp, tvb, offset + 3, 1, iDSSType);

            proto_tree_add_item(drda_tree, hf_drda_ddm_rc, tvb, offset + 4, 2, ENC_BIG_ENDIAN);
            proto_tree_add_item(drda_tree, hf_drda_ddm_length2, tvb, offset + 6, 2, ENC_BIG_ENDIAN);
            proto_tree_add_item(drda_tree, hf_drda_ddm_codepoint, tvb, offset + 8, 2, ENC_BIG_ENDIAN);

            /* The number of attributes is variable */
            for (offset += 10; offset < iCommandEnd; )
            {
                if (tvb_length_remaining(tvb, offset) >= 2)
                {
                    iLengthParam = tvb_get_ntohs(tvb, offset + 0);
                    if (iLengthParam == 0 || iLengthParam == 1) iLengthParam = iLength - 10;
                    if (tvb_length_remaining(tvb, offset) >= iLengthParam)
                    {
                        iParameterCP = tvb_get_ntohs(tvb, offset + 2);
                        ti = proto_tree_add_text(drdaroot_tree, tvb, offset, iLengthParam,
                                     DRDA_TEXT_PARAM);
                        proto_item_append_text(ti, " (%s)", val_to_str_ext(iParameterCP, &drda_opcode_vals_ext, "Unknown (0x%02x)"));
                        drda_tree_sub = proto_item_add_subtree(ti, ett_drda_param);
                        proto_tree_add_item(drda_tree_sub, hf_drda_param_length, tvb, offset, 2, ENC_BIG_ENDIAN);
                        proto_tree_add_item(drda_tree_sub, hf_drda_param_codepoint, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
                        proto_tree_add_item(drda_tree_sub, hf_drda_param_data, tvb, offset + 4, iLengthParam - 4, ENC_UTF_8|ENC_NA);
                        proto_tree_add_item(drda_tree_sub, hf_drda_param_data_ebcdic, tvb, offset + 4, iLengthParam - 4, ENC_EBCDIC|ENC_NA);
                        if (iCommand == DRDA_CP_SQLSTT)
                        {
                            /* Extract SQL statement from packet */
                            tvbuff_t* next_tvb = NULL;
                            next_tvb = tvb_new_subset(tvb, offset + 4, iLengthParam - 4, iLengthParam - 4);
                            add_new_data_source(pinfo, next_tvb, "SQL statement");
                            proto_tree_add_item(drdaroot_tree, hf_drda_sqlstatement, next_tvb, 0, iLengthParam - 5, ENC_UTF_8|ENC_NA);
                            proto_tree_add_item(drdaroot_tree, hf_drda_sqlstatement_ebcdic, next_tvb, 0, iLengthParam - 4, ENC_EBCDIC|ENC_NA);
                        }
                    }
                    offset += iLengthParam;
                }
                else
                {
                    break;
                }
            }
        }
        else
        {
            /* No tree, advance directly to next command */
            offset += iLength;
        }
    }