aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2014-09-08 15:09:50 -0400
committerMichael Mann <mmann78@netscape.net>2014-09-09 02:06:43 +0000
commitf91ef6dd4dd234a624547d93802d53c0540d2c69 (patch)
tree6d6944bcc2a3b817f98a85af0caae6f7ace3a907
parent80407a46df538011c1dcea96714c401a4078a697 (diff)
General cleanup of RTP-MIDI dissector.
The biggest changes involved: 1. Use the "bounds checking" of proto_tree_add_xxx, instead of doing it manually. There are still places where it's done "manually", but they have been drastically reduced. Someone with more understanding of the protocol/dissector would need to take a look at them. 2. proto_tree_add_text -> proto_tree_add_subtree[_format] 3. Use proto_tree_add_bitmask when appropriate. Change-Id: Iddbd2aadf5fd27f2cf9ba63873eb59dbd93b6394 Reviewed-on: https://code.wireshark.org/review/4039 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
-rw-r--r--epan/dissectors/packet-rtp-midi.c1938
1 files changed, 544 insertions, 1394 deletions
diff --git a/epan/dissectors/packet-rtp-midi.c b/epan/dissectors/packet-rtp-midi.c
index 0f63249ae3..a73f402ac5 100644
--- a/epan/dissectors/packet-rtp-midi.c
+++ b/epan/dissectors/packet-rtp-midi.c
@@ -973,19 +973,12 @@ void proto_register_rtp_midi(void);
#define RTP_MIDI_TREE_NAME_JOURNAL "Journal Section"
#define RTP_MIDI_TREE_NAME_SYSTEM_JOURNAL "System-Journal"
#define RTP_MIDI_TREE_NAME_SYSTEM_CHAPTERS "System-Chapters"
-#define RTP_MIDI_TREE_NAME_SJ_CHAPTER_D "Simple System Commands"
-#define RTP_MIDI_TREE_NAME_SJ_CHAPTER_D_FIELD_B "Reset Field"
-#define RTP_MIDI_TREE_NAME_SJ_CHAPTER_D_FIELD_G "Tune Request Field"
-#define RTP_MIDI_TREE_NAME_SJ_CHAPTER_D_FIELD_H "Song Select Field"
#define RTP_MIDI_TREE_NAME_SJ_CHAPTER_D_FIELD_J "System Common 0xF4"
#define RTP_MIDI_TREE_NAME_SJ_CHAPTER_D_FIELD_K "System Common 0xF5"
#define RTP_MIDI_TREE_NAME_SJ_CHAPTER_D_FIELD_Y "System Common 0xF9"
#define RTP_MIDI_TREE_NAME_SJ_CHAPTER_D_FIELD_Z "System Common 0xFD"
-#define RTP_MIDI_TREE_NAME_SJ_CHAPTER_V "Active Sensing"
#define RTP_MIDI_TREE_NAME_SJ_CHAPTER_Q "Sequencer State Commands"
#define RTP_MIDI_TREE_NAME_SJ_CHAPTER_F "MIDI Time Code Tape Position"
-#define RTP_MIDI_TREE_NAME_SJ_CHAPTER_F_COMPLETE "Complete field"
-#define RTP_MIDI_TREE_NAME_SJ_CHAPTER_F_PARTIAL "Partial field"
#define RTP_MIDI_TREE_NAME_SJ_CHAPTER_X "System Exclusive"
#define RTP_MIDI_TREE_NAME_SJ_CHAPTER_X_DATA "Data field (sysex commands)"
#define RTP_MIDI_TREE_NAME_SJ_CHAPTER_X_INVALID_DATA "Data field (invalid sysex commands)"
@@ -998,10 +991,6 @@ void proto_register_rtp_midi(void);
#define RTP_MIDI_TREE_NAME_CJ_CHAPTER_M "Parameter System"
#define RTP_MIDI_TREE_NAME_CJ_CHAPTER_M_LOGLIST "Log List"
#define RTP_MIDI_TREE_NAME_CJ_CHAPTER_M_LOGITEM "Log Item"
-#define RTP_MIDI_TREE_NAME_CJ_CHAPTER_M_LOG_MSB "Entry MSB"
-#define RTP_MIDI_TREE_NAME_CJ_CHAPTER_M_LOG_LSB "Entry LSB"
-#define RTP_MIDI_TREE_NAME_CJ_CHAPTER_M_LOG_A_BUTTON "A-Button"
-#define RTP_MIDI_TREE_NAME_CJ_CHAPTER_M_LOG_C_BUTTON "C-Button"
#define RTP_MIDI_TREE_NAME_CJ_CHAPTER_M_LOG_COUNT "Count"
#define RTP_MIDI_TREE_NAME_CJ_CHAPTER_W "Pitch Wheel"
#define RTP_MIDI_TREE_NAME_CJ_CHAPTER_N "Note on/off"
@@ -1012,7 +1001,6 @@ void proto_register_rtp_midi(void);
#define RTP_MIDI_TREE_NAME_CJ_CHAPTER_E_LOGLIST "Log List"
#define RTP_MIDI_TREE_NAME_CJ_CHAPTER_E_LOGITEM1 "Note Off"
#define RTP_MIDI_TREE_NAME_CJ_CHAPTER_E_LOGITEM2 "Note On/Off"
-#define RTP_MIDI_TREE_NAME_CJ_CHAPTER_T "Channel Aftertouch"
#define RTP_MIDI_TREE_NAME_CJ_CHAPTER_A "Poly Aftertouch"
#define RTP_MIDI_TREE_NAME_CJ_CHAPTER_A_LOGLIST "Log List"
#define RTP_MIDI_TREE_NAME_CJ_CHAPTER_A_LOGITEM "Pressure"
@@ -2605,18 +2593,23 @@ static int hf_rtp_midi_cj_chapter_m_log_nflag = -1;
static int hf_rtp_midi_cj_chapter_m_log_tflag = -1;
static int hf_rtp_midi_cj_chapter_m_log_vflag = -1;
static int hf_rtp_midi_cj_chapter_m_log_rflag = -1;
-static int hf_rtp_midi_cj_chapter_m_log_msb = -1;
+static int hf_rtp_midi_cj_chapter_m_log_msb = -1;
static int hf_rtp_midi_cj_chapter_m_log_msb_x = -1;
-static int hf_rtp_midi_cj_chapter_m_log_lsb = -1;
+static int hf_rtp_midi_cj_chapter_m_log_msb_entry = -1;
+static int hf_rtp_midi_cj_chapter_m_log_lsb = -1;
static int hf_rtp_midi_cj_chapter_m_log_lsb_x = -1;
+static int hf_rtp_midi_cj_chapter_m_log_lsb_entry = -1;
static int hf_rtp_midi_cj_chapter_m_log_a_button_g = -1;
static int hf_rtp_midi_cj_chapter_m_log_a_button_x = -1;
static int hf_rtp_midi_cj_chapter_m_log_a_button = -1;
+static int hf_rtp_midi_cj_chapter_m_log_a_button_full = -1;
static int hf_rtp_midi_cj_chapter_m_log_c_button = -1;
static int hf_rtp_midi_cj_chapter_m_log_c_button_g = -1;
static int hf_rtp_midi_cj_chapter_m_log_c_button_r = -1;
+static int hf_rtp_midi_cj_chapter_m_log_c_button_full = -1;
static int hf_rtp_midi_cj_chapter_m_log_count = -1;
static int hf_rtp_midi_cj_chapter_m_log_count_x = -1;
+static int hf_rtp_midi_cj_chapter_m_log_count_full = -1;
static int hf_rtp_midi_cj_chapter_w_sflag = -1;
static int hf_rtp_midi_cj_chapter_w_first = -1;
@@ -2641,7 +2634,8 @@ static int hf_rtp_midi_cj_chapter_e_log_vflag = -1;
static int hf_rtp_midi_cj_chapter_e_log_velocity = -1;
static int hf_rtp_midi_cj_chapter_e_log_count = -1;
-static int hf_rtp_midi_cj_chapter_t_sflag = -1;
+static int hf_rtp_midi_cj_chapter_t_channel_aftertouch = -1;
+static int hf_rtp_midi_cj_chapter_t_sflag = -1;
static int hf_rtp_midi_cj_chapter_t_pressure = -1;
static int hf_rtp_midi_cj_chapter_a_sflag = -1;
@@ -2651,9 +2645,11 @@ static int hf_rtp_midi_cj_chapter_a_log_notenum = -1;
static int hf_rtp_midi_cj_chapter_a_log_xflag = -1;
static int hf_rtp_midi_cj_chapter_a_log_pressure = -1;
+static int hf_rtp_midi_sj_chapter_v = -1;
static int hf_rtp_midi_sj_chapter_v_sflag = -1;
static int hf_rtp_midi_sj_chapter_v_count = -1;
+static int hf_rtp_midi_sj_chapter_d_simple_system_commands = -1;
static int hf_rtp_midi_sj_chapter_d_sflag = -1;
static int hf_rtp_midi_sj_chapter_d_bflag = -1;
static int hf_rtp_midi_sj_chapter_d_gflag = -1;
@@ -2663,10 +2659,13 @@ static int hf_rtp_midi_sj_chapter_d_kflag = -1;
static int hf_rtp_midi_sj_chapter_d_yflag = -1;
static int hf_rtp_midi_sj_chapter_d_zflag = -1;
+static int hf_rtp_midi_sj_chapter_d_reset = -1;
static int hf_rtp_midi_sj_chapter_d_reset_sflag = -1;
static int hf_rtp_midi_sj_chapter_d_reset_count = -1;
+static int hf_rtp_midi_sj_chapter_d_tune = -1;
static int hf_rtp_midi_sj_chapter_d_tune_sflag = -1;
static int hf_rtp_midi_sj_chapter_d_tune_count = -1;
+static int hf_rtp_midi_sj_chapter_d_song_sel = -1;
static int hf_rtp_midi_sj_chapter_d_song_sel_sflag = -1;
static int hf_rtp_midi_sj_chapter_d_song_sel_value = -1;
@@ -2704,6 +2703,8 @@ static int hf_rtp_midi_sj_chapter_f_pflag = -1;
static int hf_rtp_midi_sj_chapter_f_qflag = -1;
static int hf_rtp_midi_sj_chapter_f_dflag = -1;
static int hf_rtp_midi_sj_chapter_f_point = -1;
+static int hf_rtp_midi_sj_chapter_f_complete = -1;
+static int hf_rtp_midi_sj_chapter_f_partial = -1;
static int hf_rtp_midi_sj_chapter_f_mt0 = -1;
static int hf_rtp_midi_sj_chapter_f_mt1 = -1;
static int hf_rtp_midi_sj_chapter_f_mt2 = -1;
@@ -2961,108 +2962,29 @@ decodetime(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned int
* Here a Note-Off command is decoded.
*/
static int
-decode_note_off(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, unsigned int cmd_count, unsigned int offset, unsigned int cmd_len, guint8 status, unsigned int rsoffset, gboolean using_rs ) {
+decode_note_off(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, unsigned int cmd_count, unsigned int offset, guint8 status, unsigned int rsoffset, gboolean using_rs ) {
guint8 note;
guint8 velocity;
const gchar *status_str;
const gchar *note_str;
- proto_item *command_item;
proto_tree *command_tree;
status_str = val_to_str( status >> 4, rtp_midi_channel_status, rtp_midi_unknown_value_hex );
-
- /* broken: we have no further data */
- if ( !cmd_len ) {
- /* this case should never happen */
- if ( using_rs ) {
- command_item = proto_tree_add_text( tree, tvb, offset, 0, "TRUNCATED: %s (c=%d)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1 );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel_status, tvb, rsoffset, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel, tvb, rsoffset, 1, ENC_BIG_ENDIAN );
-
- } else {
- command_item = proto_tree_add_text( tree, tvb, offset - 1, 1, "TRUNCATED: %s (c=%d)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1);
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel_status, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
- }
- return -1;
- }
-
note = tvb_get_guint8( tvb, offset );
-
- /* seems to be an aborted MIDI-command */
- if ( note & RTP_MIDI_COMMAND_STATUS_FLAG ) {
- /* this case should never happen */
- if ( using_rs ) {
- command_item = proto_tree_add_text( tree, tvb, offset, 0, "ABORTED: %s (c=%d)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1 );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel_status, tvb, rsoffset, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel, tvb, rsoffset, 1, ENC_BIG_ENDIAN );
-
- } else {
- command_item = proto_tree_add_text( tree, tvb, offset - 1, 1, "ABORTED: %s (c=%d)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1 );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel_status, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
- }
- return -1;
- }
-
note_str = val_to_str_ext( note, &rtp_midi_note_values_ext, rtp_midi_unknown_value_dec );
-
- /* broken: we have only one further octet */
- if ( cmd_len < 2 ) {
- if ( using_rs ) {
- command_item = proto_tree_add_text( tree, tvb, offset, 1, "TRUNCATED: %s (c=%d, n=%s)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1, note_str );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command);
- proto_tree_add_item( command_tree, hf_rtp_midi_channel_status, tvb, rsoffset, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel, tvb, rsoffset, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_note, tvb, offset, 1, ENC_BIG_ENDIAN );
-
- } else {
- command_item = proto_tree_add_text( tree, tvb, offset - 1, 2, "TRUNCATED: %s (c=%d, n=%s)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1, note_str );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel_status, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_note, tvb, offset, 1, ENC_BIG_ENDIAN );
- }
- return -1;
- }
-
velocity = tvb_get_guint8( tvb, offset + 1 );
- /* seems to be an aborted MIDI-command */
- if ( velocity & RTP_MIDI_COMMAND_STATUS_FLAG ) {
- if ( using_rs ) {
- command_item = proto_tree_add_text( tree, tvb, offset, 1, "ABORTED: %s (c=%d, n=%s)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1, note_str );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command);
- proto_tree_add_item( command_tree, hf_rtp_midi_channel_status, tvb, rsoffset, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel, tvb, rsoffset, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_note, tvb, offset, 1, ENC_BIG_ENDIAN );
-
- } else {
- command_item = proto_tree_add_text( tree, tvb, offset - 1, 2, "ABORTED: %s (c=%d, n=%s)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1, note_str );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel_status, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_note, tvb, offset, 1, ENC_BIG_ENDIAN );
- }
- return -1;
- }
-
-
if ( using_rs ) {
- command_item = proto_tree_add_text( tree, tvb, offset, 2, "%s (c=%d, n=%s, v=%d)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1, note_str, velocity );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command);
+ command_tree = proto_tree_add_subtree_format( tree, tvb, offset, 2, ett_rtp_midi_command, NULL,
+ "%s (c=%d, n=%s, v=%d)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1, note_str, velocity );
proto_tree_add_item( command_tree, hf_rtp_midi_channel_status, tvb, rsoffset, 1, ENC_BIG_ENDIAN );
proto_tree_add_item( command_tree, hf_rtp_midi_channel, tvb, rsoffset, 1, ENC_BIG_ENDIAN );
proto_tree_add_item( command_tree, hf_rtp_midi_note, tvb, offset, 1, ENC_BIG_ENDIAN );
proto_tree_add_item( command_tree, hf_rtp_midi_velocity, tvb, offset + 1, 1, ENC_BIG_ENDIAN );
} else {
- command_item = proto_tree_add_text(tree, tvb, offset - 1, 3, "%s (c=%d, n=%s, v=%d)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1, note_str, velocity );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command );
+ command_tree = proto_tree_add_subtree_format(tree, tvb, offset - 1, 3, ett_rtp_midi_command , NULL,
+ "%s (c=%d, n=%s, v=%d)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1, note_str, velocity );
proto_tree_add_item( command_tree, hf_rtp_midi_channel_status, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
proto_tree_add_item( command_tree, hf_rtp_midi_channel, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
proto_tree_add_item( command_tree, hf_rtp_midi_note, tvb, offset, 1, ENC_BIG_ENDIAN );
@@ -3082,112 +3004,34 @@ decode_note_off(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, unsigned in
* Here a Note-On command is decoded.
*/
static int
-decode_note_on(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, unsigned int cmd_count, unsigned int offset, unsigned int cmd_len, guint8 status, unsigned int rsoffset, gboolean using_rs ) {
+decode_note_on(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, unsigned int cmd_count, unsigned int offset, guint8 status, unsigned int rsoffset, gboolean using_rs ) {
guint8 note;
guint8 velocity;
const gchar *status_str;
const gchar *note_str;
- proto_item *command_item;
proto_tree *command_tree;
status_str = val_to_str( status >> 4, rtp_midi_channel_status, rtp_midi_unknown_value_hex );
-
- /* broken: we have no further data */
- if ( !cmd_len ) {
- /* this should never happen! */
- if ( using_rs ) {
- command_item = proto_tree_add_text( tree, tvb, offset, 0, "TRUNCATED: %s (c=%d)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1 );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel_status, tvb, rsoffset, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel, tvb, rsoffset, 1, ENC_BIG_ENDIAN );
-
- } else {
- command_item = proto_tree_add_text( tree, tvb, offset - 1, 1, "TRUNCATED: %s (c=%d)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1);
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel_status, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
- }
- return -1;
- }
-
note = tvb_get_guint8( tvb, offset );
-
- /* seems to be an aborted MIDI-command */
- if ( note & RTP_MIDI_COMMAND_STATUS_FLAG ) {
- /* this should never happethis should never happen */
- if ( using_rs ) {
- command_item = proto_tree_add_text( tree, tvb, offset, 0, "ABORTED: %s (c=%d)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1 );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel_status, tvb, rsoffset, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel, tvb, rsoffset, 1, ENC_BIG_ENDIAN );
-
- } else {
- command_item = proto_tree_add_text( tree, tvb, offset - 1, 1, "ABORTED: %s (c=%d)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1 );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel_status, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
- }
- return -1;
- }
-
note_str = val_to_str_ext( note, &rtp_midi_note_values_ext, rtp_midi_unknown_value_dec );
-
- /* broken: we have only one further octet */
- if ( cmd_len < 2 ) {
- if ( using_rs ) {
- command_item = proto_tree_add_text( tree, tvb, offset, 1, "TRUNCATED: %s (c=%d, n=%s)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1, note_str );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command);
- proto_tree_add_item( command_tree, hf_rtp_midi_channel_status, tvb, rsoffset, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel, tvb, rsoffset, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_note, tvb, offset, 1, ENC_BIG_ENDIAN );
-
- } else {
- command_item = proto_tree_add_text( tree, tvb, offset - 1, 2, "TRUNCATED: %s (c=%d, n=%s)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1, note_str );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel_status, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_note, tvb, offset, 1, ENC_BIG_ENDIAN );
- }
- return -1;
- }
-
velocity = tvb_get_guint8( tvb, offset + 1 );
- /* seems to be an aborted MIDI-command */
- if ( velocity & RTP_MIDI_COMMAND_STATUS_FLAG ) {
- if ( using_rs ) {
- command_item = proto_tree_add_text( tree, tvb, offset, 1, "ABORTED: %s (c=%d, n=%s)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1, note_str );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command);
- proto_tree_add_item( command_tree, hf_rtp_midi_channel_status, tvb, rsoffset, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel, tvb, rsoffset, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_note, tvb, offset, 1, ENC_BIG_ENDIAN );
-
- } else {
- command_item = proto_tree_add_text( tree, tvb, offset - 1, 2, "ABORTED: %s (c=%d, n=%s)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1, note_str );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel_status, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_note, tvb, offset, 1, ENC_BIG_ENDIAN );
- }
- return -1;
- }
-
/* special case velocity=0 for Note-On means Note-Off (to preserve running-status!) */
if ( velocity == 0 ) {
status_str = rtp_midi_channel_status_special_off;
}
if ( using_rs ) {
- command_item = proto_tree_add_text( tree, tvb, offset, 2, "%s (c=%d, n=%s, v=%d)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1, note_str, velocity );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command);
+ command_tree = proto_tree_add_subtree_format( tree, tvb, offset, 2, ett_rtp_midi_command, NULL,
+ "%s (c=%d, n=%s, v=%d)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1, note_str, velocity );
proto_tree_add_item( command_tree, hf_rtp_midi_channel_status, tvb, rsoffset, 1, ENC_BIG_ENDIAN );
proto_tree_add_item( command_tree, hf_rtp_midi_channel, tvb, rsoffset, 1, ENC_BIG_ENDIAN );
proto_tree_add_item( command_tree, hf_rtp_midi_note, tvb, offset, 1, ENC_BIG_ENDIAN );
proto_tree_add_item( command_tree, hf_rtp_midi_velocity, tvb, offset + 1, 1, ENC_BIG_ENDIAN );
} else {
- command_item = proto_tree_add_text(tree, tvb, offset - 1, 3, "%s (c=%d, n=%s, v=%d)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1, note_str, velocity );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command );
+ command_tree = proto_tree_add_subtree_format(tree, tvb, offset - 1, 3, ett_rtp_midi_command, NULL,
+ "%s (c=%d, n=%s, v=%d)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1, note_str, velocity );
proto_tree_add_item( command_tree, hf_rtp_midi_channel_status, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
proto_tree_add_item( command_tree, hf_rtp_midi_channel, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
proto_tree_add_item( command_tree, hf_rtp_midi_note, tvb, offset, 1, ENC_BIG_ENDIAN );
@@ -3209,108 +3053,29 @@ decode_note_on(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, unsigned int
* Here polyphonic aftertouch is decoded.
*/
static int
-decode_poly_pressure(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, unsigned int cmd_count, unsigned int offset, unsigned int cmd_len, guint8 status, unsigned int rsoffset, gboolean using_rs ) {
+decode_poly_pressure(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, unsigned int cmd_count, unsigned int offset, guint8 status, unsigned int rsoffset, gboolean using_rs ) {
guint8 note;
guint8 pressure;
const gchar *status_str;
const gchar *note_str;
- proto_item *command_item;
proto_tree *command_tree;
status_str = val_to_str( status >> 4, rtp_midi_channel_status, rtp_midi_unknown_value_hex );
-
- /* broken: we have no further data */
- if ( !cmd_len ) {
- /* this should never happen */
- if ( using_rs ) {
- command_item = proto_tree_add_text( tree, tvb, offset, 0, "TRUNCATED: %s (c=%d)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1 );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel_status, tvb, rsoffset, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel, tvb, rsoffset, 1, ENC_BIG_ENDIAN );
-
- } else {
- command_item = proto_tree_add_text( tree, tvb, offset - 1, 1, "TRUNCATED: %s (c=%d)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1);
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel_status, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
- }
- return -1;
- }
-
note = tvb_get_guint8( tvb, offset );
-
- /* seems to be an aborted MIDI-command */
- if ( note & RTP_MIDI_COMMAND_STATUS_FLAG ) {
- /* this should never happen */
- if ( using_rs ) {
- command_item = proto_tree_add_text( tree, tvb, offset, 0, "ABORTED: %s (c=%d)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1 );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel_status, tvb, rsoffset, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel, tvb, rsoffset, 1, ENC_BIG_ENDIAN );
-
- } else {
- command_item = proto_tree_add_text( tree, tvb, offset - 1, 1, "ABORTED: %s (c=%d)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1 );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel_status, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
- }
- return -1;
- }
-
note_str = val_to_str_ext( note, &rtp_midi_note_values_ext, rtp_midi_unknown_value_dec );
-
- /* broken: we have only one further octet */
- if ( cmd_len < 2 ) {
- if ( using_rs ) {
- command_item = proto_tree_add_text( tree, tvb, offset, 1, "TRUNCATED: %s (c=%d, n=%s)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1, note_str );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command);
- proto_tree_add_item( command_tree, hf_rtp_midi_channel_status, tvb, rsoffset, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel, tvb, rsoffset, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_note, tvb, offset, 1, ENC_BIG_ENDIAN );
-
- } else {
- command_item = proto_tree_add_text( tree, tvb, offset - 1, 2, "TRUNCATED: %s (c=%d, n=%s)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1, note_str );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel_status, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_note, tvb, offset, 1, ENC_BIG_ENDIAN );
- }
- return -1;
- }
-
pressure = tvb_get_guint8( tvb, offset + 1 );
- /* seems to be an aborted MIDI-command */
- if ( pressure & RTP_MIDI_COMMAND_STATUS_FLAG ) {
- if ( using_rs ) {
- command_item = proto_tree_add_text( tree, tvb, offset, 1, "ABORTED: %s (c=%d, n=%s)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1, note_str );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command);
- proto_tree_add_item( command_tree, hf_rtp_midi_channel_status, tvb, rsoffset, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel, tvb, rsoffset, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_note, tvb, offset, 1, ENC_BIG_ENDIAN );
-
- } else {
- command_item = proto_tree_add_text( tree, tvb, offset - 1, 2, "ABORTED: %s (c=%d, n=%s)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1, note_str );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel_status, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_note, tvb, offset, 1, ENC_BIG_ENDIAN );
- }
- return -1;
- }
-
-
if ( using_rs ) {
- command_item = proto_tree_add_text( tree, tvb, offset, 2, "%s (c=%d, n=%s, p=%d)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1, note_str, pressure );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command);
+ command_tree = proto_tree_add_subtree_format( tree, tvb, offset, 2, ett_rtp_midi_command, NULL,
+ "%s (c=%d, n=%s, p=%d)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1, note_str, pressure );
proto_tree_add_item( command_tree, hf_rtp_midi_channel_status, tvb, rsoffset, 1, ENC_BIG_ENDIAN );
proto_tree_add_item( command_tree, hf_rtp_midi_channel, tvb, rsoffset, 1, ENC_BIG_ENDIAN );
proto_tree_add_item( command_tree, hf_rtp_midi_note, tvb, offset, 1, ENC_BIG_ENDIAN );
proto_tree_add_item( command_tree, hf_rtp_midi_pressure, tvb, offset + 1, 1, ENC_BIG_ENDIAN );
} else {
- command_item = proto_tree_add_text(tree, tvb, offset - 1, 3, "%s (c=%d, n=%s, p=%d)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1, note_str, pressure );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command );
+ command_tree = proto_tree_add_subtree_format(tree, tvb, offset - 1, 3, ett_rtp_midi_command, NULL,
+ "%s (c=%d, n=%s, p=%d)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1, note_str, pressure );
proto_tree_add_item( command_tree, hf_rtp_midi_channel_status, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
proto_tree_add_item( command_tree, hf_rtp_midi_channel, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
proto_tree_add_item( command_tree, hf_rtp_midi_note, tvb, offset, 1, ENC_BIG_ENDIAN );
@@ -3330,63 +3095,24 @@ decode_poly_pressure(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, unsign
* Here channel aftertouch is decoded.
*/
static int
-decode_channel_pressure(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, unsigned int cmd_count, unsigned int offset, unsigned int cmd_len, guint8 status, unsigned int rsoffset, gboolean using_rs ) {
+decode_channel_pressure(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, unsigned int cmd_count, unsigned int offset, guint8 status, unsigned int rsoffset, gboolean using_rs ) {
guint8 pressure;
const gchar *status_str;
- proto_item *command_item;
proto_tree *command_tree;
status_str = val_to_str( status >> 4, rtp_midi_channel_status, rtp_midi_unknown_value_hex );
-
- /* broken: we have no further data */
- if ( !cmd_len ) {
- /* this should never happen */
- if ( using_rs ) {
- command_item = proto_tree_add_text( tree, tvb, offset, 0, "TRUNCATED: %s (c=%d)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1 );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel_status, tvb, rsoffset, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel, tvb, rsoffset, 1, ENC_BIG_ENDIAN );
-
- } else {
- command_item = proto_tree_add_text( tree, tvb, offset - 1, 1, "TRUNCATED: %s (c=%d)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1);
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel_status, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
- }
- return -1;
- }
-
pressure = tvb_get_guint8( tvb, offset );
- /* seems to be an aborted MIDI-command */
- if ( pressure & RTP_MIDI_COMMAND_STATUS_FLAG ) {
- if ( using_rs ) {
- /* this should never happen */
- command_item = proto_tree_add_text( tree, tvb, offset, 0, "ABORTED: %s (c=%d)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1 );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel_status, tvb, rsoffset, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel, tvb, rsoffset, 1, ENC_BIG_ENDIAN );
-
- } else {
- command_item = proto_tree_add_text( tree, tvb, offset - 1, 1, "ABORTED: %s (c=%d)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1);
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel_status, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
- }
- return -1;
- }
-
-
if ( using_rs ) {
- command_item = proto_tree_add_text( tree, tvb, offset, 1, "%s (c=%d, p=%d)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1, pressure );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command);
+ command_tree = proto_tree_add_subtree_format( tree, tvb, offset, 1, ett_rtp_midi_command, NULL,
+ "%s (c=%d, p=%d)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1, pressure );
proto_tree_add_item( command_tree, hf_rtp_midi_channel_status, tvb, rsoffset, 1, ENC_BIG_ENDIAN );
proto_tree_add_item( command_tree, hf_rtp_midi_channel, tvb, rsoffset, 1, ENC_BIG_ENDIAN );
proto_tree_add_item( command_tree, hf_rtp_midi_channel_pressure, tvb, offset, 1, ENC_BIG_ENDIAN );
} else {
- command_item = proto_tree_add_text(tree, tvb, offset - 1, 2, "%s (c=%d, p=%d)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1, pressure );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command );
+ command_tree = proto_tree_add_subtree_format(tree, tvb, offset - 1, 2, ett_rtp_midi_command, NULL,
+ "%s (c=%d, p=%d)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1, pressure );
proto_tree_add_item( command_tree, hf_rtp_midi_channel_status, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
proto_tree_add_item( command_tree, hf_rtp_midi_channel, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
proto_tree_add_item( command_tree, hf_rtp_midi_channel_pressure, tvb, offset, 1, ENC_BIG_ENDIAN);
@@ -3406,106 +3132,28 @@ decode_channel_pressure(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, uns
* Here pitch-bend is decoded.
*/
static int
-decode_pitch_bend_change(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned int cmd_count, unsigned int offset, unsigned int cmd_len, guint8 status, unsigned int rsoffset, gboolean using_rs ) {
+decode_pitch_bend_change(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned int cmd_count, unsigned int offset, guint8 status, unsigned int rsoffset, gboolean using_rs ) {
guint8 octet1;
guint8 octet2;
guint8 pitch;
const gchar *status_str;
- proto_item *command_item;
proto_tree *command_tree;
status_str = val_to_str( status >> 4, rtp_midi_channel_status, rtp_midi_unknown_value_hex );
-
- /* broken: we have no further data */
- if ( !cmd_len ) {
- /* this should never happen */
- if ( using_rs ) {
- command_item = proto_tree_add_text( tree, tvb, offset, 0, "TRUNCATED: %s (c=%d)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1 );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel_status, tvb, rsoffset, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel, tvb, rsoffset, 1, ENC_BIG_ENDIAN );
-
- } else {
- command_item = proto_tree_add_text( tree, tvb, offset - 1, 1, "TRUNCATED: %s (c=%d)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1 );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel_status, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
- }
- return -1;
- }
-
octet1 = tvb_get_guint8( tvb, offset );
-
- /* seems to be an aborted MIDI-command */
- if ( octet1 & RTP_MIDI_COMMAND_STATUS_FLAG ) {
- /* this should never happen */
- if ( using_rs ) {
- command_item = proto_tree_add_text( tree, tvb, offset, 0, "ABORTED: %s (c=%d)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1 );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel_status, tvb, rsoffset, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel, tvb, rsoffset, 1, ENC_BIG_ENDIAN );
-
- } else {
- command_item = proto_tree_add_text( tree, tvb, offset - 1, 1, "ABORTED: %s (c=%d)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1 );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel_status, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
- }
- return -1;
- }
-
- /* broken: we have only one further octet */
- if ( cmd_len < 2 ) {
- if ( using_rs ) {
- command_item = proto_tree_add_text( tree, tvb, offset, 1, "TRUNCATED: %s (c=%d)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1 );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command);
- proto_tree_add_item( command_tree, hf_rtp_midi_channel_status, tvb, rsoffset, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel, tvb, rsoffset, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_pitch_bend_truncated, tvb, offset, 1, ENC_BIG_ENDIAN );
-
- } else {
- command_item = proto_tree_add_text( tree, tvb, offset - 1, 2, "TRUNCATED: %s (c=%d)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1 );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel_status, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_pitch_bend_truncated, tvb, offset, 1, ENC_BIG_ENDIAN );
- }
- return -1;
- }
-
octet2 = tvb_get_guint8( tvb, offset + 1 );
-
- /* seems to be an aborted MIDI-command */
- if ( octet2 & RTP_MIDI_COMMAND_STATUS_FLAG ) {
- if ( using_rs ) {
- command_item = proto_tree_add_text( tree, tvb, offset, 1, "ABORTED: %s (c=%d)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1 );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command);
- proto_tree_add_item( command_tree, hf_rtp_midi_channel_status, tvb, rsoffset, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel, tvb, rsoffset, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_pitch_bend_truncated, tvb, offset, 1, ENC_BIG_ENDIAN );
-
- } else {
- command_item = proto_tree_add_text( tree, tvb, offset - 1, 2, "ABORTED: %s (c=%d)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1 );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel_status, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_pitch_bend_truncated, tvb, offset, 1, ENC_BIG_ENDIAN );
- }
- return -1;
- }
-
pitch = ( octet1 << 7 ) | octet2;
if ( using_rs ) {
- command_item = proto_tree_add_text( tree, tvb, offset, 2, "%s (c=%d, pb=%d)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1, pitch );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command);
+ command_tree = proto_tree_add_subtree_format( tree, tvb, offset, 2, ett_rtp_midi_command, NULL,
+ "%s (c=%d, pb=%d)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1, pitch );
proto_tree_add_item( command_tree, hf_rtp_midi_channel_status, tvb, rsoffset, 1, ENC_BIG_ENDIAN );
proto_tree_add_item( command_tree, hf_rtp_midi_channel, tvb, rsoffset, 1, ENC_BIG_ENDIAN );
proto_tree_add_item( command_tree, hf_rtp_midi_pitch_bend, tvb, offset, 2, ENC_BIG_ENDIAN );
} else {
- command_item = proto_tree_add_text(tree, tvb, offset - 1, 3, "%s (c=%d, pb=%d)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1, pitch );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command );
+ command_tree = proto_tree_add_subtree_format(tree, tvb, offset - 1, 3, ett_rtp_midi_command, NULL,
+ "%s (c=%d, pb=%d)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1, pitch );
proto_tree_add_item( command_tree, hf_rtp_midi_channel_status, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
proto_tree_add_item( command_tree, hf_rtp_midi_channel, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
proto_tree_add_item( command_tree, hf_rtp_midi_pitch_bend, tvb, offset, 2, ENC_BIG_ENDIAN );
@@ -3526,63 +3174,24 @@ decode_pitch_bend_change(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree
* Here program_change is decoded.
*/
static int
-decode_program_change(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, unsigned int cmd_count, unsigned int offset, unsigned int cmd_len, guint8 status, unsigned int rsoffset, gboolean using_rs ) {
+decode_program_change(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, unsigned int cmd_count, unsigned int offset, guint8 status, unsigned int rsoffset, gboolean using_rs ) {
guint8 program;
const gchar *status_str;
- proto_item *command_item;
proto_tree *command_tree;
status_str = val_to_str( status >> 4, rtp_midi_channel_status, rtp_midi_unknown_value_hex );
-
- /* broken: we have no further data */
- if ( !cmd_len ) {
- /* this should never happen */
- if ( using_rs ) {
- command_item = proto_tree_add_text( tree, tvb, offset, 0, "TRUNCATED: %s (c=%d)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1 );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel_status, tvb, rsoffset, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel, tvb, rsoffset, 1, ENC_BIG_ENDIAN );
-
- } else {
- command_item = proto_tree_add_text( tree, tvb, offset - 1, 1, "TRUNCATED: %s (c=%d)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1);
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel_status, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
- }
- return -1;
- }
-
program = tvb_get_guint8( tvb, offset );
- /* seems to be an aborted MIDI-command */
- if ( program & RTP_MIDI_COMMAND_STATUS_FLAG ) {
- /* this should never happen */
- if ( using_rs ) {
- command_item = proto_tree_add_text( tree, tvb, offset, 0, "ABORTED: %s (c=%d)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1 );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel_status, tvb, rsoffset, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel, tvb, rsoffset, 1, ENC_BIG_ENDIAN );
-
- } else {
- command_item = proto_tree_add_text( tree, tvb, offset - 1, 1, "ABORTED: %s (c=%d)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1);
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel_status, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
- }
- return -1;
- }
-
-
if ( using_rs ) {
- command_item = proto_tree_add_text( tree, tvb, offset, 1, "%s (c=%d, p=%d)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1, program );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command);
+ command_tree = proto_tree_add_subtree_format( tree, tvb, offset, 1, ett_rtp_midi_command, NULL,
+ "%s (c=%d, p=%d)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1, program );
proto_tree_add_item( command_tree, hf_rtp_midi_channel_status, tvb, rsoffset, 1, ENC_BIG_ENDIAN );
proto_tree_add_item( command_tree, hf_rtp_midi_channel, tvb, rsoffset, 1, ENC_BIG_ENDIAN );
proto_tree_add_item( command_tree, hf_rtp_midi_program, tvb, offset, 1, ENC_BIG_ENDIAN );
} else {
- command_item = proto_tree_add_text(tree, tvb, offset - 1, 2, "%s (c=%d, p=%d)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1, program );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command );
+ command_tree = proto_tree_add_subtree_format(tree, tvb, offset - 1, 2, ett_rtp_midi_command, NULL,
+ "%s (c=%d, p=%d)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1, program );
proto_tree_add_item( command_tree, hf_rtp_midi_channel_status, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
proto_tree_add_item( command_tree, hf_rtp_midi_channel, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
proto_tree_add_item( command_tree, hf_rtp_midi_program, tvb, offset, 1, ENC_BIG_ENDIAN);
@@ -3594,8 +3203,7 @@ decode_program_change(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, unsig
col_append_fstr(pinfo->cinfo, COL_INFO, "%s (c=%d, p=%d)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1, program );
}
-
-return 1;
+ return 1;
}
@@ -3604,108 +3212,29 @@ return 1;
* Here control change is decoded.
*/
static int
-decode_control_change(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, unsigned int cmd_count, unsigned int offset, unsigned int cmd_len, guint8 status, unsigned int rsoffset, gboolean using_rs ) {
+decode_control_change(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, unsigned int cmd_count, unsigned int offset, guint8 status, unsigned int rsoffset, gboolean using_rs ) {
guint8 controller;
guint8 value;
const gchar *status_str;
const gchar *ctrl_str;
- proto_item *command_item;
proto_tree *command_tree;
status_str = val_to_str( status >> 4, rtp_midi_channel_status, rtp_midi_unknown_value_hex );
-
- /* broken: we have no further data */
- if ( !cmd_len ) {
- /* this should never happen */
- if ( using_rs ) {
- command_item = proto_tree_add_text( tree, tvb, offset, 0, "TRUNCATED: %s (c=%d)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1 );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel_status, tvb, rsoffset, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel, tvb, rsoffset, 1, ENC_BIG_ENDIAN );
-
- } else {
- command_item = proto_tree_add_text( tree, tvb, offset - 1, 1, "TRUNCATED: %s (c=%d)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1 );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel_status, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
- }
- return -1;
- }
-
controller = tvb_get_guint8( tvb, offset );
-
- /* seems to be an aborted MIDI-command */
- if ( controller & RTP_MIDI_COMMAND_STATUS_FLAG ) {
- /* this should never happen */
- if ( using_rs ) {
- command_item = proto_tree_add_text( tree, tvb, offset, 0, "ABORTED: %s (c=%d)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1 );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel_status, tvb, rsoffset, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel, tvb, rsoffset, 1, ENC_BIG_ENDIAN );
-
- } else {
- command_item = proto_tree_add_text( tree, tvb, offset - 1, 1, "ABORTED: %s (c=%d)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1 );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel_status, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
- }
- return -1;
- }
-
ctrl_str = val_to_str_ext( controller, &rtp_midi_controller_values_ext, "Unknown: %d" );
-
- /* broken: we have only one further octet */
- if ( cmd_len < 2 ) {
- if ( using_rs ) {
- command_item = proto_tree_add_text( tree, tvb, offset, 1, "TRUNCATED: %s (c=%d, ctrl=%s)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1, ctrl_str );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command);
- proto_tree_add_item( command_tree, hf_rtp_midi_channel_status, tvb, rsoffset, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel, tvb, rsoffset, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_note, tvb, offset, 1, ENC_BIG_ENDIAN );
-
- } else {
- command_item = proto_tree_add_text( tree, tvb, offset - 1, 2, "TRUNCATED: %s (c=%d, ctrl=%s)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1, ctrl_str );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel_status, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_note, tvb, offset, 1, ENC_BIG_ENDIAN );
- }
- return -1;
- }
-
value = tvb_get_guint8( tvb, offset + 1 );
- /* seems to be an aborted MIDI-command */
- if ( value & RTP_MIDI_COMMAND_STATUS_FLAG ) {
- if ( using_rs ) {
- command_item = proto_tree_add_text( tree, tvb, offset, 1, "ABORTED: %s (c=%d, ctrl=%s)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1, ctrl_str );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command);
- proto_tree_add_item( command_tree, hf_rtp_midi_channel_status, tvb, rsoffset, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel, tvb, rsoffset, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_controller, tvb, offset, 1, ENC_BIG_ENDIAN );
-
- } else {
- command_item = proto_tree_add_text( tree, tvb, offset - 1, 2, "ABORTED: %s (c=%d, ctrl=%s)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1, ctrl_str );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel_status, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_channel, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_controller, tvb, offset, 1, ENC_BIG_ENDIAN );
- }
- return -1;
- }
-
-
if ( using_rs ) {
- command_item = proto_tree_add_text( tree, tvb, offset, 2, "%s (c=%d, ctrl=%s, v=%d)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1, ctrl_str, value );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command);
+ command_tree = proto_tree_add_subtree_format( tree, tvb, offset, 2, ett_rtp_midi_command, NULL,
+ "%s (c=%d, ctrl=%s, v=%d)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1, ctrl_str, value );
proto_tree_add_item( command_tree, hf_rtp_midi_channel_status, tvb, rsoffset, 1, ENC_BIG_ENDIAN );
proto_tree_add_item( command_tree, hf_rtp_midi_channel, tvb, rsoffset, 1, ENC_BIG_ENDIAN );
proto_tree_add_item( command_tree, hf_rtp_midi_controller, tvb, offset, 1, ENC_BIG_ENDIAN );
proto_tree_add_item( command_tree, hf_rtp_midi_controller_value, tvb, offset + 1, 1, ENC_BIG_ENDIAN );
} else {
- command_item = proto_tree_add_text(tree, tvb, offset - 1, 3, "%s (c=%d, ctrl=%s, v=%d)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1, ctrl_str, value );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command );
+ command_tree = proto_tree_add_subtree_format(tree, tvb, offset - 1, 3, ett_rtp_midi_command, NULL,
+ "%s (c=%d, ctrl=%s, v=%d)", status_str, ( status & RTP_MIDI_CHANNEL_MASK ) + 1, ctrl_str, value );
proto_tree_add_item( command_tree, hf_rtp_midi_channel_status, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
proto_tree_add_item( command_tree, hf_rtp_midi_channel, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
proto_tree_add_item( command_tree, hf_rtp_midi_controller, tvb, offset, 1, ENC_BIG_ENDIAN );
@@ -3725,73 +3254,38 @@ decode_control_change(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, unsig
* Here a Sysex-Common Non-Realtime Sample Dump Header command is decoded.
*/
static unsigned int
-decode_sysex_common_nrt_sd_hdr( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned int offset, unsigned int data_len ) {
- int consumed = 0;
-
- if ( data_len < 2 )
- return -1;
+decode_sysex_common_nrt_sd_hdr( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned int offset ) {
+ unsigned int start_offset = offset;
/* sample number */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_nrt_sd_header_sn, tvb, offset, 2, ENC_BIG_ENDIAN );
offset += 2;
- data_len -= 2;
- consumed += 2;
-
- if ( data_len < 1 )
- return -1;
/* sample format */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_nrt_sd_header_sf, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
- data_len--;
- consumed++;
-
- if ( data_len < 3 )
- return -1;
/* sample period */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_nrt_sd_header_sp, tvb, offset, 3, ENC_BIG_ENDIAN );
offset += 3;
- data_len -= 3;
- consumed += 3;
-
- if ( data_len < 3 )
- return -1;
/* sample length */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_nrt_sd_header_sl, tvb, offset, 3, ENC_BIG_ENDIAN );
offset += 3;
- data_len -= 3;
- consumed += 3;
-
- if ( data_len < 3 )
- return -1;
/* loop start */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_nrt_sd_header_ls, tvb, offset, 3, ENC_BIG_ENDIAN );
offset += 3;
- data_len -= 3;
- consumed += 3;
-
- if ( data_len < 3 )
- return -1;
/* loop end */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_nrt_sd_header_le, tvb, offset, 3, ENC_BIG_ENDIAN );
offset += 3;
- data_len -= 3;
- consumed += 3;
-
- if ( data_len < 1 )
- return -1;
/* loop type */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_nrt_sd_header_lt, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
- data_len--;
- consumed++;
- return consumed;
+ return offset-start_offset;
}
/*
@@ -3799,54 +3293,36 @@ decode_sysex_common_nrt_sd_hdr( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tre
*/
static unsigned int
decode_sysex_common_nrt_sd_packet( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned int offset, unsigned int data_len ) {
- int consumed = 0;
-
- if ( data_len < 1 )
- return -1;
+ unsigned int start_offset = offset;
/* sample number */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_nrt_sd_packet_count, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
- data_len--;
- consumed++;
/* do we have sample-data? */
- if ( data_len > 1 ) {
+ if ( data_len - 1 > 1 ) {
- proto_tree_add_item( tree, hf_rtp_midi_sysex_common_nrt_sd_packet_data, tvb, offset, data_len - 1, ENC_NA );
+ proto_tree_add_item( tree, hf_rtp_midi_sysex_common_nrt_sd_packet_data, tvb, offset, data_len - 2, ENC_NA );
- offset += ( data_len - 1 );
- data_len -= ( data_len - 1 );
- consumed += ( data_len -1 );
+ offset += ( data_len - 2 );
}
- /* do we have data for the checksum! */
- if ( data_len < 1 )
- return -1;
-
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_nrt_sd_packet_check, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
- data_len--;
- consumed++;
- return consumed;
+ return offset-start_offset;
}
/*
* Here a Sysex-Common Non-Realtime Sample Dump Request command is decoded.
*/
static unsigned int
-decode_sysex_common_nrt_sd_req( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned int offset, unsigned int data_len ) {
- int consumed = 0;
-
- if ( data_len < 2 )
- return -1;
+decode_sysex_common_nrt_sd_req( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned int offset) {
/* sample number */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_nrt_sd_header_sn, tvb, offset, 2, ENC_BIG_ENDIAN );
- consumed += 2;
- return consumed;
+ return 2;
}
@@ -3856,84 +3332,50 @@ decode_sysex_common_nrt_sd_req( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tre
static unsigned int
decode_sysex_common_nrt_sd_ext( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned int offset, unsigned int data_len ) {
guint8 sub_id;
- int consumed = 0;
+ unsigned int start_offset = offset;
if ( data_len < 1 )
- return consumed;
+ return 0;
/* first we retrieve the sub-command */
sub_id = tvb_get_guint8( tvb, offset );
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_nrt_sd_ext, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
- data_len--;
- consumed++;
if ( sub_id == RTP_MIDI_SYSEX_COMMON_NRT_SD_EXT_LOOP_POINT_TRANSMISSION ) {
- if ( data_len < 2 )
- return -1;
-
/* sample number */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_nrt_sd_header_sn, tvb, offset, 2, ENC_BIG_ENDIAN );
offset += 2;
- data_len -= 2;
- consumed += 2;
-
- if ( data_len < 2 )
- return -1;
/* loop number */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_nrt_sd_ext_ln, tvb, offset, 2, ENC_BIG_ENDIAN );
offset += 2;
- data_len -= 2;
- consumed += 2;
-
- if ( data_len < 1 )
- return -1;
/* loop type */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_nrt_sd_header_lt, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
- data_len--;
- consumed++;
-
- if ( data_len < 3 )
- return -1;
/* loop start */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_nrt_sd_header_ls, tvb, offset, 3, ENC_BIG_ENDIAN );
offset += 3;
- data_len -= 3;
- consumed += 3;
-
- if ( data_len < 3 )
- return -1;
/* loop end */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_nrt_sd_header_le, tvb, offset, 3, ENC_BIG_ENDIAN );
- consumed += 3;
+ offset += 3;
} else if ( sub_id == RTP_MIDI_SYSEX_COMMON_NRT_SD_EXT_LOOP_POINTS_REQUEST ) {
- if ( data_len < 2 )
- return -1;
-
/* sample number */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_nrt_sd_header_sn, tvb, offset, 2, ENC_BIG_ENDIAN );
offset += 2;
- data_len -= 2;
- consumed += 2;
-
- if ( data_len < 2 )
- return -1;
/* loop number */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_nrt_sd_ext_ln, tvb, offset, 2, ENC_BIG_ENDIAN );
- consumed += 2;
-
+ offset += 2;
}
- return consumed;
+ return offset-start_offset;
}
/*
@@ -4021,74 +3463,52 @@ decode_sysex_common_nrt_gi( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *t
static unsigned int
decode_sysex_common_nrt_fd( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned int offset, unsigned int data_len ) {
guint8 sub_id;
- int consumed = 0;
+ unsigned int start_offset = offset;
if ( data_len < 1 )
- return consumed;
+ return 0;
/* first we retrieve the sub-command */
sub_id = tvb_get_guint8( tvb, offset );
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_nrt_fd, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
data_len--;
- consumed++;
if ( sub_id == RTP_MIDI_SYSEX_COMMON_NRT_FD_HEADER ) {
- if ( data_len < 1 )
- return -1;
-
/* type */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_nrt_fd_device_id, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
data_len--;
- consumed++;
-
- if ( data_len < 4 )
- return -1;
/* file type */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_nrt_fd_type, tvb, offset, 4, ENC_ASCII|ENC_NA );
offset += 4;
data_len -= 4;
- consumed += 4;
-
- if ( data_len < 4 )
- return -1;
/* file length */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_nrt_fd_length, tvb, offset, 4, ENC_BIG_ENDIAN );
offset += 4;
data_len -= 4;
- consumed += 4;
if ( data_len ) {
/* file-name */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_nrt_fd_name, tvb, offset, data_len, ENC_ASCII|ENC_NA );
- data_len -= data_len;
- consumed += data_len;
+ offset += data_len;
}
} else if ( sub_id == RTP_MIDI_SYSEX_COMMON_NRT_FD_DATA_PACKET ) {
- if ( data_len < 1 )
- return -1;
-
/* packet-num */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_nrt_fd_packet_num, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
data_len--;
- consumed++;
-
- if ( data_len < 1 )
- return -1;
/* byte count */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_nrt_fd_byte_count, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
data_len--;
- consumed++;
/* do we have file-data? */
if ( data_len > 1 ) {
@@ -4096,49 +3516,32 @@ decode_sysex_common_nrt_fd( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *t
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_nrt_fd_packet_data, tvb, offset, data_len - 1, ENC_NA );
offset += ( data_len - 1 );
- data_len -= ( data_len - 1 );
- consumed += ( data_len -1 );
}
- /* do we have data for the checksum? */
- if ( data_len < 1 )
- return -1;
-
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_nrt_fd_checksum, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
- data_len--;
- consumed++;
} else if ( sub_id == RTP_MIDI_SYSEX_COMMON_NRT_FD_REQUEST ) {
- if ( data_len < 1 )
- return -1;
-
/* type */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_nrt_fd_device_id, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
data_len--;
- consumed++;
-
- if ( data_len < 4 )
- return -1;
/* file type */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_nrt_fd_type, tvb, offset, 4, ENC_ASCII|ENC_NA );
offset += 4;
data_len -= 4;
- consumed += 4;
if ( data_len ) {
/* file-name */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_nrt_fd_name, tvb, offset, data_len, ENC_ASCII|ENC_NA );
- data_len -= data_len;
- consumed += data_len;
+ offset += data_len;
}
}
- return consumed;
+ return offset-start_offset;
}
/*
@@ -4148,135 +3551,83 @@ decode_sysex_common_nrt_fd( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *t
static unsigned int
decode_sysex_common_tuning( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned int offset, unsigned int data_len ) {
- proto_item *tune_item;
proto_tree *tune_tree;
const gchar *note_str;
guint8 sub_id;
- int consumed = 0;
+ unsigned int start_offset = offset;
unsigned int i;
if ( data_len < 1 )
- return consumed;
+ return 0;
/* first we retrieve the sub-command */
sub_id = tvb_get_guint8( tvb, offset );
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_tuning, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
- data_len--;
- consumed++;
if ( sub_id == RTP_MIDI_SYSEX_COMMON_TUNING_BULK_DUMP_REQUEST ) {
- if ( data_len < 1 )
- return -1;
-
/* type */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_tune_program, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
- data_len--;
- consumed++;
} else if ( sub_id == RTP_MIDI_SYSEX_COMMON_TUNING_BULK_DUMP_REPLY ) {
- if ( data_len < 1 )
- return -1;
-
/* type */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_tune_program, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
- data_len--;
- consumed++;
-
- if ( data_len < 16 )
- return -1;
/* file length */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_tune_name, tvb, offset, 16, ENC_ASCII|ENC_NA );
offset += 16;
- data_len -= 16;
- consumed += 16;
for ( i=0; i < 128; i++ ) {
-
- if ( data_len < 3 )
- return -1;
-
note_str = val_to_str_ext( i, &rtp_midi_note_values_ext, rtp_midi_unknown_value_dec );
- tune_item = proto_tree_add_text(tree, tvb, offset, 3, "Note: %s", note_str );
- tune_tree = proto_item_add_subtree( tune_item, ett_rtp_midi_sysex_common_tune_note );
+ tune_tree = proto_tree_add_subtree_format(tree, tvb, offset, 3, ett_rtp_midi_sysex_common_tune_note, NULL, "Note: %s", note_str );
/* frequency */
proto_tree_add_item( tune_tree, hf_rtp_midi_sysex_common_tune_freq, tvb, offset, 3, ENC_BIG_ENDIAN );
-
offset += 3;
- data_len -= 3;
- consumed += 3;
-
}
- if ( data_len < 1 )
- return -1;
-
/* checksum */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_tune_checksum, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
- data_len--;
- consumed++;
} else if ( sub_id == RTP_MIDI_SYSEX_COMMON_TUNING_NOTE_CHANGE ) {
guint8 changes;
- if ( data_len < 1 )
- return -1;
-
/* type */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_tune_program, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
- data_len--;
- consumed++;
-
- if ( data_len < 1 )
- return -1;
/* changes */
changes = tvb_get_guint8( tvb, offset );
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_tune_changes, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
- data_len--;
- consumed++;
for ( i=0; i < changes; i++ ) {
guint8 note;
- if ( data_len < 4 )
- return -1;
-
note = tvb_get_guint8( tvb, offset );
note_str = val_to_str_ext( note, &rtp_midi_note_values_ext, rtp_midi_unknown_value_dec );
- tune_item = proto_tree_add_text(tree, tvb, offset, 3, "Note: %s", note_str );
- tune_tree = proto_item_add_subtree( tune_item, ett_rtp_midi_sysex_common_tune_note );
+ tune_tree = proto_tree_add_subtree_format(tree, tvb, offset, 3, ett_rtp_midi_sysex_common_tune_note, NULL, "Note: %s", note_str );
/* note */
proto_tree_add_item( tune_tree, hf_rtp_midi_sysex_common_tune_note, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
- data_len--;
- consumed++;
/* frequency */
proto_tree_add_item( tune_tree, hf_rtp_midi_sysex_common_tune_freq, tvb, offset, 3, ENC_BIG_ENDIAN );
-
offset += 3;
- data_len -= 3;
- consumed += 3;
-
}
}
- return consumed;
+ return offset-start_offset;
}
/*
@@ -4284,17 +3635,11 @@ decode_sysex_common_tuning( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *t
*/
static unsigned int
decode_sysex_common_nrt_gm( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned int offset, unsigned int data_len ) {
- int consumed = 0;
-
if ( data_len < 1 )
- return consumed;
+ return 0;
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_nrt_gm, tvb, offset, 1, ENC_BIG_ENDIAN );
- offset++;
- data_len--;
- consumed++;
-
- return consumed;
+ return 1;
}
/*
@@ -4302,17 +3647,11 @@ decode_sysex_common_nrt_gm( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *t
*/
static unsigned int
decode_sysex_common_nrt_dls( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned int offset, unsigned int data_len ) {
- int consumed = 0;
-
if ( data_len < 1 )
- return consumed;
+ return 0;
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_nrt_dls, tvb, offset, 1, ENC_BIG_ENDIAN );
- offset++;
- data_len--;
- consumed++;
-
- return consumed;
+ return 1;
}
/*
@@ -4320,18 +3659,13 @@ decode_sysex_common_nrt_dls( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *
*/
static unsigned int
decode_sysex_common_nrt_eof( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned int offset, unsigned int data_len ) {
- int consumed = 0;
-
if ( data_len < 1 )
- return consumed;
+ return 0;
/* we only have a packet-number */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_nrt_sd_packet_number, tvb, offset, 1, ENC_BIG_ENDIAN );
- offset++;
- data_len--;
- consumed++;
- return consumed;
+ return 1;
}
/*
@@ -4339,18 +3673,14 @@ decode_sysex_common_nrt_eof( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *
*/
static unsigned int
decode_sysex_common_nrt_wait( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned int offset, unsigned int data_len ) {
- int consumed = 0;
if ( data_len < 1 )
- return consumed;
+ return 0;
/* we only have a packet-number */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_nrt_sd_packet_number, tvb, offset, 1, ENC_BIG_ENDIAN );
- offset++;
- data_len--;
- consumed++;
- return consumed;
+ return 1;
}
/*
@@ -4358,18 +3688,14 @@ decode_sysex_common_nrt_wait( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree
*/
static unsigned int
decode_sysex_common_nrt_cancel( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned int offset, unsigned int data_len ) {
- int consumed = 0;
if ( data_len < 1 )
- return consumed;
+ return 0;
/* we only have a packet-number */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_nrt_sd_packet_number, tvb, offset, 1, ENC_BIG_ENDIAN );
- offset++;
- data_len--;
- consumed++;
- return consumed;
+ return 1;
}
/*
@@ -4377,18 +3703,14 @@ decode_sysex_common_nrt_cancel( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tre
*/
static unsigned int
decode_sysex_common_nrt_nak( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned int offset, unsigned int data_len ) {
- int consumed = 0;
if ( data_len < 1 )
- return consumed;
+ return 0;
/* we only have a packet-number */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_nrt_sd_packet_number, tvb, offset, 1, ENC_BIG_ENDIAN );
- offset++;
- data_len--;
- consumed++;
- return consumed;
+ return 1;
}
/*
@@ -4396,18 +3718,14 @@ decode_sysex_common_nrt_nak( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *
*/
static unsigned int
decode_sysex_common_nrt_ack( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned int offset, unsigned int data_len ) {
- int consumed = 0;
if ( data_len < 1 )
- return consumed;
+ return 0;
/* we only have a packet-number */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_nrt_sd_packet_number, tvb, offset, 1, ENC_BIG_ENDIAN );
- offset++;
- data_len--;
- consumed++;
- return consumed;
+ return 1;
}
/*
@@ -4416,89 +3734,59 @@ decode_sysex_common_nrt_ack( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *
*/
static unsigned int
decode_sysex_common_nrt_mtc( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned int offset, unsigned int data_len ) {
- int consumed = 0;
+ unsigned int start_offset = offset;
if ( data_len < 1 )
- return consumed;
+ return 0;
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_nrt_mtc, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
data_len--;
- consumed++;
-
- if ( data_len < 1 )
- return -1;
/* type and hours */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_nrt_mtc_type, tvb, offset, 1, ENC_BIG_ENDIAN );
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_nrt_mtc_hr, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
data_len--;
- consumed++;
-
- if ( data_len < 1 )
- return -1;
/* minutes */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_nrt_mtc_mn, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
data_len--;
- consumed++;
-
- if ( data_len < 1 )
- return -1;
/* seconds */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_nrt_mtc_sc, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
data_len--;
- consumed++;
-
- if ( data_len < 1 )
- return -1;
/* frames */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_nrt_mtc_fr, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
data_len--;
- consumed++;
-
- if ( data_len < 1 )
- return -1;
/* fractional frames */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_nrt_mtc_ff, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
data_len--;
- consumed++;
-
- if ( data_len < 1 )
- return -1;
/* event-number (lsb) */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_nrt_mtc_enl, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
data_len--;
- consumed++;
-
- if ( data_len < 1 )
- return -1;
/* event-number (msb) */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_nrt_mtc_enm, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
data_len--;
- consumed++;
if ( data_len ) {
/* additional data */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_nrt_mtc_add, tvb, offset, data_len, ENC_NA );
- data_len -= data_len;
- consumed += data_len;
+ offset += data_len;
}
- return consumed;
+ return offset-start_offset;
}
/*
@@ -4507,43 +3795,33 @@ decode_sysex_common_nrt_mtc( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *
*/
static unsigned int
decode_sysex_common_rt_mtc_cue( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned int offset, unsigned int data_len ) {
- int consumed = 0;
+ unsigned int start_offset = offset;
if ( data_len < 1 )
- return consumed;
+ return 0;
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_rt_mtc_cueing, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
data_len--;
- consumed++;
-
- if ( data_len < 1 )
- return -1;
/* event-number (lsb) */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_rt_mtc_cue_enl, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
data_len--;
- consumed++;
-
- if ( data_len < 1 )
- return -1;
/* event-number (msb) */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_rt_mtc_cue_enm, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
data_len--;
- consumed++;
if ( data_len ) {
/* additional data */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_rt_mtc_cue_add, tvb, offset, data_len, ENC_NA );
- data_len -= data_len;
- consumed += data_len;
+ offset += data_len;
}
- return consumed;
+ return offset-start_offset;
}
@@ -4556,7 +3834,6 @@ static unsigned int
decode_sysex_common_nrt( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned int offset, unsigned int data_len ) {
guint8 common_nrt;
const gchar *nrt_str;
- proto_item *command_item;
proto_tree *command_tree;
int consumed = 0;
int ext_consumed = 0;
@@ -4577,8 +3854,7 @@ decode_sysex_common_nrt( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree
nrt_str = val_to_str( common_nrt, rtp_midi_sysex_common_nrt, "Unknown 0x%02x" );
- command_item = proto_tree_add_text(tree, tvb, offset, data_len, "%s",nrt_str );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_sysex_common_nrt );
+ command_tree = proto_tree_add_subtree(tree, tvb, offset, data_len, ett_rtp_midi_sysex_common_nrt, NULL, nrt_str );
proto_tree_add_item( command_tree, hf_rtp_midi_sysex_common_non_realtime, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
@@ -4587,13 +3863,13 @@ decode_sysex_common_nrt( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree
switch ( common_nrt ) {
case RTP_MIDI_SYSEX_COMMON_NRT_SAMPLE_DUMP_HEADER:
- ext_consumed = decode_sysex_common_nrt_sd_hdr( tvb, pinfo, command_tree, offset, data_len );
+ ext_consumed = decode_sysex_common_nrt_sd_hdr( tvb, pinfo, command_tree, offset);
break;
case RTP_MIDI_SYSEX_COMMON_NRT_SAMPLE_DATA_PACKET:
ext_consumed = decode_sysex_common_nrt_sd_packet( tvb, pinfo, command_tree, offset, data_len );
break;
case RTP_MIDI_SYSEX_COMMON_NRT_SAMPLE_DUMP_REQUEST:
- ext_consumed = decode_sysex_common_nrt_sd_req( tvb, pinfo, command_tree, offset, data_len );
+ ext_consumed = decode_sysex_common_nrt_sd_req( tvb, pinfo, command_tree, offset);
break;
case RTP_MIDI_SYSEX_COMMON_NRT_MTC:
ext_consumed = decode_sysex_common_nrt_mtc( tvb, pinfo, command_tree, offset, data_len );
@@ -4661,143 +3937,75 @@ decode_sysex_common_nrt( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree
static unsigned int
decode_sysex_common_rt_mtc( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned int offset, unsigned int data_len ) {
guint8 sub_id;
- int consumed = 0;
+ unsigned int start_offset = offset;
if ( data_len < 1 )
- return consumed;
+ return 0;
/* first we retrieve the sub-command */
sub_id = tvb_get_guint8( tvb, offset );
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_rt_mtc, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
- data_len--;
- consumed++;
if ( sub_id == RTP_MIDI_SYSEX_COMMON_RT_MTC_FULL_MESSAGE ) {
- if ( data_len < 1 )
- return -1;
-
/* type and hours */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_rt_mtc_fm_type, tvb, offset, 1, ENC_BIG_ENDIAN );
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_rt_mtc_fm_hr, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
- data_len--;
- consumed++;
-
- if ( data_len < 1 )
- return -1;
/* minutes */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_rt_mtc_fm_mn, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
- data_len--;
- consumed++;
-
- if ( data_len < 1 )
- return -1;
/* seconds */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_rt_mtc_fm_sc, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
- data_len--;
- consumed++;
-
- if ( data_len < 1 )
- return -1;
/* frames */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_rt_mtc_fm_fr, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
- data_len--;
- consumed++;
} else if ( sub_id == RTP_MIDI_SYSEX_COMMON_RT_MTC_USER_BITS ) {
- if ( data_len < 1 )
- return -1;
-
/* U1 */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_rt_mtc_ub_u1, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
- data_len--;
- consumed++;
-
- if ( data_len < 1 )
- return -1;
/* U2 */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_rt_mtc_ub_u2, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
- data_len--;
- consumed++;
-
- if ( data_len < 1 )
- return -1;
/* U3 */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_rt_mtc_ub_u3, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
- data_len--;
- consumed++;
-
- if ( data_len < 1 )
- return -1;
/* U4 */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_rt_mtc_ub_u4, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
- data_len--;
- consumed++;
-
- if ( data_len < 1 )
- return -1;
/* U5 */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_rt_mtc_ub_u5, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
- data_len--;
- consumed++;
-
- if ( data_len < 1 )
- return -1;
/* U6 */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_rt_mtc_ub_u6, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
- data_len--;
- consumed++;
-
- if ( data_len < 1 )
- return -1;
/* U7 */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_rt_mtc_ub_u7, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
- data_len--;
- consumed++;
-
- if ( data_len < 1 )
- return -1;
/* U8 */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_rt_mtc_ub_u8, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
- data_len--;
- consumed++;
-
- if ( data_len < 1 )
- return -1;
/* U9 */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_rt_mtc_ub_u9, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
- data_len--;
- consumed++;
-
}
- return consumed;
+ return offset-start_offset;
}
/*
@@ -4805,18 +4013,14 @@ decode_sysex_common_rt_mtc( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *t
*/
static unsigned int
decode_sysex_common_rt_sc( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned int offset, unsigned int data_len ) {
- int consumed = 0;
if ( data_len < 1 )
- return consumed;
+ return 0;
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_rt_sc, tvb, offset, 1, ENC_BIG_ENDIAN );
- offset++;
- data_len--;
- consumed++;
/* TODO: decode Show Control stuff */
- return consumed;
+ return 1;
}
/*
@@ -4825,93 +4029,66 @@ decode_sysex_common_rt_sc( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tr
static unsigned int
decode_sysex_common_rt_ni( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned int offset, unsigned int data_len ) {
guint8 sub_id;
- int consumed = 0;
+ unsigned int start_offset = offset;
if ( data_len < 1 )
- return consumed;
+ return 0;
/* first we retrieve the sub-command */
sub_id = tvb_get_guint8( tvb, offset );
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_rt_ni, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
- data_len--;
- consumed++;
if ( sub_id == RTP_MIDI_SYSEX_COMMON_RT_NT_BAR_NUMBER ) {
- if ( data_len < 2 )
- return -1;
-
/* bar number */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_rt_ni_bar_num, tvb, offset, 2, ENC_BIG_ENDIAN );
- consumed += 2;
+ offset += 2;
} else if ( ( sub_id == RTP_MIDI_SYSEX_COMMON_RT_NT_TIME_SIGNATURE_IMMEDIATE ) ||
( sub_id == RTP_MIDI_SYSEX_COMMON_RT_NT_TIME_SIGNATURE_DELAYED ) ) {
int bytes;
- if ( data_len < 1 )
- return -1;
-
/* bytes */
bytes = tvb_get_guint8( tvb, offset );
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_rt_ni_bytes, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
- data_len--;
- consumed++;
-
- if ( data_len < 1 )
- return -1;
/* beats / numerator */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_rt_ni_numerator, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
- data_len--;
- consumed++;
bytes--;
/* beats / denominator */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_rt_ni_denominator, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
- data_len--;
- consumed++;
bytes--;
/* clocks */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_rt_ni_midi_clocks, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
- data_len--;
- consumed++;
bytes--;
/* 32nds */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_rt_ni_32nds, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
- data_len--;
- consumed++;
bytes--;
while ( bytes > 0 ) {
- if ( data_len < 1 )
- return -1;
/* beats / numerator */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_rt_ni_numerator, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
- data_len--;
- consumed++;
bytes--;
/* beats / denominator */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_rt_ni_denominator, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
- data_len--;
- consumed++;
bytes--;
}
}
- return consumed;
+ return offset-start_offset;
}
/*
@@ -4920,39 +4097,31 @@ decode_sysex_common_rt_ni( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tr
static unsigned int
decode_sysex_common_rt_dc( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned int offset, unsigned int data_len ) {
guint8 sub_id;
- int consumed = 0;
+ unsigned int start_offset = offset;
if ( data_len < 1 )
- return consumed;
+ return 0;
/* first we retrieve the sub-command */
sub_id = tvb_get_guint8( tvb, offset );
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_rt_dc, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
- data_len--;
- consumed++;
if ( sub_id == RTP_MIDI_SYSEX_COMMON_RT_DC_MASTER_VOLUME ) {
- if ( data_len < 2 )
- return -1;
-
/* volume */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_rt_dc_volume, tvb, offset, 2, ENC_BIG_ENDIAN );
- consumed += 2;
+ offset += 2;
} else if ( sub_id == RTP_MIDI_SYSEX_COMMON_RT_DC_MASTER_BALANCE ) {
- if ( data_len < 2 )
- return -1;
-
/* balance */
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_rt_dc_balance, tvb, offset, 2, ENC_BIG_ENDIAN );
- consumed += 2;
+ offset += 2;
}
- return consumed;
+ return offset-start_offset;
}
@@ -4961,18 +4130,15 @@ decode_sysex_common_rt_dc( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tr
*/
static unsigned int
decode_sysex_common_rt_mmc_command( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned int offset, unsigned int data_len ) {
- int consumed = 0;
if ( data_len < 1 )
- return consumed;
+ return 0;
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_rt_mmc_commands, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
- data_len--;
- consumed++;
/* TODO: decode MMC stuff */
- return consumed;
+ return 1;
}
/*
@@ -4980,18 +4146,14 @@ decode_sysex_common_rt_mmc_command( tvbuff_t *tvb, packet_info *pinfo _U_, proto
*/
static unsigned int
decode_sysex_common_rt_mmc_response( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned int offset, unsigned int data_len ) {
- int consumed = 0;
if ( data_len < 1 )
- return consumed;
+ return 0;
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_rt_mmc_responses, tvb, offset, 1, ENC_BIG_ENDIAN );
- offset++;
- data_len--;
- consumed++;
/* TODO: decode MMC stuff */
- return consumed;
+ return 1;
}
@@ -5005,7 +4167,6 @@ static unsigned int
decode_sysex_common_rt( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned int offset, unsigned int data_len ) {
guint8 common_rt;
const gchar *rt_str;
- proto_item *command_item;
proto_tree *command_tree;
int consumed = 0;
int ext_consumed = 0;
@@ -5025,8 +4186,7 @@ decode_sysex_common_rt( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
common_rt = tvb_get_guint8( tvb, offset );
rt_str = val_to_str( common_rt, rtp_midi_sysex_common_rt, "Unknown 0x%02x" );
- command_item = proto_tree_add_text(tree, tvb, offset, data_len, "%s", rt_str );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_sysex_common_rt );
+ command_tree = proto_tree_add_subtree(tree, tvb, offset, data_len, ett_rtp_midi_sysex_common_rt, NULL, rt_str );
proto_tree_add_item( command_tree, hf_rtp_midi_sysex_common_realtime, tvb, offset, 1, ENC_BIG_ENDIAN );
data_len--;
@@ -5085,15 +4245,13 @@ decode_sysex_common_rt( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
*/
static unsigned int
decode_sysex_common_educational( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned int offset, unsigned int data_len ) {
- proto_item *command_item;
proto_tree *command_tree;
int consumed = 0;
if ( data_len < 1 )
return consumed;
- command_item = proto_tree_add_text(tree, tvb, offset, data_len, RTP_MIDI_TREE_NAME_COMMAND_SYSEX_EDU );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_sysex_edu );
+ command_tree = proto_tree_add_subtree(tree, tvb, offset, data_len, ett_rtp_midi_sysex_edu, NULL, RTP_MIDI_TREE_NAME_COMMAND_SYSEX_EDU );
proto_tree_add_item( command_tree, hf_rtp_midi_edu_data, tvb, offset, data_len, ENC_NA );
/* We consumed everything */
@@ -5106,7 +4264,6 @@ decode_sysex_common_educational( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tr
*/
static unsigned int
decode_sysex_common_manufacturer( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned int offset, unsigned int data_len, unsigned int manu_code _U_) {
- proto_item *command_item;
proto_tree *command_tree;
int consumed = 0;
@@ -5117,8 +4274,7 @@ decode_sysex_common_manufacturer( tvbuff_t *tvb, packet_info *pinfo _U_, proto_t
* of the sysex-data...
*/
- command_item = proto_tree_add_text(tree, tvb, offset, data_len, RTP_MIDI_TREE_NAME_COMMAND_SYSEX_MANU );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_sysex_manu );
+ command_tree = proto_tree_add_subtree(tree, tvb, offset, data_len, ett_rtp_midi_sysex_manu, NULL, RTP_MIDI_TREE_NAME_COMMAND_SYSEX_MANU );
proto_tree_add_item( command_tree, hf_rtp_midi_manu_data, tvb, offset, data_len, ENC_NA );
@@ -5134,8 +4290,7 @@ decode_sysex_common_manufacturer( tvbuff_t *tvb, packet_info *pinfo _U_, proto_t
static unsigned int
decode_sysex_start(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned int cmd_count, unsigned int offset, unsigned int cmd_len ) {
const gchar *status_str;
- proto_item *command_item;
- proto_tree *command_tree;
+ proto_tree *command_tree;
int consumed = 0;
int data_len;
int ext_consumed = 0;
@@ -5170,8 +4325,7 @@ decode_sysex_start(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsi
/* the unknown data we have does not include the trailing status-command */
data_len = consumed - 1;
- command_item = proto_tree_add_text(tree, tvb, offset - 1, 1 + consumed, "%s", status_str );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command );
+ command_tree = proto_tree_add_subtree(tree, tvb, offset - 1, 1 + consumed, ett_rtp_midi_command, NULL, status_str );
proto_tree_add_item( command_tree, hf_rtp_midi_common_status, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
/* lets see if we have enough data for the sysex-id */
@@ -5234,35 +4388,13 @@ decode_sysex_start(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsi
* Here the MIDI-Time-Code (MTC) Quarter Frame command is decoded.
*/
static int
-decode_mtc_quarter_frame(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned int cmd_count, unsigned int offset, unsigned int cmd_len ) {
- guint8 value;
+decode_mtc_quarter_frame(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned int cmd_count, unsigned int offset) {
const gchar *status_str;
- proto_item *command_item;
proto_tree *command_tree;
status_str = val_to_str( RTP_MIDI_STATUS_COMMON_MTC_QUARTER_FRAME, rtp_midi_common_status, rtp_midi_unknown_value_hex );
- /* broken: we have no further data */
- if ( !cmd_len ) {
- command_item = proto_tree_add_text( tree, tvb, offset - 1, 1, "TRUNCATED: %s ", status_str );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command );
- proto_tree_add_item( command_tree, hf_rtp_midi_common_status, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
- return -1;
- }
-
- value = tvb_get_guint8( tvb, offset );
-
- /* seems to be an aborted MIDI-command */
- if ( value & RTP_MIDI_COMMAND_STATUS_FLAG ) {
- command_item = proto_tree_add_text( tree, tvb, offset - 1, 1, "ABORTED: %s", status_str );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command );
- proto_tree_add_item( command_tree, hf_rtp_midi_common_status, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
- return -1;
- }
-
-
- command_item = proto_tree_add_text(tree, tvb, offset - 1, 2, "%s", status_str );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command );
+ command_tree = proto_tree_add_subtree(tree, tvb, offset - 1, 2, ett_rtp_midi_command, NULL, status_str );
proto_tree_add_item( command_tree, hf_rtp_midi_common_status, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
proto_tree_add_item( command_tree, hf_rtp_midi_quarter_frame_type, tvb, offset, 1, ENC_BIG_ENDIAN );
proto_tree_add_item( command_tree, hf_rtp_midi_quarter_frame_value, tvb, offset + 1, 1, ENC_BIG_ENDIAN );
@@ -5279,58 +4411,19 @@ decode_mtc_quarter_frame(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree
* Here the Song Position Pointer command is decoded.
*/
static int
-decode_song_position_pointer(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned int cmd_count, unsigned int offset, unsigned int cmd_len ) {
+decode_song_position_pointer(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned int cmd_count, unsigned int offset) {
guint8 octet1;
guint8 octet2;
guint8 position;
const gchar *status_str;
- proto_item *command_item;
proto_tree *command_tree;
status_str = val_to_str( RTP_MIDI_STATUS_COMMON_SONG_POSITION_POINTER, rtp_midi_common_status, rtp_midi_unknown_value_hex );
-
- /* broken: we have no further data */
- if ( !cmd_len ) {
- command_item = proto_tree_add_text( tree, tvb, offset - 1, 1, "TRUNCATED: %s", status_str );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command );
- proto_tree_add_item( command_tree, hf_rtp_midi_common_status, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
- return -1;
- }
-
octet1 = tvb_get_guint8( tvb, offset );
-
- /* seems to be an aborted MIDI-command */
- if ( octet1 & RTP_MIDI_COMMAND_STATUS_FLAG ) {
- command_item = proto_tree_add_text( tree, tvb, offset - 1, 1, "ABORTED: %s", status_str );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command );
- proto_tree_add_item( command_tree, hf_rtp_midi_common_status, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
- return -1;
- }
-
- /* broken: we have only one further octet */
- if ( cmd_len < 2 ) {
- command_item = proto_tree_add_text( tree, tvb, offset - 1, 2, "TRUNCATED: %s", status_str );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command );
- proto_tree_add_item( command_tree, hf_rtp_midi_common_status, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_spp_truncated, tvb, offset, 1, ENC_BIG_ENDIAN );
- return -1;
- }
-
octet2 = tvb_get_guint8( tvb, offset + 1 );
-
- /* seems to be an aborted MIDI-command */
- if ( octet2 & RTP_MIDI_COMMAND_STATUS_FLAG ) {
- command_item = proto_tree_add_text( tree, tvb, offset - 1, 2, "ABORTED: %s", status_str );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command );
- proto_tree_add_item( command_tree, hf_rtp_midi_common_status, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( command_tree, hf_rtp_midi_spp_truncated, tvb, offset, 1, ENC_BIG_ENDIAN );
- return -1;
- }
-
position = ( octet1 << 7 ) | octet2;
- command_item = proto_tree_add_text(tree, tvb, offset - 1, 3, "%s (p=%d)", status_str, position );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command );
+ command_tree = proto_tree_add_subtree_format(tree, tvb, offset - 1, 3, ett_rtp_midi_command, NULL, "%s (p=%d)", status_str, position );
proto_tree_add_item( command_tree, hf_rtp_midi_common_status, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
proto_tree_add_item( command_tree, hf_rtp_midi_spp, tvb, offset, 2, ENC_BIG_ENDIAN );
@@ -5346,34 +4439,15 @@ decode_song_position_pointer(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *
* Here a Song-Select command is decoded.
*/
static int
-decode_song_select(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned int cmd_count, unsigned int offset, unsigned int cmd_len ) {
+decode_song_select(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned int cmd_count, unsigned int offset) {
guint8 song_nr;
const gchar *status_str;
- proto_item *command_item;
proto_tree *command_tree;
status_str = val_to_str( RTP_MIDI_STATUS_COMMON_SONG_SELECT, rtp_midi_common_status, rtp_midi_unknown_value_hex );
-
- /* broken: we have no further data */
- if ( !cmd_len ) {
- command_item = proto_tree_add_text( tree, tvb, offset - 1, 1, "TRUNCATED: %s", status_str );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command );
- proto_tree_add_item( command_tree, hf_rtp_midi_common_status, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
- return -1;
- }
-
song_nr = tvb_get_guint8( tvb, offset );
- /* seems to be an aborted MIDI-command */
- if ( song_nr & RTP_MIDI_COMMAND_STATUS_FLAG ) {
- command_item = proto_tree_add_text( tree, tvb, offset - 1, 1, "ABORTED: %s", status_str );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command );
- proto_tree_add_item( command_tree, hf_rtp_midi_common_status, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
- return -1;
- }
-
- command_item = proto_tree_add_text(tree, tvb, offset - 1, 2, "%s (s=%d)", status_str, song_nr );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command );
+ command_tree = proto_tree_add_subtree_format(tree, tvb, offset - 1, 2, ett_rtp_midi_command, NULL, "%s (s=%d)", status_str, song_nr );
proto_tree_add_item( command_tree, hf_rtp_midi_common_status, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
proto_tree_add_item( command_tree, hf_rtp_midi_song_select, tvb, offset, 1, ENC_BIG_ENDIAN );
@@ -5391,7 +4465,6 @@ decode_song_select(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsi
static int
decode_undefined_f4(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned int cmd_count, unsigned int offset, unsigned int cmd_len ) {
const gchar *status_str;
- proto_item *command_item;
proto_tree *command_tree;
int consumed = 0;
@@ -5409,8 +4482,7 @@ decode_undefined_f4(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, uns
}
}
- command_item = proto_tree_add_text(tree, tvb, offset - 1, 1 + consumed, "%s", status_str );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command );
+ command_tree = proto_tree_add_subtree(tree, tvb, offset - 1, 1 + consumed, ett_rtp_midi_command, NULL, status_str );
proto_tree_add_item( command_tree, hf_rtp_midi_common_status, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
/* just add the unknown data to the tree */
proto_tree_add_item( command_tree, hf_rtp_midi_unknown_data, tvb, offset, consumed, ENC_NA );
@@ -5430,7 +4502,6 @@ decode_undefined_f4(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, uns
static int
decode_undefined_f5(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned int cmd_count, unsigned int offset, unsigned int cmd_len ) {
const gchar *status_str;
- proto_item *command_item;
proto_tree *command_tree;
int consumed = 0;
@@ -5447,8 +4518,7 @@ decode_undefined_f5(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, uns
}
}
- command_item = proto_tree_add_text(tree, tvb, offset - 1, 1 + consumed, "%s", status_str );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command );
+ command_tree = proto_tree_add_subtree(tree, tvb, offset - 1, 1 + consumed, ett_rtp_midi_command, NULL, status_str );
proto_tree_add_item( command_tree, hf_rtp_midi_common_status, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
/* just add the unknown data to the tree */
proto_tree_add_item( command_tree, hf_rtp_midi_unknown_data, tvb, offset, consumed, ENC_NA );
@@ -5468,12 +4538,10 @@ decode_undefined_f5(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, uns
static int
decode_tune_request(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned int cmd_count, unsigned int offset, unsigned int cmd_len _U_ ) {
const gchar *status_str;
- proto_item *command_item;
proto_tree *command_tree;
status_str = val_to_str( RTP_MIDI_STATUS_COMMON_TUNE_REQUEST, rtp_midi_common_status, rtp_midi_unknown_value_hex );
- command_item = proto_tree_add_text(tree, tvb, offset - 1, 1, "%s", status_str );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command );
+ command_tree = proto_tree_add_subtree(tree, tvb, offset - 1, 1, ett_rtp_midi_command, NULL, status_str );
proto_tree_add_item( command_tree, hf_rtp_midi_common_status, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
if ( cmd_count ) {
@@ -5490,7 +4558,6 @@ decode_tune_request(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, uns
static int
decode_sysex_end(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned int cmd_count, unsigned int offset, unsigned int cmd_len ) {
const gchar *status_str;
- proto_item *command_item;
proto_tree *command_tree;
int consumed = 0;
@@ -5521,8 +4588,7 @@ decode_sysex_end(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsign
}
}
- command_item = proto_tree_add_text(tree, tvb, offset - 1, 1 + consumed, "%s", status_str );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command );
+ command_tree = proto_tree_add_subtree(tree, tvb, offset - 1, 1 + consumed, ett_rtp_midi_command, NULL, status_str );
proto_tree_add_item( command_tree, hf_rtp_midi_common_status, tvb, offset - 1, 1, ENC_BIG_ENDIAN );
proto_tree_add_item( command_tree, hf_rtp_midi_unknown_data, tvb, offset, consumed - 1, ENC_NA );
proto_tree_add_item( command_tree, hf_rtp_midi_common_status, tvb, offset + consumed - 1, 1, ENC_BIG_ENDIAN );
@@ -5579,13 +4645,11 @@ decodemidi(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned int
/* midi realtime-data -> one octet -- unlike serial-wired MIDI realtime-commands in RTP-MIDI will
* not be intermingled with other MIDI-commands, so we handle this case right here and return */
if ( octet >= 0xf8 ) {
- proto_item *command_item;
proto_tree *command_tree;
const gchar *valstr;
valstr = val_to_str( octet, rtp_midi_common_status, rtp_midi_unknown_value_hex );
- command_item = proto_tree_add_text(tree, tvb, offset, 1, "%s", valstr );
- command_tree = proto_item_add_subtree( command_item, ett_rtp_midi_command);
+ command_tree = proto_tree_add_subtree(tree, tvb, offset, 1, ett_rtp_midi_command, NULL, valstr );
proto_tree_add_item( command_tree, hf_rtp_midi_common_status, tvb, offset, 1, ENC_BIG_ENDIAN );
if ( cmd_count ) {
@@ -5639,25 +4703,25 @@ decodemidi(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned int
if ( octet < 0xf0 ) {
switch ( octet >> 4 ) {
case RTP_MIDI_STATUS_CHANNEL_NOTE_OFF:
- ext_consumed = decode_note_off( tvb, pinfo, tree, cmd_count, offset, cmd_len, octet, *rsoffset, using_rs );
+ ext_consumed = decode_note_off( tvb, pinfo, tree, cmd_count, offset, octet, *rsoffset, using_rs );
break;
case RTP_MIDI_STATUS_CHANNEL_NOTE_ON:
- ext_consumed = decode_note_on( tvb, pinfo, tree, cmd_count, offset, cmd_len, octet, *rsoffset, using_rs );
+ ext_consumed = decode_note_on( tvb, pinfo, tree, cmd_count, offset, octet, *rsoffset, using_rs );
break;
case RTP_MIDI_STATUS_CHANNEL_POLYPHONIC_KEY_PRESSURE:
- ext_consumed = decode_poly_pressure(tvb, pinfo, tree, cmd_count, offset, cmd_len, octet, *rsoffset, using_rs );
+ ext_consumed = decode_poly_pressure(tvb, pinfo, tree, cmd_count, offset, octet, *rsoffset, using_rs );
break;
case RTP_MIDI_STATUS_CHANNEL_CONTROL_CHANGE:
- ext_consumed = decode_control_change(tvb, pinfo, tree, cmd_count, offset, cmd_len, octet, *rsoffset, using_rs );
+ ext_consumed = decode_control_change(tvb, pinfo, tree, cmd_count, offset, octet, *rsoffset, using_rs );
break;
case RTP_MIDI_STATUS_CHANNEL_PROGRAM_CHANGE:
- ext_consumed = decode_program_change(tvb, pinfo, tree, cmd_count, offset, cmd_len, octet, *rsoffset, using_rs );
+ ext_consumed = decode_program_change(tvb, pinfo, tree, cmd_count, offset, octet, *rsoffset, using_rs );
break;
case RTP_MIDI_STATUS_CHANNEL_CHANNEL_PRESSURE:
- ext_consumed = decode_channel_pressure(tvb, pinfo, tree, cmd_count, offset, cmd_len, octet, *rsoffset, using_rs );
+ ext_consumed = decode_channel_pressure(tvb, pinfo, tree, cmd_count, offset, octet, *rsoffset, using_rs );
break;
case RTP_MIDI_STATUS_CHANNEL_PITCH_BEND_CHANGE:
- ext_consumed = decode_pitch_bend_change(tvb, pinfo, tree, cmd_count, offset, cmd_len, octet, *rsoffset, using_rs );
+ ext_consumed = decode_pitch_bend_change(tvb, pinfo, tree, cmd_count, offset, octet, *rsoffset, using_rs );
break;
}
/* external decoder informed us of error -> pass this through */
@@ -5673,13 +4737,13 @@ decodemidi(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned int
ext_consumed = decode_sysex_start( tvb, pinfo, tree, cmd_count, offset, cmd_len );
break;
case RTP_MIDI_STATUS_COMMON_MTC_QUARTER_FRAME:
- ext_consumed = decode_mtc_quarter_frame( tvb, pinfo, tree, cmd_count, offset, cmd_len );
+ ext_consumed = decode_mtc_quarter_frame( tvb, pinfo, tree, cmd_count, offset);
break;
case RTP_MIDI_STATUS_COMMON_SONG_POSITION_POINTER:
- ext_consumed = decode_song_position_pointer( tvb, pinfo, tree, cmd_count, offset, cmd_len );
+ ext_consumed = decode_song_position_pointer( tvb, pinfo, tree, cmd_count, offset);
break;
case RTP_MIDI_STATUS_COMMON_SONG_SELECT:
- ext_consumed = decode_song_select( tvb, pinfo, tree, cmd_count, offset, cmd_len );
+ ext_consumed = decode_song_select( tvb, pinfo, tree, cmd_count, offset);
break;
case RTP_MIDI_STATUS_COMMON_UNDEFINED_F4:
ext_consumed = decode_undefined_f4( tvb, pinfo, tree, cmd_count, offset, cmd_len );
@@ -5708,10 +4772,10 @@ decodemidi(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned int
*/
static int
decode_cj_chapter_c( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned int offset ) {
- proto_item *ti;
proto_tree *rtp_midi_cj_chapter_tree;
proto_tree *rtp_midi_loglist_tree;
- int consumed = 0;
+ proto_tree *loglist_tree;
+ unsigned int start_offset = offset;
guint8 octet;
int count;
int i;
@@ -5722,44 +4786,41 @@ decode_cj_chapter_c( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, un
/* count encoded is n+1 */
count++;
- ti = proto_tree_add_text( tree, tvb, offset, 1 + 2 * count, RTP_MIDI_TREE_NAME_CJ_CHAPTER_C );
- rtp_midi_cj_chapter_tree = proto_item_add_subtree( ti, ett_rtp_midi_cj_chapter_c );
+ rtp_midi_cj_chapter_tree = proto_tree_add_subtree( tree, tvb, offset, 1 + 2 * count,
+ ett_rtp_midi_cj_chapter_c, NULL, RTP_MIDI_TREE_NAME_CJ_CHAPTER_C );
proto_tree_add_item( rtp_midi_cj_chapter_tree, hf_rtp_midi_cj_chapter_c_sflag, tvb, offset, 1, ENC_BIG_ENDIAN );
proto_tree_add_item( rtp_midi_cj_chapter_tree, hf_rtp_midi_cj_chapter_c_length, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
- consumed++;
- ti = proto_tree_add_text( rtp_midi_cj_chapter_tree, tvb, offset, count * 2, RTP_MIDI_TREE_NAME_CJ_CHAPTER_C_LOGLIST );
- rtp_midi_loglist_tree = proto_item_add_subtree( ti, ett_rtp_midi_cj_chapter_c_loglist );
+ rtp_midi_loglist_tree = proto_tree_add_subtree( rtp_midi_cj_chapter_tree, tvb, offset, count * 2,
+ ett_rtp_midi_cj_chapter_c_loglist, NULL, RTP_MIDI_TREE_NAME_CJ_CHAPTER_C_LOGLIST );
for ( i = 0; i < count; i++ ) {
- ti = proto_tree_add_text(rtp_midi_loglist_tree, tvb, offset, 2, RTP_MIDI_TREE_NAME_CJ_CHAPTER_C_LOGITEM );
- ti = proto_item_add_subtree( ti, ett_rtp_midi_cj_chapter_c_logitem );
+ loglist_tree = proto_tree_add_subtree(rtp_midi_loglist_tree, tvb, offset, 2,
+ ett_rtp_midi_cj_chapter_c_logitem, NULL, RTP_MIDI_TREE_NAME_CJ_CHAPTER_C_LOGITEM );
- proto_tree_add_item( ti, hf_rtp_midi_cj_chapter_c_sflag, tvb, offset, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( ti, hf_rtp_midi_cj_chapter_c_number, tvb, offset, 1, ENC_BIG_ENDIAN );
+ proto_tree_add_item(loglist_tree, hf_rtp_midi_cj_chapter_c_sflag, tvb, offset, 1, ENC_BIG_ENDIAN );
+ proto_tree_add_item(loglist_tree, hf_rtp_midi_cj_chapter_c_number, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
- consumed++;
octet = tvb_get_guint8( tvb, offset );
- proto_tree_add_item( ti, hf_rtp_midi_cj_chapter_c_aflag, tvb, offset, 1, ENC_BIG_ENDIAN );
+ proto_tree_add_item(loglist_tree, hf_rtp_midi_cj_chapter_c_aflag, tvb, offset, 1, ENC_BIG_ENDIAN );
/* do we have a value or alternative coding? */
if ( octet & 0x80 ) {
- proto_tree_add_item( ti, hf_rtp_midi_cj_chapter_c_tflag, tvb, offset, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( ti, hf_rtp_midi_cj_chapter_c_alt, tvb, offset, 1, ENC_BIG_ENDIAN );
+ proto_tree_add_item(loglist_tree, hf_rtp_midi_cj_chapter_c_tflag, tvb, offset, 1, ENC_BIG_ENDIAN );
+ proto_tree_add_item(loglist_tree, hf_rtp_midi_cj_chapter_c_alt, tvb, offset, 1, ENC_BIG_ENDIAN );
} else {
- proto_tree_add_item( ti, hf_rtp_midi_cj_chapter_c_value, tvb, offset, 1, ENC_BIG_ENDIAN );
+ proto_tree_add_item(loglist_tree, hf_rtp_midi_cj_chapter_c_value, tvb, offset, 1, ENC_BIG_ENDIAN );
}
offset++;
- consumed++;
}
- return consumed;
+ return offset-start_offset;
}
@@ -5769,7 +4830,6 @@ decode_cj_chapter_c( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, un
*/
static int
decode_cj_chapter_m( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned int offset ) {
- proto_item *ti;
proto_tree *rtp_midi_cj_chapter_tree;
proto_tree *rtp_midi_loglist_tree;
proto_tree *rtp_midi_loglist_item_tree;
@@ -5779,7 +4839,7 @@ decode_cj_chapter_m( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, un
int logitemhdrlen;
int logitemlen;
gboolean no_pnum_msb;
- int consumed = 0;
+ unsigned int start_offset = offset;
/* first we need to get the flags & length of this chapter */
header = tvb_get_ntohs( tvb, offset );
@@ -5787,8 +4847,7 @@ decode_cj_chapter_m( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, un
/* take of length of header */
length -= 2;
- ti = proto_tree_add_text( tree, tvb, offset, length, RTP_MIDI_TREE_NAME_CJ_CHAPTER_M );
- rtp_midi_cj_chapter_tree = proto_item_add_subtree( ti, ett_rtp_midi_cj_chapter_m );
+ rtp_midi_cj_chapter_tree = proto_tree_add_subtree( tree, tvb, offset, length, ett_rtp_midi_cj_chapter_m, NULL, RTP_MIDI_TREE_NAME_CJ_CHAPTER_M );
proto_tree_add_item( rtp_midi_cj_chapter_tree, hf_rtp_midi_cj_chapter_m_sflag, tvb, offset, 2, ENC_BIG_ENDIAN );
proto_tree_add_item( rtp_midi_cj_chapter_tree, hf_rtp_midi_cj_chapter_m_pflag, tvb, offset, 2, ENC_BIG_ENDIAN );
@@ -5799,7 +4858,6 @@ decode_cj_chapter_m( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, un
proto_tree_add_item( rtp_midi_cj_chapter_tree, hf_rtp_midi_cj_chapter_m_length, tvb, offset, 2, ENC_BIG_ENDIAN );
/* done with header */
- consumed += 2;
offset += 2;
/* do we have the pending field? */
@@ -5808,7 +4866,6 @@ decode_cj_chapter_m( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, un
proto_tree_add_item( rtp_midi_cj_chapter_tree, hf_rtp_midi_cj_chapter_m_qflag, tvb, offset, 1, ENC_BIG_ENDIAN );
proto_tree_add_item( rtp_midi_cj_chapter_tree, hf_rtp_midi_cj_chapter_m_pending, tvb, offset, 1, ENC_BIG_ENDIAN );
- consumed++;
offset++;
}
@@ -5819,8 +4876,7 @@ decode_cj_chapter_m( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, un
no_pnum_msb = ( header & 0x0400 ) && ( ( header & 0x0800 ) || ( header & 0x1000 ) );
logitemhdrlen = no_pnum_msb ? 2 : 3;
- ti = proto_tree_add_text( rtp_midi_cj_chapter_tree, tvb, offset, length, RTP_MIDI_TREE_NAME_CJ_CHAPTER_M_LOGLIST );
- rtp_midi_loglist_tree = proto_item_add_subtree( ti, ett_rtp_midi_cj_chapter_m_loglist );
+ rtp_midi_loglist_tree = proto_tree_add_subtree( rtp_midi_cj_chapter_tree, tvb, offset, length, ett_rtp_midi_cj_chapter_m_loglist, NULL, RTP_MIDI_TREE_NAME_CJ_CHAPTER_M_LOGLIST );
/* lets step through the loglist */
while ( length > 0 ) {
@@ -5859,12 +4915,11 @@ decode_cj_chapter_m( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, un
}
/* now that we have the length of the logitem, we can create the tree... */
- ti = proto_tree_add_text( rtp_midi_loglist_tree, tvb, offset, logitemlen, RTP_MIDI_TREE_NAME_CJ_CHAPTER_M_LOGITEM );
- rtp_midi_loglist_item_tree = proto_item_add_subtree( ti, ett_rtp_midi_cj_chapter_m_logitem );
+ rtp_midi_loglist_item_tree = proto_tree_add_subtree( rtp_midi_loglist_tree, tvb, offset, logitemlen,
+ ett_rtp_midi_cj_chapter_m_logitem, NULL, RTP_MIDI_TREE_NAME_CJ_CHAPTER_M_LOGITEM );
proto_tree_add_item( rtp_midi_loglist_item_tree, hf_rtp_midi_cj_chapter_m_log_sflag, tvb, offset, 1, ENC_BIG_ENDIAN );
proto_tree_add_item( rtp_midi_loglist_item_tree, hf_rtp_midi_cj_chapter_m_log_pnum_lsb, tvb, offset, 1, ENC_BIG_ENDIAN );
- consumed++;
offset++;
length--;
@@ -5872,7 +4927,6 @@ decode_cj_chapter_m( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, un
if ( !no_pnum_msb ) {
proto_tree_add_item( rtp_midi_loglist_item_tree, hf_rtp_midi_cj_chapter_m_log_qflag, tvb, offset, 1, ENC_BIG_ENDIAN );
proto_tree_add_item( rtp_midi_loglist_item_tree, hf_rtp_midi_cj_chapter_m_log_pnum_msb, tvb, offset, 1, ENC_BIG_ENDIAN );
- consumed++;
offset++;
length--;
}
@@ -5885,84 +4939,83 @@ decode_cj_chapter_m( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, un
proto_tree_add_item( rtp_midi_loglist_item_tree, hf_rtp_midi_cj_chapter_m_log_tflag, tvb, offset, 1, ENC_BIG_ENDIAN );
proto_tree_add_item( rtp_midi_loglist_item_tree, hf_rtp_midi_cj_chapter_m_log_vflag, tvb, offset, 1, ENC_BIG_ENDIAN );
proto_tree_add_item( rtp_midi_loglist_item_tree, hf_rtp_midi_cj_chapter_m_log_rflag, tvb, offset, 1, ENC_BIG_ENDIAN );
- consumed++;
offset++;
length--;
/* do we have a entry-msb field? */
if ( logitemheader & RTP_MIDI_CJ_CHAPTER_M_FLAG_J ) {
+ static const int * msb_flags[] = {
+ &hf_rtp_midi_cj_chapter_m_log_msb_x,
+ &hf_rtp_midi_cj_chapter_m_log_msb,
+ NULL
+ };
- ti = proto_tree_add_text( rtp_midi_loglist_tree, tvb, offset, 1, RTP_MIDI_TREE_NAME_CJ_CHAPTER_M_LOG_MSB );
- ti = proto_item_add_subtree( ti, ett_rtp_midi_cj_chapter_m_log_msb );
+ proto_tree_add_bitmask(rtp_midi_loglist_tree, tvb, offset, hf_rtp_midi_cj_chapter_m_log_msb_entry, ett_rtp_midi_cj_chapter_m_log_msb, msb_flags, ENC_NA);
- proto_tree_add_item( ti, hf_rtp_midi_cj_chapter_m_log_msb_x, tvb, offset, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( ti, hf_rtp_midi_cj_chapter_m_log_msb, tvb, offset, 1, ENC_BIG_ENDIAN );
-
- consumed++;
offset++;
length--;
}
/* do we have a entry-lsb field? */
if ( logitemheader & RTP_MIDI_CJ_CHAPTER_M_FLAG_K ) {
+ static const int * lsb_flags[] = {
+ &hf_rtp_midi_cj_chapter_m_log_lsb_x,
+ &hf_rtp_midi_cj_chapter_m_log_lsb,
+ NULL
+ };
- ti = proto_tree_add_text( rtp_midi_loglist_tree, tvb, offset, 1, RTP_MIDI_TREE_NAME_CJ_CHAPTER_M_LOG_LSB );
- ti = proto_item_add_subtree( ti, ett_rtp_midi_cj_chapter_m_log_lsb );
-
- proto_tree_add_item( ti, hf_rtp_midi_cj_chapter_m_log_lsb_x, tvb, offset, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( ti, hf_rtp_midi_cj_chapter_m_log_lsb, tvb, offset, 1, ENC_BIG_ENDIAN );
-
- consumed++;
+ proto_tree_add_bitmask(rtp_midi_loglist_tree, tvb, offset, hf_rtp_midi_cj_chapter_m_log_lsb_entry, ett_rtp_midi_cj_chapter_m_log_lsb, lsb_flags, ENC_NA);
offset++;
length--;
}
/* do we have an a-button field? */
if ( logitemheader & RTP_MIDI_CJ_CHAPTER_M_FLAG_L ) {
+ static const int * button_flags[] = {
+ &hf_rtp_midi_cj_chapter_m_log_a_button_g,
+ &hf_rtp_midi_cj_chapter_m_log_a_button_x,
+ &hf_rtp_midi_cj_chapter_m_log_a_button,
+ NULL
+ };
- ti = proto_tree_add_text( rtp_midi_loglist_tree, tvb, offset, 2, RTP_MIDI_TREE_NAME_CJ_CHAPTER_M_LOG_A_BUTTON );
- ti = proto_item_add_subtree( ti, ett_rtp_midi_cj_chapter_m_log_a_button );
+ proto_tree_add_bitmask(rtp_midi_loglist_tree, tvb, offset, hf_rtp_midi_cj_chapter_m_log_a_button_full, ett_rtp_midi_cj_chapter_m_log_a_button, button_flags, ENC_BIG_ENDIAN);
- proto_tree_add_item( ti, hf_rtp_midi_cj_chapter_m_log_a_button_g, tvb, offset, 2, ENC_BIG_ENDIAN );
- proto_tree_add_item( ti, hf_rtp_midi_cj_chapter_m_log_a_button_x, tvb, offset, 2, ENC_BIG_ENDIAN );
- proto_tree_add_item( ti, hf_rtp_midi_cj_chapter_m_log_a_button, tvb, offset, 2, ENC_BIG_ENDIAN );
-
- consumed += 2;
offset += 2;
length -= 2;
}
/* do we have a c-button field? */
if ( logitemheader & RTP_MIDI_CJ_CHAPTER_M_FLAG_M ) {
- ti = proto_tree_add_text( rtp_midi_loglist_tree, tvb, offset, 2, RTP_MIDI_TREE_NAME_CJ_CHAPTER_M_LOG_C_BUTTON );
- ti = proto_item_add_subtree( ti, ett_rtp_midi_cj_chapter_m_log_c_button );
+ static const int * button_flags[] = {
+ &hf_rtp_midi_cj_chapter_m_log_c_button_g,
+ &hf_rtp_midi_cj_chapter_m_log_c_button_r,
+ &hf_rtp_midi_cj_chapter_m_log_c_button,
+ NULL
+ };
- proto_tree_add_item( ti, hf_rtp_midi_cj_chapter_m_log_c_button_g, tvb, offset, 2, ENC_BIG_ENDIAN );
- proto_tree_add_item( ti, hf_rtp_midi_cj_chapter_m_log_c_button_r, tvb, offset, 2, ENC_BIG_ENDIAN );
- proto_tree_add_item( ti, hf_rtp_midi_cj_chapter_m_log_c_button, tvb, offset, 2, ENC_BIG_ENDIAN );
+ proto_tree_add_bitmask(rtp_midi_loglist_tree, tvb, offset, hf_rtp_midi_cj_chapter_m_log_c_button_full, ett_rtp_midi_cj_chapter_m_log_c_button, button_flags, ENC_BIG_ENDIAN);
- consumed += 2;
offset += 2;
length -= 2;
}
/* do we have a count field? */
if ( logitemheader & RTP_MIDI_CJ_CHAPTER_M_FLAG_N ) {
- ti = proto_tree_add_text( rtp_midi_loglist_tree, tvb, offset, 1, RTP_MIDI_TREE_NAME_CJ_CHAPTER_M_LOG_COUNT );
- ti = proto_item_add_subtree( ti, ett_rtp_midi_cj_chapter_m_log_count );
+ static const int * log_flags[] = {
+ &hf_rtp_midi_cj_chapter_m_log_count_x,
+ &hf_rtp_midi_cj_chapter_m_log_count,
+ NULL
+ };
- proto_tree_add_item( ti, hf_rtp_midi_cj_chapter_m_log_count_x, tvb, offset, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( ti, hf_rtp_midi_cj_chapter_m_log_count, tvb, offset, 1, ENC_BIG_ENDIAN );
+ proto_tree_add_bitmask(rtp_midi_loglist_tree, tvb, offset, hf_rtp_midi_cj_chapter_m_log_count_full, ett_rtp_midi_cj_chapter_m_log_count, log_flags, ENC_BIG_ENDIAN);
- consumed++;
offset++;
length--;
}
}
-
- return consumed;
+ return offset-start_offset;
}
@@ -5971,11 +5024,10 @@ decode_cj_chapter_m( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, un
*/
static int
decode_cj_chapter_n( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned int offset ) {
- proto_item *ti;
proto_tree *rtp_midi_cj_chapter_tree;
proto_tree *rtp_midi_loglist_tree;
const gchar *note_str;
- int consumed = 0;
+ unsigned int start_offset = offset;
guint16 header;
guint8 note;
guint8 velocity;
@@ -6007,8 +5059,8 @@ decode_cj_chapter_n( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, un
log_count++;
}
- ti = proto_tree_add_text( tree, tvb, offset, 2 + ( log_count * 2 ) + octet_count, RTP_MIDI_TREE_NAME_CJ_CHAPTER_N );
- rtp_midi_cj_chapter_tree = proto_item_add_subtree( ti, ett_rtp_midi_cj_chapter_n );
+ rtp_midi_cj_chapter_tree = proto_tree_add_subtree( tree, tvb, offset, 2 + ( log_count * 2 ) + octet_count,
+ ett_rtp_midi_cj_chapter_n, NULL, RTP_MIDI_TREE_NAME_CJ_CHAPTER_N );
proto_tree_add_item( rtp_midi_cj_chapter_tree, hf_rtp_midi_cj_chapter_n_bflag, tvb, offset, 2, ENC_BIG_ENDIAN );
proto_tree_add_item( rtp_midi_cj_chapter_tree, hf_rtp_midi_cj_chapter_n_len, tvb, offset, 2, ENC_BIG_ENDIAN );
@@ -6016,12 +5068,11 @@ decode_cj_chapter_n( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, un
proto_tree_add_item( rtp_midi_cj_chapter_tree, hf_rtp_midi_cj_chapter_n_high, tvb, offset, 2, ENC_BIG_ENDIAN );
offset += 2;
- consumed += 2;
if ( log_count > 0 ) {
- ti = proto_tree_add_text( rtp_midi_cj_chapter_tree, tvb, offset, log_count * 2, RTP_MIDI_TREE_NAME_CJ_CHAPTER_N_LOGLIST );
- rtp_midi_loglist_tree = proto_item_add_subtree( ti, ett_rtp_midi_cj_chapter_n_loglist );
+ rtp_midi_loglist_tree = proto_tree_add_subtree( rtp_midi_cj_chapter_tree, tvb, offset, log_count * 2,
+ ett_rtp_midi_cj_chapter_n_loglist, NULL, RTP_MIDI_TREE_NAME_CJ_CHAPTER_N_LOGLIST );
for ( i = 0; i < log_count; i++ ) {
@@ -6030,39 +5081,36 @@ decode_cj_chapter_n( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, un
note_str = val_to_str_ext( note, &rtp_midi_note_values_ext, rtp_midi_unknown_value_dec );
- ti = proto_tree_add_text(rtp_midi_loglist_tree, tvb, offset, 2, "%s (n=%s, v=%d)", RTP_MIDI_TREE_NAME_CJ_CHAPTER_N_LOGITEM, note_str, velocity );
- ti = proto_item_add_subtree( ti, ett_rtp_midi_cj_chapter_n_logitem );
+ rtp_midi_loglist_tree = proto_tree_add_subtree_format(rtp_midi_loglist_tree, tvb, offset, 2,
+ ett_rtp_midi_cj_chapter_n_logitem, NULL, "%s (n=%s, v=%d)", RTP_MIDI_TREE_NAME_CJ_CHAPTER_N_LOGITEM, note_str, velocity );
- proto_tree_add_item( ti, hf_rtp_midi_cj_chapter_n_log_sflag, tvb, offset, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( ti, hf_rtp_midi_cj_chapter_n_log_notenum, tvb, offset, 1, ENC_BIG_ENDIAN );
+ proto_tree_add_item( rtp_midi_loglist_tree, hf_rtp_midi_cj_chapter_n_log_sflag, tvb, offset, 1, ENC_BIG_ENDIAN );
+ proto_tree_add_item( rtp_midi_loglist_tree, hf_rtp_midi_cj_chapter_n_log_notenum, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
- consumed++;
- proto_tree_add_item( ti, hf_rtp_midi_cj_chapter_n_log_yflag, tvb, offset, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( ti, hf_rtp_midi_cj_chapter_n_log_velocity, tvb, offset, 1, ENC_BIG_ENDIAN );
+ proto_tree_add_item( rtp_midi_loglist_tree, hf_rtp_midi_cj_chapter_n_log_yflag, tvb, offset, 1, ENC_BIG_ENDIAN );
+ proto_tree_add_item( rtp_midi_loglist_tree, hf_rtp_midi_cj_chapter_n_log_velocity, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
- consumed++;
}
}
if ( octet_count > 0 ) {
- ti = proto_tree_add_text( rtp_midi_cj_chapter_tree, tvb, offset, log_count, RTP_MIDI_TREE_NAME_CJ_CHAPTER_N_OCTETS );
- rtp_midi_loglist_tree = proto_item_add_subtree( ti, ett_rtp_midi_cj_chapter_n_octets );
+ rtp_midi_loglist_tree = proto_tree_add_subtree( rtp_midi_cj_chapter_tree, tvb, offset, log_count,
+ ett_rtp_midi_cj_chapter_n_octets, NULL, RTP_MIDI_TREE_NAME_CJ_CHAPTER_N_OCTETS );
for ( i = 0; i < octet_count; i++ ) {
proto_tree_add_item(rtp_midi_loglist_tree, hf_rtp_midi_cj_chapter_n_log_octet, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
- consumed++;
}
}
- return consumed;
+ return offset-start_offset;
}
@@ -6071,11 +5119,10 @@ decode_cj_chapter_n( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, un
*/
static int
decode_cj_chapter_e( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned int offset ) {
- proto_item *ti;
proto_tree *rtp_midi_cj_chapter_tree;
- proto_tree *rtp_midi_loglist_tree;
+ proto_tree *rtp_midi_loglist_tree, *log_tree;
const gchar *note_str;
- int consumed = 0;
+ unsigned int start_offset = offset;
guint8 header;
guint8 note;
guint8 count_vel;
@@ -6090,17 +5137,16 @@ decode_cj_chapter_e( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, un
/* count is encoded n+1 */
log_count++;
- ti = proto_tree_add_text( tree, tvb, offset, 1 + ( log_count * 2 ), RTP_MIDI_TREE_NAME_CJ_CHAPTER_E );
- rtp_midi_cj_chapter_tree = proto_item_add_subtree( ti, ett_rtp_midi_cj_chapter_e );
+ rtp_midi_cj_chapter_tree = proto_tree_add_subtree( tree, tvb, offset, 1 + ( log_count * 2 ),
+ ett_rtp_midi_cj_chapter_e, NULL, RTP_MIDI_TREE_NAME_CJ_CHAPTER_E );
proto_tree_add_item( rtp_midi_cj_chapter_tree, hf_rtp_midi_cj_chapter_e_sflag, tvb, offset, 1, ENC_BIG_ENDIAN );
proto_tree_add_item( rtp_midi_cj_chapter_tree, hf_rtp_midi_cj_chapter_e_len, tvb, offset, 2, ENC_BIG_ENDIAN );
offset++;
- consumed++;
- ti = proto_tree_add_text( rtp_midi_cj_chapter_tree, tvb, offset, log_count * 2, RTP_MIDI_TREE_NAME_CJ_CHAPTER_E_LOGLIST );
- rtp_midi_loglist_tree = proto_item_add_subtree( ti, ett_rtp_midi_cj_chapter_e_loglist );
+ rtp_midi_loglist_tree = proto_tree_add_subtree( rtp_midi_cj_chapter_tree, tvb, offset, log_count * 2,
+ ett_rtp_midi_cj_chapter_e_loglist, NULL, RTP_MIDI_TREE_NAME_CJ_CHAPTER_E_LOGLIST );
for ( i = 0; i < log_count; i++ ) {
@@ -6111,30 +5157,29 @@ decode_cj_chapter_e( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, un
note_str = val_to_str_ext( note, &rtp_midi_note_values_ext, rtp_midi_unknown_value_dec );
if ( octet & 0x80 ) {
- ti = proto_tree_add_text(rtp_midi_loglist_tree, tvb, offset, 2, "%s (n=%s, v=%d)", RTP_MIDI_TREE_NAME_CJ_CHAPTER_E_LOGITEM1, note_str, count_vel );
+ log_tree = proto_tree_add_subtree_format(rtp_midi_loglist_tree, tvb, offset, 2, ett_rtp_midi_cj_chapter_e_logitem, NULL,
+ "%s (n=%s, v=%d)", RTP_MIDI_TREE_NAME_CJ_CHAPTER_E_LOGITEM1, note_str, count_vel );
} else {
- ti = proto_tree_add_text(rtp_midi_loglist_tree, tvb, offset, 2, "%s (n=%s, c=%d)", RTP_MIDI_TREE_NAME_CJ_CHAPTER_E_LOGITEM2, note_str, count_vel );
+ log_tree = proto_tree_add_subtree_format(rtp_midi_loglist_tree, tvb, offset, 2, ett_rtp_midi_cj_chapter_e_logitem, NULL,
+ "%s (n=%s, c=%d)", RTP_MIDI_TREE_NAME_CJ_CHAPTER_E_LOGITEM2, note_str, count_vel );
}
- ti = proto_item_add_subtree( ti, ett_rtp_midi_cj_chapter_e_logitem );
- proto_tree_add_item( ti, hf_rtp_midi_cj_chapter_e_log_sflag, tvb, offset, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( ti, hf_rtp_midi_cj_chapter_e_log_notenum, tvb, offset, 1, ENC_BIG_ENDIAN );
+ proto_tree_add_item( log_tree, hf_rtp_midi_cj_chapter_e_log_sflag, tvb, offset, 1, ENC_BIG_ENDIAN );
+ proto_tree_add_item( log_tree, hf_rtp_midi_cj_chapter_e_log_notenum, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
- consumed++;
- proto_tree_add_item( ti, hf_rtp_midi_cj_chapter_e_log_vflag, tvb, offset, 1, ENC_BIG_ENDIAN );
+ proto_tree_add_item( log_tree, hf_rtp_midi_cj_chapter_e_log_vflag, tvb, offset, 1, ENC_BIG_ENDIAN );
if ( octet & 0x80 ) {
- proto_tree_add_item( ti, hf_rtp_midi_cj_chapter_e_log_velocity, tvb, offset, 1, ENC_BIG_ENDIAN );
+ proto_tree_add_item( log_tree, hf_rtp_midi_cj_chapter_e_log_velocity, tvb, offset, 1, ENC_BIG_ENDIAN );
} else {
- proto_tree_add_item( ti, hf_rtp_midi_cj_chapter_e_log_count, tvb, offset, 1, ENC_BIG_ENDIAN );
+ proto_tree_add_item( log_tree, hf_rtp_midi_cj_chapter_e_log_count, tvb, offset, 1, ENC_BIG_ENDIAN );
}
offset++;
- consumed++;
}
- return consumed;
+ return offset-start_offset;
}
@@ -6149,11 +5194,10 @@ decode_cj_chapter_e( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, un
*/
static int
decode_cj_chapter_a( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned int offset ) {
- proto_item *ti;
proto_tree *rtp_midi_cj_chapter_tree;
- proto_tree *rtp_midi_loglist_tree;
+ proto_tree *rtp_midi_loglist_tree, *log_tree;
const gchar *note_str;
- int consumed = 0;
+ unsigned int start_offset = offset;
guint8 header;
guint8 note;
guint8 pressure;
@@ -6167,17 +5211,14 @@ decode_cj_chapter_a( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, un
/* count is encoded n+1 */
log_count++;
- ti = proto_tree_add_text( tree, tvb, offset, 1 + ( log_count * 2 ), RTP_MIDI_TREE_NAME_CJ_CHAPTER_A );
- rtp_midi_cj_chapter_tree = proto_item_add_subtree( ti, ett_rtp_midi_cj_chapter_a );
+ rtp_midi_cj_chapter_tree = proto_tree_add_subtree( tree, tvb, offset, 1 + ( log_count * 2 ), ett_rtp_midi_cj_chapter_a, NULL, RTP_MIDI_TREE_NAME_CJ_CHAPTER_A );
proto_tree_add_item( rtp_midi_cj_chapter_tree, hf_rtp_midi_cj_chapter_a_sflag, tvb, offset, 1, ENC_BIG_ENDIAN );
proto_tree_add_item( rtp_midi_cj_chapter_tree, hf_rtp_midi_cj_chapter_a_len, tvb, offset, 2, ENC_BIG_ENDIAN );
offset++;
- consumed++;
- ti = proto_tree_add_text( rtp_midi_cj_chapter_tree, tvb, offset, log_count * 2, RTP_MIDI_TREE_NAME_CJ_CHAPTER_A_LOGLIST );
- rtp_midi_loglist_tree = proto_item_add_subtree( ti, ett_rtp_midi_cj_chapter_a_loglist );
+ rtp_midi_loglist_tree = proto_tree_add_subtree( rtp_midi_cj_chapter_tree, tvb, offset, log_count * 2, ett_rtp_midi_cj_chapter_a_loglist, NULL, RTP_MIDI_TREE_NAME_CJ_CHAPTER_A_LOGLIST );
for ( i = 0; i < log_count; i++ ) {
@@ -6186,23 +5227,21 @@ decode_cj_chapter_a( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, un
note_str = val_to_str_ext( note, &rtp_midi_note_values_ext, rtp_midi_unknown_value_dec );
- ti = proto_tree_add_text(rtp_midi_loglist_tree, tvb, offset, 2, "%s (n=%s, p=%d)", RTP_MIDI_TREE_NAME_CJ_CHAPTER_A_LOGITEM, note_str, pressure );
- ti = proto_item_add_subtree( ti, ett_rtp_midi_cj_chapter_a_logitem );
+ log_tree = proto_tree_add_subtree_format(rtp_midi_loglist_tree, tvb, offset, 2, ett_rtp_midi_cj_chapter_a_logitem, NULL,
+ "%s (n=%s, p=%d)", RTP_MIDI_TREE_NAME_CJ_CHAPTER_A_LOGITEM, note_str, pressure );
- proto_tree_add_item( ti, hf_rtp_midi_cj_chapter_a_log_sflag, tvb, offset, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( ti, hf_rtp_midi_cj_chapter_a_log_notenum, tvb, offset, 1, ENC_BIG_ENDIAN );
+ proto_tree_add_item( log_tree, hf_rtp_midi_cj_chapter_a_log_sflag, tvb, offset, 1, ENC_BIG_ENDIAN );
+ proto_tree_add_item( log_tree, hf_rtp_midi_cj_chapter_a_log_notenum, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
- consumed++;
- proto_tree_add_item( ti, hf_rtp_midi_cj_chapter_a_log_xflag, tvb, offset, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( ti, hf_rtp_midi_cj_chapter_a_log_pressure, tvb, offset, 1, ENC_BIG_ENDIAN );
+ proto_tree_add_item( log_tree, hf_rtp_midi_cj_chapter_a_log_xflag, tvb, offset, 1, ENC_BIG_ENDIAN );
+ proto_tree_add_item( log_tree, hf_rtp_midi_cj_chapter_a_log_pressure, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
- consumed++;
}
- return consumed;
+ return offset-start_offset;
}
@@ -6214,7 +5253,6 @@ decode_cj_chapter_a( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, un
*/
static int
decode_channel_journal( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned int offset ) {
- proto_item *ti;
proto_tree *rtp_midi_chanjournal_tree;
proto_tree *rtp_midi_cj_chapters_tree;
proto_tree *rtp_midi_cj_chapter_tree;
@@ -6227,8 +5265,8 @@ decode_channel_journal( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
chanflags = tvb_get_ntoh24( tvb, offset );
chanjourlen = ( chanflags & RTP_MIDI_CJ_MASK_LENGTH ) >> 8;
- ti = proto_tree_add_text( tree, tvb, offset, chanjourlen, "%s", val_to_str( ( chanflags & RTP_MIDI_CJ_MASK_CHANNEL ) >> RTP_MIDI_CJ_CHANNEL_SHIFT, rtp_midi_channels, rtp_midi_unknown_value_hex ) );
- rtp_midi_chanjournal_tree = proto_item_add_subtree( ti, ett_rtp_midi_channeljournal );
+ rtp_midi_chanjournal_tree = proto_tree_add_subtree( tree, tvb, offset, chanjourlen, ett_rtp_midi_channeljournal, NULL,
+ val_to_str( ( chanflags & RTP_MIDI_CJ_MASK_CHANNEL ) >> RTP_MIDI_CJ_CHANNEL_SHIFT, rtp_midi_channels, rtp_midi_unknown_value_hex ) );
proto_tree_add_item( rtp_midi_chanjournal_tree, hf_rtp_midi_chanjour_sflag, tvb, offset, 3, ENC_BIG_ENDIAN );
proto_tree_add_item( rtp_midi_chanjournal_tree, hf_rtp_midi_chanjour_chan, tvb, offset, 3, ENC_BIG_ENDIAN );
@@ -6243,8 +5281,8 @@ decode_channel_journal( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
proto_tree_add_item( rtp_midi_chanjournal_tree, hf_rtp_midi_chanjour_toc_t, tvb, offset, 3, ENC_BIG_ENDIAN );
proto_tree_add_item( rtp_midi_chanjournal_tree, hf_rtp_midi_chanjour_toc_a, tvb, offset, 3, ENC_BIG_ENDIAN );
- ti = proto_tree_add_text( rtp_midi_chanjournal_tree, tvb, offset + 3, chanjourlen - 3, RTP_MIDI_TREE_NAME_CHANNEL_CHAPTERS );
- rtp_midi_cj_chapters_tree = proto_item_add_subtree( ti, ett_rtp_midi_channelchapters );
+ rtp_midi_cj_chapters_tree = proto_tree_add_subtree( rtp_midi_chanjournal_tree, tvb, offset + 3, chanjourlen - 3,
+ ett_rtp_midi_channelchapters, NULL, RTP_MIDI_TREE_NAME_CHANNEL_CHAPTERS );
/* take care of length of header */
offset += 3;
@@ -6253,8 +5291,8 @@ decode_channel_journal( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
/* Do we have a program change chapter? */
if ( chanflags & RTP_MIDI_CJ_FLAG_P ) {
- ti = proto_tree_add_text( rtp_midi_cj_chapters_tree, tvb, offset, 3, RTP_MIDI_TREE_NAME_CJ_CHAPTER_P );
- rtp_midi_cj_chapter_tree = proto_item_add_subtree( ti, ett_rtp_midi_cj_chapter_p );
+ rtp_midi_cj_chapter_tree = proto_tree_add_subtree( rtp_midi_cj_chapters_tree, tvb, offset, 3,
+ ett_rtp_midi_cj_chapter_p, NULL, RTP_MIDI_TREE_NAME_CJ_CHAPTER_P );
proto_tree_add_item( rtp_midi_cj_chapter_tree, hf_rtp_midi_cj_chapter_p_sflag, tvb, offset, 1, ENC_BIG_ENDIAN );
proto_tree_add_item( rtp_midi_cj_chapter_tree, hf_rtp_midi_cj_chapter_p_program, tvb, offset, 1, ENC_BIG_ENDIAN );
@@ -6291,8 +5329,8 @@ decode_channel_journal( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
/* Do we have a pitch-wheel chapter? */
if ( chanflags & RTP_MIDI_CJ_FLAG_W ) {
- ti = proto_tree_add_text( rtp_midi_cj_chapters_tree, tvb, offset, 2, RTP_MIDI_TREE_NAME_CJ_CHAPTER_W );
- rtp_midi_cj_chapter_tree = proto_item_add_subtree( ti, ett_rtp_midi_cj_chapter_w );
+ rtp_midi_cj_chapter_tree = proto_tree_add_subtree( rtp_midi_cj_chapters_tree, tvb, offset, 2,
+ ett_rtp_midi_cj_chapter_w, NULL, RTP_MIDI_TREE_NAME_CJ_CHAPTER_W );
proto_tree_add_item( rtp_midi_cj_chapter_tree, hf_rtp_midi_cj_chapter_w_sflag, tvb, offset, 1, ENC_BIG_ENDIAN );
proto_tree_add_item( rtp_midi_cj_chapter_tree, hf_rtp_midi_cj_chapter_w_first, tvb, offset, 1, ENC_BIG_ENDIAN );
@@ -6329,12 +5367,13 @@ decode_channel_journal( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
/* Do we have channel aftertouch chapter? */
if ( chanflags & RTP_MIDI_CJ_FLAG_T ) {
+ static const int * flags_t[] = {
+ &hf_rtp_midi_cj_chapter_t_sflag,
+ &hf_rtp_midi_cj_chapter_t_pressure,
+ NULL
+ };
- ti = proto_tree_add_text( rtp_midi_cj_chapters_tree, tvb, offset, 1, RTP_MIDI_TREE_NAME_CJ_CHAPTER_T );
- rtp_midi_cj_chapter_tree = proto_item_add_subtree( ti, ett_rtp_midi_cj_chapter_t );
-
- proto_tree_add_item( rtp_midi_cj_chapter_tree, hf_rtp_midi_cj_chapter_t_sflag, tvb, offset, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( rtp_midi_cj_chapter_tree, hf_rtp_midi_cj_chapter_t_pressure, tvb, offset, 1, ENC_BIG_ENDIAN );
+ proto_tree_add_bitmask(rtp_midi_cj_chapters_tree, tvb, offset, hf_rtp_midi_cj_chapter_t_channel_aftertouch, ett_rtp_midi_cj_chapter_t, flags_t, ENC_NA);
offset++;
consumed++;
@@ -6363,9 +5402,8 @@ decode_channel_journal( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
static int
decode_sj_chapter_d_f4( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned int offset ) {
- proto_item *ti;
proto_tree *rtp_midi_field_tree;
- int consumed = 0;
+ unsigned int start_offset = offset;
guint16 f4flags;
guint16 f4length;
@@ -6374,8 +5412,7 @@ decode_sj_chapter_d_f4( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
f4length = f4flags & RTP_MIDI_SJ_CHAPTER_D_SYSCOM_MASK_LENGTH;
/* now we can display our tree, as we now have the full length */
- ti = proto_tree_add_text( tree, tvb, offset, f4length, RTP_MIDI_TREE_NAME_SJ_CHAPTER_D_FIELD_J );
- rtp_midi_field_tree = proto_item_add_subtree( ti, ett_rtp_midi_sj_chapter_d_field_j );
+ rtp_midi_field_tree = proto_tree_add_subtree( tree, tvb, offset, f4length, ett_rtp_midi_sj_chapter_d_field_j, NULL, RTP_MIDI_TREE_NAME_SJ_CHAPTER_D_FIELD_J );
proto_tree_add_item( rtp_midi_field_tree, hf_rtp_midi_sj_chapter_d_syscom_sflag, tvb, offset, 2, ENC_BIG_ENDIAN );
proto_tree_add_item( rtp_midi_field_tree, hf_rtp_midi_sj_chapter_d_syscom_cflag, tvb, offset, 2, ENC_BIG_ENDIAN );
@@ -6385,7 +5422,6 @@ decode_sj_chapter_d_f4( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
proto_tree_add_item( rtp_midi_field_tree, hf_rtp_midi_sj_chapter_d_syscom_length, tvb, offset, 2, ENC_BIG_ENDIAN );
offset += 2;
- consumed += 2;
f4length -= 2;
if ( f4flags & RTP_MIDI_SJ_CHAPTER_D_SYSCOM_FLAG_C ) {
@@ -6393,7 +5429,6 @@ decode_sj_chapter_d_f4( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
proto_tree_add_item( rtp_midi_field_tree, hf_rtp_midi_sj_chapter_d_syscom_count, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
- consumed++;
f4length--;
}
@@ -6419,19 +5454,18 @@ decode_sj_chapter_d_f4( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
proto_tree_add_item( rtp_midi_field_tree, hf_rtp_midi_sj_chapter_d_syscom_legal, tvb, offset, f4length, ENC_NA );
offset += f4length;
- f4length -= f4length;
}
/* if we still have data, the length-field was incorrect we dump the data here and abort! */
if ( f4length > 0 ) {
proto_tree_add_item( rtp_midi_field_tree, hf_rtp_midi_sj_chapter_d_syscom_data, tvb, offset, f4length, ENC_NA );
- consumed += f4length;
+ offset += f4length;
/* must be a protocol error - since we have a length, we can recover...*/
}
- return consumed;
+ return offset-start_offset;
}
@@ -6441,9 +5475,8 @@ decode_sj_chapter_d_f4( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
static int
decode_sj_chapter_d_f5( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned int offset ) {
- proto_item *ti;
proto_tree *rtp_midi_field_tree;
- int consumed = 0;
+ unsigned int start_offset = offset;
guint16 f5flags;
guint16 f5length;
@@ -6452,8 +5485,7 @@ decode_sj_chapter_d_f5( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
f5length = f5flags & RTP_MIDI_SJ_CHAPTER_D_SYSCOM_MASK_LENGTH;
/* now we can display our tree, as we now have the full length */
- ti = proto_tree_add_text( tree, tvb, offset, f5length, RTP_MIDI_TREE_NAME_SJ_CHAPTER_D_FIELD_K );
- rtp_midi_field_tree = proto_item_add_subtree( ti, ett_rtp_midi_sj_chapter_d_field_k );
+ rtp_midi_field_tree = proto_tree_add_subtree( tree, tvb, offset, f5length, ett_rtp_midi_sj_chapter_d_field_k, NULL, RTP_MIDI_TREE_NAME_SJ_CHAPTER_D_FIELD_K );
proto_tree_add_item( rtp_midi_field_tree, hf_rtp_midi_sj_chapter_d_syscom_sflag, tvb, offset, 2, ENC_BIG_ENDIAN );
proto_tree_add_item( rtp_midi_field_tree, hf_rtp_midi_sj_chapter_d_syscom_cflag, tvb, offset, 2, ENC_BIG_ENDIAN );
@@ -6463,7 +5495,6 @@ decode_sj_chapter_d_f5( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
proto_tree_add_item( rtp_midi_field_tree, hf_rtp_midi_sj_chapter_d_syscom_length, tvb, offset, 2, ENC_BIG_ENDIAN );
offset += 2;
- consumed += 2;
f5length -= 2;
if ( f5flags & RTP_MIDI_SJ_CHAPTER_D_SYSCOM_FLAG_C ) {
@@ -6471,7 +5502,6 @@ decode_sj_chapter_d_f5( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
proto_tree_add_item( rtp_midi_field_tree, hf_rtp_midi_sj_chapter_d_syscom_count, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
- consumed++;
f5length--;
}
@@ -6497,18 +5527,18 @@ decode_sj_chapter_d_f5( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
proto_tree_add_item( rtp_midi_field_tree, hf_rtp_midi_sj_chapter_d_syscom_legal, tvb, offset, f5length, ENC_NA );
offset += f5length;
- f5length -= f5length;
+ f5length = 0;
}
/* if we still have data, we dump it here - see above! */
if ( f5length > 0 ) {
proto_tree_add_item( rtp_midi_field_tree, hf_rtp_midi_sj_chapter_d_syscom_data, tvb, offset, f5length, ENC_NA );
- consumed += f5length;
+ offset += f5length;
/* must be a protocol error - since we have a length, we can recover...*/
}
- return consumed;
+ return offset-start_offset;
}
/*
@@ -6517,9 +5547,8 @@ decode_sj_chapter_d_f5( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
static int
decode_sj_chapter_d_f9( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned int offset ) {
- proto_item *ti;
proto_tree *rtp_midi_field_tree;
- int consumed = 0;
+ unsigned int start_offset = offset;
guint8 f9flags;
guint8 f9length;
@@ -6528,8 +5557,7 @@ decode_sj_chapter_d_f9( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
f9length = f9flags & RTP_MIDI_SJ_CHAPTER_D_SYSREAL_MASK_LENGTH;
/* now we can display our tree, as we now have the full length */
- ti = proto_tree_add_text( tree, tvb, offset, f9length, RTP_MIDI_TREE_NAME_SJ_CHAPTER_D_FIELD_Y );
- rtp_midi_field_tree = proto_item_add_subtree( ti, ett_rtp_midi_sj_chapter_d_field_y );
+ rtp_midi_field_tree = proto_tree_add_subtree( tree, tvb, offset, f9length, ett_rtp_midi_sj_chapter_d_field_y, NULL, RTP_MIDI_TREE_NAME_SJ_CHAPTER_D_FIELD_Y );
proto_tree_add_item( rtp_midi_field_tree, hf_rtp_midi_sj_chapter_d_sysreal_sflag, tvb, offset, 1, ENC_BIG_ENDIAN );
proto_tree_add_item( rtp_midi_field_tree, hf_rtp_midi_sj_chapter_d_sysreal_cflag, tvb, offset, 1, ENC_BIG_ENDIAN );
@@ -6537,7 +5565,6 @@ decode_sj_chapter_d_f9( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
proto_tree_add_item( rtp_midi_field_tree, hf_rtp_midi_sj_chapter_d_sysreal_length, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
- consumed++;
f9length--;
if ( f9flags & RTP_MIDI_SJ_CHAPTER_D_SYSREAL_FLAG_C ) {
@@ -6545,7 +5572,6 @@ decode_sj_chapter_d_f9( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
proto_tree_add_item( rtp_midi_field_tree, hf_rtp_midi_sj_chapter_d_sysreal_count, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
- consumed++;
f9length--;
}
@@ -6553,7 +5579,7 @@ decode_sj_chapter_d_f9( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
proto_tree_add_item( rtp_midi_field_tree, hf_rtp_midi_sj_chapter_d_sysreal_legal, tvb, offset, f9length, ENC_NA );
offset += f9length;
- f9length -= f9length;
+ f9length = 0;
}
/* if we still have data, the length-field was incorrect we dump the data here and abort! */
@@ -6561,11 +5587,11 @@ decode_sj_chapter_d_f9( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
if ( f9length > 0 ) {
proto_tree_add_item( rtp_midi_field_tree, hf_rtp_midi_sj_chapter_d_sysreal_data, tvb, offset, f9length, ENC_NA );
- consumed += f9length;
+ offset += f9length;
/* must be a protocol error - since we have a length, we can recover...*/
}
- return consumed;
+ return offset-start_offset;
}
@@ -6575,9 +5601,8 @@ decode_sj_chapter_d_f9( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
static int
decode_sj_chapter_d_fd( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned int offset ) {
- proto_item *ti;
proto_tree *rtp_midi_field_tree;
- int consumed = 0;
+ unsigned int start_offset = offset;
guint8 fdflags;
guint8 fdlength;
@@ -6586,8 +5611,7 @@ decode_sj_chapter_d_fd( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
fdlength = fdflags & RTP_MIDI_SJ_CHAPTER_D_SYSREAL_MASK_LENGTH;
/* now we can display our tree, as we now have the full length */
- ti = proto_tree_add_text( tree, tvb, offset, fdlength, RTP_MIDI_TREE_NAME_SJ_CHAPTER_D_FIELD_Z );
- rtp_midi_field_tree = proto_item_add_subtree( ti, ett_rtp_midi_sj_chapter_d_field_z );
+ rtp_midi_field_tree = proto_tree_add_subtree( tree, tvb, offset, fdlength, ett_rtp_midi_sj_chapter_d_field_z, NULL, RTP_MIDI_TREE_NAME_SJ_CHAPTER_D_FIELD_Z );
proto_tree_add_item( rtp_midi_field_tree, hf_rtp_midi_sj_chapter_d_sysreal_sflag, tvb, offset, 1, ENC_BIG_ENDIAN );
proto_tree_add_item( rtp_midi_field_tree, hf_rtp_midi_sj_chapter_d_sysreal_cflag, tvb, offset, 1, ENC_BIG_ENDIAN );
@@ -6595,7 +5619,6 @@ decode_sj_chapter_d_fd( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
proto_tree_add_item( rtp_midi_field_tree, hf_rtp_midi_sj_chapter_d_sysreal_length, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
- consumed++;
fdlength--;
if ( fdflags & RTP_MIDI_SJ_CHAPTER_D_SYSREAL_FLAG_C ) {
@@ -6603,7 +5626,6 @@ decode_sj_chapter_d_fd( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
proto_tree_add_item( rtp_midi_field_tree, hf_rtp_midi_sj_chapter_d_sysreal_count, tvb, offset, 1, ENC_BIG_ENDIAN );
offset++;
- consumed++;
fdlength--;
}
@@ -6611,7 +5633,7 @@ decode_sj_chapter_d_fd( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
proto_tree_add_item( rtp_midi_field_tree, hf_rtp_midi_sj_chapter_d_sysreal_legal, tvb, offset, fdlength, ENC_NA );
offset += fdlength;
- fdlength -= fdlength;
+ fdlength = 0;
}
/* if we still have data, the length-field was incorrect we dump the data here and abort! */
@@ -6620,11 +5642,11 @@ decode_sj_chapter_d_fd( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
proto_tree_add_item( rtp_midi_field_tree, hf_rtp_midi_sj_chapter_d_sysreal_data, tvb, offset, fdlength, ENC_NA );
- consumed += fdlength;
+ offset += fdlength;
/* must be a protocol error - since we have a length, we can recover...*/
}
- return consumed;
+ return offset-start_offset;
}
@@ -6634,74 +5656,74 @@ decode_sj_chapter_d_fd( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
*/
static int
decode_sj_chapter_d( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned int offset ) {
- proto_item *ti;
proto_item *tix;
proto_tree *rtp_midi_sj_chapter_tree;
- proto_tree *rtp_midi_field_tree;
guint8 header;
- int consumed = 0;
+ unsigned int start_offset = offset;
int ext_consumed;
+ static const int * chapter_d_flags[] = {
+ &hf_rtp_midi_sj_chapter_d_sflag,
+ &hf_rtp_midi_sj_chapter_d_bflag,
+ &hf_rtp_midi_sj_chapter_d_gflag,
+ &hf_rtp_midi_sj_chapter_d_hflag,
+ &hf_rtp_midi_sj_chapter_d_jflag,
+ &hf_rtp_midi_sj_chapter_d_kflag,
+ &hf_rtp_midi_sj_chapter_d_yflag,
+ &hf_rtp_midi_sj_chapter_d_zflag,
+ NULL
+ };
+
/* first we need to get the flags of this chapter */
header = tvb_get_guint8( tvb, offset );
/*
- * we don't know the complete length yet - we now that we have at least the header -> 1.
+ * we don't know the complete length yet - we know that we have at least the header -> 1.
* At the end we set the real length...
*/
- tix = proto_tree_add_text( tree, tvb, offset, 1, RTP_MIDI_TREE_NAME_SJ_CHAPTER_D );
+ tix = proto_tree_add_bitmask(tree, tvb, offset, hf_rtp_midi_sj_chapter_d_simple_system_commands, ett_rtp_midi_sj_chapter_d, chapter_d_flags, ENC_NA);
rtp_midi_sj_chapter_tree = proto_item_add_subtree( tix, ett_rtp_midi_sj_chapter_d );
- proto_tree_add_item( rtp_midi_sj_chapter_tree, hf_rtp_midi_sj_chapter_d_sflag, tvb, offset, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( rtp_midi_sj_chapter_tree, hf_rtp_midi_sj_chapter_d_bflag, tvb, offset, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( rtp_midi_sj_chapter_tree, hf_rtp_midi_sj_chapter_d_gflag, tvb, offset, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( rtp_midi_sj_chapter_tree, hf_rtp_midi_sj_chapter_d_hflag, tvb, offset, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( rtp_midi_sj_chapter_tree, hf_rtp_midi_sj_chapter_d_jflag, tvb, offset, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( rtp_midi_sj_chapter_tree, hf_rtp_midi_sj_chapter_d_kflag, tvb, offset, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( rtp_midi_sj_chapter_tree, hf_rtp_midi_sj_chapter_d_yflag, tvb, offset, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( rtp_midi_sj_chapter_tree, hf_rtp_midi_sj_chapter_d_zflag, tvb, offset, 1, ENC_BIG_ENDIAN );
-
/* done with header */
- consumed++;
offset++;
/* do we have Reset field? */
if ( header & RTP_MIDI_SJ_CHAPTER_D_FLAG_B ) {
- ti = proto_tree_add_text( rtp_midi_sj_chapter_tree, tvb, offset, 1, RTP_MIDI_TREE_NAME_SJ_CHAPTER_D_FIELD_B );
- rtp_midi_field_tree = proto_item_add_subtree( ti, ett_rtp_midi_sj_chapter_d_field_b );
-
- proto_tree_add_item( rtp_midi_field_tree, hf_rtp_midi_sj_chapter_d_reset_sflag, tvb, offset, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( rtp_midi_field_tree, hf_rtp_midi_sj_chapter_d_reset_count, tvb, offset, 1, ENC_BIG_ENDIAN );
+ static const int * reset_flags[] = {
+ &hf_rtp_midi_sj_chapter_d_reset_sflag,
+ &hf_rtp_midi_sj_chapter_d_reset_count,
+ NULL
+ };
+ proto_tree_add_bitmask(rtp_midi_sj_chapter_tree, tvb, offset, hf_rtp_midi_sj_chapter_d_reset, ett_rtp_midi_sj_chapter_d_field_b, reset_flags, ENC_NA);
offset++;
- consumed++;
}
/* do we have Tune request field? */
if ( header & RTP_MIDI_SJ_CHAPTER_D_FLAG_G ) {
- ti = proto_tree_add_text( rtp_midi_sj_chapter_tree, tvb, offset, 1, RTP_MIDI_TREE_NAME_SJ_CHAPTER_D_FIELD_G );
- rtp_midi_field_tree = proto_item_add_subtree( ti, ett_rtp_midi_sj_chapter_d_field_g );
-
- proto_tree_add_item( rtp_midi_field_tree, hf_rtp_midi_sj_chapter_d_tune_sflag, tvb, offset, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( rtp_midi_field_tree, hf_rtp_midi_sj_chapter_d_tune_count, tvb, offset, 1, ENC_BIG_ENDIAN );
+ static const int * tune_flags[] = {
+ &hf_rtp_midi_sj_chapter_d_tune_sflag,
+ &hf_rtp_midi_sj_chapter_d_tune_count,
+ NULL
+ };
+ proto_tree_add_bitmask(rtp_midi_sj_chapter_tree, tvb, offset, hf_rtp_midi_sj_chapter_d_tune, ett_rtp_midi_sj_chapter_d_field_g, tune_flags, ENC_BIG_ENDIAN);
offset++;
- consumed++;
}
/* do we have Song select field? */
if ( header & RTP_MIDI_SJ_CHAPTER_D_FLAG_H ) {
- ti = proto_tree_add_text( rtp_midi_sj_chapter_tree, tvb, offset, 1, RTP_MIDI_TREE_NAME_SJ_CHAPTER_D_FIELD_H );
- rtp_midi_field_tree = proto_item_add_subtree( ti, ett_rtp_midi_sj_chapter_d_field_h );
-
- proto_tree_add_item( rtp_midi_field_tree, hf_rtp_midi_sj_chapter_d_song_sel_sflag, tvb, offset, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( rtp_midi_field_tree, hf_rtp_midi_sj_chapter_d_song_sel_value, tvb, offset, 1, ENC_BIG_ENDIAN );
+ static const int * song_flags[] = {
+ &hf_rtp_midi_sj_chapter_d_song_sel_sflag,
+ &hf_rtp_midi_sj_chapter_d_song_sel_value,
+ NULL
+ };
+ proto_tree_add_bitmask(rtp_midi_sj_chapter_tree, tvb, offset, hf_rtp_midi_sj_chapter_d_song_sel, ett_rtp_midi_sj_chapter_d_field_h, song_flags, ENC_BIG_ENDIAN);
offset++;
- consumed++;
}
/* do we have 0xF4 field? */
@@ -6710,7 +5732,6 @@ decode_sj_chapter_d( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, un
if ( ext_consumed < 0 ) {
return ext_consumed;
}
- consumed += ext_consumed;
offset += ext_consumed;
}
@@ -6720,7 +5741,6 @@ decode_sj_chapter_d( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, un
if ( ext_consumed < 0 ) {
return ext_consumed;
}
- consumed += ext_consumed;
offset += ext_consumed;
}
@@ -6730,7 +5750,6 @@ decode_sj_chapter_d( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, un
if ( ext_consumed < 0 ) {
return ext_consumed;
}
- consumed += ext_consumed;
offset += ext_consumed;
}
@@ -6740,13 +5759,13 @@ decode_sj_chapter_d( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, un
if ( ext_consumed < 0 ) {
return ext_consumed;
}
- consumed += ext_consumed;
+ offset += ext_consumed;
}
/* now we know the complete length and set it. */
- proto_item_set_len( tix, consumed );
- return consumed;
+ proto_item_set_len( tix, offset-start_offset );
+ return offset-start_offset;
}
/*
@@ -6754,10 +5773,9 @@ decode_sj_chapter_d( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, un
*/
static int
decode_sj_chapter_q( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned int offset ) {
- proto_item *ti;
proto_tree *rtp_midi_sj_chapter_tree;
guint8 header;
- int consumed = 0;
+ unsigned int start_offset = offset;
int len = 1;
/* first we need to get the flags of this chapter */
@@ -6771,8 +5789,7 @@ decode_sj_chapter_q( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, un
}
/* now we have the length... */
- ti = proto_tree_add_text( tree, tvb, offset, len, RTP_MIDI_TREE_NAME_SJ_CHAPTER_Q );
- rtp_midi_sj_chapter_tree = proto_item_add_subtree( ti, ett_rtp_midi_sj_chapter_q );
+ rtp_midi_sj_chapter_tree = proto_tree_add_subtree( tree, tvb, offset, len, ett_rtp_midi_sj_chapter_q, NULL, RTP_MIDI_TREE_NAME_SJ_CHAPTER_Q );
proto_tree_add_item( rtp_midi_sj_chapter_tree, hf_rtp_midi_sj_chapter_q_sflag, tvb, offset, 1, ENC_BIG_ENDIAN );
proto_tree_add_item( rtp_midi_sj_chapter_tree, hf_rtp_midi_sj_chapter_q_nflag, tvb, offset, 1, ENC_BIG_ENDIAN );
@@ -6784,13 +5801,11 @@ decode_sj_chapter_q( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, un
proto_tree_add_item( rtp_midi_sj_chapter_tree, hf_rtp_midi_sj_chapter_q_clock, tvb, offset, 3, ENC_BIG_ENDIAN );
- consumed += 3;
offset += 3;
} else {
proto_tree_add_item( rtp_midi_sj_chapter_tree, hf_rtp_midi_sj_chapter_q_top, tvb, offset, 1, ENC_BIG_ENDIAN );
- consumed++;
offset++;
}
@@ -6798,10 +5813,10 @@ decode_sj_chapter_q( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, un
proto_tree_add_item( rtp_midi_sj_chapter_tree, hf_rtp_midi_sj_chapter_q_timetools, tvb, offset, 3, ENC_BIG_ENDIAN );
- consumed += 3;
+ offset += 3;
}
- return consumed;
+ return offset-start_offset;
}
/*
@@ -6809,11 +5824,9 @@ decode_sj_chapter_q( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, un
*/
static int
decode_sj_chapter_f( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned int offset ) {
- proto_item *ti;
proto_tree *rtp_midi_sj_chapter_tree;
- proto_tree *rtp_midi_sj_field_tree;
guint8 header;
- int consumed = 0;
+ unsigned int start_offset = offset;
int len = 1;
/* first we need to get the flags of this chapter */
@@ -6827,8 +5840,7 @@ decode_sj_chapter_f( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, un
}
/* now we have the length... */
- ti = proto_tree_add_text( tree, tvb, offset, len, RTP_MIDI_TREE_NAME_SJ_CHAPTER_F );
- rtp_midi_sj_chapter_tree = proto_item_add_subtree( ti, ett_rtp_midi_sj_chapter_f );
+ rtp_midi_sj_chapter_tree = proto_tree_add_subtree( tree, tvb, offset, len, ett_rtp_midi_sj_chapter_f, NULL, RTP_MIDI_TREE_NAME_SJ_CHAPTER_F );
proto_tree_add_item( rtp_midi_sj_chapter_tree, hf_rtp_midi_sj_chapter_f_sflag, tvb, offset, 1, ENC_BIG_ENDIAN );
proto_tree_add_item( rtp_midi_sj_chapter_tree, hf_rtp_midi_sj_chapter_f_cflag, tvb, offset, 1, ENC_BIG_ENDIAN );
@@ -6837,53 +5849,57 @@ decode_sj_chapter_f( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, un
proto_tree_add_item( rtp_midi_sj_chapter_tree, hf_rtp_midi_sj_chapter_f_dflag, tvb, offset, 1, ENC_BIG_ENDIAN );
proto_tree_add_item( rtp_midi_sj_chapter_tree, hf_rtp_midi_sj_chapter_f_point, tvb, offset, 1, ENC_BIG_ENDIAN );
- consumed++;
offset++;
if ( header & RTP_MIDI_SJ_CHAPTER_F_FLAG_C ) {
- ti = proto_tree_add_text( rtp_midi_sj_chapter_tree, tvb, offset, 4, RTP_MIDI_TREE_NAME_SJ_CHAPTER_F_COMPLETE );
- rtp_midi_sj_field_tree = proto_item_add_subtree( ti, ett_rtp_midi_sj_chapter_f_complete );
-
if ( header & RTP_MIDI_SJ_CHAPTER_F_FLAG_Q ) {
- proto_tree_add_item( rtp_midi_sj_field_tree, hf_rtp_midi_sj_chapter_f_mt0, tvb, offset, 4, ENC_BIG_ENDIAN );
- proto_tree_add_item( rtp_midi_sj_field_tree, hf_rtp_midi_sj_chapter_f_mt1, tvb, offset, 4, ENC_BIG_ENDIAN );
- proto_tree_add_item( rtp_midi_sj_field_tree, hf_rtp_midi_sj_chapter_f_mt2, tvb, offset, 4, ENC_BIG_ENDIAN );
- proto_tree_add_item( rtp_midi_sj_field_tree, hf_rtp_midi_sj_chapter_f_mt3, tvb, offset, 4, ENC_BIG_ENDIAN );
- proto_tree_add_item( rtp_midi_sj_field_tree, hf_rtp_midi_sj_chapter_f_mt4, tvb, offset, 4, ENC_BIG_ENDIAN );
- proto_tree_add_item( rtp_midi_sj_field_tree, hf_rtp_midi_sj_chapter_f_mt5, tvb, offset, 4, ENC_BIG_ENDIAN );
- proto_tree_add_item( rtp_midi_sj_field_tree, hf_rtp_midi_sj_chapter_f_mt6, tvb, offset, 4, ENC_BIG_ENDIAN );
- proto_tree_add_item( rtp_midi_sj_field_tree, hf_rtp_midi_sj_chapter_f_mt7, tvb, offset, 4, ENC_BIG_ENDIAN );
-
+ static const int * fq_flags[] = {
+ &hf_rtp_midi_sj_chapter_f_mt0,
+ &hf_rtp_midi_sj_chapter_f_mt1,
+ &hf_rtp_midi_sj_chapter_f_mt2,
+ &hf_rtp_midi_sj_chapter_f_mt3,
+ &hf_rtp_midi_sj_chapter_f_mt4,
+ &hf_rtp_midi_sj_chapter_f_mt5,
+ &hf_rtp_midi_sj_chapter_f_mt6,
+ &hf_rtp_midi_sj_chapter_f_mt7,
+ NULL
+ };
+
+ proto_tree_add_bitmask(rtp_midi_sj_chapter_tree, tvb, offset, hf_rtp_midi_sj_chapter_f_complete, ett_rtp_midi_sj_chapter_f_complete, fq_flags, ENC_BIG_ENDIAN);
} else {
- proto_tree_add_item( rtp_midi_sj_field_tree, hf_rtp_midi_sj_chapter_f_hr, tvb, offset, 4, ENC_BIG_ENDIAN );
- proto_tree_add_item( rtp_midi_sj_field_tree, hf_rtp_midi_sj_chapter_f_mn, tvb, offset, 4, ENC_BIG_ENDIAN );
- proto_tree_add_item( rtp_midi_sj_field_tree, hf_rtp_midi_sj_chapter_f_sc, tvb, offset, 4, ENC_BIG_ENDIAN );
- proto_tree_add_item( rtp_midi_sj_field_tree, hf_rtp_midi_sj_chapter_f_fr, tvb, offset, 4, ENC_BIG_ENDIAN );
+ static const int * f_flags[] = {
+ &hf_rtp_midi_sj_chapter_f_hr,
+ &hf_rtp_midi_sj_chapter_f_mn,
+ &hf_rtp_midi_sj_chapter_f_sc,
+ &hf_rtp_midi_sj_chapter_f_fr,
+ NULL
+ };
+
+ proto_tree_add_bitmask(rtp_midi_sj_chapter_tree, tvb, offset, hf_rtp_midi_sj_chapter_f_complete, ett_rtp_midi_sj_chapter_f_complete, f_flags, ENC_BIG_ENDIAN);
}
- consumed += 4;
offset += 4;
}
if ( header & RTP_MIDI_SJ_CHAPTER_F_FLAG_P ) {
+ static const int * fp_flags[] = {
+ &hf_rtp_midi_sj_chapter_f_mt0,
+ &hf_rtp_midi_sj_chapter_f_mt1,
+ &hf_rtp_midi_sj_chapter_f_mt2,
+ &hf_rtp_midi_sj_chapter_f_mt3,
+ &hf_rtp_midi_sj_chapter_f_mt4,
+ &hf_rtp_midi_sj_chapter_f_mt5,
+ &hf_rtp_midi_sj_chapter_f_mt6,
+ &hf_rtp_midi_sj_chapter_f_mt7,
+ NULL
+ };
- ti = proto_tree_add_text( rtp_midi_sj_chapter_tree, tvb, offset, 4, RTP_MIDI_TREE_NAME_SJ_CHAPTER_F_PARTIAL );
- rtp_midi_sj_field_tree = proto_item_add_subtree( ti, ett_rtp_midi_sj_chapter_f_partial );
-
- proto_tree_add_item( rtp_midi_sj_field_tree, hf_rtp_midi_sj_chapter_f_mt0, tvb, offset, 4, ENC_BIG_ENDIAN );
- proto_tree_add_item( rtp_midi_sj_field_tree, hf_rtp_midi_sj_chapter_f_mt1, tvb, offset, 4, ENC_BIG_ENDIAN );
- proto_tree_add_item( rtp_midi_sj_field_tree, hf_rtp_midi_sj_chapter_f_mt2, tvb, offset, 4, ENC_BIG_ENDIAN );
- proto_tree_add_item( rtp_midi_sj_field_tree, hf_rtp_midi_sj_chapter_f_mt3, tvb, offset, 4, ENC_BIG_ENDIAN );
- proto_tree_add_item( rtp_midi_sj_field_tree, hf_rtp_midi_sj_chapter_f_mt4, tvb, offset, 4, ENC_BIG_ENDIAN );
- proto_tree_add_item( rtp_midi_sj_field_tree, hf_rtp_midi_sj_chapter_f_mt5, tvb, offset, 4, ENC_BIG_ENDIAN );
- proto_tree_add_item( rtp_midi_sj_field_tree, hf_rtp_midi_sj_chapter_f_mt6, tvb, offset, 4, ENC_BIG_ENDIAN );
- proto_tree_add_item( rtp_midi_sj_field_tree, hf_rtp_midi_sj_chapter_f_mt7, tvb, offset, 4, ENC_BIG_ENDIAN );
-
- consumed += 4;
+ proto_tree_add_bitmask(rtp_midi_sj_chapter_tree, tvb, offset, hf_rtp_midi_sj_chapter_f_partial, ett_rtp_midi_sj_chapter_f_partial, fp_flags, ENC_BIG_ENDIAN);
+ offset += 4;
}
- return consumed;
+ return offset-start_offset;
}
/*
@@ -6891,7 +5907,6 @@ decode_sj_chapter_f( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, un
*/
static int
decode_sj_chapter_x( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned int offset, unsigned int max_length ) {
- proto_item *ti;
proto_tree *rtp_midi_sj_chapter_tree;
proto_tree *rtp_midi_sj_data_tree;
guint8 header;
@@ -6903,8 +5918,7 @@ decode_sj_chapter_x( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, un
/* first we need to get the flags of this chapter */
header = tvb_get_guint8( tvb, offset );
- ti = proto_tree_add_text( tree, tvb, offset, max_length, RTP_MIDI_TREE_NAME_SJ_CHAPTER_X );
- rtp_midi_sj_chapter_tree = proto_item_add_subtree( ti, ett_rtp_midi_sj_chapter_x );
+ rtp_midi_sj_chapter_tree = proto_tree_add_subtree( tree, tvb, offset, max_length, ett_rtp_midi_sj_chapter_x, NULL, RTP_MIDI_TREE_NAME_SJ_CHAPTER_X );
proto_tree_add_item( rtp_midi_sj_chapter_tree, hf_rtp_midi_sj_chapter_x_sflag, tvb, offset, 1, ENC_BIG_ENDIAN );
proto_tree_add_item( rtp_midi_sj_chapter_tree, hf_rtp_midi_sj_chapter_x_tflag, tvb, offset, 1, ENC_BIG_ENDIAN );
@@ -6976,8 +5990,8 @@ decode_sj_chapter_x( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, un
/* XXX: 'cmdlen' in the following is always 0 (since initialized to 0 above) ??? */
if ( header & RTP_MIDI_SJ_CHAPTER_X_FLAG_D ) {
- ti = proto_tree_add_text( rtp_midi_sj_chapter_tree, tvb, offset, max_length - consumed, RTP_MIDI_TREE_NAME_SJ_CHAPTER_X_DATA );
- rtp_midi_sj_data_tree = proto_item_add_subtree( ti, ett_rtp_midi_sj_chapter_x_data );
+ rtp_midi_sj_data_tree = proto_tree_add_subtree( rtp_midi_sj_chapter_tree, tvb, offset, max_length - consumed,
+ ett_rtp_midi_sj_chapter_x_data, NULL, RTP_MIDI_TREE_NAME_SJ_CHAPTER_X_DATA );
while ( consumed < max_length ) {
octet = tvb_get_guint8( tvb, offset + cmdlen );
if ( octet & 0x80 ) {
@@ -6997,13 +6011,8 @@ decode_sj_chapter_x( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, un
/* this should not ever enter - we still have data, but flag d was apparently not set... */
if ( consumed < max_length ) {
- ti = proto_tree_add_text( rtp_midi_sj_chapter_tree, tvb, offset, max_length - consumed, RTP_MIDI_TREE_NAME_SJ_CHAPTER_X_INVALID_DATA );
- rtp_midi_sj_data_tree = proto_item_add_subtree( ti, ett_rtp_midi_sj_chapter_x_data );
-
- proto_tree_add_item( rtp_midi_sj_data_tree, hf_rtp_midi_sj_chapter_x_invalid_data, tvb, offset, max_length - consumed, ENC_NA );
-
+ proto_tree_add_item( rtp_midi_sj_chapter_tree, hf_rtp_midi_sj_chapter_x_invalid_data, tvb, offset, max_length - consumed, ENC_NA );
consumed = max_length;
-
}
return consumed;
@@ -7016,10 +6025,9 @@ decode_sj_chapter_x( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, un
*/
static int
decode_system_journal( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned int offset ) {
- proto_item *ti;
proto_tree *rtp_midi_sysjournal_tree;
proto_tree *rtp_midi_sj_chapters_tree;
- int consumed = 0;
+ unsigned int start_offset = offset;
int ext_consumed = 0;
guint16 sysjourlen;
guint16 systemflags;
@@ -7027,8 +6035,7 @@ decode_system_journal( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
systemflags = tvb_get_ntohs( tvb, offset );
sysjourlen = systemflags & RTP_MIDI_SJ_MASK_LENGTH;
- ti = proto_tree_add_text( tree, tvb, offset, sysjourlen, RTP_MIDI_TREE_NAME_SYSTEM_JOURNAL );
- rtp_midi_sysjournal_tree = proto_item_add_subtree( ti, ett_rtp_midi_systemjournal );
+ rtp_midi_sysjournal_tree = proto_tree_add_subtree( tree, tvb, offset, sysjourlen, ett_rtp_midi_systemjournal, NULL, RTP_MIDI_TREE_NAME_SYSTEM_JOURNAL );
proto_tree_add_item( rtp_midi_sysjournal_tree, hf_rtp_midi_sysjour_toc_s, tvb, offset, 2, ENC_BIG_ENDIAN );
proto_tree_add_item( rtp_midi_sysjournal_tree, hf_rtp_midi_sysjour_toc_d, tvb, offset, 2, ENC_BIG_ENDIAN );
@@ -7039,71 +6046,54 @@ decode_system_journal( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
proto_tree_add_item( rtp_midi_sysjournal_tree, hf_rtp_midi_sysjour_len, tvb, offset, 2, ENC_BIG_ENDIAN );
offset += 2;
- consumed += 2;
- ti = proto_tree_add_text( rtp_midi_sysjournal_tree, tvb, offset, sysjourlen - 2, RTP_MIDI_TREE_NAME_SYSTEM_CHAPTERS );
- rtp_midi_sj_chapters_tree = proto_item_add_subtree( ti, ett_rtp_midi_systemchapters );
+ rtp_midi_sj_chapters_tree = proto_tree_add_subtree( rtp_midi_sysjournal_tree, tvb, offset, sysjourlen - 2,
+ ett_rtp_midi_systemchapters, NULL, RTP_MIDI_TREE_NAME_SYSTEM_CHAPTERS );
/* Do we have a simple system commands chapter? */
if ( systemflags & RTP_MIDI_SJ_FLAG_D ) {
- ext_consumed = decode_sj_chapter_d( tvb, pinfo, rtp_midi_sj_chapters_tree, offset );
- if ( ext_consumed < 0 ) {
- return ext_consumed;
- }
- consumed += ext_consumed;
- offset += ext_consumed;
+ offset += decode_sj_chapter_d( tvb, pinfo, rtp_midi_sj_chapters_tree, offset );
}
/* Do we have a active sensing chapter? */
if ( systemflags & RTP_MIDI_SJ_FLAG_V ) {
- proto_tree *rtp_midi_sj_chapter_tree;
-
- ti = proto_tree_add_text( rtp_midi_sj_chapters_tree, tvb, offset, 1, RTP_MIDI_TREE_NAME_SJ_CHAPTER_V );
- rtp_midi_sj_chapter_tree = proto_item_add_subtree( ti, ett_rtp_midi_sj_chapter_v );
+ static const int * v_flags[] = {
+ &hf_rtp_midi_sj_chapter_v_sflag,
+ &hf_rtp_midi_sj_chapter_v_count,
+ NULL
+ };
- proto_tree_add_item( rtp_midi_sj_chapter_tree, hf_rtp_midi_sj_chapter_v_sflag, tvb, offset, 1, ENC_BIG_ENDIAN );
- proto_tree_add_item( rtp_midi_sj_chapter_tree, hf_rtp_midi_sj_chapter_v_count, tvb, offset, 1, ENC_BIG_ENDIAN );
+ proto_tree_add_bitmask(rtp_midi_sj_chapters_tree, tvb, offset, hf_rtp_midi_sj_chapter_v, ett_rtp_midi_sj_chapter_v, v_flags, ENC_BIG_ENDIAN);
offset++;
- consumed++;
}
/* Do we have a sequencer state commands chapter? */
if ( systemflags & RTP_MIDI_SJ_FLAG_Q ) {
- ext_consumed = decode_sj_chapter_q( tvb, pinfo, rtp_midi_sj_chapters_tree, offset );
- if ( ext_consumed < 0 ) {
- return ext_consumed;
- }
- consumed += ext_consumed;
- offset += ext_consumed;
+ offset += decode_sj_chapter_q( tvb, pinfo, rtp_midi_sj_chapters_tree, offset );
}
/* Do we have a MTC chapter? */
if ( systemflags & RTP_MIDI_SJ_FLAG_F ) {
- ext_consumed = decode_sj_chapter_f( tvb, pinfo, rtp_midi_sj_chapters_tree, offset );
- if ( ext_consumed < 0 ) {
- return ext_consumed;
- }
- consumed += ext_consumed;
- offset += ext_consumed;
+ offset += decode_sj_chapter_f( tvb, pinfo, rtp_midi_sj_chapters_tree, offset );
}
/* Do we have a Sysex chapter? */
if ( systemflags & RTP_MIDI_SJ_FLAG_X ) {
- ext_consumed = decode_sj_chapter_x( tvb, pinfo, rtp_midi_sj_chapters_tree, offset, sysjourlen - consumed );
+ ext_consumed = decode_sj_chapter_x( tvb, pinfo, rtp_midi_sj_chapters_tree, offset, sysjourlen - (offset-start_offset) );
if ( ext_consumed < 0 ) {
return ext_consumed;
}
- consumed += ext_consumed;
+ offset += ext_consumed;
}
/* Make sanity check for consumed data vs. stated length of system journal */
- if ( consumed != sysjourlen ) {
+ if ( offset-start_offset != sysjourlen ) {
return -1;
}
- return consumed;
+ return offset-start_offset;
}
@@ -7161,9 +6151,7 @@ dissect_rtp_midi( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree )
/* see if we have small or large len-field */
if (flags & RTP_MIDI_CS_FLAG_B) {
- guint8 octet;
- octet = tvb_get_guint8( tvb, offset+1 );
- cmd_len = ( cmd_len << 8 ) | octet;
+ cmd_len = tvb_get_ntohs( tvb, offset) & RTP_MIDI_CS_MASK_LONGLEN;
proto_tree_add_item( rtp_midi_tree, hf_rtp_midi_longlen, tvb, offset, 2, ENC_BIG_ENDIAN );
offset += 2;
} else {
@@ -7173,11 +6161,9 @@ dissect_rtp_midi( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree )
/* if we have a command-section -> dissect it */
if ( cmd_len ) {
- proto_item *command_item;
proto_tree *rtp_midi_commands_tree;
- command_item = proto_tree_add_text( rtp_midi_tree, tvb, offset, cmd_len, RTP_MIDI_TREE_NAME_COMMAND );
- rtp_midi_commands_tree = proto_item_add_subtree( command_item, ett_rtp_midi_commands );
+ rtp_midi_commands_tree = proto_tree_add_subtree( rtp_midi_tree, tvb, offset, cmd_len, ett_rtp_midi_commands, NULL, RTP_MIDI_TREE_NAME_COMMAND );
/* No commands decoded yet */
cmd_count = 0;
@@ -7224,14 +6210,12 @@ dissect_rtp_midi( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree )
/* if we have a journal-section -> dissect it */
if ( flags & RTP_MIDI_CS_FLAG_J ) {
- proto_item *journal_item;
proto_tree *rtp_midi_journal_tree;
- journal_item = proto_tree_add_text( rtp_midi_tree, tvb, offset, -1, RTP_MIDI_TREE_NAME_JOURNAL );
- rtp_midi_journal_tree = proto_item_add_subtree( journal_item, ett_rtp_midi_journal );
+ rtp_midi_journal_tree = proto_tree_add_subtree( rtp_midi_tree, tvb, offset, -1, ett_rtp_midi_journal, NULL, RTP_MIDI_TREE_NAME_JOURNAL );
/* lets get the main flags from the recovery journal header */
- flags = tvb_get_guint8( tvb, offset );
+ flags = tvb_get_guint8( tvb, offset );
proto_tree_add_item( rtp_midi_journal_tree, hf_rtp_midi_sflag, tvb, offset, 1, ENC_BIG_ENDIAN );
proto_tree_add_item( rtp_midi_journal_tree, hf_rtp_midi_yflag, tvb, offset, 1, ENC_BIG_ENDIAN );
@@ -7266,8 +6250,7 @@ dissect_rtp_midi( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree )
/* do we have channel journal(s)? */
if ( flags & RTP_MIDI_JS_FLAG_A ) {
proto_tree *rtp_midi_chanjournals_tree;
- ti = proto_tree_add_text( rtp_midi_journal_tree, tvb, offset, -1, RTP_MIDI_TREE_NAME_CHANNEL_JOURNAL );
- rtp_midi_chanjournals_tree = proto_item_add_subtree( ti, ett_rtp_midi_channeljournals );
+ rtp_midi_chanjournals_tree = proto_tree_add_subtree( rtp_midi_journal_tree, tvb, offset, -1, ett_rtp_midi_channeljournals, NULL, RTP_MIDI_TREE_NAME_CHANNEL_JOURNAL );
/* iterate through all the channels specified in header */
for ( i = 0; i <= totchan; i++ ) {
@@ -8327,6 +7310,19 @@ proto_register_rtp_midi( void )
},
{
+ &hf_rtp_midi_cj_chapter_m_log_msb_entry,
+ {
+ "Entry MSB",
+ "rtpmidi.cj_chapter_m_log_msb_entry",
+ FT_UINT8,
+ BASE_HEX,
+ NULL,
+ 0x0,
+ NULL, HFILL
+ }
+ },
+
+ {
&hf_rtp_midi_cj_chapter_m_log_msb_x,
{
"Chapter M Log MSB X-Flag",
@@ -8353,6 +7349,19 @@ proto_register_rtp_midi( void )
},
{
+ &hf_rtp_midi_cj_chapter_m_log_lsb_entry,
+ {
+ "Entry LSB",
+ "rtpmidi.cj_chapter_m_log_lsb_entry",
+ FT_UINT8,
+ BASE_HEX,
+ NULL,
+ 0x0,
+ NULL, HFILL
+ }
+ },
+
+ {
&hf_rtp_midi_cj_chapter_m_log_lsb_x,
{
"Chapter M Log LSB X-Flag",
@@ -8418,6 +7427,19 @@ proto_register_rtp_midi( void )
},
{
+ &hf_rtp_midi_cj_chapter_m_log_a_button_full,
+ {
+ "A-Button",
+ "rtpmidi.cj_chapter_m_log_a_button_full",
+ FT_UINT16,
+ BASE_HEX,
+ NULL,
+ 0x0,
+ NULL, HFILL
+ }
+ },
+
+ {
&hf_rtp_midi_cj_chapter_m_log_c_button_g,
{
"Chapter M Log C-Button G-Flag",
@@ -8457,6 +7479,19 @@ proto_register_rtp_midi( void )
},
{
+ &hf_rtp_midi_cj_chapter_m_log_c_button_full,
+ {
+ "C-Button",
+ "rtpmidi.cj_chapter_m_log_c_button_full",
+ FT_UINT16,
+ BASE_HEX,
+ NULL,
+ 0x0,
+ NULL, HFILL
+ }
+ },
+
+ {
&hf_rtp_midi_cj_chapter_m_log_count_x,
{
"Chapter M Log Count X-Flag",
@@ -8483,6 +7518,19 @@ proto_register_rtp_midi( void )
},
{
+ &hf_rtp_midi_cj_chapter_m_log_count_full,
+ {
+ "Count",
+ "rtpmidi.cj_chapter_m_log_count_full",
+ FT_UINT8,
+ BASE_HEX,
+ NULL,
+ 0x0,
+ NULL, HFILL
+ }
+ },
+
+ {
&hf_rtp_midi_cj_chapter_w_sflag,
{
"Chapter W S-Flag",
@@ -8743,6 +7791,19 @@ proto_register_rtp_midi( void )
},
{
+ &hf_rtp_midi_cj_chapter_t_channel_aftertouch,
+ {
+ "Channel Aftertouch",
+ "rtpmidi.cj_chapter_t_channel_aftertouch",
+ FT_UINT8,
+ BASE_HEX,
+ NULL,
+ 0x0,
+ NULL, HFILL
+ }
+ },
+
+ {
&hf_rtp_midi_cj_chapter_t_sflag,
{
"Chapter T S-Flag",
@@ -8847,6 +7908,19 @@ proto_register_rtp_midi( void )
},
{
+ &hf_rtp_midi_sj_chapter_v,
+ {
+ "Active Sensing",
+ "rtpmidi.sj_chapter_v",
+ FT_UINT8,
+ BASE_HEX,
+ NULL,
+ 0x0,
+ NULL, HFILL
+ }
+ },
+
+ {
&hf_rtp_midi_sj_chapter_v_sflag,
{
"Chapter V S-Flag",
@@ -8873,6 +7947,19 @@ proto_register_rtp_midi( void )
},
{
+ &hf_rtp_midi_sj_chapter_d_simple_system_commands,
+ {
+ "Simple System Commands",
+ "rtpmidi.sj_chapter_d_simple_system_commands",
+ FT_UINT8,
+ BASE_HEX,
+ NULL,
+ 0x0,
+ NULL, HFILL
+ }
+ },
+
+ {
&hf_rtp_midi_sj_chapter_d_sflag,
{
"Chapter D S-Flag",
@@ -8977,6 +8064,19 @@ proto_register_rtp_midi( void )
},
{
+ &hf_rtp_midi_sj_chapter_d_reset,
+ {
+ "Reset Field",
+ "rtpmidi.cj_chapter_d_reset",
+ FT_UINT8,
+ BASE_HEX,
+ NULL,
+ 0x0,
+ NULL, HFILL
+ }
+ },
+
+ {
&hf_rtp_midi_sj_chapter_d_reset_sflag,
{
"Chapter D Reset S-Flag",
@@ -9003,6 +8103,19 @@ proto_register_rtp_midi( void )
},
{
+ &hf_rtp_midi_sj_chapter_d_tune,
+ {
+ "Tune Request Field",
+ "rtpmidi.cj_chapter_d_tune",
+ FT_UINT8,
+ BASE_HEX,
+ NULL,
+ 0x0,
+ NULL, HFILL
+ }
+ },
+
+ {
&hf_rtp_midi_sj_chapter_d_tune_sflag,
{
"Chapter D Tune Request S-Flag",
@@ -9029,6 +8142,19 @@ proto_register_rtp_midi( void )
},
{
+ &hf_rtp_midi_sj_chapter_d_song_sel,
+ {
+ "Song Select Field",
+ "rtpmidi.cj_chapter_d_song_sel",
+ FT_UINT8,
+ BASE_HEX,
+ NULL,
+ 0x0,
+ NULL, HFILL
+ }
+ },
+
+ {
&hf_rtp_midi_sj_chapter_d_song_sel_sflag,
{
"Chapter D Song Select S-Flag",
@@ -9434,6 +8560,30 @@ proto_register_rtp_midi( void )
}
},
{
+ &hf_rtp_midi_sj_chapter_f_complete,
+ {
+ "Complete field",
+ "rtpmidi.sj_chapter_f_complete",
+ FT_UINT32,
+ BASE_HEX,
+ NULL,
+ 0x0,
+ NULL, HFILL
+ }
+ },
+ {
+ &hf_rtp_midi_sj_chapter_f_partial,
+ {
+ "Partial field",
+ "rtpmidi.sj_chapter_f_partial",
+ FT_UINT32,
+ BASE_HEX,
+ NULL,
+ 0x0,
+ NULL, HFILL
+ }
+ },
+ {
&hf_rtp_midi_sj_chapter_f_mt0,
{
"Chapter F MTC MT0",