Fix expert_...() calls to not be under 'if (tree)';Do other minor changes;

Minor changes;
 - Remove #include <epan/etypes.h>; It's not needed;
 - Do some whitespace changes;
 - Use tab-width=8 in editor modelines

Change-Id: I84a1c9bc814fae384c4d5a434c2f9aed865c76ae
Reviewed-on: https://code.wireshark.org/review/899
Reviewed-by: Bill Meier <wmeier@newsguy.com>
Tested-by: Bill Meier <wmeier@newsguy.com>
This commit is contained in:
Bill Meier 2014-03-31 22:50:39 -04:00
parent 4958cd7e50
commit a72dc7a2dd
1 changed files with 120 additions and 115 deletions

View File

@ -32,7 +32,6 @@
#include "config.h"
#include <epan/packet.h>
#include <epan/etypes.h>
#include <epan/expert.h>
void proto_register_1722a(void);
@ -257,11 +256,11 @@ static void dissect_1722a (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
subtype = tvb_get_guint8(tvb, IEEE_1722A_CD_OFFSET);
subtype &= IEEE_1722A_SUBTYPE_MASK;
if (tree)
{
switch (subtype)
{
case IEEE_1722A_SUBTYPE_AVTP_AUDIO:
if (tree)
{
proto_tree_add_item(ieee1722a_tree, hf_1722a_mrfield, tvb, IEEE_1722A_VERSION_OFFSET, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(ieee1722a_tree, hf_1722a_tvfield, tvb, IEEE_1722A_VERSION_OFFSET, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(ieee1722a_tree, hf_1722a_seqnum, tvb, IEEE_1722A_SEQ_NUM_OFFSET, 1, ENC_BIG_ENDIAN);
@ -270,6 +269,24 @@ static void dissect_1722a (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
proto_tree_add_item(ieee1722a_tree, hf_1722a_avbtp_timestamp, tvb, IEEE_1722A_TIMESTAMP_OFFSET, 4, ENC_BIG_ENDIAN);
proto_tree_add_item(ieee1722a_tree, hf_1722a_format_info, tvb, IEEE_1722A_FORMAT_INFO_OFFSET, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(ieee1722a_tree, hf_1722a_nominal_sample_rate, tvb, IEEE_1722A_NOM_SAMPLE_RATE_OFFSET, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(ieee1722a_tree, hf_1722a_channels_per_frame, tvb, IEEE_1722A_CHANNELS_PER_FRAME_OFFSET, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(ieee1722a_tree, hf_1722a_bit_depth, tvb, IEEE_1722A_BIT_DEPTH_OFFSET, 1, ENC_BIG_ENDIAN);
ti = proto_tree_add_item(ieee1722a_tree, hf_1722a_stream_data_length, tvb, IEEE_1722A_STREAM_DATA_LENGTH_OFFSET, 2, ENC_BIG_ENDIAN);
proto_item_append_text(ti, " bytes");
proto_tree_add_item(ieee1722a_tree, hf_1722a_sparse_timestamp, tvb, IEEE_1722A_SPARSE_TIMESTAMP_OFFSET, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(ieee1722a_tree, hf_1722a_evtfield, tvb, IEEE_1722A_EVT_OFFSET, 1, ENC_BIG_ENDIAN);
}
/* Make the Audio sample tree. */
datalen = tvb_get_ntohs(tvb, IEEE_1722A_STREAM_DATA_LENGTH_OFFSET); /* Length of audio data in bytes */
ti = proto_tree_add_item(ieee1722a_tree, hf_1722a_data, tvb, IEEE_1722A_DATA_OFFSET, datalen, ENC_NA);
audio_tree = proto_item_add_subtree(ti, ett_1722a_audio);
/* Need to get the offset of where the audio data starts */
offset = IEEE_1722A_DATA_OFFSET;
channels_per_frame = tvb_get_ntohs(tvb, IEEE_1722A_CHANNELS_PER_FRAME_OFFSET);
channels_per_frame &= IEEE_1722A_CHANNEL_PER_FRAME_MASK;
switch (tvb_get_guint8(tvb, IEEE_1722A_FORMAT_INFO_OFFSET))
{
case 0:
@ -291,24 +308,6 @@ static void dissect_1722a (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
break;
}
proto_tree_add_item(ieee1722a_tree, hf_1722a_nominal_sample_rate, tvb, IEEE_1722A_NOM_SAMPLE_RATE_OFFSET, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(ieee1722a_tree, hf_1722a_channels_per_frame, tvb, IEEE_1722A_CHANNELS_PER_FRAME_OFFSET, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(ieee1722a_tree, hf_1722a_bit_depth, tvb, IEEE_1722A_BIT_DEPTH_OFFSET, 1, ENC_BIG_ENDIAN);
ti = proto_tree_add_item(ieee1722a_tree, hf_1722a_stream_data_length, tvb, IEEE_1722A_STREAM_DATA_LENGTH_OFFSET, 2, ENC_BIG_ENDIAN);
proto_item_append_text(ti, " bytes");
proto_tree_add_item(ieee1722a_tree, hf_1722a_sparse_timestamp, tvb, IEEE_1722A_SPARSE_TIMESTAMP_OFFSET, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(ieee1722a_tree, hf_1722a_evtfield, tvb, IEEE_1722A_EVT_OFFSET, 1, ENC_BIG_ENDIAN);
/* Make the Audio sample tree. */
datalen = tvb_get_ntohs(tvb, IEEE_1722A_STREAM_DATA_LENGTH_OFFSET); /* Length of audio data in bytes */
ti = proto_tree_add_item(ieee1722a_tree, hf_1722a_data, tvb, IEEE_1722A_DATA_OFFSET, datalen, ENC_NA);
audio_tree = proto_item_add_subtree(ti, ett_1722a_audio);
/* Need to get the offset of where the audio data starts */
offset = IEEE_1722A_DATA_OFFSET;
channels_per_frame = tvb_get_ntohs(tvb, IEEE_1722A_CHANNELS_PER_FRAME_OFFSET);
channels_per_frame &= IEEE_1722A_CHANNEL_PER_FRAME_MASK;
if (sample_width == 0)
{
expert_add_info(pinfo, ti, &ei_sample_width);
@ -320,6 +319,8 @@ static void dissect_1722a (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
expert_add_info(pinfo, ti, &ei_channels_per_frame);
}
else
{
if (tree)
{
/* Loop through all samples and add them to the audio tree. */
for (j = 0; j < ((datalen * 8) / (channels_per_frame * sample_width)); j++)
@ -335,6 +336,7 @@ static void dissect_1722a (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
}
}
}
}
break;
case IEEE_1722A_SUBTYPE_CRF:
proto_tree_add_item(ieee1722a_tree, hf_1722a_mrfield, tvb, IEEE_1722A_VERSION_OFFSET, 1, ENC_BIG_ENDIAN);
@ -350,6 +352,8 @@ static void dissect_1722a (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
/* Audio Timestamp Case */
case IEEE_1722A_CRF_AUDIO_SAMPLE_TIMESTAMP:
if (tree)
{
proto_tree_add_item(ieee1722a_tree, hf_1722a_clock_frequency, tvb, IEEE_1722A_CRF_CLOCK_FREQUENCY_OFFSET, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(ieee1722a_tree, hf_1722a_clock_multiplier, tvb, IEEE_1722A_CRF_CLOCK_MULTIPLIER_OFFSET, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(ieee1722a_tree, hf_1722a_timestamp_interval, tvb, IEEE_1722A_CRF_TIMESTAMP_INTERVAL_OFFSET, 2, ENC_BIG_ENDIAN);
@ -365,6 +369,7 @@ static void dissect_1722a (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
proto_tree_add_item(timestamp_tree, hf_1722a_crf_timestamp_data, tvb, offset, IEEE_1722A_CRF_TIMESTAMP_SIZE, ENC_NA);
offset += IEEE_1722A_CRF_TIMESTAMP_SIZE;
}
}
break;
default:
expert_add_info(pinfo, ti, &ei_clock_reference_type);
@ -374,9 +379,9 @@ static void dissect_1722a (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
default:
/* This dissector only registers for subtype 0x02 (AVTP Audio Format) and 0x05 (Clock Reference Format)
which will be handled above. So we won`t enter the default path. */
DISSECTOR_ASSERT_NOT_REACHED();
break;
}
}
}
/* Register the protocol with Wireshark */
@ -517,10 +522,10 @@ void proto_reg_handoff_1722a(void)
*
* Local variables:
* c-basic-offset: 4
* tab-width: 4
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* vi: set shiftwidth=4 tabstop=4 expandtab:
* :indentSize=4:tabSize=4:noTabs=true:
* vi: set shiftwidth=4 tabstop=8 expandtab:
* :indentSize=4:tabSize=8:noTabs=true:
*/