예제 #1
0
static void dissect_icp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
	proto_tree *icp_tree , *payload_tree;
	proto_item *ti;
	guint8 opcode;
	guint16 message_length;
	guint32 request_number;
	guint32 options;

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

	opcode=tvb_get_guint8(tvb, 0);
	message_length=tvb_get_ntohs(tvb, 2);
	request_number=tvb_get_ntohl(tvb, 4);

	col_add_fstr(pinfo->cinfo,COL_INFO,"Opcode: %s (%u), Req Nr: %u",
		     val_to_str_const(opcode, opcode_vals, "Unknown"), opcode,
		     request_number);

	if (tree)
	{

		ti = proto_tree_add_item(tree,proto_icp, tvb, 0, message_length, ENC_NA);
		icp_tree = proto_item_add_subtree(ti, ett_icp);

		proto_tree_add_uint(icp_tree,hf_icp_opcode, tvb, 0, 1, opcode);

		proto_tree_add_item(icp_tree,hf_icp_version, tvb, 1, 1, ENC_BIG_ENDIAN);

		proto_tree_add_uint(icp_tree,hf_icp_length, tvb, 2, 2, message_length);

		proto_tree_add_uint(icp_tree,hf_icp_request_nr, tvb, 4, 4,
				    request_number);

		options=tvb_get_ntohl(tvb, 8);
		if ( (opcode == CODE_ICP_OP_QUERY) && ((options & 0x80000000 ) != 0) )
		{
			proto_tree_add_item(icp_tree, hf_icp_option_hit_obj, tvb, 8, 4, ENC_NA);
		}
		if ( (opcode == CODE_ICP_OP_QUERY)&& ((options & 0x40000000 ) != 0) )
		{
			proto_tree_add_item(icp_tree, hf_icp_option_src_rtt, tvb, 8, 4, ENC_NA);
		}
		if ((opcode != CODE_ICP_OP_QUERY)&& ((options & 0x40000000 ) != 0))
		{
			proto_tree_add_item(icp_tree, hf_icp_option_src_rtt, tvb, 8, 4, ENC_NA);
            proto_tree_add_item(icp_tree, hf_icp_rtt, tvb, 12, 4, ENC_BIG_ENDIAN);
		}

		proto_tree_add_item(icp_tree, hf_icp_sender_host_ip_address, tvb, 16, 4, ENC_BIG_ENDIAN);

		payload_tree = proto_tree_add_subtree(icp_tree, tvb,
						      20, message_length - 20,
						      ett_icp_payload, NULL, "Payload");
		dissect_icp_payload(tvb, pinfo, 20, payload_tree, opcode);
	}
}
예제 #2
0
static void dissect_icp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
  proto_tree *icp_tree , *payload_tree;
  proto_item *ti , *payloadtf;
  guint8 opcode;
  guint16 message_length;
  guint32 request_number;
  guint32 options;
  guint32 option_data;

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

  opcode=tvb_get_guint8(tvb, 0);
  message_length=tvb_get_ntohs(tvb, 2);
  request_number=tvb_get_ntohl(tvb, 4);

  if (check_col(pinfo->cinfo, COL_INFO))
  {
        col_add_fstr(pinfo->cinfo,COL_INFO,"Opcode: %s (%u), Req Nr: %u",
		val_to_str(opcode, opcode_vals, "Unknown"), opcode,
		request_number);
  }

  if (tree)
  {

        ti = proto_tree_add_item(tree,proto_icp, tvb, 0, message_length, ENC_NA);
        icp_tree = proto_item_add_subtree(ti, ett_icp);

        proto_tree_add_uint(icp_tree,hf_icp_opcode, tvb, 0, 1, opcode);

        proto_tree_add_item(icp_tree,hf_icp_version, tvb, 1, 1, ENC_BIG_ENDIAN);

        proto_tree_add_uint(icp_tree,hf_icp_length, tvb, 2, 2, message_length);

        proto_tree_add_uint(icp_tree,hf_icp_request_nr, tvb, 4, 4,
                request_number);

	options=tvb_get_ntohl(tvb, 8);
	if ( (opcode == CODE_ICP_OP_QUERY) && ((options & 0x80000000 ) != 0) )
	{
		proto_tree_add_text(icp_tree, tvb,8,4,
			"option: ICP_FLAG_HIT_OBJ");
  	}
	if ( (opcode == CODE_ICP_OP_QUERY)&& ((options & 0x40000000 ) != 0) )
	{
		proto_tree_add_text(icp_tree, tvb,8,4,
			"option:ICP_FLAG_SRC_RTT");
  	}
	if ((opcode != CODE_ICP_OP_QUERY)&& ((options & 0x40000000 ) != 0))
	{
		option_data=tvb_get_ntohl(tvb, 12);
		proto_tree_add_text(icp_tree, tvb,8,8,
			"option: ICP_FLAG_SCR_RTT RTT=%u",
			option_data & 0x0000ffff);
	}

	proto_tree_add_text(icp_tree, tvb, 16, 4,
			"Sender Host IP address %s",
			tvb_ip_to_str(tvb, 16));

        payloadtf = proto_tree_add_text(icp_tree, tvb,
                        20, message_length - 20,
                        "Payload");
        payload_tree = proto_item_add_subtree(payloadtf, ett_icp_payload);
        dissect_icp_payload(tvb, 20, payload_tree, opcode);
  }
}