diff options
author | Michael Mann <mmann78@netscape.net> | 2016-10-22 14:25:35 -0400 |
---|---|---|
committer | Roland Knall <rknall@gmail.com> | 2016-10-24 18:27:18 +0000 |
commit | b5587379b7e31c8e418f51a7db9d836b33a7efe1 (patch) | |
tree | 336e4480beafe7bfc15786cf6174fc92f2ac1aaa /epan/dissectors/packet-amqp.c | |
parent | e3ecb9310c9973f85f7d0bd06ef8cf7dc7ecf3c2 (diff) |
Overhaul AMQP dissector
1. Remove AMQP_INCREMENT macro. Bounds checking mostly handled already
by proto_tree_add_xxx and tvb_get_xxx. Needed to add a few more
tvb_reported_length_remaining() calls for completeness.
2. Fill in some of the gaps of unaccounted for bytes. Still have way
too many instances where bytes aren't claimed by a field.
3. Some small reordering of functions allowed for massive removal of
formal declarations.
4. Add amqp_0_10_get_32bit_size_new to add a field, check for size and
add expert info if size > 0xFFFF
5. Remove "hf_" from list type items as they are not real hf_ fields
and could cause confusion. Also made items static.
6. Convert some FT_STRING and FT_BYTES fields to FT_UINT_STRING and
FT_UINT_BYTES. Helps account for some "missing" bytes.
Change-Id: I7ed269221d294ce89feacc0642b2070681288172
Reviewed-on: https://code.wireshark.org/review/18423
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Roland Knall <rknall@gmail.com>
Diffstat (limited to 'epan/dissectors/packet-amqp.c')
-rw-r--r-- | epan/dissectors/packet-amqp.c | 4711 |
1 files changed, 2039 insertions, 2672 deletions
diff --git a/epan/dissectors/packet-amqp.c b/epan/dissectors/packet-amqp.c index b6ae647e5e..2d1adc7ffd 100644 --- a/epan/dissectors/packet-amqp.c +++ b/epan/dissectors/packet-amqp.c @@ -45,6 +45,7 @@ #include <epan/prefs.h> #include <epan/to_str.h> #include <epan/proto_data.h> +#include <wsutil/str_util.h> #include "packet-tcp.h" #include "packet-ssl.h" @@ -56,16 +57,6 @@ void proto_reg_handoff_amqp(void); #define AMQP_PORT 5672 static guint amqps_port = 5671; /* AMQP over TLS/SSL */ -/* Generic defines */ - -#define AMQP_INCREMENT(offset, addend, bound) {\ - THROW_ON( \ - (((unsigned)(offset) + (unsigned)(addend)) < (unsigned)(offset)) || \ - (((unsigned)(offset) + (unsigned)(addend)) > (unsigned)(bound )) \ - , ReportedBoundsError); \ - offset += (addend); \ -} - /* * This dissector handles AMQP 0-9, 0-10 and 1.0. The conversation structure * contains the version being run - it's only really reliably detected at @@ -430,559 +421,12 @@ typedef struct _amqp_channel_t { /* Private functions */ -static int -dissect_amqp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data); - -static void -check_amqp_version(tvbuff_t *tvb, amqp_conv *conn); - -static guint -get_amqp_1_0_message_len(packet_info *pinfo, tvbuff_t *tvb, int offset, void* data); - -static guint -dissect_amqp_1_0_list(tvbuff_t *tvb, - packet_info *pinfo, - int offset, - int bound, - proto_item *item, - int hf_amqp_type, - guint32 hf_amqp_subtype_count, - const int **hf_amqp_subtypes, - const char *name); - -static guint -dissect_amqp_1_0_map(tvbuff_t *tvb, - packet_info *pinfo, - int offset, - int bound, - proto_item *item, - int hf_amqp_type, - const char *name); - -static guint -dissect_amqp_1_0_array(tvbuff_t *tvb, - packet_info *pinfo, - int offset, - int bound, - proto_item *item, - int hf_amqp_type, - guint32 hf_amqp_subtype_count, - const int **hf_amqp_subtypes, - const char *name); - -static guint -get_amqp_0_10_message_len(packet_info *pinfo, tvbuff_t *tvb, int offset, void* data); - -static guint -get_amqp_0_9_message_len(packet_info *pinfo, tvbuff_t *tvb, int offset, void* data); - -static void -dissect_amqp_0_9_field_table(tvbuff_t *tvb, packet_info *pinfo, int offset, guint length, proto_item *item); - -static void -dissect_amqp_0_9_field_array(tvbuff_t *tvb, packet_info *pinfo, int offset, guint length, proto_item *item); - static guint dissect_amqp_0_9_field_value(tvbuff_t *tvb, packet_info *pinfo, int offset, guint length, const char *name, proto_tree *field_table_tree); static void -dissect_amqp_0_10_map(tvbuff_t *tvb, - int offset, - int bound, - int length, - proto_item *item); - -static void -dissect_amqp_0_10_xid (tvbuff_t *tvb, - int offset, - guint16 xid_length, - proto_item *ti); - -static void -dissect_amqp_0_10_connection(tvbuff_t *tvb, - packet_info *pinfo, - proto_tree *tree, - int offset, guint16 length); - -static void -dissect_amqp_0_10_session(tvbuff_t *tvb, - packet_info *pinfo, - proto_tree *tree, - int offset, guint16 length); - -static void -dissect_amqp_0_10_execution(tvbuff_t *tvb, - packet_info *pinfo, - proto_tree *tree, - int offset, guint16 length); - -static void -dissect_amqp_0_10_message(tvbuff_t *tvb, - packet_info *pinfo, - proto_tree *tree, - int offset, guint16 length); - -static void -dissect_amqp_0_10_tx(tvbuff_t *tvb, - packet_info *pinfo, - proto_tree *tree, - int offset, guint16 length); - -static void -dissect_amqp_0_10_dtx(tvbuff_t *tvb, - packet_info *pinfo, - proto_tree *tree, - int offset, guint16 length); - -static void -dissect_amqp_0_10_exchange(tvbuff_t *tvb, - packet_info *pinfo, - proto_tree *tree, - int offset, guint16 length); - -static void -dissect_amqp_0_10_queue(tvbuff_t *tvb, - packet_info *pinfo, - proto_tree *tree, - int offset, guint16 length); - -static void -dissect_amqp_0_10_file(tvbuff_t *tvb, - packet_info *pinfo, - proto_tree *tree, - int offset, guint16 length); - -static void -dissect_amqp_0_10_stream(tvbuff_t *tvb, - packet_info *pinfo, - proto_tree *tree, - int offset, guint16 length); - -static void -dissect_amqp_0_10_struct32(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, - int offset, guint32 struct_length); - -static guint32 -dissect_amqp_1_0_AMQP_frame(tvbuff_t *tvb, - guint offset, - guint16 bound, - proto_item *amqp_tree, - packet_info *pinfo, - const gchar **method_name); - -static guint32 -dissect_amqp_1_0_SASL_frame(tvbuff_t *tvb, - guint offset, - guint16 bound, - proto_item *amqp_tree, - packet_info *pinfo, - const gchar **method_name); - -static int -dissect_amqp_1_0_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_); - -static int -dissect_amqp_0_10_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_); - -static int -dissect_amqp_0_9_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_); - -static int -dissect_amqp_0_9_method_connection_start(tvbuff_t *tvb, packet_info *pinfo, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_connection_start_ok(tvbuff_t *tvb, packet_info *pinfo, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_connection_secure(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_connection_secure_ok(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_connection_tune(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_connection_tune_ok(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_connection_open(tvbuff_t *tvb, packet_info *pinfo, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_connection_open_ok(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_connection_redirect(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_connection_close(tvbuff_t *tvb, packet_info *pinfo, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_connection_close_ok(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_connection_blocked(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_connection_unblocked(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_channel_open(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_channel_open_ok(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_channel_flow(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_channel_flow_ok(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_channel_close(guint16 channel_num, tvbuff_t *tvb, - packet_info *pinfo, int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_channel_close_ok(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_channel_resume(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_channel_ping(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_channel_pong(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_channel_ok(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_access_request(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_access_request_ok(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_exchange_declare(tvbuff_t *tvb, packet_info *pinfo, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_exchange_declare_ok(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_exchange_bind(tvbuff_t *tvb, packet_info *pinfo, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_exchange_bind_ok(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_exchange_delete(tvbuff_t *tvb, packet_info *pinfo, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_exchange_delete_ok(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_queue_declare(tvbuff_t *tvb, packet_info *pinfo, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_queue_declare_ok(tvbuff_t *tvb, packet_info *pinfo, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_queue_bind(tvbuff_t *tvb, packet_info *pinfo, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_queue_bind_ok(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_queue_unbind(tvbuff_t *tvb, packet_info *pinfo, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_queue_unbind_ok(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_queue_purge(tvbuff_t *tvb, packet_info *pinfo, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_queue_purge_ok(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_queue_delete(tvbuff_t *tvb, packet_info *pinfo, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_queue_delete_ok(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_basic_qos(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_basic_qos_ok(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_basic_consume(tvbuff_t *tvb, packet_info *pinfo, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_basic_consume_ok(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_basic_cancel(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_basic_cancel_ok(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_basic_publish(guint16 channel_num, - tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_basic_return(tvbuff_t *tvb, packet_info *pinfo, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_basic_deliver(guint16 channel_num, - tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_basic_get(tvbuff_t *tvb, packet_info *pinfo, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_basic_get_ok(guint16 channel_num, - tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_basic_get_empty(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_basic_ack(guint16 channel_num, - tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_basic_reject(guint16 channel_num, - tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_basic_recover_async(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_basic_recover(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_basic_recover_ok(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_basic_nack(guint16 channel_num, - tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_file_qos(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_file_qos_ok(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_file_consume(tvbuff_t *tvb, packet_info *pinfo, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_file_consume_ok(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_file_cancel(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_file_cancel_ok(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_file_open(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_file_open_ok(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_file_stage(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_file_publish(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_file_return(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_file_deliver(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_file_ack(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_file_reject(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_stream_qos(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_stream_qos_ok(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_stream_consume(tvbuff_t *tvb, packet_info *pinfo, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_stream_consume_ok(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_stream_cancel(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_stream_cancel_ok(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_stream_publish(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_stream_return(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_stream_deliver(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_tx_select(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_tx_select_ok(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_tx_commit(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_tx_commit_ok(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_tx_rollback(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_tx_rollback_ok(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_dtx_select(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_dtx_select_ok(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_dtx_start(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_dtx_start_ok(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_tunnel_request(tvbuff_t *tvb, packet_info *pinfo, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_confirm_select(tvbuff_t *tvb, - int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_method_confirm_select_ok(guint16 channel_num, - tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *args_tree); - -static int -dissect_amqp_0_9_content_header_basic(tvbuff_t *tvb, packet_info *pinfo, - int offset, proto_tree *prop_tree); - -static int -dissect_amqp_0_9_content_header_file(tvbuff_t *tvb, packet_info *pinfo, - int offset, proto_tree *prop_tree); - -static int -dissect_amqp_0_9_content_header_stream(tvbuff_t *tvb, packet_info *pinfo, - int offset, proto_tree *prop_tree); - -static int -dissect_amqp_0_9_content_header_tunnel(tvbuff_t *tvb, packet_info *pifo, - int offset, proto_tree *prop_tree); +dissect_amqp_0_10_struct32(tvbuff_t *tvb, packet_info *pinfo, proto_item *ti); static amqp_channel_t* get_conversation_channel(conversation_t *conv, guint16 channel_num); @@ -1013,7 +457,6 @@ generate_ack_reference(tvbuff_t *tvb, packet_info *pinfo, proto_tree *prop_tree) typedef int (*type_formatter)(tvbuff_t *tvb, guint offset, /* In tvb where data starts */ - guint bound, /* Last byte in tvb */ guint length, /* Length of data, if known */ const char **value); /* Receive formatted val */ struct amqp_typeinfo { @@ -1028,7 +471,6 @@ struct amqp_typeinfo { typedef int (*type_dissector)(tvbuff_t *tvb, packet_info *pinfo, guint offset, /* In tvb where data starts */ - guint bound, /* Last byte in tvb */ guint length, /* Length of data, if known */ proto_item *item, int hf_amqp_type); @@ -1071,7 +513,6 @@ get_amqp_1_0_value_formatter(tvbuff_t *tvb, packet_info *pinfo, guint8 code, int offset, - int bound, int hf_amqp_type, const char *name, guint32 hf_amqp_subtype_count, @@ -1082,7 +523,6 @@ get_amqp_1_0_value_formatter(tvbuff_t *tvb, static guint get_amqp_1_0_type_formatter(tvbuff_t *tvb, int offset, - int bound, int *hf_amqp_type, const char **name, guint32 *hf_amqp_subtype_count, @@ -1093,7 +533,6 @@ static void get_amqp_1_0_type_value_formatter(tvbuff_t *tvb, packet_info *pinfo, int offset, - int bound, int hf_amqp_type, const char *name, guint *length_size, @@ -1103,112 +542,98 @@ get_amqp_1_0_type_value_formatter(tvbuff_t *tvb, static int dissect_amqp_1_0_fixed(tvbuff_t *tvb, packet_info *pinfo, - guint offset, guint bound _U_, guint length, + guint offset, guint length, proto_item *item, int hf_amqp_type); static int dissect_amqp_1_0_variable(tvbuff_t *tvb, packet_info *pinfo, - guint offset, guint bound, guint length, + guint offset, guint length, proto_item *item, int hf_amqp_type); static int dissect_amqp_1_0_timestamp(tvbuff_t *tvb, packet_info *pinfo _U_, - guint offset, guint bound _U_, guint length, + guint offset, guint length, proto_item *item, int hf_amqp_type); static int dissect_amqp_1_0_skip(tvbuff_t *tvb _U_, packet_info *pinfo _U_, - guint offset _U_, guint bound _U_, guint length _U_, + guint offset _U_, guint length _U_, proto_item *item _U_, int hf_amqp_type _U_); static int dissect_amqp_1_0_zero(tvbuff_t *tvb _U_, packet_info *pinfo _U_, - guint offset _U_, guint bound _U_, guint length _U_, + guint offset _U_, guint length _U_, proto_item *item _U_, int hf_amqp_type _U_); static int dissect_amqp_1_0_true(tvbuff_t *tvb, packet_info *pinfo, - guint offset, guint bound _U_, guint length _U_, + guint offset, guint length _U_, proto_item *item, int hf_amqp_type); static int dissect_amqp_1_0_false(tvbuff_t *tvb, packet_info *pinfo, - guint offset, guint bound _U_, guint length _U_, + guint offset, guint length _U_, proto_item *item, int hf_amqp_type); static int format_amqp_1_0_null(tvbuff_t *tvb _U_, - guint offset, guint bound _U_, guint length _U_, + guint offset, guint length _U_, const char **value _U_); static int -format_amqp_1_0_boolean_true(tvbuff_t *tvb, - guint offset, guint bound _U_, guint length _U_, +format_amqp_1_0_boolean_true(tvbuff_t *tvb, guint offset, guint length _U_, const char **value); static int -format_amqp_1_0_boolean_false(tvbuff_t *tvb, - guint offset, guint bound _U_, guint length _U_, +format_amqp_1_0_boolean_false(tvbuff_t *tvb, guint offset, guint length _U_, const char **value); static int -format_amqp_1_0_boolean(tvbuff_t *tvb, - guint offset, guint bound _U_, guint length _U_, +format_amqp_1_0_boolean(tvbuff_t *tvb, guint offset, guint length _U_, const char **value); static int -format_amqp_1_0_uint(tvbuff_t *tvb, - guint offset, guint bound _U_, guint length, +format_amqp_1_0_uint(tvbuff_t *tvb, guint offset, guint length, const char **value); static int -format_amqp_1_0_int(tvbuff_t *tvb, - guint offset, guint bound _U_, guint length, +format_amqp_1_0_int(tvbuff_t *tvb, guint offset, guint length, const char **value); static int -format_amqp_1_0_float(tvbuff_t *tvb, - guint offset, guint bound _U_, guint length _U_, +format_amqp_1_0_float(tvbuff_t *tvb, guint offset, guint length _U_, const char **value); static int -format_amqp_1_0_double(tvbuff_t *tvb, - guint offset, guint bound _U_, guint length _U_, +format_amqp_1_0_double(tvbuff_t *tvb, guint offset, guint length _U_, const char **value); static int -format_amqp_1_0_decimal(tvbuff_t *tvb _U_, - guint offset _U_, guint bound _U_, guint length, +format_amqp_1_0_decimal(tvbuff_t *tvb _U_, guint offset _U_, guint length, const char **value); static int -format_amqp_1_0_char(tvbuff_t *tvb, - guint offset, guint bound _U_, guint length _U_, +format_amqp_1_0_char(tvbuff_t *tvb, guint offset, guint length _U_, const char **value); static int -format_amqp_1_0_timestamp(tvbuff_t *tvb, - guint offset, guint bound _U_, guint length _U_, +format_amqp_1_0_timestamp(tvbuff_t *tvb, guint offset, guint length _U_, const char **value); static int -format_amqp_1_0_uuid(tvbuff_t *tvb, - guint offset, guint bound _U_, guint length _U_, +format_amqp_1_0_uuid(tvbuff_t *tvb, guint offset, guint length _U_, const char **value); static int -format_amqp_1_0_bin(tvbuff_t *tvb, - guint offset, guint bound _U_, guint length, +format_amqp_1_0_bin(tvbuff_t *tvb, guint offset, guint length, const char **value); static int -format_amqp_1_0_str(tvbuff_t *tvb, - guint offset, guint bound, guint length, +format_amqp_1_0_str(tvbuff_t *tvb, guint offset, guint length, const char **value); static int -format_amqp_1_0_symbol(tvbuff_t *tvb, - guint offset, guint bound, guint length, +format_amqp_1_0_symbol(tvbuff_t *tvb, guint offset, guint length, const char **value); static gboolean @@ -1219,37 +644,37 @@ get_amqp_0_10_type_formatter(guint8 code, static int format_amqp_0_10_bin(tvbuff_t *tvb, - guint offset, guint bound, guint length, + guint offset, guint length, const char **value); static int format_amqp_0_10_int(tvbuff_t *tvb, - guint offset, guint bound, guint length, + guint offset, guint length, const char **value); static int format_amqp_0_10_uint(tvbuff_t *tvb, - guint offset, guint bound, guint length, + guint offset, guint length, const char **value); static int format_amqp_0_10_char(tvbuff_t *tvb, - guint offset, guint bound, guint length, + guint offset, guint length, const char **value); static int format_amqp_0_10_boolean(tvbuff_t *tvb, - guint offset, guint bound, guint length, + guint offset, guint length, const char **value); static int format_amqp_0_10_vbin(tvbuff_t *tvb, - guint offset, guint bound, guint length, + guint offset, guint length, const char **value); static int format_amqp_0_10_str(tvbuff_t *tvb, - guint offset, guint bound, guint length, + guint offset, guint length, const char **value); static void @@ -1259,7 +684,6 @@ format_amqp_0_10_sequence_set(tvbuff_t *tvb, guint offset, guint length, /* Various handles */ static int proto_amqp = -1; -static const char* element_suffix [] = {"", "s"}; /* to distinguish singular/plural in "list of 1 item" vs. "list of 2 items" */ /* 1.0 handles */ @@ -1437,15 +861,15 @@ static struct amqp_synonym_types_t amqp_synonym_types[] = { * i.e. sasl.init method has 3 arguments in a list (mechanism, init.response, hostname) * so when dissecting sasl.init arguments list, identify the list items with * corresponding hf_* variable */ -const int* hf_amqp_1_0_sasl_mechanisms_items[] = { &hf_amqp_1_0_mechanisms }; -const int* hf_amqp_1_0_sasl_init_items[] = { &hf_amqp_1_0_mechanism, +static const int* amqp_1_0_sasl_mechanisms_items[] = { &hf_amqp_1_0_mechanisms }; +static const int* amqp_1_0_sasl_init_items[] = { &hf_amqp_1_0_mechanism, &hf_amqp_1_0_initResponse, &hf_amqp_1_0_hostname }; -const int* hf_amqp_1_0_sasl_challenge_items[] = { &hf_amqp_1_0_saslChallenge }; -const int* hf_amqp_1_0_sasl_response_items[] = { &hf_amqp_1_0_saslResponse }; -const int* hf_amqp_1_0_sasl_outcome_items[] = { &hf_amqp_1_0_saslCode, +static const int* amqp_1_0_sasl_challenge_items[] = { &hf_amqp_1_0_saslChallenge }; +static const int* amqp_1_0_sasl_response_items[] = { &hf_amqp_1_0_saslResponse }; +static const int* amqp_1_0_sasl_outcome_items[] = { &hf_amqp_1_0_saslCode, &hf_amqp_1_0_saslAdditionalData }; -const int* hf_amqp_1_0_amqp_open_items[] = { &hf_amqp_1_0_containerId, +static const int* amqp_1_0_amqp_open_items[] = { &hf_amqp_1_0_containerId, &hf_amqp_1_0_hostname, &hf_amqp_1_0_maxFrameSize, &hf_amqp_1_0_channelMax, @@ -1455,7 +879,7 @@ const int* hf_amqp_1_0_amqp_open_items[] = { &hf_amqp_1_0_containerId, &hf_amqp_1_0_offeredCapabilities, &hf_amqp_1_0_desiredCapabilities, &hf_amqp_1_0_properties }; -const int* hf_amqp_1_0_amqp_begin_items[] = { &hf_amqp_1_0_remoteChannel, +static const int* amqp_1_0_amqp_begin_items[] = { &hf_amqp_1_0_remoteChannel, &hf_amqp_1_0_nextOutgoingId, &hf_amqp_1_0_incomingWindow, &hf_amqp_1_0_outgoingWindow, @@ -1463,7 +887,7 @@ const int* hf_amqp_1_0_amqp_begin_items[] = { &hf_amqp_1_0_remoteChannel, &hf_amqp_1_0_offeredCapabilities, &hf_amqp_1_0_desiredCapabilities, &hf_amqp_1_0_properties }; -const int* hf_amqp_1_0_amqp_attach_items[] = { &hf_amqp_1_0_name, +static const int* amqp_1_0_amqp_attach_items[] = { &hf_amqp_1_0_name, &hf_amqp_1_0_handle, &hf_amqp_1_0_role, &hf_amqp_1_0_sndSettleMode, @@ -1477,7 +901,7 @@ const int* hf_amqp_1_0_amqp_attach_items[] = { &hf_amqp_1_0_name, &hf_amqp_1_0_offeredCapabilities, &hf_amqp_1_0_desiredCapabilities, &hf_amqp_1_0_properties }; -const int* hf_amqp_1_0_amqp_flow_items[] = { &hf_amqp_1_0_nextIncomingId, +static const int* amqp_1_0_amqp_flow_items[] = { &hf_amqp_1_0_nextIncomingId, &hf_amqp_1_0_incomingWindow, &hf_amqp_1_0_nextOutgoingId, &hf_amqp_1_0_outgoingWindow, @@ -1488,7 +912,7 @@ const int* hf_amqp_1_0_amqp_flow_items[] = { &hf_amqp_1_0_nextIncomingId, &hf_amqp_1_0_drain, &hf_amqp_1_0_echo, &hf_amqp_1_0_properties }; -const int* hf_amqp_1_0_amqp_transfer_items[] = { &hf_amqp_1_0_handle, +static const int* amqp_1_0_amqp_transfer_items[] = { &hf_amqp_1_0_handle, &hf_amqp_1_0_deliveryId, &hf_amqp_1_0_deliveryTag, &hf_amqp_1_0_messageFormat, @@ -1499,32 +923,32 @@ const int* hf_amqp_1_0_amqp_transfer_items[] = { &hf_amqp_1_0_handle, &hf_amqp_1_0_resume, &hf_amqp_1_0_aborted, &hf_amqp_1_0_batchable }; -const int* hf_amqp_1_0_amqp_disposition_items[] = { &hf_amqp_1_0_role, +static const int* amqp_1_0_amqp_disposition_items[] = { &hf_amqp_1_0_role, &hf_amqp_1_0_first, &hf_amqp_1_0_last, &hf_amqp_1_0_settled, &hf_amqp_1_0_state, &hf_amqp_1_0_batchable }; -const int* hf_amqp_1_0_amqp_detach_items[] = { &hf_amqp_1_0_handle, +static const int* amqp_1_0_amqp_detach_items[] = { &hf_amqp_1_0_handle, &hf_amqp_1_0_closed, &hf_amqp_1_0_error }; -const int* hf_amqp_1_0_amqp_end_items[] = { &hf_amqp_1_0_error }; -const int* hf_amqp_1_0_amqp_close_items[] = { &hf_amqp_1_0_error }; -const int* hf_amqp_1_0_error_items[] = { &hf_amqp_1_0_condition, +static const int* amqp_1_0_amqp_end_items[] = { &hf_amqp_1_0_error }; +static const int* amqp_1_0_amqp_close_items[] = { &hf_amqp_1_0_error }; +static const int* amqp_1_0_error_items[] = { &hf_amqp_1_0_condition, &hf_amqp_1_0_description, &hf_amqp_1_0_info }; -const int* hf_amqp_1_0_messageHeader_items[] = { &hf_amqp_1_0_durable, +static const int* amqp_1_0_messageHeader_items[] = { &hf_amqp_1_0_durable, &hf_amqp_1_0_priority, &hf_amqp_1_0_ttl, &hf_amqp_1_0_firstAcquirer, &hf_amqp_1_0_deliveryCount }; -const int* hf_amqp_1_0_received_items[] = { &hf_amqp_1_0_sectionNumber, +static const int* amqp_1_0_received_items[] = { &hf_amqp_1_0_sectionNumber, &hf_amqp_1_0_sectionOffset }; -const int* hf_amqp_1_0_rejected_items[] = { &hf_amqp_1_0_error }; -const int* hf_amqp_1_0_modified_items[] = { &hf_amqp_1_0_deliveryFailed, +static const int* amqp_1_0_rejected_items[] = { &hf_amqp_1_0_error }; +static const int* amqp_1_0_modified_items[] = { &hf_amqp_1_0_deliveryFailed, &hf_amqp_1_0_undeliverableHere, &hf_amqp_1_0_messageAnnotations }; -const int* hf_amqp_1_0_source_items[] = { &hf_amqp_1_0_address, +static const int* amqp_1_0_source_items[] = { &hf_amqp_1_0_address, &hf_amqp_1_0_terminusDurable, &hf_amqp_1_0_expiryPolicy, &hf_amqp_1_0_timeout, @@ -1535,14 +959,14 @@ const int* hf_amqp_1_0_source_items[] = { &hf_amqp_1_0_address, &hf_amqp_1_0_defaultOutcome, &hf_amqp_1_0_outcomes, &hf_amqp_1_0_capabilities }; -const int* hf_amqp_1_0_target_items[] = { &hf_amqp_1_0_address, +static const int* amqp_1_0_target_items[] = { &hf_amqp_1_0_address, &hf_amqp_1_0_terminusDurable, &hf_amqp_1_0_expiryPolicy, &hf_amqp_1_0_timeout, &hf_amqp_1_0_dynamic, &hf_amqp_1_0_dynamicNodeProperties, &hf_amqp_1_0_capabilities }; -const int* hf_amqp_1_0_messageProperties_items[] = { &hf_amqp_1_0_messageId, +static const int* amqp_1_0_messageProperties_items[] = { &hf_amqp_1_0_messageId, &hf_amqp_1_0_userId, &hf_amqp_1_0_to, &hf_amqp_1_0_subject, @@ -1555,12 +979,12 @@ const int* hf_amqp_1_0_messageProperties_items[] = { &hf_amqp_1_0_messageId, &hf_amqp_1_0_groupId, &hf_amqp_1_0_groupSequence, &hf_amqp_1_0_replyToGroupId }; -const int* hf_amqp_1_0_coordinator_items[] = { &hf_amqp_1_0_capabilities }; -const int* hf_amqp_1_0_declare_items[] = { &hf_amqp_1_0_globalId }; -const int* hf_amqp_1_0_discharge_items[] = { &hf_amqp_1_0_txnId, +static const int* amqp_1_0_coordinator_items[] = { &hf_amqp_1_0_capabilities }; +static const int* amqp_1_0_declare_items[] = { &hf_amqp_1_0_globalId }; +static const int* amqp_1_0_discharge_items[] = { &hf_amqp_1_0_txnId, &hf_amqp_1_0_fail }; -const int* hf_amqp_1_0_declared_items[] = { &hf_amqp_1_0_txnId }; -const int* hf_amqp_1_0_transactionalState_items[] = { &hf_amqp_1_0_txnId, +static const int* amqp_1_0_declared_items[] = { &hf_amqp_1_0_txnId }; +static const int* amqp_1_0_transactionalState_items[] = { &hf_amqp_1_0_txnId, &hf_amqp_1_0_outcome }; /* 0-10 handles */ @@ -1584,7 +1008,14 @@ static int hf_amqp_0_10_stream_method = -1; static int hf_amqp_0_10_argument_packing_flags = -1; static int hf_amqp_0_10_session_header = -1; static int hf_amqp_0_10_session_header_sync = -1; -static int hf_amqp_0_10_undissected_struct32 = -1; +static int hf_amqp_0_10_struct32_size = -1; +static int hf_amqp_0_10_struct32 = -1; +static int hf_amqp_0_10_struct32_padding = -1; +static int hf_amqp_0_10_struct32_class = -1; +static int hf_amqp_0_10_struct32_struct = -1; +static int hf_amqp_0_10_array_type = -1; +static int hf_amqp_0_10_array_element_count = -1; +static int hf_amqp_0_10_array_string = -1; static int hf_amqp_0_10_message_body = -1; static int hf_amqp_0_10_dtx_xid = -1; static int hf_amqp_0_10_dtx_xid_format = -1; @@ -1645,6 +1076,7 @@ static int hf_amqp_0_10_struct_stream_properties_headers = -1; static int hf_amqp_0_10_struct_stream_properties_priority = -1; static int hf_amqp_0_10_struct_stream_properties_timestamp = -1; static int hf_amqp_0_10_method_session_attach_name = -1; +static int hf_amqp_0_10_method_session_attach_name_size = -1; static int hf_amqp_0_10_method_session_attach_force = -1; static int hf_amqp_0_10_method_session_detached_code = -1; static int hf_amqp_0_10_method_session_timeout = -1; @@ -1753,6 +1185,7 @@ static int hf_amqp_0_10_method_stream_deliver_delivery_tag = -1; static int hf_amqp_0_10_method_stream_deliver_exchange = -1; static int hf_amqp_0_10_method_stream_deliver_queue = -1; static int hf_amqp_channel = -1; +static int hf_amqp_reserved = -1; static int hf_amqp_0_9_type = -1; static int hf_amqp_0_9_length = -1; static int hf_amqp_0_9_method_class_id = -1; @@ -2031,6 +1464,7 @@ static int hf_amqp_header_tunnel_proxy_name = -1; static int hf_amqp_header_tunnel_data_name = -1; static int hf_amqp_header_tunnel_durable = -1; static int hf_amqp_header_tunnel_broadcast = -1; +static int hf_amqp_0_10_dtx_xa_status = -1; static int hf_amqp_payload = -1; static int hf_amqp_init_protocol = -1; static int hf_amqp_init_id = -1; @@ -2041,6 +1475,22 @@ static int hf_amqp_init_version_minor = -1; static int hf_amqp_init_version_revision = -1; static int hf_amqp_message_in = -1; static int hf_amqp_ack_in = -1; +static int hf_amqp_method_connection_start_server_properties_size = -1; +static int hf_amqp_0_10_method_connection_start_mechanisms_size = -1; +static int hf_amqp_0_10_method_connection_start_locales_size = -1; +static int hf_amqp_method_connection_start_ok_client_properties_size = -1; +static int hf_amqp_0_10_method_connection_open_capabilities_size = -1; +static int hf_amqp_0_10_method_connection_open_ok_known_hosts_size = -1; +static int hf_amqp_0_10_method_connection_redirect_known_hosts_size = -1; +static int hf_amqp_0_10_method_execution_error_info_size = -1; +static int hf_amqp_0_10_method_exchange_declare_arguments_size = -1; +static int hf_amqp_0_10_method_queue_declare_arguments_size = -1; +static int hf_amqp_0_10_method_file_consume_arguments_size = -1; +static int hf_amqp_0_10_method_stream_consume_arguments_size = -1; +static int hf_amqp_0_10_struct_message_properties_application_headers_size = -1; +static int hf_amqp_0_10_struct_file_properties_headers_size = -1; +static int hf_amqp_0_10_struct_stream_properties_headers_size = -1; +static int hf_amqp_0_10_struct_dtx_recover_result_size = -1; static gint ett_amqp = -1; static gint ett_header = -1; @@ -2050,6 +1500,7 @@ static gint ett_field_table = -1; static gint ett_amqp_init = -1; static gint ett_amqp_0_10_map = -1; static gint ett_amqp_0_10_array = -1; +static gint ett_amqp_0_10_struct = -1; static gint ett_amqp_1_0_list = -1; static gint ett_amqp_1_0_array = -1; static gint ett_amqp_1_0_map = -1; @@ -2062,7 +1513,7 @@ static expert_field ei_amqp_unknown_stream_method = EI_INIT; static expert_field ei_amqp_unknown_basic_method = EI_INIT; static expert_field ei_amqp_unknown_frame_type = EI_INIT; static expert_field ei_amqp_field_short = EI_INIT; -/* static expert_field ei_amqp_bad_length = EI_INIT; */ +static expert_field ei_amqp_bad_length = EI_INIT; static expert_field ei_amqp_unknown_command_class = EI_INIT; static expert_field ei_amqp_unknown_tunnel_method = EI_INIT; static expert_field ei_amqp_unknown_confirm_method = EI_INIT; @@ -2081,7 +1532,10 @@ static expert_field ei_amqp_unknown_sasl_command = EI_INIT; static expert_field ei_amqp_unknown_amqp_command = EI_INIT; static expert_field ei_amqp_unknown_amqp_type = EI_INIT; static expert_field ei_amqp_invalid_number_of_params = EI_INIT; +static expert_field ei_amqp_size_exceeds_65K = EI_INIT; static expert_field ei_amqp_amqp_1_0_frame_length_exceeds_65K = EI_INIT; +static expert_field ei_amqp_array_type_unknown = EI_INIT; + /* Various enumerations */ static const value_string amqp_1_0_SASL_code_value [] = { @@ -2434,6 +1888,22 @@ static const value_string amqp_0_10_stream_return_codes [] = { {0, NULL} }; +static const value_string amqp_0_10_struct32_vals[] = { + { ((AMQP_0_10_CLASS_MESSAGE << 8) | (AMQP_0_10_STRUCT_MESSAGE_DELIVERY_PROPERTIES)), "message.delivery-properties" }, + { ((AMQP_0_10_CLASS_MESSAGE << 8) | (AMQP_0_10_STRUCT_MESSAGE_FRAGMENT_PROPERTIES)), "message.fragment-properties" }, + { ((AMQP_0_10_CLASS_MESSAGE << 8) | (AMQP_0_10_STRUCT_MESSAGE_MESSAGE_PROPERTIES)), "message.message-properties" }, + { ((AMQP_0_10_CLASS_MESSAGE << 8) | (AMQP_0_10_STRUCT_MESSAGE_ACQUIRED)), "message.acquired" }, + { ((AMQP_0_10_CLASS_MESSAGE << 8) | (AMQP_0_10_STRUCT_MESSAGE_RESUME_RESULT)), "message.resume-result" }, + { ((AMQP_0_10_CLASS_DTX << 8) | (AMQP_0_10_STRUCT_DTX_XA_RESULT)), "dtx.xa-status" }, + { ((AMQP_0_10_CLASS_DTX << 8) | (AMQP_0_10_STRUCT_DTX_RECOVER_RESULT)), "dtx.recover-result" }, + { ((AMQP_0_10_CLASS_EXCHANGE << 8) | (AMQP_0_10_STRUCT_EXCHANGE_QUERY_RESULT)), "exchange.exchange-query-result" }, + { ((AMQP_0_10_CLASS_EXCHANGE << 8) | (AMQP_0_10_STRUCT_EXCHANGE_BOUND_RESULT)), "exchange.exchange-bound-result" }, + { ((AMQP_0_10_CLASS_QUEUE << 8) | (AMQP_0_10_STRUCT_QUEUE_QUERY_RESULT)), "queue.queue-query-result" }, + { ((AMQP_0_10_CLASS_FILE << 8) | (AMQP_0_10_STRUCT_FILE_PROPERTIES)), "file.file-properties" }, + { ((AMQP_0_10_CLASS_STREAM << 8) | (AMQP_0_10_STRUCT_STREAM_PROPERTIES)), "stream.stream-properties" }, + { 0, NULL } +}; + static const value_string amqp_0_9_frame_types [] = { {AMQP_0_9_FRAME_TYPE_METHOD, "Method"}, {AMQP_0_9_FRAME_TYPE_CONTENT_HEADER, "Content header"}, @@ -2603,6 +2073,12 @@ static const value_string amqp_method_tunnel_methods [] = { {0, NULL} }; +static const value_string amqp_0_10_array_type_vals [] = { + {AMQP_0_10_TYPE_STR16, "str16"}, + {AMQP_0_10_TYPE_STRUCT32, "struct32"}, + {0, NULL} +}; + static const value_string amqp_method_confirm_methods [] = { {10, "Select"}, {11, "Select-Ok"}, @@ -2670,84 +2146,35 @@ static struct amqp1_typeinfo amqp_1_0_fixed_types[] = { /* see explanation at declaration of amqp_defined_types_t */ static struct amqp_defined_types_t amqp_1_0_defined_types[] = { - {AMQP_1_0_AMQP_TYPE_ERROR, &hf_amqp_1_0_error, 3, hf_amqp_1_0_error_items }, - {AMQP_1_0_AMQP_TYPE_HEADER, &hf_amqp_1_0_messageHeader, 5, hf_amqp_1_0_messageHeader_items }, + {AMQP_1_0_AMQP_TYPE_ERROR, &hf_amqp_1_0_error, 3, amqp_1_0_error_items }, + {AMQP_1_0_AMQP_TYPE_HEADER, &hf_amqp_1_0_messageHeader, 5, amqp_1_0_messageHeader_items }, {AMQP_1_0_AMQP_TYPE_DELIVERY_ANNOTATIONS, &hf_amqp_1_0_deliveryAnnotations, 0, NULL }, {AMQP_1_0_AMQP_TYPE_MESSAGE_ANNOTATIONS, &hf_amqp_1_0_messageAnnotations, 0, NULL }, - {AMQP_1_0_AMQP_TYPE_PROPERTIES, &hf_amqp_1_0_messageProperties, 13, hf_amqp_1_0_messageProperties_items }, + {AMQP_1_0_AMQP_TYPE_PROPERTIES, &hf_amqp_1_0_messageProperties, 13, amqp_1_0_messageProperties_items }, {AMQP_1_0_AMQP_TYPE_APPLICATION_PROPERTIES, &hf_amqp_1_0_applicationProperties, 0, NULL }, {AMQP_1_0_AMQP_TYPE_DATA, &hf_amqp_1_0_data, 0, NULL }, {AMQP_1_0_AMQP_TYPE_AMQP_SEQUENCE, &hf_amqp_1_0_amqp_sequence, 0, NULL }, {AMQP_1_0_AMQP_TYPE_AMQP_VALUE, &hf_amqp_1_0_amqp_value, 0, NULL }, {AMQP_1_0_AMQP_TYPE_FOOTER, &hf_amqp_1_0_footer, 0, NULL }, - {AMQP_1_0_AMQP_TYPE_RECEIVED, &hf_amqp_1_0_received, 2, hf_amqp_1_0_received_items }, + {AMQP_1_0_AMQP_TYPE_RECEIVED, &hf_amqp_1_0_received, 2, amqp_1_0_received_items }, {AMQP_1_0_AMQP_TYPE_ACCEPTED, &hf_amqp_1_0_accepted, 0, NULL }, - {AMQP_1_0_AMQP_TYPE_REJECTED, &hf_amqp_1_0_rejected, 1, hf_amqp_1_0_rejected_items }, + {AMQP_1_0_AMQP_TYPE_REJECTED, &hf_amqp_1_0_rejected, 1, amqp_1_0_rejected_items }, {AMQP_1_0_AMQP_TYPE_RELEASED, &hf_amqp_1_0_released, 0, NULL }, - {AMQP_1_0_AMQP_TYPE_MODIFIED, &hf_amqp_1_0_modified, 3, hf_amqp_1_0_modified_items }, - {AMQP_1_0_AMQP_TYPE_SOURCE, &hf_amqp_1_0_source, 11, hf_amqp_1_0_source_items }, - {AMQP_1_0_AMQP_TYPE_TARGET, &hf_amqp_1_0_target, 7, hf_amqp_1_0_target_items }, + {AMQP_1_0_AMQP_TYPE_MODIFIED, &hf_amqp_1_0_modified, 3, amqp_1_0_modified_items }, + {AMQP_1_0_AMQP_TYPE_SOURCE, &hf_amqp_1_0_source, 11, amqp_1_0_source_items }, + {AMQP_1_0_AMQP_TYPE_TARGET, &hf_amqp_1_0_target, 7, amqp_1_0_target_items }, {AMQP_1_0_AMQP_TYPE_DELETE_ON_CLOSE, &hf_amqp_1_0_deleteOnClose, 0, NULL }, {AMQP_1_0_AMQP_TYPE_DELETE_ON_NO_LINKS, &hf_amqp_1_0_deleteOnNoLinks, 0, NULL }, {AMQP_1_0_AMQP_TYPE_DELETE_ON_NO_MESSAGE, &hf_amqp_1_0_deleteOnNoMessages, 0, NULL }, {AMQP_1_0_AMQP_TYPE_DELETE_ON_NO_LINKS_OR_MESSAGE, &hf_amqp_1_0_deleteOnNoLinksOrMessages, 0, NULL }, - {AMQP_1_0_AMQP_TYPE_COORDINATOR, &hf_amqp_1_0_coordinator, 1, hf_amqp_1_0_coordinator_items }, - {AMQP_1_0_AMQP_TYPE_DECLARE, &hf_amqp_1_0_declare, 1, hf_amqp_1_0_declare_items }, - {AMQP_1_0_AMQP_TYPE_DISCHARGE, &hf_amqp_1_0_discharge, 2, hf_amqp_1_0_discharge_items }, - {AMQP_1_0_AMQP_TYPE_DECLARED, &hf_amqp_1_0_declared, 1, hf_amqp_1_0_declared_items }, - {AMQP_1_0_AMQP_TYPE_TRANSACTIONAL_STATE, &hf_amqp_1_0_transactionalState, 2, hf_amqp_1_0_transactionalState_items }, + {AMQP_1_0_AMQP_TYPE_COORDINATOR, &hf_amqp_1_0_coordinator, 1, amqp_1_0_coordinator_items }, + {AMQP_1_0_AMQP_TYPE_DECLARE, &hf_amqp_1_0_declare, 1, amqp_1_0_declare_items }, + {AMQP_1_0_AMQP_TYPE_DISCHARGE, &hf_amqp_1_0_discharge, 2, amqp_1_0_discharge_items }, + {AMQP_1_0_AMQP_TYPE_DECLARED, &hf_amqp_1_0_declared, 1, amqp_1_0_declared_items }, + {AMQP_1_0_AMQP_TYPE_TRANSACTIONAL_STATE, &hf_amqp_1_0_transactionalState, 2, amqp_1_0_transactionalState_items }, { 0, NULL, 0, NULL } }; -/* Main dissection routine */ - -static int -dissect_amqp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data) -{ - conversation_t *conv; - amqp_conv *conn; - - col_set_str(pinfo->cinfo, COL_PROTOCOL, "AMQP"); - col_clear(pinfo->cinfo, COL_INFO); - - /* We need at least 8 bytes to check the protocol and get the frame size */ - if (tvb_reported_length (tvb) < 8) { - /* But at this moment we don't know how much we will need */ - pinfo->desegment_len = DESEGMENT_ONE_MORE_SEGMENT; - return -1; /* need more data */ - } - - /* Find (or build) conversation to remember the protocol version */ - conv = find_or_create_conversation(pinfo); - conn = (amqp_conv *)conversation_get_proto_data(conv, proto_amqp); - if (conn == NULL) { - conn = wmem_new0(wmem_file_scope(), amqp_conv); - conn->channels = wmem_map_new(wmem_file_scope(), g_direct_hash, g_direct_equal); - conversation_add_proto_data(conv, proto_amqp, conn); - } - check_amqp_version(tvb, conn); - switch(conn->version) { - case AMQP_V0_9: - tcp_dissect_pdus(tvb, pinfo, tree, TRUE, 7, get_amqp_0_9_message_len, - dissect_amqp_0_9_frame, data); - break; - case AMQP_V0_10: - tcp_dissect_pdus(tvb, pinfo, tree, TRUE, 8, get_amqp_0_10_message_len, - dissect_amqp_0_10_frame, data); - break; - case AMQP_V1_0: - tcp_dissect_pdus(tvb, pinfo, tree, TRUE, 8, get_amqp_1_0_message_len, - dissect_amqp_1_0_frame, data); - break; - default: - col_append_str(pinfo->cinfo, COL_INFO, "AMQP (unknown version)"); - col_set_fence(pinfo->cinfo, COL_INFO); - break; - } - - return tvb_captured_length(tvb); -} - static void check_amqp_version(tvbuff_t *tvb, amqp_conv *conn) { @@ -2803,6 +2230,7 @@ check_amqp_version(tvbuff_t *tvb, amqp_conv *conn) return; } + static guint get_amqp_1_0_message_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset, void *data _U_) @@ -2847,6 +2275,7 @@ get_amqp_0_9_message_len(packet_info *pinfo _U_, tvbuff_t *tvb, return length + 8; } + /* Dissection routine for AMQP 0-9 field tables */ static void @@ -3165,14 +2594,25 @@ amqp_0_10_get_32bit_size(tvbuff_t *tvb, int offset) { return AMQP_0_10_SIZE_MAX(size); } +static guint +amqp_0_10_get_32bit_size_new(proto_tree* tree, packet_info* pinfo, tvbuff_t *tvb, int hf, int offset) { + guint size; + proto_item* ti; + + ti = proto_tree_add_item_ret_uint(tree, hf, tvb, offset, 4, ENC_BIG_ENDIAN, &size); + if (size > 0xFFFF) + { + expert_add_info(pinfo, ti, &ei_amqp_size_exceeds_65K); + size = 0xFFFF; + } + + return size; +} + /* Dissection routine for AMQP 0-10 maps */ static void -dissect_amqp_0_10_map(tvbuff_t *tvb, - int offset, /* Start of map in tvb */ - int bound, /* How far into tvb we can go */ - int length, /* Length of map */ - proto_item *item) +dissect_amqp_0_10_map(tvbuff_t *tvb, proto_item *item) { proto_item *map_tree; guint namelen, size; @@ -3180,28 +2620,25 @@ dissect_amqp_0_10_map(tvbuff_t *tvb, const char *name; const char *amqp_typename; const char *value; - guint32 field_count; + guint32 i, field_count; + int offset = 0; type_formatter formatter; map_tree = proto_item_add_subtree(item, ett_amqp_0_10_map); field_count = tvb_get_ntohl(tvb, offset); - AMQP_INCREMENT(offset, 4, bound); - length -= 4; + offset += 4; proto_item_append_text(item, " (%d entries)", field_count); - while ((field_count > 0) && (length > 0)) { + for (i = 0; ((i < field_count) && (tvb_reported_length_remaining(tvb, offset) > 0)); i++) { guint field_length = 0; guint field_start = offset; namelen = tvb_get_guint8(tvb, offset); - AMQP_INCREMENT(offset, 1, bound); - length -= 1; + offset += 1; name = (char*) tvb_get_string_enc(wmem_packet_scope(), tvb, offset, namelen, ENC_UTF_8|ENC_NA); - AMQP_INCREMENT(offset, namelen, bound); - length -= namelen; + offset += namelen; type = tvb_get_guint8(tvb, offset); - AMQP_INCREMENT(offset, 1, bound); - length -= 1; + offset += 1; if (get_amqp_0_10_type_formatter(type, &amqp_typename, &formatter, &size)) { - field_length = formatter(tvb, offset, bound, size, &value); /* includes var 'length' field if var field */ + field_length = formatter(tvb, offset, size, &value); /* includes var 'length' field if var field */ field_length = AMQP_0_10_SIZE_MAX(field_length); proto_tree_add_none_format(map_tree, hf_amqp_field, @@ -3210,8 +2647,7 @@ dissect_amqp_0_10_map(tvbuff_t *tvb, 1 + namelen + 1 + field_length, "%s (%s): %s", name, amqp_typename, value); - AMQP_INCREMENT(offset, field_length, bound); - length -= field_length; + offset += field_length; } else { /* type not found in table: Do special processing */ guint size_field_len = 0; @@ -3275,147 +2711,108 @@ dissect_amqp_0_10_map(tvbuff_t *tvb, } /* default */ } /* switch (type) */ - AMQP_INCREMENT(offset, (size_field_len + field_length), bound); - length -= (size_field_len + field_length); + offset += (size_field_len + field_length); } - - field_count -= 1; } } /* Dissection routine for AMQP 0-10 maps */ - static void dissect_amqp_0_10_array(tvbuff_t *tvb, packet_info *pinfo, int offset, /* Start of array in tvb */ - int bound, /* How far into tvb we can go */ - int length, /* Length of array */ proto_item *item) { - proto_item *array_tree; - proto_item *sub; - guint8 type; + proto_item *array_item, *type_item, *struct_item; + proto_tree *array_tree; guint16 len16; - const char *amqp_typename; - const char *value; - int element_start; - int externally_formatted; - guint32 element_count; + guint32 type, i, element_count; guint32 struct_length; + tvbuff_t *next_tvb; - array_tree = 0; - type = tvb_get_guint8(tvb, offset); - AMQP_INCREMENT(offset, 1, bound); - length -= 1; - element_count = tvb_get_ntohl(tvb, offset); - AMQP_INCREMENT(offset, 4, bound); - length -= 4; - proto_item_append_text(item, " (array of %d element%s)", element_count, element_suffix[element_count!=1]); - if (element_count > 1) - array_tree = proto_item_add_subtree(item, ett_amqp_0_10_array); - while ((element_count > 0) && (length > 0)) { - element_start = offset; - externally_formatted = 0; + element_count = tvb_get_ntohl(tvb, offset+1); + array_tree = proto_tree_add_subtree_format(item, tvb, offset, 5, ett_amqp_0_10_array, &array_item, "Array of %d element%s)", element_count, plurality(element_count, "", "s")); + + type_item = proto_tree_add_item_ret_uint(array_tree, hf_amqp_0_10_array_type, tvb, offset, 1, ENC_NA, &type); + offset += 1; + proto_tree_add_item_ret_uint(array_tree, hf_amqp_0_10_array_element_count, tvb, offset, 4, ENC_BIG_ENDIAN, &element_count); + offset += 4; + + for (i = 0; ((i < element_count) && (tvb_reported_length_remaining(tvb, offset) > 0)); i++) { switch (type) { case AMQP_0_10_TYPE_STR16: - amqp_typename = "str16"; len16 = tvb_get_ntohs(tvb, offset); - AMQP_INCREMENT(offset, 2, bound); - length -= 2; - value = (char*) tvb_get_string_enc(wmem_packet_scope(), tvb, offset, len16, ENC_UTF_8|ENC_NA); - AMQP_INCREMENT(offset, len16, bound); - length -= len16; + proto_tree_add_item(array_tree, hf_amqp_0_10_array_string, tvb, offset, 2, ENC_UTF_8|ENC_BIG_ENDIAN); + offset += (2 + len16); break; case AMQP_0_10_TYPE_STRUCT32: - amqp_typename = "struct32"; - value = "structure"; - externally_formatted = 1; - struct_length = amqp_0_10_get_32bit_size(tvb, offset); - AMQP_INCREMENT(offset, 4, bound); - length -= 4; - array_tree = proto_item_add_subtree(item, ett_amqp_0_10_array); - sub = proto_tree_add_none_format(array_tree, hf_amqp_field, tvb, - element_start, - offset - element_start, - "(%s): ", amqp_typename); - dissect_amqp_0_10_struct32(tvb, pinfo, sub, offset, struct_length); - AMQP_INCREMENT(offset, struct_length, bound); - length -= struct_length; + struct_length = amqp_0_10_get_32bit_size_new(array_tree, pinfo, tvb, hf_amqp_0_10_struct32_size, offset); + offset += 4; + + array_tree = proto_item_add_subtree(array_item, ett_amqp_0_10_array); + struct_item = proto_tree_add_item(array_tree, + hf_amqp_0_10_struct32, + tvb, offset, 2, ENC_BIG_ENDIAN); + proto_item_set_len(struct_item, struct_length); + + if (struct_length > (guint32)tvb_reported_length_remaining(tvb, offset)) + { + next_tvb = tvb_new_subset_remaining(tvb, offset); + } + else + { + next_tvb = tvb_new_subset_length(tvb, offset, struct_length); + } + dissect_amqp_0_10_struct32(next_tvb, pinfo, struct_item); + offset += struct_length; break; default: - proto_tree_add_none_format(array_tree, hf_amqp_field, tvb, - element_start, - offset - element_start, - "(unknown type %d)", - type); + expert_add_info(pinfo, type_item, &ei_amqp_array_type_unknown); /* Don't bother continuing through the loop: we don't know how * much to increment the offset by and the type doesn't change * so there's nothing interesting to do... */ return; } - - element_count -= 1; - if (externally_formatted) - continue; - - if (array_tree != 0) { - proto_tree_add_none_format(array_tree, hf_amqp_field, tvb, - element_start, - offset - element_start, - "(%s): %s", - amqp_typename, - value); - } - else { - proto_item_append_text(item, ": (%s): %s", amqp_typename, value); - } } } static void dissect_amqp_0_10_xid (tvbuff_t *tvb, int offset, - guint16 xid_length, proto_item *ti) { proto_item *xid_tree; guint8 flag1/*, flag2*/; - guint8 len8; - int max_length; - max_length = offset + xid_length; xid_tree = proto_item_add_subtree(ti, ett_args); flag1 = tvb_get_guint8(tvb, offset); /*flag2 = tvb_get_guint8(tvb, offset+1);*/ proto_tree_add_item(xid_tree, hf_amqp_0_10_argument_packing_flags, tvb, offset, 2, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 2, max_length); + offset += 2; if (flag1 & 0x01) { /* format (uint32) */ proto_tree_add_item(xid_tree, hf_amqp_0_10_dtx_xid_format, tvb, offset, 4, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 4, max_length); + offset += 4; } if (flag1 & 0x02) { /* global-id (vbin8) */ - len8 = tvb_get_guint8(tvb, offset); proto_tree_add_item(xid_tree, hf_amqp_0_10_dtx_xid_global_id, - tvb, offset + 1, len8, ENC_NA); - AMQP_INCREMENT(offset, (1 + len8), max_length); + tvb, offset, 1, ENC_NA); + offset += (1 + tvb_get_guint8(tvb, offset)); } if (flag1 & 0x04) { /* branch-id (vbin8) */ - len8 = tvb_get_guint8(tvb, offset); proto_tree_add_item(xid_tree, hf_amqp_0_10_dtx_xid_branch_id, - tvb, offset + 1, len8, ENC_NA); - AMQP_INCREMENT(offset, (1 + len8), max_length); + tvb, offset, 1, ENC_NA); + /* offset += (1 + tvb_get_guint8(tvb, offset)); */ } } @@ -3424,8 +2821,7 @@ dissect_amqp_0_10_xid (tvbuff_t *tvb, static void dissect_amqp_0_10_connection(tvbuff_t *tvb, packet_info *pinfo, - proto_tree *tree, - int offset, guint16 length) + proto_tree *tree) { proto_item *args_tree; proto_item *ti; @@ -3435,20 +2831,21 @@ dissect_amqp_0_10_connection(tvbuff_t *tvb, guint32 arg_length; int flags_offset; const gchar *method_name; + int offset = 0; + tvbuff_t *next_tvb; method = tvb_get_guint8(tvb, offset+1); method_name = val_to_str_const(method, amqp_0_10_connection_methods, "<invalid connection method>"); - col_append_str(pinfo->cinfo, COL_INFO, method_name); - col_append_str(pinfo->cinfo, COL_INFO, " "); + col_append_fstr(pinfo->cinfo, COL_INFO, "%s ", method_name); col_set_fence(pinfo->cinfo, COL_INFO); proto_tree_add_item(tree, hf_amqp_0_10_connection_method, tvb, offset+1, 1, ENC_BIG_ENDIAN); + offset += 2; ti = proto_tree_add_item(tree, hf_amqp_method_arguments, - tvb, offset + 2, length - 2, ENC_NA); + tvb, offset, -1, ENC_NA); args_tree = proto_item_add_subtree(ti, ett_args); - AMQP_INCREMENT(offset, 2, length); /* * The flag bits are a simple bit string, not a net-byte-order * field. tvb_get_bits16() doesn't know how to do little-endian @@ -3460,31 +2857,35 @@ dissect_amqp_0_10_connection(tvbuff_t *tvb, flags_item = proto_tree_add_item(args_tree, hf_amqp_0_10_argument_packing_flags, tvb, offset, 2, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 2, length); + offset += 2; switch (method) { case AMQP_0_10_METHOD_CONNECTION_START: if ((flag1 & ~0x07) || (flag2 != 0)) expert_add_info(pinfo, flags_item, &ei_amqp_bad_flag_value); if (flag1 & 0x01) { /* server-properties (map) */ - arg_length = amqp_0_10_get_32bit_size(tvb, offset); - AMQP_INCREMENT(offset, 4, length); + arg_length = amqp_0_10_get_32bit_size_new(args_tree, pinfo, tvb, hf_amqp_method_connection_start_server_properties_size, offset); + offset += 4; ti = proto_tree_add_item(args_tree, hf_amqp_method_connection_start_server_properties, tvb, offset, arg_length, ENC_NA); - dissect_amqp_0_10_map (tvb, - offset, - offset + arg_length, - arg_length, - ti); - AMQP_INCREMENT(offset, arg_length, length); + if (arg_length > (guint32)tvb_reported_length_remaining(tvb, offset)) + { + next_tvb = tvb_new_subset_remaining(tvb, offset); + } + else + { + next_tvb = tvb_new_subset_length(tvb, offset, arg_length); + } + dissect_amqp_0_10_map (next_tvb, ti); + offset += arg_length; } if (flag1 & 0x02) { /* mechanisms (str16-array) */ - arg_length = amqp_0_10_get_32bit_size(tvb, offset); - AMQP_INCREMENT(offset, 4, length); + arg_length = amqp_0_10_get_32bit_size_new(args_tree, pinfo, tvb, hf_amqp_0_10_method_connection_start_mechanisms_size, offset); + offset += 4; ti = proto_tree_add_item(args_tree, hf_amqp_0_10_method_connection_start_mechanisms, tvb, @@ -3493,15 +2894,13 @@ dissect_amqp_0_10_connection(tvbuff_t *tvb, dissect_amqp_0_10_array (tvb, pinfo, offset, - offset + arg_length, - arg_length, ti); - AMQP_INCREMENT(offset, arg_length, length); + offset += arg_length; } if (flag1 & 0x04) { /* locales (str16-array) */ - arg_length = amqp_0_10_get_32bit_size(tvb, offset); - AMQP_INCREMENT(offset, 4, length); + arg_length = amqp_0_10_get_32bit_size_new(args_tree, pinfo, tvb, hf_amqp_0_10_method_connection_start_locales_size, offset); + offset += 4; ti = proto_tree_add_item(args_tree, hf_amqp_0_10_method_connection_start_locales, tvb, @@ -3510,10 +2909,8 @@ dissect_amqp_0_10_connection(tvbuff_t *tvb, dissect_amqp_0_10_array (tvb, pinfo, offset, - offset + arg_length, - arg_length, ti); - AMQP_INCREMENT(offset, arg_length, length); + /* offset += arg_length; */ } break; @@ -3522,43 +2919,46 @@ dissect_amqp_0_10_connection(tvbuff_t *tvb, expert_add_info(pinfo, flags_item, &ei_amqp_bad_flag_value); if (flag1 & 0x01) { /* client-properties (map) */ - arg_length = amqp_0_10_get_32bit_size(tvb, offset); - AMQP_INCREMENT(offset, 4, length); + arg_length = amqp_0_10_get_32bit_size_new(args_tree, pinfo, tvb, hf_amqp_method_connection_start_ok_client_properties_size, offset); + offset += 4; ti = proto_tree_add_item(args_tree, hf_amqp_method_connection_start_ok_client_properties, tvb, offset, arg_length, ENC_NA); - dissect_amqp_0_10_map (tvb, - offset, - offset + arg_length, - arg_length, - ti); - AMQP_INCREMENT(offset, arg_length, length); + if (arg_length > (guint32)tvb_reported_length_remaining(tvb, offset)) + { + next_tvb = tvb_new_subset_remaining(tvb, offset); + } + else + { + next_tvb = tvb_new_subset_length(tvb, offset, arg_length); + } + dissect_amqp_0_10_map (next_tvb, ti); + offset += arg_length; } if (flag1 & 0x02) { /* mechanism (str8) */ proto_tree_add_item(args_tree, hf_amqp_method_connection_start_ok_mechanism, - tvb, offset + 1, tvb_get_guint8(tvb, offset), - ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, 1 + tvb_get_guint8(tvb, offset), length); + tvb, offset, 1, + ENC_ASCII|ENC_BIG_ENDIAN); + offset += (1 + tvb_get_guint8(tvb, offset)); } if (flag1 & 0x04) { /* response (vbin32) */ proto_tree_add_item(args_tree, hf_amqp_method_connection_start_ok_response, - tvb, offset + 4, amqp_0_10_get_32bit_size(tvb, offset), - ENC_NA); - AMQP_INCREMENT(offset, 4 + amqp_0_10_get_32bit_size(tvb, offset), length); + tvb, offset, 4, + ENC_BIG_ENDIAN); + offset += (4 + tvb_get_ntohl(tvb, offset)); } if (flag1 & 0x08) { /* locale (str8) */ proto_tree_add_item(args_tree, hf_amqp_method_connection_start_ok_locale, - tvb, offset + 1, tvb_get_guint8(tvb, offset), - ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, 1 + tvb_get_guint8(tvb, offset), length); + tvb, offset + 1, 1, ENC_ASCII|ENC_BIG_ENDIAN); + /* offset += (1 + tvb_get_guint8(tvb, offset)); */ } break; @@ -3569,9 +2969,9 @@ dissect_amqp_0_10_connection(tvbuff_t *tvb, /* challenge (vbin32) */ proto_tree_add_item(args_tree, hf_amqp_method_connection_secure_challenge, - tvb, offset + 4, amqp_0_10_get_32bit_size(tvb, offset), - ENC_NA); - AMQP_INCREMENT(offset, 4 + amqp_0_10_get_32bit_size(tvb, offset), length); + tvb, offset, 4, + ENC_BIG_ENDIAN); + /* offset += (4 + tvb_get_ntohl(tvb, offset)); */ } break; @@ -3582,9 +2982,9 @@ dissect_amqp_0_10_connection(tvbuff_t *tvb, /* response (vbin32) */ proto_tree_add_item(args_tree, hf_amqp_method_connection_secure_ok_response, - tvb, offset + 4, amqp_0_10_get_32bit_size(tvb, offset), - ENC_NA); - AMQP_INCREMENT(offset, 4 + amqp_0_10_get_32bit_size(tvb, offset), length); + tvb, offset, 4, + ENC_BIG_ENDIAN); + /* offset += (4 + tvb_get_ntohl(tvb, offset)); */ } break; @@ -3596,28 +2996,28 @@ dissect_amqp_0_10_connection(tvbuff_t *tvb, proto_tree_add_item(args_tree, hf_amqp_method_connection_tune_channel_max, tvb, offset, 2, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 2, length); + offset += 2; } if (flag1 & 0x02) { /* max-frame-size (uint16) */ proto_tree_add_item(args_tree, hf_amqp_0_10_method_connection_tune_frame_max, tvb, offset, 2, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 2, length); + offset += 2; } if (flag1 & 0x04) { /* heartbeat-min (uint16) */ proto_tree_add_item(args_tree, hf_amqp_0_10_method_connection_tune_heartbeat_min, tvb, offset, 2, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 2, length); + offset += 2; } if (flag1 & 0x08) { /* heartbeat-max (uint16) */ proto_tree_add_item(args_tree, hf_amqp_0_10_method_connection_tune_heartbeat_max, tvb, offset, 2, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 2, length); + /* offset += 2; */ } break; @@ -3629,21 +3029,21 @@ dissect_amqp_0_10_connection(tvbuff_t *tvb, proto_tree_add_item(args_tree, hf_amqp_method_connection_tune_ok_channel_max, tvb, offset, 2, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 2, length); + offset += 2; } if (flag1 & 0x02) { /* max-frame-size (uint16) */ proto_tree_add_item(args_tree, hf_amqp_0_10_method_connection_tune_ok_frame_max, tvb, offset, 2, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 2, length); + offset += 2; } if (flag1 & 0x04) { /* heartbeat (uint16) */ proto_tree_add_item(args_tree, hf_amqp_method_connection_tune_ok_heartbeat, tvb, offset, 2, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 2, length); + /* offset += 2; */ } break; @@ -3655,14 +3055,14 @@ dissect_amqp_0_10_connection(tvbuff_t *tvb, proto_tree_add_item(args_tree, hf_amqp_method_connection_open_virtual_host, tvb, - offset + 1, - tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, tvb_get_guint8(tvb, offset) + 1, length); + offset, + 1, ENC_ASCII|ENC_BIG_ENDIAN); + offset += (1 + tvb_get_guint8(tvb, offset)); } if (flag1 & 0x02) { /* capabilities (str16-array) */ - arg_length = amqp_0_10_get_32bit_size(tvb, offset); - AMQP_INCREMENT(offset, 4, length); + arg_length = amqp_0_10_get_32bit_size_new(args_tree, pinfo, tvb, hf_amqp_0_10_method_connection_open_capabilities_size, offset); + offset += 4; ti = proto_tree_add_item(args_tree, hf_amqp_0_10_method_connection_open_capabilities, tvb, @@ -3671,10 +3071,8 @@ dissect_amqp_0_10_connection(tvbuff_t *tvb, dissect_amqp_0_10_array (tvb, pinfo, offset, - offset + arg_length, - arg_length, ti); - AMQP_INCREMENT(offset, arg_length, length); + /* offset += arg_length; */ } /* * 3rd argument is an optional bit, insist. @@ -3689,8 +3087,8 @@ dissect_amqp_0_10_connection(tvbuff_t *tvb, expert_add_info(pinfo, flags_item, &ei_amqp_bad_flag_value); if (flag1 & 0x01) { /* known-hosts (amqp-host-array) */ - arg_length = amqp_0_10_get_32bit_size(tvb, offset); - AMQP_INCREMENT(offset, 4, length); + arg_length = amqp_0_10_get_32bit_size_new(args_tree, pinfo, tvb, hf_amqp_0_10_method_connection_open_ok_known_hosts_size, offset); + offset += 4; ti = proto_tree_add_item(args_tree, hf_amqp_0_10_method_connection_open_ok_known_hosts, tvb, @@ -3699,10 +3097,8 @@ dissect_amqp_0_10_connection(tvbuff_t *tvb, dissect_amqp_0_10_array (tvb, pinfo, offset, - offset + arg_length, - arg_length, ti); - AMQP_INCREMENT(offset, arg_length, length); + /* offset += arg_length; */ } break; @@ -3713,14 +3109,14 @@ dissect_amqp_0_10_connection(tvbuff_t *tvb, /* host (amqp-host-url [str16]) */ proto_tree_add_item(args_tree, hf_amqp_method_connection_redirect_host, - tvb, offset + 2, tvb_get_ntohs(tvb, offset), - ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, 2 + tvb_get_ntohs(tvb, offset), length); + tvb, offset, 2, + ENC_ASCII|ENC_BIG_ENDIAN); + offset += (2 + tvb_get_ntohs(tvb, offset)); } if (flag1 & 0x02) { /* known-hosts (amqp-host-array) */ - arg_length = amqp_0_10_get_32bit_size(tvb, offset); - AMQP_INCREMENT(offset, 4, length); + arg_length = amqp_0_10_get_32bit_size_new(args_tree, pinfo, tvb, hf_amqp_0_10_method_connection_redirect_known_hosts_size, offset); + offset += 4; ti = proto_tree_add_item(args_tree, hf_amqp_0_10_method_connection_redirect_known_hosts, tvb, @@ -3729,10 +3125,8 @@ dissect_amqp_0_10_connection(tvbuff_t *tvb, dissect_amqp_0_10_array (tvb, pinfo, offset, - offset + arg_length, - arg_length, ti); - AMQP_INCREMENT(offset, arg_length, length); + /* offset += arg_length; */ } break; @@ -3747,15 +3141,14 @@ dissect_amqp_0_10_connection(tvbuff_t *tvb, proto_tree_add_item(args_tree, hf_amqp_0_10_method_connection_close_reply_code, tvb, offset, 2, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 2, length); + offset += 2; } if (flag1 & 0x02) { /* reply-text (str8) */ proto_tree_add_item(args_tree, hf_amqp_method_connection_close_reply_text, - tvb, offset + 1, tvb_get_guint8(tvb, offset), - ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, 1 + tvb_get_guint8(tvb, offset), length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + /* offset + (1 + tvb_get_guint8(tvb, offset)); */ } break; @@ -3767,32 +3160,31 @@ dissect_amqp_0_10_connection(tvbuff_t *tvb, static void dissect_amqp_0_10_session(tvbuff_t *tvb, packet_info *pinfo, - proto_tree *tree, - int offset, guint16 length) + proto_tree *tree) { proto_item *args_tree; proto_item *ti; proto_item *flags_item; guint8 method; guint8 flag1, flag2; - guint16 size; + guint32 size; guint32 array_size; int flags_offset; const gchar *method_name; + int offset = 0; method = tvb_get_guint8(tvb, offset+1); method_name = val_to_str_const(method, amqp_0_10_session_methods, "<invalid session method>"); - col_append_str(pinfo->cinfo, COL_INFO, method_name); - col_append_str(pinfo->cinfo, COL_INFO, " "); + col_append_fstr(pinfo->cinfo, COL_INFO, "%s ", method_name); col_set_fence(pinfo->cinfo, COL_INFO); proto_tree_add_item(tree, hf_amqp_0_10_session_method, tvb, offset+1, 1, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 2, length); + offset += 2; ti = proto_tree_add_item(tree, hf_amqp_method_arguments, - tvb, offset, length - 2, ENC_NA); + tvb, offset, -1, ENC_NA); args_tree = proto_item_add_subtree(ti, ett_args); /* * The flag bits are a simple bit string, not a net-byte-order @@ -3805,19 +3197,20 @@ dissect_amqp_0_10_session(tvbuff_t *tvb, flags_item = proto_tree_add_item(args_tree, hf_amqp_0_10_argument_packing_flags, tvb, offset, 2, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 2, length); + offset += 2; switch (method) { case AMQP_0_10_METHOD_SESSION_ATTACH: if ((flag1 & ~0x03) || ((flag2 != 0))) expert_add_info(pinfo, flags_item, &ei_amqp_bad_flag_value); if (flag1 & 0x01) { /* name (vbin16) */ - size = tvb_get_ntohs(tvb, offset); - AMQP_INCREMENT(offset, 2, length); + proto_tree_add_item_ret_uint(args_tree, hf_amqp_0_10_method_session_attach_name_size, + tvb, offset, 2, ENC_BIG_ENDIAN, &size); + offset += 2; proto_tree_add_item(args_tree, hf_amqp_0_10_method_session_attach_name, tvb, offset, size, ENC_NA); - AMQP_INCREMENT(offset, size, length); + /* offset += size; */ } /* * 2nd argument is an optional bit, force. @@ -3833,12 +3226,13 @@ dissect_amqp_0_10_session(tvbuff_t *tvb, expert_add_info(pinfo, flags_item, &ei_amqp_bad_flag_value); if (flag1 & 0x01) { /* name (vbin16) */ - size = tvb_get_ntohs(tvb, offset); - AMQP_INCREMENT(offset, 2, length); + proto_tree_add_item_ret_uint(args_tree, hf_amqp_0_10_method_session_attach_name_size, + tvb, offset, 2, ENC_BIG_ENDIAN, &size); + offset += 2; proto_tree_add_item(args_tree, hf_amqp_0_10_method_session_attach_name, tvb, offset, size, ENC_NA); - AMQP_INCREMENT(offset, size, length); + /* offset += size; */ } break; @@ -3847,19 +3241,20 @@ dissect_amqp_0_10_session(tvbuff_t *tvb, expert_add_info(pinfo, flags_item, &ei_amqp_bad_flag_value); if (flag1 & 0x01) { /* name (vbin16) */ - size = tvb_get_ntohs(tvb, offset); - AMQP_INCREMENT(offset, 2, length); + proto_tree_add_item_ret_uint(args_tree, hf_amqp_0_10_method_session_attach_name_size, + tvb, offset, 2, ENC_BIG_ENDIAN, &size); + offset += 2; proto_tree_add_item(args_tree, hf_amqp_0_10_method_session_attach_name, tvb, offset, size, ENC_NA); - AMQP_INCREMENT(offset, size, length); + offset += size; } if (flag1 & 0x02) { /* code (detach-code [uint8]) */ proto_tree_add_item(args_tree, hf_amqp_0_10_method_session_detached_code, tvb, offset, 1, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 1, length); + /* offset += 1; */ } break; @@ -3872,7 +3267,7 @@ dissect_amqp_0_10_session(tvbuff_t *tvb, proto_tree_add_item(args_tree, hf_amqp_0_10_method_session_timeout, tvb, offset, 4, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 4, length); + /* offset += 4; */ } break; @@ -3884,14 +3279,14 @@ dissect_amqp_0_10_session(tvbuff_t *tvb, proto_tree_add_item(args_tree, hf_amqp_0_10_method_session_command_point_id, tvb, offset, 4, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 4, length); + offset += 4; } if (flag1 & 0x02) { /* command-offset (uint64) */ proto_tree_add_item(args_tree, hf_amqp_0_10_method_session_command_point_offset, tvb, offset, 8, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 8, length); + /* offset += 8; */ } break; @@ -3904,9 +3299,9 @@ dissect_amqp_0_10_session(tvbuff_t *tvb, ti = proto_tree_add_item(args_tree, hf_amqp_0_10_method_session_commands, tvb, offset, size + 2, ENC_NA); - AMQP_INCREMENT(offset, 2, length); + offset += 2; format_amqp_0_10_sequence_set(tvb, offset, size, ti); - AMQP_INCREMENT(offset, size, length); + offset += size; } if (flag1 & 0x02) { /* fragments (command-fragments [array of command-fragment]) */ @@ -3914,14 +3309,12 @@ dissect_amqp_0_10_session(tvbuff_t *tvb, ti = proto_tree_add_item(args_tree, hf_amqp_0_10_method_session_fragments, tvb, offset, array_size + 4, ENC_NA); - AMQP_INCREMENT(offset, 4, length); + offset += 4; dissect_amqp_0_10_array(tvb, pinfo, offset, - offset + array_size, - length, ti); - AMQP_INCREMENT(offset, array_size, length); + /* offset += array_size; */ } break; @@ -3934,9 +3327,9 @@ dissect_amqp_0_10_session(tvbuff_t *tvb, ti = proto_tree_add_item(args_tree, hf_amqp_0_10_method_session_commands, tvb, offset, size + 2, ENC_NA); - AMQP_INCREMENT(offset, 2, length); + offset += 2; format_amqp_0_10_sequence_set(tvb, offset, size, ti); - AMQP_INCREMENT(offset, size, length); + offset += size; } if (flag1 & 0x02) { /* fragments (command-fragments [array of command-fragment]) */ @@ -3944,14 +3337,12 @@ dissect_amqp_0_10_session(tvbuff_t *tvb, ti = proto_tree_add_item(args_tree, hf_amqp_0_10_method_session_fragments, tvb, offset, array_size + 4, ENC_NA); - AMQP_INCREMENT(offset, 4, length); + offset += 4; dissect_amqp_0_10_array(tvb, pinfo, offset, - offset + array_size, - length, ti); - AMQP_INCREMENT(offset, array_size, length); + /* offset += array_size; */ } break; @@ -3964,9 +3355,9 @@ dissect_amqp_0_10_session(tvbuff_t *tvb, ti = proto_tree_add_item(args_tree, hf_amqp_0_10_method_session_commands, tvb, offset, size + 2, ENC_NA); - AMQP_INCREMENT(offset, 2, length); + offset += 2; format_amqp_0_10_sequence_set(tvb, offset, size, ti); - AMQP_INCREMENT(offset, size, length); + /* offset += size; */ } /* * 2nd argument is an optional bit, timely-reply. @@ -3985,9 +3376,9 @@ dissect_amqp_0_10_session(tvbuff_t *tvb, ti = proto_tree_add_item(args_tree, hf_amqp_0_10_method_session_commands, tvb, offset, size + 2, ENC_NA); - AMQP_INCREMENT(offset, 2, length); + offset += 2; format_amqp_0_10_sequence_set(tvb, offset, size, ti); - AMQP_INCREMENT(offset, size, length); + /* offset += size; */ } break; @@ -4014,9 +3405,9 @@ dissect_amqp_0_10_session(tvbuff_t *tvb, ti = proto_tree_add_item(args_tree, hf_amqp_0_10_method_session_commands, tvb, offset, size + 2, ENC_NA); - AMQP_INCREMENT(offset, 2, length); + offset += 2; format_amqp_0_10_sequence_set(tvb, offset, size, ti); - AMQP_INCREMENT(offset, size, length); + /* offset += size; */ } break; @@ -4026,29 +3417,28 @@ dissect_amqp_0_10_session(tvbuff_t *tvb, static void dissect_amqp_0_10_execution(tvbuff_t *tvb, packet_info *pinfo, - proto_tree *tree, - int offset, guint16 length) + proto_tree *tree) { proto_item *args_tree; proto_item *ti; proto_item *flags_item; guint8 amqp_class = 0, method; guint8 flag1, flag2; - guint16 size; guint32 struct_size; int class_hf; const gchar *method_name; + int offset = 0; + tvbuff_t *next_tvb; method = tvb_get_guint8(tvb, offset+1); method_name = val_to_str_const(method, amqp_0_10_execution_methods, "<invalid execution method>"); - col_append_str(pinfo->cinfo, COL_INFO, method_name); - col_append_str(pinfo->cinfo, COL_INFO, " "); + col_append_fstr(pinfo->cinfo, COL_INFO, "%s ", method_name); col_set_fence(pinfo->cinfo, COL_INFO); proto_tree_add_item(tree, hf_amqp_0_10_execution_method, tvb, offset+1, 1, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 2, length); + offset += 2; /* * Session header is 2 bytes; one that tells that it's 1 byte long, then * the byte itself. Bit 0 is sync. @@ -4061,10 +3451,10 @@ dissect_amqp_0_10_execution(tvbuff_t *tvb, else proto_tree_add_item(tree, hf_amqp_0_10_session_header_sync, tvb, offset + 1, 1, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 2, length); + offset += 2; ti = proto_tree_add_item(tree, hf_amqp_method_arguments, - tvb, offset, length - 4, ENC_NA); + tvb, offset, -1, ENC_NA); args_tree = proto_item_add_subtree(ti, ett_args); /* * The flag bits are a simple bit string, not a net-byte-order @@ -4076,7 +3466,7 @@ dissect_amqp_0_10_execution(tvbuff_t *tvb, flags_item = proto_tree_add_item(args_tree, hf_amqp_0_10_argument_packing_flags, tvb, offset, 2, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 2, length); + offset += 2; switch (method) { case AMQP_0_10_METHOD_EXECUTION_SYNC: if ((flag1 != 0) || (flag2 != 0)) @@ -4091,17 +3481,27 @@ dissect_amqp_0_10_execution(tvbuff_t *tvb, proto_tree_add_item(args_tree, hf_amqp_0_10_method_execution_command_id, tvb, offset, 4, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 4, length); + offset += 4; } if (flag1 & 0x02) { /* value (struct32) */ - struct_size = amqp_0_10_get_32bit_size(tvb, offset); - AMQP_INCREMENT(offset, 4, length); + struct_size = amqp_0_10_get_32bit_size_new(args_tree, pinfo, tvb, hf_amqp_0_10_struct32_size, offset); + offset += 4; + ti = proto_tree_add_item(args_tree, - hf_amqp_0_10_undissected_struct32, - tvb, offset, struct_size, ENC_NA); - dissect_amqp_0_10_struct32(tvb, pinfo, ti, offset, struct_size); - AMQP_INCREMENT(offset, struct_size, length); + hf_amqp_0_10_struct32, + tvb, offset, 2, ENC_BIG_ENDIAN); + proto_item_set_len(ti, struct_size); + if (struct_size > (guint32)tvb_reported_length_remaining(tvb, offset)) + { + next_tvb = tvb_new_subset_remaining(tvb, offset); + } + else + { + next_tvb = tvb_new_subset_length(tvb, offset, struct_size); + } + dissect_amqp_0_10_struct32(next_tvb, pinfo, ti); + /* offset += struct_size; */ } break; @@ -4113,21 +3513,21 @@ dissect_amqp_0_10_execution(tvbuff_t *tvb, proto_tree_add_item(args_tree, hf_amqp_0_10_method_execution_exception_error, tvb, offset, 2, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 2, length); + offset += 2; } if (flag1 & 0x02) { /* command-id (sequence-no [uint32]) */ proto_tree_add_item(args_tree, hf_amqp_0_10_method_execution_command_id, tvb, offset, 4, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 4, length); + offset += 4; } if (flag1 & 0x04) { /* class-code (uint8) */ amqp_class = tvb_get_guint8(tvb, offset); proto_tree_add_item(args_tree, hf_amqp_0_10_class, tvb, offset, 1, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 1, length); + offset += 1; } if (flag1 & 0x08) { /* command-code (uint8) */ @@ -4171,36 +3571,39 @@ dissect_amqp_0_10_execution(tvbuff_t *tvb, tvb, offset, 1, ENC_BIG_ENDIAN); else expert_add_info_format(pinfo, args_tree, &ei_amqp_invalid_class_code, "Invalid class code %x", amqp_class); - AMQP_INCREMENT(offset, 1, length); + offset += 1; } if (flag1 & 0x10) { /* field-index (uint8) */ proto_tree_add_item(args_tree, hf_amqp_0_10_method_execution_field_index, tvb, offset, 1, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 1, length); + offset += 1; } if (flag1 & 0x20) { /* description (str16) */ - size = tvb_get_ntohs(tvb, offset); proto_tree_add_item(args_tree, hf_amqp_0_10_method_execution_description, - tvb, offset + 2, size, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (2 + size), length); + tvb, offset, 2, ENC_ASCII|ENC_BIG_ENDIAN); + offset += (2 + tvb_get_ntohs(tvb, offset)); } if (flag1 & 0x40) { /* error-info (map) */ - struct_size = amqp_0_10_get_32bit_size(tvb, offset); - AMQP_INCREMENT(offset, 4, length); + struct_size = amqp_0_10_get_32bit_size_new(args_tree, pinfo, tvb, hf_amqp_0_10_method_execution_error_info_size, offset); + offset += 4; ti = proto_tree_add_item(args_tree, hf_amqp_0_10_method_execution_error_info, tvb, offset, struct_size, ENC_NA); - dissect_amqp_0_10_map (tvb, - offset, - offset + struct_size, - struct_size, - ti); - AMQP_INCREMENT(offset, struct_size, length); + if (struct_size > (guint32)tvb_reported_length_remaining(tvb, offset)) + { + next_tvb = tvb_new_subset_remaining(tvb, offset); + } + else + { + next_tvb = tvb_new_subset_length(tvb, offset, struct_size); + } + dissect_amqp_0_10_map (next_tvb, ti); + /* offset += struct_size; */ } break; } @@ -4209,29 +3612,30 @@ dissect_amqp_0_10_execution(tvbuff_t *tvb, static void dissect_amqp_0_10_message(tvbuff_t *tvb, packet_info *pinfo, - proto_tree *tree, - int offset, guint16 length) + proto_tree *tree) { proto_item *args_tree; proto_item *ti; proto_item *flags_item; - guint8 method, str_size; + guint8 method; guint8 flag1, flag2; guint16 size; guint32 map_size; int flags_offset; const gchar *method_name; + int offset = 0; + tvbuff_t *next_tvb; method = tvb_get_guint8(tvb, offset+1); method_name = val_to_str_const(method, amqp_0_10_message_methods, "<invalid message method>"); - col_append_str(pinfo->cinfo, COL_INFO, method_name); - col_append_str(pinfo->cinfo, COL_INFO, " "); + col_append_fstr(pinfo->cinfo, COL_INFO, "%s ", method_name); col_set_fence(pinfo->cinfo, COL_INFO); proto_tree_add_item(tree, hf_amqp_0_10_message_method, tvb, offset+1, 1, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 2, length); + offset += 2; + /* * Session header is 2 bytes; one that tells that it's 1 byte long, then * the byte itself. Bit 0 is sync. @@ -4244,10 +3648,10 @@ dissect_amqp_0_10_message(tvbuff_t *tvb, else proto_tree_add_item(tree, hf_amqp_0_10_session_header_sync, tvb, offset + 1, 1, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 2, length); + offset += 2; ti = proto_tree_add_item(tree, hf_amqp_method_arguments, - tvb, offset, length - 4, ENC_NA); + tvb, offset, -1, ENC_NA); args_tree = proto_item_add_subtree(ti, ett_args); /* * The flag bits are a simple bit string, not a net-byte-order @@ -4260,29 +3664,28 @@ dissect_amqp_0_10_message(tvbuff_t *tvb, flags_item = proto_tree_add_item(args_tree, hf_amqp_0_10_argument_packing_flags, tvb, offset, 2, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 2, length); + offset += 2; switch (method) { case AMQP_0_10_METHOD_MESSAGE_TRANSFER: if ((flag1 & ~0x07) || (flag2 != 0)) expert_add_info(pinfo, flags_item, &ei_amqp_bad_flag_value); if (flag1 & 0x01) { /* destination (str8) */ - str_size = tvb_get_guint8(tvb, offset); proto_tree_add_item(args_tree, hf_amqp_0_10_method_message_transfer_destination, - tvb, offset + 1, str_size, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (1 + str_size), length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + offset += (1 + tvb_get_guint8(tvb, offset)); } if (flag1 & 0x02) { /* accept-mode (accept-mode [uint8]) */ proto_tree_add_item(args_tree, hf_amqp_0_10_method_message_transfer_accept_mode, tvb, offset, 1, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 1, length); + offset += 1; } if (flag1 & 0x04) { /* acquire-mode (acquire-mode [uint8]) */ proto_tree_add_item(args_tree, hf_amqp_0_10_method_message_transfer_acquire_mode, tvb, offset, 1, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 1, length); + /* offset += 1; */ } break; @@ -4295,9 +3698,9 @@ dissect_amqp_0_10_message(tvbuff_t *tvb, ti = proto_tree_add_item(args_tree, hf_amqp_0_10_method_message_accept_transfers, tvb, offset, size + 2, ENC_NA); - AMQP_INCREMENT(offset, 2, length); + offset += 2; format_amqp_0_10_sequence_set(tvb, offset, size, ti); - AMQP_INCREMENT(offset, size, length); + /* offset += size; */ } break; @@ -4310,22 +3713,21 @@ dissect_amqp_0_10_message(tvbuff_t *tvb, ti = proto_tree_add_item(args_tree, hf_amqp_0_10_method_message_accept_transfers, tvb, offset, size + 2, ENC_NA); - AMQP_INCREMENT(offset, 2, length); + offset += 2; format_amqp_0_10_sequence_set(tvb, offset, size, ti); - AMQP_INCREMENT(offset, size, length); + offset += size; } if (flag1 & 0x02) { /* reject-code (reject-code [uint16]) */ proto_tree_add_item(args_tree, hf_amqp_0_10_method_message_transfer_reject_code, tvb, offset, 2, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 2, length); + offset += 2; } if (flag1 & 0x04) { /* text (str8) */ - str_size = tvb_get_guint8(tvb, offset); proto_tree_add_item(args_tree, hf_amqp_0_10_method_message_reject_text, - tvb, offset + 1, str_size, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (1 + str_size), length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + /* offset += (1 + tvb_get_guint8(tvb, offset)); */ } break; @@ -4338,9 +3740,9 @@ dissect_amqp_0_10_message(tvbuff_t *tvb, proto_tree_add_item(args_tree, hf_amqp_0_10_method_message_accept_transfers, tvb, offset, size + 2, ENC_NA); - AMQP_INCREMENT(offset, 2, length); + offset += 2; format_amqp_0_10_sequence_set(tvb, offset, size, ti); - AMQP_INCREMENT(offset, size, length); + /* offset += size; */ } /* * 2nd argument is an optional bit, set-redelivered. @@ -4359,9 +3761,9 @@ dissect_amqp_0_10_message(tvbuff_t *tvb, proto_tree_add_item(args_tree, hf_amqp_0_10_method_message_accept_transfers, tvb, offset, size + 2, ENC_NA); - AMQP_INCREMENT(offset, 2, length); + offset += 2; format_amqp_0_10_sequence_set(tvb, offset, size, ti); - AMQP_INCREMENT(offset, size, length); + /* offset += size; */ } break; @@ -4370,19 +3772,17 @@ dissect_amqp_0_10_message(tvbuff_t *tvb, expert_add_info(pinfo, flags_item, &ei_amqp_bad_flag_value); if (flag1 & 0x01) { /* destination (destination [str8]) */ - str_size = tvb_get_guint8(tvb, offset); proto_tree_add_item(args_tree, hf_amqp_0_10_method_message_dest, - tvb, offset + 1, str_size, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, 1 + str_size, length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + offset += (1 + tvb_get_guint8(tvb, offset)); } if (flag1 & 0x02) { /* resume-id (resume-id [str16]) */ - size = tvb_get_ntohs(tvb, offset); proto_tree_add_item(args_tree, hf_amqp_0_10_method_message_resume_id, - tvb, offset + 2, size, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, 2 + size, length); + tvb, offset, 2, ENC_ASCII|ENC_BIG_ENDIAN); + /* offset += (2 + tvb_get_ntohs(tvb, offset)); */ } break; @@ -4391,31 +3791,29 @@ dissect_amqp_0_10_message(tvbuff_t *tvb, expert_add_info(pinfo, flags_item, &ei_amqp_bad_flag_value); if (flag1 & 0x01) { /* queue (queue.name [str8]) */ - str_size = tvb_get_guint8(tvb, offset); proto_tree_add_item(args_tree, hf_amqp_0_10_method_message_subscribe_queue, - tvb, offset + 1, str_size, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, 1 + str_size, length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + offset += (1 + tvb_get_guint8(tvb, offset)); } if (flag1 & 0x02) { /* destination (destination [str8]) */ - str_size = tvb_get_guint8(tvb, offset); proto_tree_add_item(args_tree, hf_amqp_0_10_method_message_dest, - tvb, offset + 1, str_size, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, 1 + str_size, length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + offset += (1 + tvb_get_guint8(tvb, offset)); } if (flag1 & 0x04) { /* accept-mode (accept-mode [uint8]) */ proto_tree_add_item(args_tree, hf_amqp_0_10_method_message_transfer_accept_mode, tvb, offset, 1, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 1, length); + offset += 1; } if (flag1 & 0x08) { /* acquire-mode (acquire-mode [uint8]) */ proto_tree_add_item(args_tree, hf_amqp_0_10_method_message_transfer_acquire_mode, tvb, offset, 1, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 1, length); + offset += 1; } /* * 5th argument is an optional bit, exclusive. @@ -4425,18 +3823,17 @@ dissect_amqp_0_10_message(tvbuff_t *tvb, tvb, flags_offset, 1, ENC_BIG_ENDIAN); if (flag1 & 0x20) { /* resume-id (resume-id [str16]) */ - size = tvb_get_ntohs(tvb, offset); proto_tree_add_item(args_tree, hf_amqp_0_10_method_message_resume_id, - tvb, offset, 2 + size, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, 2 + size, length); + tvb, offset, 2, ENC_ASCII|ENC_BIG_ENDIAN); + offset += (2 + tvb_get_ntohs(tvb, offset)); } if (flag1 & 0x40) { /* resume-ttl (uint64) */ proto_tree_add_item(args_tree, hf_amqp_0_10_method_message_subscribe_resume_ttl, tvb, offset, 8, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 8, length); + offset += 8; } if (flag1 & 0x80) { /* arguments (map) */ @@ -4446,12 +3843,16 @@ dissect_amqp_0_10_message(tvbuff_t *tvb, tvb, offset, 4 + map_size, ENC_NA); - dissect_amqp_0_10_map (tvb, - offset + 4, - offset + 4 + map_size, - map_size, - ti); - AMQP_INCREMENT(offset, 4 + map_size, length); + if (map_size > (guint32)tvb_reported_length_remaining(tvb, offset)) + { + next_tvb = tvb_new_subset_remaining(tvb, offset); + } + else + { + next_tvb = tvb_new_subset_length(tvb, offset, map_size); + } + dissect_amqp_0_10_map (next_tvb, ti); + /* offset += (4 + map_size); */ } break; @@ -4460,11 +3861,10 @@ dissect_amqp_0_10_message(tvbuff_t *tvb, expert_add_info(pinfo, flags_item, &ei_amqp_bad_flag_value); if (flag1 & 0x01) { /* destination (destination [str8]) */ - str_size = tvb_get_guint8(tvb, offset); proto_tree_add_item(args_tree, hf_amqp_0_10_method_message_dest, - tvb, offset + 1, str_size, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, 1 + str_size, length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + /* offset += (1 + tvb_get_guint8(tvb, offset)); */ } break; @@ -4473,18 +3873,17 @@ dissect_amqp_0_10_message(tvbuff_t *tvb, expert_add_info(pinfo, flags_item, &ei_amqp_bad_flag_value); if (flag1 & 0x01) { /* destination (destination [str8]) */ - str_size = tvb_get_guint8(tvb, offset); proto_tree_add_item(args_tree, hf_amqp_0_10_method_message_dest, - tvb, offset + 1, str_size, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, 1 + str_size, length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + offset += (1 + tvb_get_guint8(tvb, offset)); } if (flag1 & 0x02) { /* flow-mode (flow-mode [uint8]) */ proto_tree_add_item(args_tree, hf_amqp_0_10_method_message_flow_mode, tvb, offset, 1, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 1, length); + /* offset += 1; */ } break; @@ -4493,25 +3892,24 @@ dissect_amqp_0_10_message(tvbuff_t *tvb, expert_add_info(pinfo, flags_item, &ei_amqp_bad_flag_value); if (flag1 & 0x01) { /* destination (destination [str8]) */ - str_size = tvb_get_guint8(tvb, offset); proto_tree_add_item(args_tree, hf_amqp_0_10_method_message_dest, - tvb, offset + 1, str_size, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, 1 + str_size, length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + offset += (1 + tvb_get_guint8(tvb, offset)); } if (flag1 & 0x02) { /* unit (credit-unit [uint8]) */ proto_tree_add_item(args_tree, hf_amqp_0_10_method_message_credit_unit, tvb, offset, 1, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 1, length); + offset += 1; } if (flag1 & 0x04) { /* value (uint32) */ proto_tree_add_item(args_tree, hf_amqp_0_10_method_message_credit_value, tvb, offset, 4, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 4, length); + /* offset += 4; */ } break; @@ -4520,11 +3918,10 @@ dissect_amqp_0_10_message(tvbuff_t *tvb, expert_add_info(pinfo, flags_item, &ei_amqp_bad_flag_value); if (flag1 & 0x01) { /* destination (destination [str8]) */ - str_size = tvb_get_guint8(tvb, offset); proto_tree_add_item(args_tree, hf_amqp_0_10_method_message_dest, - tvb, offset + 1, str_size, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, 1 + str_size, length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + /* offset += (1 + tvb_get_guint8(tvb, offset)); */ } break; @@ -4533,11 +3930,10 @@ dissect_amqp_0_10_message(tvbuff_t *tvb, expert_add_info(pinfo, flags_item, &ei_amqp_bad_flag_value); if (flag1 & 0x01) { /* destination (destination [str8]) */ - str_size = tvb_get_guint8(tvb, offset); proto_tree_add_item(args_tree, hf_amqp_0_10_method_message_dest, - tvb, offset + 1, str_size, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, 1 + str_size, length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + /* offset += (1 + tvb_get_guint8(tvb, offset)); */ } break; } @@ -4546,24 +3942,23 @@ dissect_amqp_0_10_message(tvbuff_t *tvb, static void dissect_amqp_0_10_tx(tvbuff_t *tvb, packet_info *pinfo, - proto_tree *tree, - int offset, guint16 length) + proto_tree *tree) { guint8 method; guint8 flag1, flag2; const gchar *method_name; proto_item *ti; + int offset = 1; method = tvb_get_guint8(tvb, offset+1); method_name = val_to_str_const(method, amqp_0_10_tx_methods, "<invalid tx method>"); - col_append_str(pinfo->cinfo, COL_INFO, method_name); - col_append_str(pinfo->cinfo, COL_INFO, " "); + col_append_fstr(pinfo->cinfo, COL_INFO, "%s ", method_name); col_set_fence(pinfo->cinfo, COL_INFO); proto_tree_add_item(tree, hf_amqp_0_10_tx_method, tvb, offset+1, 1, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 2, length); + offset += 2; /* * Session header is 2 bytes; one that tells that it's 1 byte long, then * the byte itself. Bit 0 is sync. @@ -4576,7 +3971,7 @@ dissect_amqp_0_10_tx(tvbuff_t *tvb, else proto_tree_add_item(tree, hf_amqp_0_10_session_header_sync, tvb, offset + 1, 1, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 2, length); + /* offset += 2; */ /* No args on any method in this class */ } @@ -4584,8 +3979,7 @@ dissect_amqp_0_10_tx(tvbuff_t *tvb, static void dissect_amqp_0_10_dtx(tvbuff_t *tvb, packet_info *pinfo, - proto_tree *tree, - int offset, guint16 length) + proto_tree *tree) { proto_item *args_tree; proto_item *ti; @@ -4595,17 +3989,17 @@ dissect_amqp_0_10_dtx(tvbuff_t *tvb, guint16 xid_length; int flags_offset; const gchar *method_name; + int offset = 0; method = tvb_get_guint8(tvb, offset+1); method_name = val_to_str_const(method, amqp_0_10_dtx_methods, "<invalid dtx method>"); - col_append_str(pinfo->cinfo, COL_INFO, method_name); - col_append_str(pinfo->cinfo, COL_INFO, " "); + col_append_fstr(pinfo->cinfo, COL_INFO, "%s ", method_name); col_set_fence(pinfo->cinfo, COL_INFO); proto_tree_add_item(tree, hf_amqp_0_10_dtx_method, tvb, offset+1, 1, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 2, length); + offset += 2; /* * Session header is 2 bytes; one that tells that it's 1 byte long, then * the byte itself. Bit 0 is sync. @@ -4618,7 +4012,7 @@ dissect_amqp_0_10_dtx(tvbuff_t *tvb, else proto_tree_add_item(tree, hf_amqp_0_10_session_header_sync, tvb, offset + 1, 1, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 2, length); + offset += 2; /* No args for dtx.select or dtx.recover */ if ((method == AMQP_0_10_METHOD_DTX_SELECT) || @@ -4626,7 +4020,7 @@ dissect_amqp_0_10_dtx(tvbuff_t *tvb, return; ti = proto_tree_add_item(tree, hf_amqp_method_arguments, - tvb, offset, length - 4, ENC_NA); + tvb, offset, -1, ENC_NA); args_tree = proto_item_add_subtree(ti, ett_args); /* @@ -4640,14 +4034,14 @@ dissect_amqp_0_10_dtx(tvbuff_t *tvb, flags_item = proto_tree_add_item(args_tree, hf_amqp_0_10_argument_packing_flags, tvb, offset, 2, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 2, length); + offset += 2; switch (method) { case AMQP_0_10_METHOD_DTX_START: if ((flag1 & ~0x07) || (flag2 != 0)) expert_add_info(pinfo, flags_item, &ei_amqp_bad_flag_value); if (flag1 & 0x01) { /* xid (xid) */ xid_length = tvb_get_ntohs(tvb, offset); - AMQP_INCREMENT(offset, 2, length); + offset += 2; ti = proto_tree_add_item(args_tree, hf_amqp_0_10_dtx_xid, tvb, @@ -4655,9 +4049,8 @@ dissect_amqp_0_10_dtx(tvbuff_t *tvb, xid_length + 2, ENC_NA); dissect_amqp_0_10_xid (tvb, offset, - xid_length, ti); - AMQP_INCREMENT(offset, xid_length, length); + /* offset += xid_length; */ } /* * 2nd, 3rd arguments are optional bits. @@ -4676,7 +4069,7 @@ dissect_amqp_0_10_dtx(tvbuff_t *tvb, expert_add_info(pinfo, flags_item, &ei_amqp_bad_flag_value); if (flag1 & 0x01) { /* xid (xid) */ xid_length = tvb_get_ntohs(tvb, offset); - AMQP_INCREMENT(offset, 2, length); + offset += 2; ti = proto_tree_add_item(args_tree, hf_amqp_0_10_dtx_xid, tvb, @@ -4684,9 +4077,8 @@ dissect_amqp_0_10_dtx(tvbuff_t *tvb, xid_length + 2, ENC_NA); dissect_amqp_0_10_xid (tvb, offset, - xid_length, ti); - AMQP_INCREMENT(offset, xid_length, length); + /* offset += xid_length; */ } /* * 2nd, 3rd arguments are optional bits. @@ -4704,7 +4096,7 @@ dissect_amqp_0_10_dtx(tvbuff_t *tvb, expert_add_info(pinfo, flags_item, &ei_amqp_bad_flag_value); if (flag1 & 0x01) { /* xid (xid) */ xid_length = tvb_get_ntohs(tvb, offset); - AMQP_INCREMENT(offset, 2, length); + offset += 2; ti = proto_tree_add_item(args_tree, hf_amqp_0_10_dtx_xid, tvb, @@ -4712,9 +4104,8 @@ dissect_amqp_0_10_dtx(tvbuff_t *tvb, xid_length + 2, ENC_NA); dissect_amqp_0_10_xid (tvb, offset, - xid_length, ti); - AMQP_INCREMENT(offset, xid_length, length); + /* offset += xid_length; */ } /* * 2nd argument is an optional bit. @@ -4732,7 +4123,7 @@ dissect_amqp_0_10_dtx(tvbuff_t *tvb, expert_add_info(pinfo, flags_item, &ei_amqp_bad_flag_value); if (flag1 & 0x01) { /* xid (xid) */ xid_length = tvb_get_ntohs(tvb, offset); - AMQP_INCREMENT(offset, 2, length); + offset += 2; ti = proto_tree_add_item(args_tree, hf_amqp_0_10_dtx_xid, tvb, @@ -4740,9 +4131,8 @@ dissect_amqp_0_10_dtx(tvbuff_t *tvb, xid_length + 2, ENC_NA); dissect_amqp_0_10_xid (tvb, offset, - xid_length, ti); - AMQP_INCREMENT(offset, xid_length, length); + /* offset += xid_length; */ } break; @@ -4751,7 +4141,7 @@ dissect_amqp_0_10_dtx(tvbuff_t *tvb, expert_add_info(pinfo, flags_item, &ei_amqp_bad_flag_value); if (flag1 & 0x01) { /* xid (xid) */ xid_length = tvb_get_ntohs(tvb, offset); - AMQP_INCREMENT(offset, 2, length); + offset += 2; ti = proto_tree_add_item(args_tree, hf_amqp_0_10_dtx_xid, tvb, @@ -4759,15 +4149,14 @@ dissect_amqp_0_10_dtx(tvbuff_t *tvb, xid_length + 2, ENC_NA); dissect_amqp_0_10_xid (tvb, offset, - xid_length, ti); - AMQP_INCREMENT(offset, xid_length, length); + offset += xid_length; } if (flag1 & 0x02) { /* timeout (uint32) */ proto_tree_add_item(args_tree, hf_amqp_0_10_method_dtx_set_timeout_timeout, tvb, offset, 4, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 4, length); + /* offset += 2; */ } break; @@ -4777,29 +4166,28 @@ dissect_amqp_0_10_dtx(tvbuff_t *tvb, static void dissect_amqp_0_10_exchange(tvbuff_t *tvb, packet_info *pinfo, - proto_tree *tree, - int offset, guint16 length) + proto_tree *tree) { proto_item *args_tree; proto_item *ti; proto_item *flags_item; guint8 method; guint8 flag1, flag2; - guint8 str_size; guint32 map_length; int flags_offset; const gchar *method_name; + int offset = 0; + tvbuff_t *next_tvb; method = tvb_get_guint8(tvb, offset+1); method_name = val_to_str_const(method, amqp_0_10_exchange_methods, "<invalid exchange method>"); - col_append_str(pinfo->cinfo, COL_INFO, method_name); - col_append_str(pinfo->cinfo, COL_INFO, " "); + col_append_fstr(pinfo->cinfo, COL_INFO, "%s ", method_name); col_set_fence(pinfo->cinfo, COL_INFO); proto_tree_add_item(tree, hf_amqp_0_10_exchange_method, tvb, offset+1, 1, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 2, length); + offset += 2; /* * Session header is 2 bytes; one that tells that it's 1 byte long, then * the byte itself. Bit 0 is sync. @@ -4812,10 +4200,10 @@ dissect_amqp_0_10_exchange(tvbuff_t *tvb, else proto_tree_add_item(tree, hf_amqp_0_10_session_header_sync, tvb, offset + 1, 1, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 2, length); + offset += 2; ti = proto_tree_add_item(tree, hf_amqp_method_arguments, - tvb, offset, length - 4, ENC_NA); + tvb, offset, -1, ENC_NA); args_tree = proto_item_add_subtree(ti, ett_args); /* @@ -4829,31 +4217,28 @@ dissect_amqp_0_10_exchange(tvbuff_t *tvb, flags_item = proto_tree_add_item(args_tree, hf_amqp_0_10_argument_packing_flags, tvb, offset, 2, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 2, length); + offset += 2; switch (method) { case AMQP_0_10_METHOD_EXCHANGE_DECLARE: if ((flag1 & ~0x7f) || (flag2 != 0)) expert_add_info(pinfo, flags_item, &ei_amqp_bad_flag_value); if (flag1 & 0x01) { /* exchange (name [str8]) */ - str_size = tvb_get_guint8(tvb, offset); proto_tree_add_item(args_tree, hf_amqp_0_10_method_exchange_declare_exchange, - tvb, offset + 1, str_size, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (1 + str_size), length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + offset += (1 + tvb_get_guint8(tvb, offset)); } if (flag1 & 0x02) { /* type (str8) */ - str_size = tvb_get_guint8(tvb, offset); proto_tree_add_item(args_tree, hf_amqp_0_10_method_exchange_declare_type, - tvb, offset + 1, str_size, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (1 + str_size), length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + offset += (1 + tvb_get_guint8(tvb, offset)); } if (flag1 & 0x04) { /* alternate-exchange (name [str8]) */ - str_size = tvb_get_guint8(tvb, offset); proto_tree_add_item(args_tree, hf_amqp_0_10_method_exchange_declare_alt_exchange, - tvb, offset + 1, str_size, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (1 + str_size), length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + offset += (1 + tvb_get_guint8(tvb, offset)); } /* * 4th-6th arguments are optional bits. @@ -4868,19 +4253,23 @@ dissect_amqp_0_10_exchange(tvbuff_t *tvb, hf_amqp_0_10_method_exchange_declare_auto_delete, tvb, flags_offset, 1, ENC_BIG_ENDIAN); if (flag1 & 0x40) { /* arguments (map) */ - map_length = amqp_0_10_get_32bit_size(tvb, offset); - AMQP_INCREMENT(offset, 4, length); + map_length = amqp_0_10_get_32bit_size_new(args_tree, pinfo, tvb, hf_amqp_0_10_method_exchange_declare_arguments_size, offset); + offset += 4; ti = proto_tree_add_item(args_tree, hf_amqp_0_10_method_exchange_declare_arguments, tvb, - offset - 4, - map_length + 4, ENC_NA); - dissect_amqp_0_10_map (tvb, - offset, - offset + map_length, - map_length, - ti); - AMQP_INCREMENT(offset, map_length, length); + offset, + map_length, ENC_NA); + if (map_length > (guint32)tvb_reported_length_remaining(tvb, offset)) + { + next_tvb = tvb_new_subset_remaining(tvb, offset); + } + else + { + next_tvb = tvb_new_subset_length(tvb, offset, map_length); + } + dissect_amqp_0_10_map (next_tvb, ti); + /* offset += map_length; */ } break; @@ -4888,11 +4277,10 @@ dissect_amqp_0_10_exchange(tvbuff_t *tvb, if ((flag1 & ~0x03) || (flag2 != 0)) expert_add_info(pinfo, flags_item, &ei_amqp_bad_flag_value); if (flag1 & 0x01) { /* exchange (name [str8]) */ - str_size = tvb_get_guint8(tvb, offset); proto_tree_add_item(args_tree, hf_amqp_0_10_method_exchange_declare_exchange, - tvb, offset + 1, str_size, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (1 + str_size), length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + /* offset += (1 + tvb_get_guint8(tvb, offset)); */ } /* * 2nd argument is an optional bit. @@ -4906,11 +4294,10 @@ dissect_amqp_0_10_exchange(tvbuff_t *tvb, if ((flag1 & ~0x01) || (flag2 != 0)) expert_add_info(pinfo, flags_item, &ei_amqp_bad_flag_value); if (flag1 & 0x01) { /* exchange (name [str8]) */ - str_size = tvb_get_guint8(tvb, offset); proto_tree_add_item(args_tree, hf_amqp_0_10_method_exchange_declare_exchange, - tvb, offset + 1, str_size, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (1 + str_size), length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + /* offset += (1 + tvb_get_guint8(tvb, offset)); */ } break; @@ -4918,40 +4305,41 @@ dissect_amqp_0_10_exchange(tvbuff_t *tvb, if ((flag1 & ~0x0f) || (flag2 != 0)) expert_add_info(pinfo, flags_item, &ei_amqp_bad_flag_value); if (flag1 & 0x01) { /* queue (queue.name [str8]) */ - str_size = tvb_get_guint8(tvb, offset); proto_tree_add_item(args_tree, hf_amqp_0_10_method_exchange_bind_queue, - tvb, offset + 1, str_size, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (1 + str_size), length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + offset += (1 + tvb_get_guint8(tvb, offset)); } if (flag1 & 0x02) { /* exchange (name [str8]) */ - str_size = tvb_get_guint8(tvb, offset); proto_tree_add_item(args_tree, hf_amqp_0_10_method_exchange_declare_exchange, - tvb, offset + 1, str_size, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (1 + str_size), length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + offset += (1 + tvb_get_guint8(tvb, offset)); } if (flag1 & 0x04) { /* binding-key (str8) */ - str_size = tvb_get_guint8(tvb, offset); proto_tree_add_item(args_tree, hf_amqp_0_10_method_exchange_binding_key, - tvb, offset + 1, str_size, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (1 + str_size), length); + tvb, offset, 1, ENC_ASCII|ENC_NA); + offset += (1 + tvb_get_guint8(tvb, offset)); } if (flag1 & 0x08) { /* arguments (map) */ - map_length = amqp_0_10_get_32bit_size(tvb, offset); - AMQP_INCREMENT(offset, 4, length); + map_length = amqp_0_10_get_32bit_size_new(args_tree, pinfo, tvb, hf_amqp_0_10_method_exchange_declare_arguments_size, offset); + offset += 4; ti = proto_tree_add_item(args_tree, hf_amqp_0_10_method_exchange_declare_arguments, tvb, - offset - 4, - map_length + 4, ENC_NA); - dissect_amqp_0_10_map (tvb, - offset, - offset + map_length, - map_length, - ti); - AMQP_INCREMENT(offset, map_length, length); + offset, + map_length, ENC_NA); + if (map_length > (guint32)tvb_reported_length_remaining(tvb, offset)) + { + next_tvb = tvb_new_subset_remaining(tvb, offset); + } + else + { + next_tvb = tvb_new_subset_length(tvb, offset, map_length); + } + dissect_amqp_0_10_map (next_tvb, ti); + /* offset += map_length; */ } break; @@ -4959,25 +4347,22 @@ dissect_amqp_0_10_exchange(tvbuff_t *tvb, if ((flag1 & ~0x07) || (flag2 != 0)) expert_add_info(pinfo, flags_item, &ei_amqp_bad_flag_value); if (flag1 & 0x01) { /* queue (queue.name [str8]) */ - str_size = tvb_get_guint8(tvb, offset); proto_tree_add_item(args_tree, hf_amqp_0_10_method_exchange_bind_queue, - tvb, offset + 1, str_size, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (1 + str_size), length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + offset += (1 + tvb_get_guint8(tvb, offset)); } if (flag1 & 0x02) { /* exchange (name [str8]) */ - str_size = tvb_get_guint8(tvb, offset); proto_tree_add_item(args_tree, hf_amqp_0_10_method_exchange_declare_exchange, - tvb, offset + 1, str_size, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (1 + str_size), length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + offset += (1 + tvb_get_guint8(tvb, offset)); } if (flag1 & 0x04) { /* binding-key (str8) */ - str_size = tvb_get_guint8(tvb, offset); proto_tree_add_item(args_tree, hf_amqp_0_10_method_exchange_binding_key, - tvb, offset + 1, str_size, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (1 + str_size), length); + tvb, offset, 1, ENC_ASCII|ENC_NA); + /* offset += (1 + tvb_get_guint8(tvb, offset)); */ } break; @@ -4985,40 +4370,41 @@ dissect_amqp_0_10_exchange(tvbuff_t *tvb, if ((flag1 & ~0x0f) || (flag2 != 0)) expert_add_info(pinfo, flags_item, &ei_amqp_bad_flag_value); if (flag1 & 0x01) { /* exchange (name [str8]) */ - str_size = tvb_get_guint8(tvb, offset); proto_tree_add_item(args_tree, hf_amqp_0_10_method_exchange_declare_exchange, - tvb, offset + 1, str_size, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (1 + str_size), length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + offset += (1 + tvb_get_guint8(tvb, offset)); } if (flag1 & 0x02) { /* queue (queue.name [str8]) */ - str_size = tvb_get_guint8(tvb, offset); proto_tree_add_item(args_tree, hf_amqp_0_10_method_exchange_bind_queue, - tvb, offset + 1, str_size, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (1 + str_size), length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + offset += (1 + tvb_get_guint8(tvb, offset)); } if (flag1 & 0x04) { /* binding-key (str8) */ - str_size = tvb_get_guint8(tvb, offset); proto_tree_add_item(args_tree, hf_amqp_0_10_method_exchange_binding_key, - tvb, offset + 1, str_size, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (1 + str_size), length); + tvb, offset, 1, ENC_ASCII|ENC_NA); + offset += (1 + tvb_get_guint8(tvb, offset)); } if (flag1 & 0x08) { /* arguments (map) */ - map_length = amqp_0_10_get_32bit_size(tvb, offset); - AMQP_INCREMENT(offset, 4, length); + map_length = amqp_0_10_get_32bit_size_new(args_tree, pinfo, tvb, hf_amqp_0_10_method_exchange_declare_arguments_size, offset); + offset += 4; ti = proto_tree_add_item(args_tree, hf_amqp_0_10_method_exchange_declare_arguments, tvb, - offset - 4, - map_length + 4, ENC_NA); - dissect_amqp_0_10_map (tvb, - offset, - offset + map_length, - map_length, - ti); - AMQP_INCREMENT(offset, map_length, length); + offset, + map_length, ENC_NA); + if (map_length > (guint32)tvb_reported_length_remaining(tvb, offset)) + { + next_tvb = tvb_new_subset_remaining(tvb, offset); + } + else + { + next_tvb = tvb_new_subset_length(tvb, offset, map_length); + } + dissect_amqp_0_10_map (next_tvb, ti); + /* offset += map_length; */ } break; } @@ -5027,29 +4413,28 @@ dissect_amqp_0_10_exchange(tvbuff_t *tvb, static void dissect_amqp_0_10_queue(tvbuff_t *tvb, packet_info *pinfo, - proto_tree *tree, - int offset, guint16 length) + proto_tree *tree) { proto_item *args_tree; proto_item *ti; proto_item *flags_item; guint8 method; guint8 flag1, flag2; - guint8 str_size; guint32 map_length; int flags_offset; const gchar *method_name; + int offset = 0; + tvbuff_t *next_tvb; method = tvb_get_guint8(tvb, offset+1); method_name = val_to_str_const(method, amqp_0_10_queue_methods, "<invalid queue method>"); - col_append_str(pinfo->cinfo, COL_INFO, method_name); - col_append_str(pinfo->cinfo, COL_INFO, " "); + col_append_fstr(pinfo->cinfo, COL_INFO, "%s ", method_name); col_set_fence(pinfo->cinfo, COL_INFO); proto_tree_add_item(tree, hf_amqp_0_10_queue_method, tvb, offset+1, 1, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 2, length); + offset += 2; /* * Session header is 2 bytes; one that tells that it's 1 byte long, then * the byte itself. Bit 0 is sync. @@ -5062,10 +4447,10 @@ dissect_amqp_0_10_queue(tvbuff_t *tvb, else proto_tree_add_item(tree, hf_amqp_0_10_session_header_sync, tvb, offset + 1, 1, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 2, length); + offset += 2; ti = proto_tree_add_item(tree, hf_amqp_method_arguments, - tvb, offset, length - 4, ENC_NA); + tvb, offset, -1, ENC_NA); args_tree = proto_item_add_subtree(ti, ett_args); /* @@ -5079,24 +4464,22 @@ dissect_amqp_0_10_queue(tvbuff_t *tvb, flags_item = proto_tree_add_item(args_tree, hf_amqp_0_10_argument_packing_flags, tvb, offset, 2, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 2, length); + offset += 2; switch (method) { case AMQP_0_10_METHOD_QUEUE_DECLARE: if ((flag1 & ~0x7f) || (flag2 != 0)) expert_add_info(pinfo, flags_item, &ei_amqp_bad_flag_value); if (flag1 & 0x01) { /* queue (name [str8]) */ - str_size = tvb_get_guint8(tvb, offset); proto_tree_add_item(args_tree, hf_amqp_0_10_method_queue_name, - tvb, offset + 1, str_size, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (1 + str_size), length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + offset += (1 + tvb_get_guint8(tvb, offset)); } if (flag1 & 0x02) { /* alternate-exchange (exchange.name [str8]) */ - str_size = tvb_get_guint8(tvb, offset); proto_tree_add_item(args_tree, hf_amqp_0_10_method_queue_alt_exchange, - tvb, offset + 1, str_size, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (1 + str_size), length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + offset += (1 + tvb_get_guint8(tvb, offset)); } /* * 3rd-6th arguments are optional bits. @@ -5114,19 +4497,23 @@ dissect_amqp_0_10_queue(tvbuff_t *tvb, hf_amqp_0_10_method_queue_declare_auto_delete, tvb, flags_offset, 1, ENC_BIG_ENDIAN); if (flag1 & 0x40) { /* arguments (map) */ - map_length = amqp_0_10_get_32bit_size(tvb, offset); - AMQP_INCREMENT(offset, 4, length); + map_length = amqp_0_10_get_32bit_size_new(args_tree, pinfo, tvb, hf_amqp_0_10_method_queue_declare_arguments_size, offset); + offset += 4; ti = proto_tree_add_item(args_tree, hf_amqp_0_10_method_queue_declare_arguments, tvb, - offset - 4, - map_length + 4, ENC_NA); - dissect_amqp_0_10_map (tvb, - offset, - offset + map_length, - map_length, - ti); - AMQP_INCREMENT(offset, map_length, length); + offset, + map_length, ENC_NA); + if (map_length > (guint32)tvb_reported_length_remaining(tvb, offset)) + { + next_tvb = tvb_new_subset_remaining(tvb, offset); + } + else + { + next_tvb = tvb_new_subset_length(tvb, offset, map_length); + } + dissect_amqp_0_10_map (next_tvb, ti); + /* offset += map_length; */ } break; @@ -5134,11 +4521,10 @@ dissect_amqp_0_10_queue(tvbuff_t *tvb, if ((flag1 & ~0x07) || (flag2 != 0)) expert_add_info(pinfo, flags_item, &ei_amqp_bad_flag_value); if (flag1 & 0x01) { /* queue (name [str8]) */ - str_size = tvb_get_guint8(tvb, offset); proto_tree_add_item(args_tree, hf_amqp_0_10_method_queue_name, - tvb, offset + 1, str_size, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (1 + str_size), length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + /* offset += (1 + tvb_get_guint8(tvb, offset)); */ } /* * 2nd-3rd arguments are optional bits. @@ -5155,11 +4541,10 @@ dissect_amqp_0_10_queue(tvbuff_t *tvb, if ((flag1 & ~0x01) || (flag2 != 0)) expert_add_info(pinfo, flags_item, &ei_amqp_bad_flag_value); if (flag1 & 0x01) { /* queue (name [str8]) */ - str_size = tvb_get_guint8(tvb, offset); proto_tree_add_item(args_tree, hf_amqp_0_10_method_queue_name, - tvb, offset + 1, str_size, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (1 + str_size), length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + /* offset += (1 + tvb_get_guint8(tvb, offset)); */ } break; @@ -5167,11 +4552,10 @@ dissect_amqp_0_10_queue(tvbuff_t *tvb, if ((flag1 & ~0x01) || (flag2 != 0)) expert_add_info(pinfo, flags_item, &ei_amqp_bad_flag_value); if (flag1 & 0x01) { /* queue (name [str8]) */ - str_size = tvb_get_guint8(tvb, offset); proto_tree_add_item(args_tree, hf_amqp_0_10_method_queue_name, - tvb, offset + 1, str_size, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (1 + str_size), length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + /* offset += (1 + tvb_get_guint8(tvb, offset)); */ } break; } @@ -5180,29 +4564,28 @@ dissect_amqp_0_10_queue(tvbuff_t *tvb, static void dissect_amqp_0_10_file(tvbuff_t *tvb, packet_info *pinfo, - proto_tree *tree, - int offset, guint16 length) + proto_tree *tree) { proto_item *args_tree; proto_item *ti; proto_item *flags_item; guint8 method; guint8 flag1, flag2; - guint8 str_size; guint32 map_length; int flags_offset; const gchar *method_name; + int offset = 0; + tvbuff_t *next_tvb; method = tvb_get_guint8(tvb, offset+1); method_name = val_to_str_const(method, amqp_0_10_file_methods, "<invalid file method>"); - col_append_str(pinfo->cinfo, COL_INFO, method_name); - col_append_str(pinfo->cinfo, COL_INFO, " "); + col_append_fstr(pinfo->cinfo, COL_INFO, "%s ", method_name); col_set_fence(pinfo->cinfo, COL_INFO); proto_tree_add_item(tree, hf_amqp_0_10_file_method, tvb, offset+1, 1, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 2, length); + offset += 2; /* * Session header is 2 bytes; one that tells that it's 1 byte long, then * the byte itself. Bit 0 is sync. @@ -5215,10 +4598,10 @@ dissect_amqp_0_10_file(tvbuff_t *tvb, else proto_tree_add_item(tree, hf_amqp_0_10_session_header_sync, tvb, offset + 1, 1, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 2, length); + offset += 2; ti = proto_tree_add_item(tree, hf_amqp_method_arguments, - tvb, offset, length - 4, ENC_NA); + tvb, offset, -1, ENC_NA); args_tree = proto_item_add_subtree(ti, ett_args); /* @@ -5232,7 +4615,7 @@ dissect_amqp_0_10_file(tvbuff_t *tvb, flags_item = proto_tree_add_item(args_tree, hf_amqp_0_10_argument_packing_flags, tvb, offset, 2, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 2, length); + offset += 2; switch (method) { case AMQP_0_10_METHOD_FILE_QOS: if ((flag1 & ~0x07) || (flag2 != 0)) @@ -5241,13 +4624,13 @@ dissect_amqp_0_10_file(tvbuff_t *tvb, proto_tree_add_item(args_tree, hf_amqp_0_10_method_file_qos_prefetch_size, tvb, offset, 4, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 4, length); + offset += 4; } if (flag1 & 0x02) { /* prefetch-count (uint16) */ proto_tree_add_item(args_tree, hf_amqp_0_10_method_file_qos_prefetch_count, tvb, offset, 2, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 2, length); + /* offset += 2; */ } /* * 3rd argument is an optional bit. @@ -5266,18 +4649,16 @@ dissect_amqp_0_10_file(tvbuff_t *tvb, if ((flag1 & ~0x7f) || (flag2 != 0)) expert_add_info(pinfo, flags_item, &ei_amqp_bad_flag_value); if (flag1 & 0x01) { /* queue (queue.name [str8]) */ - str_size = tvb_get_guint8(tvb, offset); proto_tree_add_item(args_tree, hf_amqp_0_10_method_queue_name, - tvb, offset + 1, str_size, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (1 + str_size), length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + offset += (1 + tvb_get_guint8(tvb, offset)); } if (flag1 & 0x02) { /* consumer-tag (str8) */ - str_size = tvb_get_guint8(tvb, offset); proto_tree_add_item(args_tree, hf_amqp_0_10_method_file_consumer_tag, - tvb, offset + 1, str_size, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (1 + str_size), length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + offset += (1 + tvb_get_guint8(tvb, offset)); } /* * 3rd-6th arguments are optional bits. @@ -5295,19 +4676,23 @@ dissect_amqp_0_10_file(tvbuff_t *tvb, hf_amqp_0_10_method_file_consume_nowait, tvb, flags_offset, 1, ENC_BIG_ENDIAN); if (flag1 & 0x40) { /* arguments (map) */ - map_length = amqp_0_10_get_32bit_size(tvb, offset); - AMQP_INCREMENT(offset, 4, length); + map_length = amqp_0_10_get_32bit_size_new(args_tree, pinfo, tvb, hf_amqp_0_10_method_file_consume_arguments_size, offset); + offset += 4; ti = proto_tree_add_item(args_tree, hf_amqp_0_10_method_file_consume_arguments, tvb, - offset - 4, - map_length + 4, ENC_NA); - dissect_amqp_0_10_map (tvb, - offset, - offset + map_length, - map_length, - ti); - AMQP_INCREMENT(offset, map_length, length); + offset, + map_length, ENC_NA); + if (map_length > (guint32)tvb_reported_length_remaining(tvb, offset)) + { + next_tvb = tvb_new_subset_remaining(tvb, offset); + } + else + { + next_tvb = tvb_new_subset_length(tvb, offset, map_length); + } + dissect_amqp_0_10_map (next_tvb, ti); + /* offset += map_length; */ } break; @@ -5316,11 +4701,10 @@ dissect_amqp_0_10_file(tvbuff_t *tvb, if ((flag1 & ~0x01) || (flag2 != 0)) expert_add_info(pinfo, flags_item, &ei_amqp_bad_flag_value); if (flag1 & 0x01) { /* consumer-tag (str8) */ - str_size = tvb_get_guint8(tvb, offset); proto_tree_add_item(args_tree, hf_amqp_0_10_method_file_consumer_tag, - tvb, offset + 1, str_size, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (1 + str_size), length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + /* offset += (1 + tvb_get_guint8(tvb, offset)); */ } break; @@ -5328,17 +4712,16 @@ dissect_amqp_0_10_file(tvbuff_t *tvb, if ((flag1 & ~0x03) || (flag2 != 0)) expert_add_info(pinfo, flags_item, &ei_amqp_bad_flag_value); if (flag1 & 0x01) { /* identifier (str8) */ - str_size = tvb_get_guint8(tvb, offset); proto_tree_add_item(args_tree, hf_amqp_0_10_method_file_identifier, - tvb, offset + 1, str_size, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (1 + str_size), length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + offset += (1 + tvb_get_guint8(tvb, offset)); } if (flag1 & 0x02) { /* content-size (uint64) */ proto_tree_add_item(args_tree, hf_amqp_0_10_method_file_open_content_size, tvb, offset, 8, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 8, length); + /* offset += 8; */ } break; @@ -5349,7 +4732,7 @@ dissect_amqp_0_10_file(tvbuff_t *tvb, proto_tree_add_item(args_tree, hf_amqp_0_10_method_file_open_ok_staged_size, tvb, offset, 8, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 8, length); + /* offset += 8; */ } break; @@ -5357,18 +4740,16 @@ dissect_amqp_0_10_file(tvbuff_t *tvb, if ((flag1 & ~0x1f) || (flag2 != 0)) expert_add_info(pinfo, flags_item, &ei_amqp_bad_flag_value); if (flag1 & 0x01) { /* exchange (exchange.name [str8]) */ - str_size = tvb_get_guint8(tvb, offset); proto_tree_add_item(args_tree, hf_amqp_0_10_method_file_publish_exchange, - tvb, offset + 1, str_size, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (1 + str_size), length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + offset += (1 + tvb_get_guint8(tvb, offset)); } if (flag1 & 0x02) { /* routing-key (str8) */ - str_size = tvb_get_guint8(tvb, offset); proto_tree_add_item(args_tree, hf_amqp_0_10_method_file_publish_routing_key, - tvb, offset + 1, str_size, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (1 + str_size), length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + offset += (1 + tvb_get_guint8(tvb, offset)); } /* * 3rd-4th arguments are optional bits. @@ -5380,11 +4761,10 @@ dissect_amqp_0_10_file(tvbuff_t *tvb, hf_amqp_0_10_method_file_publish_immediate, tvb, flags_offset, 1, ENC_BIG_ENDIAN); if (flag1 & 0x10) { /* identifier (str8) */ - str_size = tvb_get_guint8(tvb, offset); proto_tree_add_item(args_tree, hf_amqp_0_10_method_file_identifier, - tvb, offset + 1, str_size, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (1 + str_size), length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + /* offset += (1 + tvb_get_guint8(tvb, offset)); */ } break; @@ -5395,28 +4775,25 @@ dissect_amqp_0_10_file(tvbuff_t *tvb, proto_tree_add_item(args_tree, hf_amqp_0_10_method_file_return_reply_code, tvb, offset, 2, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 2, length); + offset += 2; } if (flag1 & 0x02) { /* reply-text (str8) */ - str_size = tvb_get_guint8(tvb, offset); proto_tree_add_item(args_tree, hf_amqp_0_10_method_file_return_reply_text, - tvb, offset + 1, str_size, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (1 + str_size), length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + offset += (1 + tvb_get_guint8(tvb, offset)); } if (flag1 & 0x04) { /* exchange (exchange.name [str8]) */ - str_size = tvb_get_guint8(tvb, offset); proto_tree_add_item(args_tree, hf_amqp_0_10_method_file_return_exchange, - tvb, offset + 1, str_size, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (1 + str_size), length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + offset += (1 + tvb_get_guint8(tvb, offset)); } if (flag1 & 0x08) { /* routing-key (str8) */ - str_size = tvb_get_guint8(tvb, offset); proto_tree_add_item(args_tree, hf_amqp_0_10_method_file_return_routing_key, - tvb, offset + 1, str_size, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (1 + str_size), length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + /* offset += (1 + tvb_get_guint8(tvb, offset)); */ } break; @@ -5424,17 +4801,16 @@ dissect_amqp_0_10_file(tvbuff_t *tvb, if ((flag1 & ~0x3f) || (flag2 != 0)) expert_add_info(pinfo, flags_item, &ei_amqp_bad_flag_value); if (flag1 & 0x01) { /* consumer-tag (str8) */ - str_size = tvb_get_guint8(tvb, offset); proto_tree_add_item(args_tree, hf_amqp_0_10_method_file_deliver_consumer_tag, - tvb, offset + 1, str_size, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (1 + str_size), length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + offset += (1 + tvb_get_guint8(tvb, offset)); } if (flag1 & 0x02) { /* delivery-tag (uint64) */ proto_tree_add_item(args_tree, hf_amqp_0_10_method_file_deliver_delivery_tag, tvb, offset, 8, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 8, length); + offset += 8; } /* * 3rd argument is an optional bit. @@ -5443,25 +4819,22 @@ dissect_amqp_0_10_file(tvbuff_t *tvb, hf_amqp_0_10_method_file_deliver_redelivered, tvb, flags_offset, 1, ENC_BIG_ENDIAN); if (flag1 & 0x08) { /* exchange (exchange.name [str8]) */ - str_size = tvb_get_guint8(tvb, offset); proto_tree_add_item(args_tree, hf_amqp_0_10_method_file_deliver_exchange, - tvb, offset + 1, str_size, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (1 + str_size), length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + offset += (1 + tvb_get_guint8(tvb, offset)); } if (flag1 & 0x10) { /* routing-key (str8) */ - str_size = tvb_get_guint8(tvb, offset); proto_tree_add_item(args_tree, hf_amqp_0_10_method_file_deliver_routing_key, - tvb, offset + 1, str_size, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (1 + str_size), length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + offset += (1 + tvb_get_guint8(tvb, offset)); } if (flag1 & 0x20) { /* identifier (str8) */ - str_size = tvb_get_guint8(tvb, offset); proto_tree_add_item(args_tree, hf_amqp_0_10_method_file_identifier, - tvb, offset + 1, str_size, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (1 + str_size), length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + /* offset += (1 + tvb_get_guint8(tvb, offset)); */ } break; @@ -5472,7 +4845,7 @@ dissect_amqp_0_10_file(tvbuff_t *tvb, proto_tree_add_item(args_tree, hf_amqp_0_10_method_file_ack_delivery_tag, tvb, offset, 8, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 8, length); + /* offset += 8; */ } /* * 2nd argument is an optional bit. @@ -5489,7 +4862,7 @@ dissect_amqp_0_10_file(tvbuff_t *tvb, proto_tree_add_item(args_tree, hf_amqp_0_10_method_file_reject_delivery_tag, tvb, offset, 8, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 8, length); + /* offset += 8; */ } /* * 2nd argument is an optional bit. @@ -5504,29 +4877,28 @@ dissect_amqp_0_10_file(tvbuff_t *tvb, static void dissect_amqp_0_10_stream(tvbuff_t *tvb, packet_info *pinfo, - proto_tree *tree, - int offset, guint16 length) + proto_tree *tree) { proto_item *args_tree; proto_item *ti; proto_item *flags_item; guint8 method; guint8 flag1, flag2; - guint8 str_size; guint32 map_length; int flags_offset; const gchar *method_name; + int offset = 0; + tvbuff_t *next_tvb; method = tvb_get_guint8(tvb, offset+1); method_name = val_to_str_const(method, amqp_0_10_stream_methods, "<invalid stream method>"); - col_append_str(pinfo->cinfo, COL_INFO, method_name); - col_append_str(pinfo->cinfo, COL_INFO, " "); + col_append_fstr(pinfo->cinfo, COL_INFO, "%s ", method_name); col_set_fence(pinfo->cinfo, COL_INFO); proto_tree_add_item(tree, hf_amqp_0_10_stream_method, tvb, offset+1, 1, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 2, length); + offset += 2; /* * Session header is 2 bytes; one that tells that it's 1 byte long, then * the byte itself. Bit 0 is sync. @@ -5539,10 +4911,10 @@ dissect_amqp_0_10_stream(tvbuff_t *tvb, else proto_tree_add_item(tree, hf_amqp_0_10_session_header_sync, tvb, offset + 1, 1, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 2, length); + offset += 2; ti = proto_tree_add_item(tree, hf_amqp_method_arguments, - tvb, offset, length - 4, ENC_NA); + tvb, offset, -1, ENC_NA); args_tree = proto_item_add_subtree(ti, ett_args); /* @@ -5556,7 +4928,7 @@ dissect_amqp_0_10_stream(tvbuff_t *tvb, flags_item = proto_tree_add_item(args_tree, hf_amqp_0_10_argument_packing_flags, tvb, offset, 2, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 2, length); + offset += 2; switch (method) { case AMQP_0_10_METHOD_STREAM_QOS: if ((flag1 & ~0x0f) || (flag2 != 0)) @@ -5565,19 +4937,19 @@ dissect_amqp_0_10_stream(tvbuff_t *tvb, proto_tree_add_item(args_tree, hf_amqp_0_10_method_stream_qos_prefetch_size, tvb, offset, 4, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 4, length); + offset += 4; } if (flag1 & 0x02) { /* prefetch-count (uint16) */ proto_tree_add_item(args_tree, hf_amqp_0_10_method_stream_qos_prefetch_count, tvb, offset, 2, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 2, length); + offset += 2; } if (flag1 & 0x04) { /* consume-rate (uint32) */ proto_tree_add_item(args_tree, hf_amqp_0_10_method_stream_qos_prefetch_size, tvb, offset, 4, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 4, length); + /* offset += 4; */ } /* * 4th argument is an optional bit. @@ -5595,18 +4967,16 @@ dissect_amqp_0_10_stream(tvbuff_t *tvb, if ((flag1 & ~0x3f) || (flag2 != 0)) expert_add_info(pinfo, flags_item, &ei_amqp_bad_flag_value); if (flag1 & 0x01) { /* queue (queue.name [str8]) */ - str_size = tvb_get_guint8(tvb, offset); proto_tree_add_item(args_tree, hf_amqp_0_10_method_queue_name, - tvb, offset + 1, str_size, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (1 + str_size), length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + offset += (1 + tvb_get_guint8(tvb, offset)); } if (flag1 & 0x02) { /* consumer-tag (str8) */ - str_size = tvb_get_guint8(tvb, offset); proto_tree_add_item(args_tree, hf_amqp_0_10_method_stream_consumer_tag, - tvb, offset + 1, str_size, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (1 + str_size), length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + offset += (1 + tvb_get_guint8(tvb, offset)); } /* * 3rd-5th arguments are optional bits. @@ -5621,19 +4991,23 @@ dissect_amqp_0_10_stream(tvbuff_t *tvb, hf_amqp_0_10_method_stream_consume_nowait, tvb, flags_offset, 1, ENC_BIG_ENDIAN); if (flag1 & 0x20) { /* arguments (map) */ - map_length = amqp_0_10_get_32bit_size(tvb, offset); - AMQP_INCREMENT(offset, 4, length); + map_length = amqp_0_10_get_32bit_size_new(args_tree, pinfo, tvb, hf_amqp_0_10_method_stream_consume_arguments_size, offset); + offset += 4; ti = proto_tree_add_item(args_tree, hf_amqp_0_10_method_stream_consume_arguments, tvb, - offset - 4, - map_length + 4, ENC_NA); - dissect_amqp_0_10_map (tvb, - offset, - offset + map_length, - map_length, - ti); - AMQP_INCREMENT(offset, map_length, length); + offset, + map_length, ENC_NA); + if (map_length > (guint32)tvb_reported_length_remaining(tvb, offset)) + { + next_tvb = tvb_new_subset_remaining(tvb, offset); + } + else + { + next_tvb = tvb_new_subset_length(tvb, offset, map_length); + } + dissect_amqp_0_10_map (next_tvb, ti); + /* offset += map_length; */ } break; @@ -5642,11 +5016,10 @@ dissect_amqp_0_10_stream(tvbuff_t *tvb, if ((flag1 & ~0x01) || (flag2 != 0)) expert_add_info(pinfo, flags_item, &ei_amqp_bad_flag_value); if (flag1 & 0x01) { /* consumer-tag (str8) */ - str_size = tvb_get_guint8(tvb, offset); proto_tree_add_item(args_tree, hf_amqp_0_10_method_stream_consumer_tag, - tvb, offset + 1, str_size, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (1 + str_size), length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + /* offset += (1 + tvb_get_guint8(tvb, offset)); */ } break; @@ -5654,18 +5027,16 @@ dissect_amqp_0_10_stream(tvbuff_t *tvb, if ((flag1 & ~0x0f) || (flag2 != 0)) expert_add_info(pinfo, flags_item, &ei_amqp_bad_flag_value); if (flag1 & 0x01) { /* exchange (exchange.name [str8]) */ - str_size = tvb_get_guint8(tvb, offset); proto_tree_add_item(args_tree, hf_amqp_0_10_method_stream_publish_exchange, - tvb, offset + 1, str_size, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (1 + str_size), length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + offset += (1 + tvb_get_guint8(tvb, offset)); } if (flag1 & 0x02) { /* routing-key (str8) */ - str_size = tvb_get_guint8(tvb, offset); proto_tree_add_item(args_tree, hf_amqp_0_10_method_stream_publish_routing_key, - tvb, offset + 1, str_size, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (1 + str_size), length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + /* offset += (1 + tvb_get_guint8(tvb, offset)); */ } /* * 3rd-4th arguments are optional bits. @@ -5685,28 +5056,25 @@ dissect_amqp_0_10_stream(tvbuff_t *tvb, proto_tree_add_item(args_tree, hf_amqp_0_10_method_stream_return_reply_code, tvb, offset, 2, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 2, length); + offset += 2; } if (flag1 & 0x02) { /* reply-text (str8) */ - str_size = tvb_get_guint8(tvb, offset); proto_tree_add_item(args_tree, hf_amqp_0_10_method_stream_return_reply_text, - tvb, offset + 1, str_size, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (1 + str_size), length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + offset += (1 + tvb_get_guint8(tvb, offset)); } if (flag1 & 0x04) { /* exchange (exchange.name [str8]) */ - str_size = tvb_get_guint8(tvb, offset); proto_tree_add_item(args_tree, hf_amqp_0_10_method_stream_return_exchange, - tvb, offset + 1, str_size, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (1 + str_size), length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + offset += (1 + tvb_get_guint8(tvb, offset)); } if (flag1 & 0x08) { /* routing-key (str8) */ - str_size = tvb_get_guint8(tvb, offset); proto_tree_add_item(args_tree, hf_amqp_0_10_method_stream_return_routing_key, - tvb, offset + 1, str_size, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (1 + str_size), length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + /* offset += (1 + tvb_get_guint8(tvb, offset)); */ } break; @@ -5714,31 +5082,28 @@ dissect_amqp_0_10_stream(tvbuff_t *tvb, if ((flag1 & ~0x0f) || (flag2 != 0)) expert_add_info(pinfo, flags_item, &ei_amqp_bad_flag_value); if (flag1 & 0x01) { /* consumer-tag (str8) */ - str_size = tvb_get_guint8(tvb, offset); proto_tree_add_item(args_tree, hf_amqp_0_10_method_stream_deliver_consumer_tag, - tvb, offset + 1, str_size, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (1 + str_size), length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + offset += (1 + tvb_get_guint8(tvb, offset)); } if (flag1 & 0x02) { /* delivery-tag (uint64) */ proto_tree_add_item(args_tree, hf_amqp_0_10_method_stream_deliver_delivery_tag, tvb, offset, 8, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 8, length); + offset += 8; } if (flag1 & 0x04) { /* exchange (exchange.name [str8]) */ - str_size = tvb_get_guint8(tvb, offset); proto_tree_add_item(args_tree, hf_amqp_0_10_method_stream_deliver_exchange, - tvb, offset + 1, str_size, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (1 + str_size), length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + offset += (1 + tvb_get_guint8(tvb, offset)); } if (flag1 & 0x08) { /* queue (queue.name [str8]) */ - str_size = tvb_get_guint8(tvb, offset); proto_tree_add_item(args_tree, hf_amqp_0_10_method_stream_deliver_queue, - tvb, offset + 1, str_size, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (1 + str_size), length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + /* offset += (1 + tvb_get_guint8(tvb, offset)); */ } break; } @@ -5747,23 +5112,18 @@ dissect_amqp_0_10_stream(tvbuff_t *tvb, static void dissect_amqp_0_10_struct_delivery_properties(tvbuff_t *tvb, packet_info *pinfo, - proto_tree *tree, - int offset, - guint32 struct_length) + proto_tree *tree) { proto_item *args_tree; proto_item *flags_item; guint8 flag1, flag2; - guint8 len8; - guint16 len16; guint64 timestamp; int flags_offset; - int max_length; nstime_t tv; + int offset = 0; - max_length = offset + AMQP_0_10_SIZE_MAX(struct_length); args_tree = proto_item_add_subtree(tree, ett_args); - AMQP_INCREMENT(offset, 2, max_length); /* Skip class and struct codes */ + offset += 2; /* Skip class and struct codes */ flags_offset = offset; flag1 = tvb_get_guint8(tvb, offset); flag2 = tvb_get_guint8(tvb, offset+1); @@ -5772,7 +5132,7 @@ dissect_amqp_0_10_struct_delivery_properties(tvbuff_t *tvb, tvb, offset, 2, ENC_BIG_ENDIAN); if (flag2 & ~0x0f) expert_add_info(pinfo, flags_item, &ei_amqp_bad_flag_value); - AMQP_INCREMENT(offset, 2, max_length); + offset += 2; /* First 3 fields are bits */ proto_tree_add_item(args_tree, @@ -5789,21 +5149,21 @@ dissect_amqp_0_10_struct_delivery_properties(tvbuff_t *tvb, proto_tree_add_item(args_tree, hf_amqp_0_10_struct_delivery_properties_priority, tvb, offset, 1, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 1, max_length); + offset += 1; } if (flag1 & 0x10) { /* delivery-mode (delivery-mode [uint8]) */ proto_tree_add_item(args_tree, hf_amqp_0_10_struct_delivery_properties_mode, tvb, offset, 1, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 1, max_length); + offset += 1; } if (flag1 & 0x20) { /* ttl (uint64) */ proto_tree_add_item(args_tree, hf_amqp_0_10_struct_delivery_properties_ttl, tvb, offset, 8, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 8, max_length); + offset += 8; } if (flag1 & 0x40) { /* timestamp (datetime [uint64]) */ @@ -5813,7 +5173,7 @@ dissect_amqp_0_10_struct_delivery_properties(tvbuff_t *tvb, proto_tree_add_time(args_tree, hf_amqp_0_10_struct_delivery_properties_timestamp, tvb, offset, 8, &tv); - AMQP_INCREMENT(offset, 8, max_length); + offset += 8; } if (flag1 & 0x80) { /* expiration (datetime [uint64]) */ @@ -5823,57 +5183,51 @@ dissect_amqp_0_10_struct_delivery_properties(tvbuff_t *tvb, proto_tree_add_time(args_tree, hf_amqp_0_10_struct_delivery_properties_expiration, tvb, offset, 8, &tv); - AMQP_INCREMENT(offset, 8, max_length); + offset += 8; } if (flag2 & 0x01) { /* exchange (exchange.name [str8]) */ - len8 = tvb_get_guint8(tvb, offset); proto_tree_add_item(args_tree, hf_amqp_0_10_struct_delivery_properties_exchange, - tvb, offset + 1, len8, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (1 + len8), max_length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + offset += (1 + tvb_get_guint8(tvb, offset)); } if (flag2 & 0x02) { /* routing-key (str8) */ - len8 = tvb_get_guint8(tvb, offset); proto_tree_add_item(args_tree, hf_amqp_0_10_struct_delivery_properties_routing_key, - tvb, offset + 1, len8, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (1 + len8), max_length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + offset += (1 + tvb_get_guint8(tvb, offset)); } if (flag2 & 0x04) { /* resume-id (resume-id [str16]) */ - len16 = tvb_get_ntohs(tvb, offset); proto_tree_add_item(args_tree, hf_amqp_0_10_method_message_resume_id, - tvb, offset + 2, len16, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (2 + len16), max_length); + tvb, offset, 2, ENC_ASCII|ENC_BIG_ENDIAN); + offset += (2 + tvb_get_ntohs(tvb, offset)); } if (flag2 & 0x08) { /* resume-ttl (uint64) */ proto_tree_add_item(args_tree, hf_amqp_0_10_struct_delivery_properties_resume_ttl, tvb, offset, 8, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 8, max_length); + /* offset += 8; */ } } static void dissect_amqp_0_10_struct_fragment_properties(tvbuff_t *tvb, packet_info *pinfo, - proto_tree *tree, - int offset, - guint32 struct_length) + proto_tree *tree) { proto_item *args_tree; proto_item *flags_item; guint8 flag1, flag2; int flags_offset; - int max_length; + int offset = 0; - max_length = offset + AMQP_0_10_SIZE_MAX(struct_length); args_tree = proto_item_add_subtree(tree, ett_args); - AMQP_INCREMENT(offset, 2, max_length); /* Skip class and struct codes */ + offset += 2; /* Skip class and struct codes */ flags_offset = offset; flag1 = tvb_get_guint8(tvb, offset); flag2 = tvb_get_guint8(tvb, offset+1); @@ -5882,7 +5236,7 @@ dissect_amqp_0_10_struct_fragment_properties(tvbuff_t *tvb, tvb, offset, 2, ENC_BIG_ENDIAN); if ((flag1 & ~0x07) || (flag2 != 0)) expert_add_info(pinfo, flags_item, &ei_amqp_bad_flag_value); - AMQP_INCREMENT(offset, 2, max_length); + offset += 2; /* First 2 fields are bits */ proto_tree_add_item(args_tree, @@ -5896,16 +5250,14 @@ dissect_amqp_0_10_struct_fragment_properties(tvbuff_t *tvb, proto_tree_add_item(args_tree, hf_amqp_0_10_struct_fragment_properties_size, tvb, offset, 8, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 8, max_length); + /* offset += 8; */ } } static void dissect_amqp_0_10_struct_message_properties(tvbuff_t *tvb, packet_info *pinfo, - proto_tree *tree, - int offset, - guint32 struct_length) + proto_tree *tree) { proto_item *ti; proto_item *frag; @@ -5913,15 +5265,13 @@ dissect_amqp_0_10_struct_message_properties(tvbuff_t *tvb, proto_item *flags_item, *subflags_item; guint8 flag1, flag2; guint8 subflag1, subflag2; - guint8 len8; guint16 len16; guint32 map_length; - e_guid_t uuid; - int max_length; + int offset = 0; + tvbuff_t *next_tvb; - max_length = offset + AMQP_0_10_SIZE_MAX(struct_length); frag = proto_item_add_subtree(tree, ett_args); - AMQP_INCREMENT(offset, 2, max_length); /* Skip class and struct codes */ + offset += 2; /* Skip class and struct codes */ flag1 = tvb_get_guint8(tvb, offset); flag2 = tvb_get_guint8(tvb, offset+1); flags_item = proto_tree_add_item(frag, @@ -5929,35 +5279,33 @@ dissect_amqp_0_10_struct_message_properties(tvbuff_t *tvb, tvb, offset, 2, ENC_BIG_ENDIAN); if (flag2 & ~0x01) expert_add_info(pinfo, flags_item, &ei_amqp_bad_flag_value); - AMQP_INCREMENT(offset, 2, max_length); + offset += 2; if (flag1 & 0x01) { /* content-length (uint64) */ proto_tree_add_item(frag, hf_amqp_0_10_struct_message_properties_content_len, tvb, offset, 8, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 8, max_length); + offset += 8; } if (flag1 & 0x02) { /* message-id (uuid) */ - tvb_get_guid(tvb, offset, &uuid, ENC_BIG_ENDIAN); - proto_tree_add_guid(frag, + proto_tree_add_item(frag, hf_amqp_0_10_struct_message_properties_message_id, - tvb, offset, 16, &uuid); - AMQP_INCREMENT(offset, 16, max_length); + tvb, offset, 16, ENC_BIG_ENDIAN); + offset += 16; } if (flag1 & 0x04) { /* correlation-id (vbin16) */ - len16 = tvb_get_ntohs(tvb, offset); proto_tree_add_item(frag, hf_amqp_0_10_struct_message_properties_correlation, - tvb, offset + 2, len16, ENC_NA); - AMQP_INCREMENT(offset, (2 + len16), max_length); + tvb, offset, 2, ENC_BIG_ENDIAN); + offset += (2 + tvb_get_ntohs(tvb, offset)); } if (flag1 & 0x08) { /* reply-to (reply-to) */ /* This is another struct, length 2, packing 2 */ len16 = tvb_get_ntohs(tvb, offset); - AMQP_INCREMENT(offset, 2, max_length); + offset += 2; ti = proto_tree_add_item(frag, hf_amqp_0_10_struct_message_properties_reply_to, tvb, offset, len16, ENC_NA); @@ -5969,93 +5317,88 @@ dissect_amqp_0_10_struct_message_properties(tvbuff_t *tvb, subflag2 = tvb_get_guint8(tvb, offset + 1); if ((subflag1 & ~0x03) || (subflag2 != 0)) expert_add_info(pinfo, subflags_item, &ei_amqp_bad_flag_value); - AMQP_INCREMENT(offset, 2, max_length); + offset += 2; if (subflag1 & 0x01) { /* exchange (str8) */ - len8 = tvb_get_guint8(tvb, offset); proto_tree_add_item(args_tree, hf_amqp_0_10_struct_reply_to_exchange, - tvb, offset + 1, len8, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (1 + len8), max_length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + offset += (1 + tvb_get_guint8(tvb, offset)); } if (subflag1 & 0x02) { /* routing-key (str8) */ - len8 = tvb_get_guint8(tvb, offset); proto_tree_add_item(args_tree, hf_amqp_0_10_struct_reply_to_routing_key, - tvb, offset + 1, len8, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (1 + len8), max_length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + offset += (1 + tvb_get_guint8(tvb, offset)); } } if (flag1 & 0x10) { /* content-type (str8) */ - len8 = tvb_get_guint8(tvb, offset); proto_tree_add_item(frag, hf_amqp_0_10_struct_message_properties_content_type, - tvb, offset + 1, len8, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (1 + len8), max_length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + offset += (1 + tvb_get_guint8(tvb, offset)); } if (flag1 & 0x20) { /* content-encoding (str8) */ - len8 = tvb_get_guint8(tvb, offset); proto_tree_add_item(frag, hf_amqp_0_10_struct_message_properties_content_encoding, - tvb, offset + 1, len8, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (1 + len8), max_length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + offset += (1 + tvb_get_guint8(tvb, offset)); } if (flag1 & 0x40) { /* user-id (vbin16 ) */ - len16 = tvb_get_ntohs(tvb, offset); proto_tree_add_item(frag, hf_amqp_0_10_struct_message_properties_user_id, - tvb, offset + 2, len16, ENC_NA); - AMQP_INCREMENT(offset, (2 + len16), max_length); + tvb, offset, 2, ENC_BIG_ENDIAN); + offset += (2 + tvb_get_ntohs(tvb, offset)); } if (flag1 & 0x80) { /* app-id (vbin16 ) */ - len16 = tvb_get_ntohs(tvb, offset); proto_tree_add_item(frag, hf_amqp_0_10_struct_message_properties_app_id, - tvb, offset + 2, len16, ENC_NA); - AMQP_INCREMENT(offset, (2 + len16), max_length); + tvb, offset, 2, ENC_BIG_ENDIAN); + offset += (2 + tvb_get_ntohs(tvb, offset)); } if (flag2 & 0x01) { /* application-headers (map) */ - map_length = amqp_0_10_get_32bit_size(tvb, offset); - AMQP_INCREMENT(offset, 4, max_length); + map_length = amqp_0_10_get_32bit_size_new(frag, pinfo, tvb, hf_amqp_0_10_struct_message_properties_application_headers_size, offset); + offset += 4; ti = proto_tree_add_item(frag, hf_amqp_0_10_struct_message_properties_application_headers, tvb, offset, map_length, ENC_NA); - dissect_amqp_0_10_map (tvb, - offset, - offset + map_length, - map_length, - ti); - AMQP_INCREMENT(offset, map_length, max_length); + if (map_length > (guint32)tvb_reported_length_remaining(tvb, offset)) + { + next_tvb = tvb_new_subset_remaining(tvb, offset); + } + else + { + next_tvb = tvb_new_subset_length(tvb, offset, map_length); + } + dissect_amqp_0_10_map (next_tvb, ti); + /* offset += map_length; */ } } static void dissect_amqp_0_10_struct_exchange_query_result(tvbuff_t *tvb, packet_info *pinfo, - proto_item *tree, - int offset, - guint32 struct_length) + proto_item *tree) { proto_item *ti; proto_item *result; proto_item *flags_item; guint8 flag1, flag2; - guint8 len8; guint32 map_length; int flags_offset; - int max_length; + int offset = 0; + tvbuff_t *next_tvb; - max_length = offset + AMQP_0_10_SIZE_MAX(struct_length); result = proto_item_add_subtree(tree, ett_args); - AMQP_INCREMENT(offset, 2, max_length); /* Skip class and struct codes */ + offset += 2; /* Skip class and struct codes */ flags_offset = offset; flag1 = tvb_get_guint8(tvb, offset); flag2 = tvb_get_guint8(tvb, offset+1); @@ -6064,14 +5407,13 @@ dissect_amqp_0_10_struct_exchange_query_result(tvbuff_t *tvb, tvb, offset, 2, ENC_BIG_ENDIAN); if (flag2 & ~0x0f) expert_add_info(pinfo, flags_item, &ei_amqp_bad_flag_value); - AMQP_INCREMENT(offset, 2, max_length); + offset += 2; if (flag1 & 0x01) { /* type (str8) */ - len8 = tvb_get_guint8(tvb, offset); proto_tree_add_item(result, hf_amqp_0_10_method_exchange_declare_type, - tvb, offset + 1, len8, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (1 + len8), max_length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + offset += (1 + tvb_get_guint8(tvb, offset)); } proto_tree_add_item(result, hf_amqp_0_10_struct_exchange_query_result_durable, @@ -6081,41 +5423,42 @@ dissect_amqp_0_10_struct_exchange_query_result(tvbuff_t *tvb, tvb, flags_offset, 1, ENC_BIG_ENDIAN); if (flag1 & 0x08) { /* arguments (map) */ - map_length = amqp_0_10_get_32bit_size(tvb, offset); - AMQP_INCREMENT(offset, 4, max_length); + map_length = amqp_0_10_get_32bit_size_new(result, pinfo, tvb, hf_amqp_0_10_method_exchange_declare_arguments_size, offset); + offset += 4; ti = proto_tree_add_item(result, hf_amqp_0_10_method_exchange_declare_arguments, tvb, - offset - 4, - map_length + 4, ENC_NA); - dissect_amqp_0_10_map (tvb, - offset, - offset + map_length, - map_length, - ti); - AMQP_INCREMENT(offset, map_length, max_length); + offset, + map_length, ENC_NA); + if (map_length > (guint32)tvb_reported_length_remaining(tvb, offset)) + { + next_tvb = tvb_new_subset_remaining(tvb, offset); + } + else + { + next_tvb = tvb_new_subset_length(tvb, offset, map_length); + } + dissect_amqp_0_10_map (next_tvb, ti); + /* offset += map_length; */ } } static void dissect_amqp_0_10_struct_queue_query_result(tvbuff_t *tvb, packet_info *pinfo, - proto_item *tree, - int offset, - guint32 struct_length) + proto_item *tree) { proto_item *ti; proto_item *result; proto_item *flags_item; guint8 flag1, flag2; - guint8 len8; guint32 map_length; int flags_offset; - int max_length; + int offset = 0; + tvbuff_t *next_tvb; - max_length = offset + AMQP_0_10_SIZE_MAX(struct_length); result = proto_item_add_subtree(tree, ett_args); - AMQP_INCREMENT(offset, 2, max_length); /* Skip class and struct codes */ + offset += 2; /* Skip class and struct codes */ flags_offset = offset; flag1 = tvb_get_guint8(tvb, offset); flag2 = tvb_get_guint8(tvb, offset+1); @@ -6125,21 +5468,19 @@ dissect_amqp_0_10_struct_queue_query_result(tvbuff_t *tvb, if (flag2 != 0) expert_add_info(pinfo, flags_item, &ei_amqp_bad_flag_value); - AMQP_INCREMENT(offset, 2, max_length); + offset += 2; if (flag1 & 0x01) { /* queue (name [str8]) */ - len8 = tvb_get_guint8(tvb, offset); proto_tree_add_item(result, hf_amqp_0_10_method_queue_name, - tvb, offset + 1, len8, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (1 + len8), max_length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + offset += (1 + tvb_get_guint8(tvb, offset)); } if (flag1 & 0x02) { /* alternate-exchange (exchange.name [str8]) */ - len8 = tvb_get_guint8(tvb, offset); proto_tree_add_item(result, hf_amqp_0_10_method_queue_alt_exchange, - tvb, offset + 1, len8, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (1 + len8), max_length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + offset += (1 + tvb_get_guint8(tvb, offset)); } /* * 3rd-5th arguments are optional bits. @@ -6154,54 +5495,55 @@ dissect_amqp_0_10_struct_queue_query_result(tvbuff_t *tvb, hf_amqp_0_10_struct_queue_query_result_auto_delete, tvb, flags_offset, 1, ENC_BIG_ENDIAN); if (flag1 & 0x20) { /* arguments (map) */ - map_length = amqp_0_10_get_32bit_size(tvb, offset); - AMQP_INCREMENT(offset, 4, max_length); + map_length = amqp_0_10_get_32bit_size_new(result, pinfo, tvb, hf_amqp_0_10_method_queue_declare_arguments_size, offset); + offset += 4; ti = proto_tree_add_item(result, hf_amqp_0_10_method_queue_declare_arguments, tvb, - offset - 4, - map_length + 4, ENC_NA); - dissect_amqp_0_10_map (tvb, - offset, - offset + map_length, - map_length, - ti); - AMQP_INCREMENT(offset, (int)map_length, max_length); + offset, + map_length, ENC_NA); + if (map_length > (guint32)tvb_reported_length_remaining(tvb, offset)) + { + next_tvb = tvb_new_subset_remaining(tvb, offset); + } + else + { + next_tvb = tvb_new_subset_length(tvb, offset, map_length); + } + dissect_amqp_0_10_map (next_tvb, ti); + offset += map_length; } if (flag1 & 0x40) { /* message-count (uint32) */ proto_tree_add_item(result, hf_amqp_0_10_struct_queue_query_result_message_count, tvb, offset, 4, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 4, max_length); + offset += 4; } if (flag1 & 0x80) { /* subscriber-count (uint32) */ proto_tree_add_item(result, hf_amqp_0_10_struct_queue_query_result_subscriber_count, tvb, offset, 4, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 4, max_length); + /* offset += 4; */ } } static void dissect_amqp_0_10_struct_file_properties(tvbuff_t *tvb, packet_info *pinfo, - proto_tree *tree, - int offset, - guint32 struct_length) + proto_tree *tree) { proto_item *ti; proto_item *props; proto_item *flags_item; guint8 flag1, flag2; - guint8 len8; guint32 map_length; guint64 timestamp; - int max_length; + int offset = 0; nstime_t tv; + tvbuff_t *next_tvb; - max_length = offset + AMQP_0_10_SIZE_MAX(struct_length); props = proto_item_add_subtree(tree, ett_args); - AMQP_INCREMENT(offset, 2, max_length); /* Skip class and struct codes */ + offset += 2; /* Skip class and struct codes */ flag1 = tvb_get_guint8(tvb, offset); flag2 = tvb_get_guint8(tvb, offset+1); flags_item = proto_tree_add_item(props, @@ -6209,69 +5551,68 @@ dissect_amqp_0_10_struct_file_properties(tvbuff_t *tvb, tvb, offset, 2, ENC_BIG_ENDIAN); if (flag2 & ~0x01) expert_add_info(pinfo, flags_item, &ei_amqp_bad_flag_value); - AMQP_INCREMENT(offset, 2, max_length); + offset += 2; if (flag1 & 0x01) { /* content-type (str8) */ - len8 = tvb_get_guint8(tvb, offset); proto_tree_add_item(props, hf_amqp_0_10_struct_file_properties_content_type, - tvb, offset + 1, len8, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (1 + len8), max_length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + offset += (1 + tvb_get_guint8(tvb, offset)); } if (flag1 & 0x02) { /* content-encoding (str8) */ - len8 = tvb_get_guint8(tvb, offset); proto_tree_add_item(props, hf_amqp_0_10_struct_file_properties_content_encoding, - tvb, offset + 1, len8, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (1 + len8), max_length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + offset += (1 + tvb_get_guint8(tvb, offset)); } if (flag1 & 0x04) { /* headers (map) */ - map_length = amqp_0_10_get_32bit_size(tvb, offset); - AMQP_INCREMENT(offset, 4, max_length); + map_length = amqp_0_10_get_32bit_size_new(props, pinfo, tvb, hf_amqp_0_10_struct_file_properties_headers_size, offset); + offset += 4; ti = proto_tree_add_item(props, hf_amqp_0_10_struct_file_properties_headers, tvb, offset, map_length, ENC_NA); - dissect_amqp_0_10_map (tvb, - offset, - offset + map_length, - map_length, - ti); - AMQP_INCREMENT(offset, map_length, max_length); + if (map_length > (guint32)tvb_reported_length_remaining(tvb, offset)) + { + next_tvb = tvb_new_subset_remaining(tvb, offset); + } + else + { + next_tvb = tvb_new_subset_length(tvb, offset, map_length); + } + dissect_amqp_0_10_map (next_tvb, ti); + offset += map_length; } if (flag1 & 0x08) { /* priority (uint8) */ proto_tree_add_item(props, hf_amqp_0_10_struct_file_properties_priority, tvb, offset, 1, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 1, max_length); + offset += 1; } if (flag1 & 0x10) { /* reply-to (str8) */ - len8 = tvb_get_guint8(tvb, offset); proto_tree_add_item(props, hf_amqp_0_10_struct_file_properties_reply_to, - tvb, offset + 1, len8, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (1 + len8), max_length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + offset += (1 + tvb_get_guint8(tvb, offset)); } if (flag1 & 0x20) { /* message-id (str8) */ - len8 = tvb_get_guint8(tvb, offset); proto_tree_add_item(props, hf_amqp_0_10_struct_file_properties_message_id, - tvb, offset + 1, len8, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (1 + len8), max_length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + offset += (1 + tvb_get_guint8(tvb, offset)); } if (flag1 & 0x40) { /* filename (str8) */ - len8 = tvb_get_guint8(tvb, offset); proto_tree_add_item(props, hf_amqp_0_10_struct_file_properties_filename, - tvb, offset + 1, len8, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (1 + len8), max_length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + offset += (1 + tvb_get_guint8(tvb, offset)); } if (flag1 & 0x80) { /* timestamp (datetime [uint64]) */ @@ -6281,38 +5622,34 @@ dissect_amqp_0_10_struct_file_properties(tvbuff_t *tvb, proto_tree_add_time(props, hf_amqp_0_10_struct_file_properties_timestamp, tvb, offset, 8, &tv); - AMQP_INCREMENT(offset, 8, max_length); + offset += 8; } if (flag2 & 0x01) { /* cluster-id (str8) */ - len8 = tvb_get_guint8(tvb, offset); proto_tree_add_item(props, hf_amqp_0_10_struct_file_properties_cluster_id, - tvb, offset + 1, len8, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (1 + len8), max_length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + /* offset += (1 + tvb_get_guint8(tvb, offset)); */ } } static void dissect_amqp_0_10_struct_stream_properties(tvbuff_t *tvb, packet_info *pinfo, - proto_tree *tree, - int offset, - guint32 struct_length) + proto_tree *tree) { proto_item *ti; proto_item *props; proto_item *flags_item; guint8 flag1, flag2; - guint8 len8; guint32 map_length; guint64 timestamp; - int max_length; + int offset = 0; nstime_t tv; + tvbuff_t *next_tvb; - max_length = offset + AMQP_0_10_SIZE_MAX(struct_length); props = proto_item_add_subtree(tree, ett_args); - AMQP_INCREMENT(offset, 2, max_length); /* Skip class and struct codes */ + offset += 2; /* Skip class and struct codes */ flag1 = tvb_get_guint8(tvb, offset); flag2 = tvb_get_guint8(tvb, offset+1); flags_item = proto_tree_add_item(props, @@ -6320,45 +5657,47 @@ dissect_amqp_0_10_struct_stream_properties(tvbuff_t *tvb, tvb, offset, 2, ENC_BIG_ENDIAN); if ((flag1 & ~0x1f) || (flag2 != 0)) expert_add_info(pinfo, flags_item, &ei_amqp_bad_flag_value); - AMQP_INCREMENT(offset, 2, max_length); + offset += 2; if (flag1 & 0x01) { /* content-type (str8) */ - len8 = tvb_get_guint8(tvb, offset); proto_tree_add_item(props, hf_amqp_0_10_struct_stream_properties_content_type, - tvb, offset + 1, len8, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (1 + len8), max_length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + offset += (1 + tvb_get_guint8(tvb, offset)); } if (flag1 & 0x02) { /* content-encoding (str8) */ - len8 = tvb_get_guint8(tvb, offset); proto_tree_add_item(props, hf_amqp_0_10_struct_stream_properties_content_encoding, - tvb, offset + 1, len8, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, (1 + len8), max_length); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + offset += (1 + tvb_get_guint8(tvb, offset)); } if (flag1 & 0x04) { /* headers (map) */ - map_length = amqp_0_10_get_32bit_size(tvb, offset); - AMQP_INCREMENT(offset, 4, max_length); + map_length = amqp_0_10_get_32bit_size_new(props, pinfo, tvb, hf_amqp_0_10_struct_stream_properties_headers_size, offset); + offset += 4; ti = proto_tree_add_item(props, hf_amqp_0_10_struct_stream_properties_headers, tvb, offset, map_length, ENC_NA); - dissect_amqp_0_10_map (tvb, - offset, - offset + map_length, - map_length, - ti); - AMQP_INCREMENT(offset, map_length, max_length); + if (map_length > (guint32)tvb_reported_length_remaining(tvb, offset)) + { + next_tvb = tvb_new_subset_remaining(tvb, offset); + } + else + { + next_tvb = tvb_new_subset_length(tvb, offset, map_length); + } + dissect_amqp_0_10_map (next_tvb, ti); + offset += map_length; } if (flag1 & 0x08) { /* priority (uint8) */ proto_tree_add_item(props, hf_amqp_0_10_struct_stream_properties_priority, tvb, offset, 1, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 1, max_length); + offset += 1; } if (flag1 & 0x10) { /* timestamp (datetime [uint64]) */ @@ -6368,86 +5707,67 @@ dissect_amqp_0_10_struct_stream_properties(tvbuff_t *tvb, proto_tree_add_time(props, hf_amqp_0_10_struct_stream_properties_timestamp, tvb, offset, 8, &tv); - AMQP_INCREMENT(offset, 8, max_length); + /* offset += 8; */ } } static void dissect_amqp_0_10_struct32(tvbuff_t *tvb, packet_info *pinfo, - proto_tree *tree, - int offset, - guint32 struct_length) + proto_item *ti) { - guint8 class_code; - guint8 struct_code; + guint32 class_code, struct_code; guint8 flag1; guint16 size; - guint16 value; - guint32 array_length; - guint32 consumed; - proto_tree *ti; - proto_tree *result; + proto_item *ti2, *result; + proto_tree *tree; + int offset = 0; - consumed = 0; - class_code = tvb_get_guint8(tvb, offset); - struct_code = tvb_get_guint8(tvb, offset + 1); + tree = proto_item_add_subtree(ti, ett_args); + + proto_tree_add_item_ret_uint(tree, hf_amqp_0_10_struct32_class, tvb, offset, 1, ENC_NA, &class_code); + proto_tree_add_item_ret_uint(tree, hf_amqp_0_10_struct32_struct, tvb, offset+1, 1, ENC_NA, &struct_code); switch(class_code) { case AMQP_0_10_CLASS_MESSAGE: switch (struct_code) { case AMQP_0_10_STRUCT_MESSAGE_DELIVERY_PROPERTIES: - proto_item_set_text(tree, "message.delivery-properties"); dissect_amqp_0_10_struct_delivery_properties(tvb, pinfo, - tree, - offset, - struct_length); + tree); break; case AMQP_0_10_STRUCT_MESSAGE_FRAGMENT_PROPERTIES: - proto_item_set_text(tree, "message.fragment-properties"); dissect_amqp_0_10_struct_fragment_properties(tvb, pinfo, - tree, - offset, - struct_length); + tree); break; case AMQP_0_10_STRUCT_MESSAGE_MESSAGE_PROPERTIES: - proto_item_set_text(tree, "message.message-properties"); dissect_amqp_0_10_struct_message_properties(tvb, pinfo, - tree, - offset, - struct_length); + tree); break; case AMQP_0_10_STRUCT_MESSAGE_ACQUIRED: - proto_item_set_text(tree, "message.acquired"); result = proto_item_add_subtree(tree, ett_args); - AMQP_INCREMENT(consumed, 2, struct_length); /* Class/type codes */ - offset += 2; + offset += 2; /* Class/type codes */ flag1 = tvb_get_guint8(tvb, offset); proto_tree_add_item(result, hf_amqp_0_10_argument_packing_flags, tvb, offset, 2, ENC_BIG_ENDIAN); - AMQP_INCREMENT(consumed, 2, struct_length); offset += 2; if (flag1 & 0x01) { /* transfers (commands [sequence-set]) */ size = tvb_get_ntohs(tvb, offset); - ti = proto_tree_add_item(result, + ti2 = proto_tree_add_item(result, hf_amqp_0_10_struct_acquired_transfers, tvb, offset, size + 2, ENC_NA); - format_amqp_0_10_sequence_set(tvb, offset + 2, size, ti); + format_amqp_0_10_sequence_set(tvb, offset + 2, size, ti2); } break; case AMQP_0_10_STRUCT_MESSAGE_RESUME_RESULT: - proto_item_set_text(tree, "message.resume-result"); result = proto_item_add_subtree(tree, ett_args); - AMQP_INCREMENT(consumed, 2, struct_length); /* Class/type codes */ - offset += 2; + offset += 2; /* Class/type codes */ flag1 = tvb_get_guint8(tvb, offset); proto_tree_add_item(result, hf_amqp_0_10_argument_packing_flags, tvb, offset, 2, ENC_BIG_ENDIAN); - AMQP_INCREMENT(consumed, 2, struct_length); offset += 2; if (flag1 & 0x01) { /* offset (uint64) */ @@ -6462,35 +5782,22 @@ dissect_amqp_0_10_struct32(tvbuff_t *tvb, case AMQP_0_10_CLASS_DTX: switch (struct_code) { case AMQP_0_10_STRUCT_DTX_XA_RESULT: - AMQP_INCREMENT(consumed, 2, struct_length); /* Class/type codes */ - offset += 2; + offset += 2; /* Class/type codes */ /*flag1 = tvb_get_guint8(tvb, offset);*/ - AMQP_INCREMENT(consumed, 2, struct_length); /* Packing bytes */ + proto_tree_add_item(tree, hf_amqp_0_10_struct32_padding, tvb, offset, 2, ENC_NA); offset += 2; - value = tvb_get_ntohs(tvb, offset); - AMQP_INCREMENT(consumed, 2, struct_length); /* xa status value */ - /*offset += 2;*/ - proto_item_set_text(tree, "dtx.xa-status: %s", - val_to_str(value, - amqp_0_10_xa_status, - "Invalid xa-status %d")); + proto_tree_add_item(tree, hf_amqp_0_10_dtx_xa_status, tvb, offset, 2, ENC_BIG_ENDIAN); break; case AMQP_0_10_STRUCT_DTX_RECOVER_RESULT: - proto_item_set_text(tree, "dtx.recover-result"); - AMQP_INCREMENT(consumed, 2, struct_length); /* Class/type codes */ + offset += 2; /* Class/type codes */ + proto_tree_add_item(tree, hf_amqp_0_10_struct32_padding, tvb, offset, 2, ENC_NA); offset += 2; - /*flag1 = tvb_get_guint8(tvb, offset);*/ - AMQP_INCREMENT(consumed, 2, struct_length); /* Packing bytes */ - offset += 2; - array_length = amqp_0_10_get_32bit_size(tvb, offset); - AMQP_INCREMENT(consumed, 4, struct_length); + amqp_0_10_get_32bit_size_new(tree, pinfo, tvb, hf_amqp_0_10_struct_dtx_recover_result_size, offset); offset += 4; dissect_amqp_0_10_array(tvb, pinfo, offset, - offset + array_length, - array_length, tree); break; } @@ -6499,19 +5806,14 @@ dissect_amqp_0_10_struct32(tvbuff_t *tvb, case AMQP_0_10_CLASS_EXCHANGE: switch (struct_code) { case AMQP_0_10_STRUCT_EXCHANGE_QUERY_RESULT: - proto_item_set_text(tree, "exchange.exchange-query-result"); dissect_amqp_0_10_struct_exchange_query_result(tvb, pinfo, - tree, - offset, - struct_length); + tree); break; case AMQP_0_10_STRUCT_EXCHANGE_BOUND_RESULT: - proto_item_set_text(tree, "exchange.exchange-bound-result"); result = proto_item_add_subtree(tree, ett_args); - AMQP_INCREMENT(consumed, 2, struct_length); /* Class/type codes */ - offset += 2; + offset += 2; /* Class/type codes */ proto_tree_add_item(result, hf_amqp_0_10_struct_exchange_bound_result_exchange_not_found, tvb, offset, 1, ENC_BIG_ENDIAN); @@ -6534,12 +5836,7 @@ dissect_amqp_0_10_struct32(tvbuff_t *tvb, case AMQP_0_10_CLASS_QUEUE: switch (struct_code) { case AMQP_0_10_STRUCT_QUEUE_QUERY_RESULT: - proto_item_set_text(tree, "queue.queue-query-result"); - dissect_amqp_0_10_struct_queue_query_result(tvb, - pinfo, - tree, - offset, - struct_length); + dissect_amqp_0_10_struct_queue_query_result(tvb, pinfo, tree); break; } break; @@ -6547,12 +5844,7 @@ dissect_amqp_0_10_struct32(tvbuff_t *tvb, case AMQP_0_10_CLASS_FILE: switch (struct_code) { case AMQP_0_10_STRUCT_FILE_PROPERTIES: - proto_item_set_text(tree, "file.file-properties"); - dissect_amqp_0_10_struct_file_properties(tvb, - pinfo, - tree, - offset, - struct_length); + dissect_amqp_0_10_struct_file_properties(tvb, pinfo, tree); break; } break; @@ -6560,12 +5852,7 @@ dissect_amqp_0_10_struct32(tvbuff_t *tvb, case AMQP_0_10_CLASS_STREAM: switch (struct_code) { case AMQP_0_10_STRUCT_STREAM_PROPERTIES: - proto_item_set_text(tree, "stream.stream-properties"); - dissect_amqp_0_10_struct_stream_properties(tvb, - pinfo, - tree, - offset, - struct_length); + dissect_amqp_0_10_struct_stream_properties(tvb, pinfo, tree); break; } break; @@ -6588,7 +5875,6 @@ static guint dissect_amqp_1_0_list(tvbuff_t *tvb, packet_info *pinfo, int offset, - int bound, proto_item *item, int hf_amqp_type, guint32 hf_amqp_subtype_count, @@ -6598,7 +5884,7 @@ dissect_amqp_1_0_list(tvbuff_t *tvb, proto_item *list_tree; guint8 type; guint8 count_len; - guint32 element_count; + guint32 i, element_count; guint32 element_size; guint32 decoded_element_size; guint32 orig_offset; @@ -6609,17 +5895,8 @@ dissect_amqp_1_0_list(tvbuff_t *tvb, decoded_elements = 0; orig_offset = offset; - if (proto_registrar_get_ftype(hf_amqp_type) != FT_NONE) - { - expert_add_info_format(pinfo, item, &ei_amqp_unknown_amqp_type, - "Unexpected list type at frame position %d of field \"%s\"", - offset, - name ? name : proto_registrar_get_name(hf_amqp_type)); - return bound-orig_offset; - } - type = tvb_get_guint8(tvb, offset); - AMQP_INCREMENT(offset, 1, bound); + offset += 1; switch (type) { case AMQP_1_0_TYPE_LIST0: count_len = 0; @@ -6647,7 +5924,7 @@ dissect_amqp_1_0_list(tvbuff_t *tvb, &ei_amqp_unknown_amqp_type, "Unknown AMQP list type %d", type); - return bound-orig_offset; + return 0; } list_tree = proto_tree_add_none_format(item, @@ -6657,14 +5934,14 @@ dissect_amqp_1_0_list(tvbuff_t *tvb, element_size+1+count_len, "%s", name ? name : proto_registrar_get_name(hf_amqp_type)); - AMQP_INCREMENT(offset, count_len*2, bound); + offset += (count_len*2); if (element_count > 0) list_tree = proto_item_add_subtree(list_tree, ett_amqp_1_0_list); /* display the item count for custom lists only * standard structures contain NULL items, so the real element count is different */ if (hf_amqp_subtype_count == 0) - proto_item_append_text(list_tree, " (list of %d element%s)", element_count, element_suffix[element_count!=1]); + proto_item_append_text(list_tree, " (list of %d element%s)", element_count, plurality(element_count, "", "s")); if (element_count > element_size) { @@ -6673,10 +5950,10 @@ dissect_amqp_1_0_list(tvbuff_t *tvb, &ei_amqp_invalid_number_of_params, "Number of list elements (%d) bigger than list size (%d)", element_count, element_size); - return bound-orig_offset; + return 0; } - while ((element_count > 0) && (offset < bound)) { + for (i = 0; ((i < element_count) && (tvb_reported_length_remaining(tvb, offset) > 0)); i++) { decoded_element_size = 0; if (decoded_elements<hf_amqp_subtype_count) hf_amqp_item = *(hf_amqp_subtypes[decoded_elements]); @@ -6685,16 +5962,14 @@ dissect_amqp_1_0_list(tvbuff_t *tvb, get_amqp_1_0_type_value_formatter(tvb, pinfo, offset, - bound, hf_amqp_item, NULL, &decoded_element_size, list_tree); - element_count -= 1; decoded_elements += 1; - AMQP_INCREMENT(offset, decoded_element_size, bound); + offset += decoded_element_size; } - if (element_count > 0) + if (i != element_count) expert_add_info_format(pinfo, list_tree, &ei_amqp_invalid_number_of_params, @@ -6710,7 +5985,6 @@ static guint dissect_amqp_1_0_map(tvbuff_t *tvb, packet_info *pinfo, int offset, - int bound, proto_item *item, int hf_amqp_type, const char *name) @@ -6728,17 +6002,8 @@ dissect_amqp_1_0_map(tvbuff_t *tvb, map_tree = 0; orig_offset = offset; - if (proto_registrar_get_ftype(hf_amqp_type) != FT_NONE) - { - expert_add_info_format(pinfo, item, &ei_amqp_unknown_amqp_type, - "Unexpected map type at frame position %d of field \"%s\"", - offset, - name ? name : proto_registrar_get_name(hf_amqp_type)); - return bound-orig_offset; - } - type = tvb_get_guint8(tvb, offset); - AMQP_INCREMENT(offset, 1, bound); + offset += 1; switch (type) { case AMQP_1_0_TYPE_MAP8: count_len = 1; @@ -6761,7 +6026,7 @@ dissect_amqp_1_0_map(tvbuff_t *tvb, &ei_amqp_unknown_amqp_type, "Unknown AMQP map type %d", type); - return bound-orig_offset; + return tvb_reported_length_remaining(tvb, orig_offset); } map_tree = proto_tree_add_none_format(item, @@ -6771,7 +6036,7 @@ dissect_amqp_1_0_map(tvbuff_t *tvb, element_size+1+count_len, "%s", name ? name : proto_registrar_get_name(hf_amqp_type)); - AMQP_INCREMENT(offset, count_len*2, bound); + offset += (count_len*2); if (element_count > 0) map_tree = proto_item_add_subtree(map_tree, ett_amqp_1_0_map); @@ -6781,7 +6046,7 @@ dissect_amqp_1_0_map(tvbuff_t *tvb, &ei_amqp_invalid_number_of_params, "Odd number of map items: %d", element_count); - return bound-orig_offset; + return tvb_reported_length_remaining(tvb, orig_offset); } if (element_count > element_size) @@ -6791,21 +6056,21 @@ dissect_amqp_1_0_map(tvbuff_t *tvb, &ei_amqp_invalid_number_of_params, "Number of map elements (%d) bigger than map size (%d)", element_count, element_size); - return bound-orig_offset; + return tvb_reported_length_remaining(tvb, orig_offset); } proto_item_append_text(map_tree, " (map of %d element%s)", (element_count/2), - element_suffix[(element_count/2)!=1]); + plurality(element_count/2, "", "s")); - while (element_count > 0) { + while ((element_count > 0) && (tvb_reported_length_remaining(tvb, offset) > 0)) { if (element_count%2 == 0) { /* decode key */ element_type = decode_fixed_type(tvb_get_guint8(tvb, offset)); if (element_type) { - decoded_element_size=element_type->formatter(tvb, offset+1, bound, element_type->known_size, &value); - AMQP_INCREMENT(offset, decoded_element_size+1, bound); + decoded_element_size=element_type->formatter(tvb, offset+1, element_type->known_size, &value); + offset += (decoded_element_size+1); } else { /* can't decode key type */ @@ -6819,19 +6084,18 @@ dissect_amqp_1_0_map(tvbuff_t *tvb, &ei_amqp_unknown_amqp_type, "Unknown AMQP map key type %d", tvb_get_guint8(tvb, offset)); - AMQP_INCREMENT(offset, 1, bound); + offset += 1; } } else { /* decode value */ get_amqp_1_0_type_value_formatter(tvb, pinfo, offset, - bound, hf_amqp_1_0_list, /* dynamic item */ value, &decoded_element_size, map_tree); - AMQP_INCREMENT(offset, decoded_element_size, bound); + offset += decoded_element_size; } element_count--; } @@ -6845,7 +6109,6 @@ static guint dissect_amqp_1_0_array(tvbuff_t *tvb, packet_info *pinfo, int offset, - int bound, proto_item *item, int hf_amqp_type, guint32 hf_amqp_subtype_count, @@ -6855,7 +6118,7 @@ dissect_amqp_1_0_array(tvbuff_t *tvb, proto_item *array_tree; guint8 type; guint8 count_len; - guint32 element_count; + guint32 i, element_count; guint32 element_size; guint32 element_type; guint32 decoded_element_size; @@ -6870,17 +6133,8 @@ dissect_amqp_1_0_array(tvbuff_t *tvb, decoded_elements = 0; orig_offset = offset; - if (proto_registrar_get_ftype(hf_amqp_type) != FT_NONE) - { - expert_add_info_format(pinfo, item, &ei_amqp_unknown_amqp_type, - "Unexpected array type at frame position %d of field \"%s\"", - offset, - name ? name : proto_registrar_get_name(hf_amqp_type)); - return bound-orig_offset; - } - type = tvb_get_guint8(tvb, offset); - AMQP_INCREMENT(offset, 1, bound); + offset += 1; switch (type) { case AMQP_1_0_TYPE_ARRAY8: count_len = 1; @@ -6903,12 +6157,11 @@ dissect_amqp_1_0_array(tvbuff_t *tvb, &ei_amqp_unknown_amqp_type, "Unknown AMQP array type %d", type); - return bound-orig_offset; + return tvb_reported_length_remaining(tvb, orig_offset); } element_type = get_amqp_1_0_type_formatter(tvb, offset+count_len*2, - bound, &hf_amqp_type, &type_name_array, &hf_amqp_subtype_count_array, @@ -6922,14 +6175,14 @@ dissect_amqp_1_0_array(tvbuff_t *tvb, element_size+1+count_len, "%s", name ? name : proto_registrar_get_name(hf_amqp_type)); - AMQP_INCREMENT(offset, count_len*2+decoded_element_size, bound); + offset += (count_len*2+decoded_element_size); if (element_count > 0) array_tree = proto_item_add_subtree(array_tree, ett_amqp_1_0_array); /* display the item count for custom arrays only * standard structures contain NULL items, so the real element count is different */ if (hf_amqp_subtype_count == 0) - proto_item_append_text(array_tree, " (array of %d element%s)", element_count, element_suffix[element_count!=1]); + proto_item_append_text(array_tree, " (array of %d element%s)", element_count, plurality(element_count, "", "s")); if (element_count > element_size) { @@ -6938,10 +6191,10 @@ dissect_amqp_1_0_array(tvbuff_t *tvb, &ei_amqp_invalid_number_of_params, "Number of array elements (%d) bigger than array size (%d)", element_count, element_size); - return bound-orig_offset; + return tvb_reported_length_remaining(tvb, orig_offset); } - while ((element_count > 0) && (offset < bound)) { + for (i = 0; ((i < element_count) && (tvb_reported_length_remaining(tvb, offset) > 0)); i++) { decoded_element_size = 0; if (decoded_elements<hf_amqp_subtype_count) hf_amqp_item = *(hf_amqp_subtypes[decoded_elements]); @@ -6951,20 +6204,18 @@ dissect_amqp_1_0_array(tvbuff_t *tvb, pinfo, element_type, /* code */ offset, - offset+element_size, /* bound */ hf_amqp_item, (proto_registrar_get_nth(hf_amqp_type))->name, /* name */ hf_amqp_subtype_count_array, /* subitem list count */ hf_amqp_subtypes_array, /* subitem list hf_.. list */ &decoded_element_size, array_tree); - element_count -= 1; decoded_elements += 1; if (decoded_element_size==0) decoded_element_size=1; /* necessary for 0x40 or similar values where value_formatter returns size of _value_ 0 (type=1 not counted) */ - AMQP_INCREMENT(offset, decoded_element_size, bound); + offset += decoded_element_size; } - if (element_count > 0) + if (i != element_count) expert_add_info_format(pinfo, array_tree, &ei_amqp_invalid_number_of_params, @@ -6978,224 +6229,203 @@ dissect_amqp_1_0_array(tvbuff_t *tvb, * tvb, offset, length, amqp_tree, pinfo: obvious * method_name: what to print to col_append_str method in dissect_amqp_1_0_frame */ -static guint32 +static void dissect_amqp_1_0_AMQP_frame(tvbuff_t *tvb, - guint offset, - guint16 bound, - proto_item *amqp_tree, - packet_info *pinfo, - const gchar **method_name) + proto_item *amqp_item, + packet_info *pinfo) { proto_item *args_tree; guint32 arg_length = 0; - guint8 method; - guint orig_offset = offset; + guint32 method; + gint offset = 0; + proto_item* ti; - if (bound == offset) { /* empty keepalive sent */ - *method_name = "(empty)"; - return 0; + args_tree = proto_item_add_subtree(amqp_item, ett_args); + + if (tvb_reported_length(tvb) == 0) { /* empty keepalive sent */ + col_append_fstr(pinfo->cinfo, COL_INFO, "(empty)"); + col_set_fence(pinfo->cinfo, COL_INFO); + return; } - args_tree = proto_item_add_subtree(amqp_tree, ett_args); - method = tvb_get_guint8(tvb, offset+2); - *method_name = val_to_str_const(method, amqp_1_0_AMQP_performatives, - "<invalid AMQP performative>"); - proto_tree_add_item(args_tree, hf_amqp_1_0_amqp_performative, tvb, offset+2, 1, ENC_BIG_ENDIAN); - AMQP_INCREMENT(offset, 3, bound); /* descriptor-constructor & fixed_one length & AMQP performative code */ + + ti = proto_tree_add_item_ret_uint(args_tree, hf_amqp_1_0_amqp_performative, tvb, offset+2, 1, ENC_BIG_ENDIAN, &method); + col_append_fstr(pinfo->cinfo, COL_INFO, "%s ", val_to_str_const(method, amqp_1_0_AMQP_performatives, "<invalid AMQP performative>")); + col_set_fence(pinfo->cinfo, COL_INFO); + + offset += 3; /* descriptor-constructor & fixed_one length & AMQP performative code */ switch(method) { case AMQP_1_0_AMQP_OPEN: - arg_length = dissect_amqp_1_0_list(tvb, - pinfo, - offset, - bound, - args_tree, - hf_amqp_method_arguments, - 10, hf_amqp_1_0_amqp_open_items, NULL); + dissect_amqp_1_0_list(tvb, + pinfo, + offset, + args_tree, + hf_amqp_method_arguments, + 10, amqp_1_0_amqp_open_items, NULL); break; case AMQP_1_0_AMQP_BEGIN: - arg_length = dissect_amqp_1_0_list(tvb, - pinfo, - offset, - bound, - args_tree, - hf_amqp_method_arguments, - 8, hf_amqp_1_0_amqp_begin_items, NULL); + dissect_amqp_1_0_list(tvb, + pinfo, + offset, + args_tree, + hf_amqp_method_arguments, + 8, amqp_1_0_amqp_begin_items, NULL); break; case AMQP_1_0_AMQP_ATTACH: - arg_length = dissect_amqp_1_0_list(tvb, - pinfo, - offset, - bound, - args_tree, - hf_amqp_method_arguments, - 14, hf_amqp_1_0_amqp_attach_items, NULL); + dissect_amqp_1_0_list(tvb, + pinfo, + offset, + args_tree, + hf_amqp_method_arguments, + 14, amqp_1_0_amqp_attach_items, NULL); break; case AMQP_1_0_AMQP_FLOW: - arg_length = dissect_amqp_1_0_list(tvb, - pinfo, - offset, - bound, - args_tree, - hf_amqp_method_arguments, - 11, hf_amqp_1_0_amqp_flow_items, NULL); + dissect_amqp_1_0_list(tvb, + pinfo, + offset, + args_tree, + hf_amqp_method_arguments, + 11, amqp_1_0_amqp_flow_items, NULL); break; case AMQP_1_0_AMQP_TRANSFER: arg_length = dissect_amqp_1_0_list(tvb, pinfo, offset, - bound, args_tree, hf_amqp_method_arguments, - 11, hf_amqp_1_0_amqp_transfer_items, NULL); + 11, amqp_1_0_amqp_transfer_items, NULL); + /* now decode message header, annotations, properties and data */ - while (offset+arg_length < bound) { - AMQP_INCREMENT(offset, arg_length, bound); + while ((arg_length > 0) && (tvb_reported_length_remaining(tvb, offset + arg_length) > 0)) { + offset += arg_length; get_amqp_1_0_type_value_formatter(tvb, - pinfo, - offset, - bound, - hf_amqp_1_0_list, /* dynamic item */ - NULL, - &arg_length, - args_tree); + pinfo, + offset, + hf_amqp_1_0_list, /* dynamic item */ + NULL, + &arg_length, + args_tree); } break; case AMQP_1_0_AMQP_DISPOSITION: - arg_length = dissect_amqp_1_0_list(tvb, - pinfo, - offset, - bound, - args_tree, - hf_amqp_method_arguments, - 6, hf_amqp_1_0_amqp_disposition_items, NULL); + dissect_amqp_1_0_list(tvb, + pinfo, + offset, + args_tree, + hf_amqp_method_arguments, + 6, amqp_1_0_amqp_disposition_items, NULL); break; case AMQP_1_0_AMQP_DETACH: - arg_length = dissect_amqp_1_0_list(tvb, - pinfo, - offset, - bound, - args_tree, - hf_amqp_method_arguments, - 3, hf_amqp_1_0_amqp_detach_items, NULL); + dissect_amqp_1_0_list(tvb, + pinfo, + offset, + args_tree, + hf_amqp_method_arguments, + 3, amqp_1_0_amqp_detach_items, NULL); break; case AMQP_1_0_AMQP_END: - arg_length = dissect_amqp_1_0_list(tvb, - pinfo, - offset, - bound, - args_tree, - hf_amqp_method_arguments, - 1, hf_amqp_1_0_amqp_end_items, NULL); + dissect_amqp_1_0_list(tvb, + pinfo, + offset, + args_tree, + hf_amqp_method_arguments, + 1, amqp_1_0_amqp_end_items, NULL); break; case AMQP_1_0_AMQP_CLOSE: - arg_length = dissect_amqp_1_0_list(tvb, - pinfo, - offset, - bound, - args_tree, - hf_amqp_method_arguments, - 1, hf_amqp_1_0_amqp_close_items, NULL); + dissect_amqp_1_0_list(tvb, + pinfo, + offset, + args_tree, + hf_amqp_method_arguments, + 1, amqp_1_0_amqp_close_items, NULL); break; default: expert_add_info_format(pinfo, - amqp_tree, + ti, &ei_amqp_unknown_amqp_command, "Unknown AMQP performative %d", - tvb_get_guint8(tvb, offset + 2)); - return bound-orig_offset; + method); } - return (arg_length) + (offset-orig_offset); } /* decodes AMQP 1.0 SASL methods (mechanisms offer, challenge, response,..) * arguments: see dissect_amqp_1_0_AMQP_frame */ -static guint32 +static void dissect_amqp_1_0_SASL_frame(tvbuff_t *tvb, - guint offset, - guint16 bound, - proto_item *amqp_tree, - packet_info *pinfo, - const gchar **method_name) + proto_item *amqp_item, + packet_info *pinfo) { proto_item *args_tree; - guint32 arg_length = 0; - guint8 method; - guint orig_offset = offset; + guint32 method; + gint offset = 0; + proto_item *ti; + + args_tree = proto_item_add_subtree(amqp_item, ett_args); + ti = proto_tree_add_item_ret_uint(args_tree, hf_amqp_1_0_sasl_method, tvb, offset+2, 1, ENC_BIG_ENDIAN, &method); - args_tree = proto_item_add_subtree(amqp_tree, ett_args); - method = tvb_get_guint8(tvb, offset+2); - *method_name = val_to_str_const(method, amqp_1_0_SASL_methods, - "<invalid SASL method>"); - proto_tree_add_item(args_tree, hf_amqp_1_0_sasl_method, tvb, offset+2, 1, ENC_BIG_ENDIAN); + col_append_fstr(pinfo->cinfo, COL_INFO, "%s ", val_to_str_const(method, amqp_1_0_SASL_methods, "<invalid SASL method>")); + col_set_fence(pinfo->cinfo, COL_INFO); - AMQP_INCREMENT(offset, 3, bound); /* descriptor-constructor & fixed_one length & SASL method code */ + offset += 3; /* descriptor-constructor & fixed_one length & SASL method code */ switch(method) { case AMQP_1_0_SASL_MECHANISMS: - arg_length = dissect_amqp_1_0_list(tvb, - pinfo, - offset, - bound, - args_tree, - hf_amqp_method_arguments, - 1, hf_amqp_1_0_sasl_mechanisms_items, NULL); + dissect_amqp_1_0_list(tvb, + pinfo, + offset, + args_tree, + hf_amqp_method_arguments, + 1, amqp_1_0_sasl_mechanisms_items, NULL); break; case AMQP_1_0_SASL_INIT: - arg_length = dissect_amqp_1_0_list(tvb, - pinfo, - offset, - bound, - args_tree, - hf_amqp_method_arguments, - 3, hf_amqp_1_0_sasl_init_items, NULL); + dissect_amqp_1_0_list(tvb, + pinfo, + offset, + args_tree, + hf_amqp_method_arguments, + 3, amqp_1_0_sasl_init_items, NULL); break; case AMQP_1_0_SASL_CHALLENGE: - arg_length = dissect_amqp_1_0_list(tvb, - pinfo, - offset, - bound, - args_tree, - hf_amqp_method_arguments, - 1, hf_amqp_1_0_sasl_challenge_items, NULL); + dissect_amqp_1_0_list(tvb, + pinfo, + offset, + args_tree, + hf_amqp_method_arguments, + 1, amqp_1_0_sasl_challenge_items, NULL); break; case AMQP_1_0_SASL_RESPONSE: - arg_length = dissect_amqp_1_0_list(tvb, - pinfo, - offset, - bound, - args_tree, - hf_amqp_method_arguments, - 1, hf_amqp_1_0_sasl_response_items, NULL); + dissect_amqp_1_0_list(tvb, + pinfo, + offset, + args_tree, + hf_amqp_method_arguments, + 1, amqp_1_0_sasl_response_items, NULL); break; case AMQP_1_0_SASL_OUTCOME: - arg_length = dissect_amqp_1_0_list(tvb, - pinfo, - offset, - bound, - args_tree, - hf_amqp_method_arguments, - 2, hf_amqp_1_0_sasl_outcome_items, NULL); + dissect_amqp_1_0_list(tvb, + pinfo, + offset, + args_tree, + hf_amqp_method_arguments, + 2, amqp_1_0_sasl_outcome_items, NULL); break; default: expert_add_info_format(pinfo, - amqp_tree, + ti, &ei_amqp_unknown_sasl_command, "Unknown SASL command %d", - tvb_get_guint8(tvb, offset + 2)); - return bound-orig_offset; + method); } - return (arg_length) + (offset-orig_offset); } static int dissect_amqp_1_0_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) { - proto_item *ti = NULL; - proto_item *amqp_tree = NULL; + proto_item *ti, *size_item; + proto_tree *amqp_tree; guint8 frame_type; - guint16 length; - guint32 arg_length = 0; + guint32 length; guint offset; - const gchar *method_name = NULL; + tvbuff_t *next_tvb; col_clear(pinfo->cinfo, COL_INFO); @@ -7204,19 +6434,15 @@ dissect_amqp_1_0_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void guint8 proto_major; guint8 proto_minor; guint8 proto_revision; - wmem_strbuf_t *strbuf; proto_major = tvb_get_guint8(tvb, 5); proto_minor = tvb_get_guint8(tvb, 6); proto_revision = tvb_get_guint8(tvb, 7); - strbuf = wmem_strbuf_new_label(wmem_packet_scope()); - wmem_strbuf_append_printf(strbuf, - "Protocol-Header%s %d-%d-%d ", + col_append_fstr(pinfo->cinfo, COL_INFO, "Protocol-Header%s %d-%d-%d ", (tvb_get_guint8(tvb, 4)==0x2) ? "(TLS)" : "", /* frame type = 2 => TLS */ proto_major, proto_minor, proto_revision); - col_append_str(pinfo->cinfo, COL_INFO, wmem_strbuf_get_str(strbuf)); col_set_fence(pinfo->cinfo, COL_INFO); if (tree) { @@ -7232,37 +6458,45 @@ dissect_amqp_1_0_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void } /* Protocol frame */ - if (tree) { - /* frame header */ - ti = proto_tree_add_item(tree, proto_amqp, tvb, 0, -1, ENC_NA); - amqp_tree = proto_item_add_subtree(ti, ett_amqp); - proto_tree_add_item(amqp_tree, hf_amqp_1_0_size, tvb, 0, 4, ENC_BIG_ENDIAN); - proto_tree_add_item(amqp_tree, hf_amqp_1_0_doff, tvb, 4, 1, ENC_BIG_ENDIAN); - proto_tree_add_item(amqp_tree, hf_amqp_1_0_type, tvb, 5, 1, ENC_BIG_ENDIAN); - proto_tree_add_item(amqp_tree, hf_amqp_channel, tvb, 6, 2, ENC_BIG_ENDIAN); - } + + /* frame header */ + ti = proto_tree_add_item(tree, proto_amqp, tvb, 0, -1, ENC_NA); + amqp_tree = proto_item_add_subtree(ti, ett_amqp); + size_item = proto_tree_add_item_ret_uint(amqp_tree, hf_amqp_1_0_size, tvb, 0, 4, ENC_BIG_ENDIAN, &length); + proto_tree_add_item(amqp_tree, hf_amqp_1_0_doff, tvb, 4, 1, ENC_BIG_ENDIAN); + proto_tree_add_item(amqp_tree, hf_amqp_1_0_type, tvb, 5, 1, ENC_BIG_ENDIAN); + proto_tree_add_item(amqp_tree, hf_amqp_channel, tvb, 6, 2, ENC_BIG_ENDIAN); /* XXX: The original code used only the low-order 16 bits of the 32 bit length * field from the PDU as the length to dissect */ + if (length > 0xFFFF) { - guint length32; - length32 = tvb_get_ntohl(tvb, 0); - length = (length32 < 0x10000U) ? length32 : 0xFFFFU; - if (length32 > length) { - expert_add_info(pinfo, ti, &ei_amqp_amqp_1_0_frame_length_exceeds_65K); - } + length = 0xFFFF; + expert_add_info(pinfo, size_item, &ei_amqp_amqp_1_0_frame_length_exceeds_65K); } offset = 4*tvb_get_guint8(tvb,4); /* i.e. 4*DOFF */ frame_type = tvb_get_guint8(tvb, 5); - THROW_ON((length < offset), ReportedBoundsError); + if (length < offset) { + expert_add_info(pinfo, size_item, &ei_amqp_bad_length); + return 8; + } + + if (length > (guint32)tvb_reported_length_remaining(tvb, offset)) + { + next_tvb = tvb_new_subset_remaining(tvb, offset); + } + else + { + next_tvb = tvb_new_subset_length(tvb, offset, length); + } switch(frame_type) { case AMQP_1_0_AMQP_FRAME: - arg_length = dissect_amqp_1_0_AMQP_frame(tvb, offset, length, amqp_tree, pinfo, &method_name); + dissect_amqp_1_0_AMQP_frame(next_tvb, amqp_tree, pinfo); break; case AMQP_1_0_SASL_FRAME: - arg_length = dissect_amqp_1_0_SASL_frame(tvb, offset, length, amqp_tree, pinfo, &method_name); + dissect_amqp_1_0_SASL_frame(next_tvb, amqp_tree, pinfo); break; case AMQP_1_0_TLS_FRAME: /* should not occur, this is handled in '(tvb_memeql(tvb, 0, "AMQP", 4) == 0)' test above */ @@ -7270,10 +6504,7 @@ dissect_amqp_1_0_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void default: expert_add_info_format(pinfo, amqp_tree, &ei_amqp_unknown_frame_type, "Unknown frame type %d", frame_type); } - AMQP_INCREMENT(offset, arg_length, length); - col_append_str(pinfo->cinfo, COL_INFO, method_name); - col_append_str(pinfo->cinfo, COL_INFO, " "); - col_set_fence(pinfo->cinfo, COL_INFO); + return tvb_reported_length(tvb); } @@ -7286,21 +6517,18 @@ dissect_amqp_0_10_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, voi guint16 length; guint32 struct_length; guint offset; + tvbuff_t *next_tvb; /* Heuristic - protocol initialisation frame starts with 'AMQP' */ if (tvb_memeql(tvb, 0, "AMQP", 4) == 0) { guint8 proto_major; guint8 proto_minor; - wmem_strbuf_t *strbuf; proto_major = tvb_get_guint8(tvb, 6); proto_minor = tvb_get_guint8(tvb, 7); - strbuf = wmem_strbuf_new_label(wmem_packet_scope()); - wmem_strbuf_append_printf(strbuf, - "Protocol-Header %d-%d ", + col_append_fstr(pinfo->cinfo, COL_INFO, "Protocol-Header %d-%d ", proto_major, proto_minor); - col_append_str(pinfo->cinfo, COL_INFO, wmem_strbuf_get_str(strbuf)); col_set_fence(pinfo->cinfo, COL_INFO); if (tree) { @@ -7325,12 +6553,13 @@ dissect_amqp_0_10_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, voi proto_tree_add_item(amqp_tree, hf_amqp_0_10_size, tvb, 2, 2, ENC_BIG_ENDIAN); proto_tree_add_item(amqp_tree, hf_amqp_0_10_track, tvb, 5, 1, ENC_BIG_ENDIAN); proto_tree_add_item(amqp_tree, hf_amqp_channel, tvb, 6, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(amqp_tree, hf_amqp_reserved, tvb, 8, 4, ENC_BIG_ENDIAN); } frame_type = tvb_get_guint8(tvb, 1); length = tvb_get_ntohs(tvb, 2); offset = 12; - THROW_ON((length <= 13), ReportedBoundsError); + next_tvb = tvb_new_subset_remaining(tvb, offset); switch(frame_type) { case AMQP_0_10_FRAME_COMMAND: @@ -7339,44 +6568,34 @@ dissect_amqp_0_10_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, voi proto_tree_add_item(amqp_tree, hf_amqp_0_10_class, tvb, offset+0, 1, ENC_BIG_ENDIAN); switch(tvb_get_guint8(tvb, offset + 0)) { case AMQP_0_10_CLASS_CONNECTION: - dissect_amqp_0_10_connection(tvb, pinfo, amqp_tree, - offset, length); + dissect_amqp_0_10_connection(next_tvb, pinfo, amqp_tree); break; case AMQP_0_10_CLASS_SESSION: - dissect_amqp_0_10_session(tvb, pinfo, amqp_tree, - offset, length); + dissect_amqp_0_10_session(next_tvb, pinfo, amqp_tree); break; case AMQP_0_10_CLASS_EXECUTION: - dissect_amqp_0_10_execution(tvb, pinfo, amqp_tree, - offset, length); + dissect_amqp_0_10_execution(next_tvb, pinfo, amqp_tree); break; case AMQP_0_10_CLASS_MESSAGE: - dissect_amqp_0_10_message(tvb, pinfo, amqp_tree, - offset, length); + dissect_amqp_0_10_message(next_tvb, pinfo, amqp_tree); break; case AMQP_0_10_CLASS_TX: - dissect_amqp_0_10_tx(tvb, pinfo, amqp_tree, - offset, length); + dissect_amqp_0_10_tx(next_tvb, pinfo, amqp_tree); break; case AMQP_0_10_CLASS_DTX: - dissect_amqp_0_10_dtx(tvb, pinfo, amqp_tree, - offset, length); + dissect_amqp_0_10_dtx(next_tvb, pinfo, amqp_tree); break; case AMQP_0_10_CLASS_EXCHANGE: - dissect_amqp_0_10_exchange(tvb, pinfo, amqp_tree, - offset, length); + dissect_amqp_0_10_exchange(next_tvb, pinfo, amqp_tree); break; case AMQP_0_10_CLASS_QUEUE: - dissect_amqp_0_10_queue(tvb, pinfo, amqp_tree, - offset, length); + dissect_amqp_0_10_queue(next_tvb, pinfo, amqp_tree); break; case AMQP_0_10_CLASS_FILE: - dissect_amqp_0_10_file(tvb, pinfo, amqp_tree, - offset, length); + dissect_amqp_0_10_file(next_tvb, pinfo, amqp_tree); break; case AMQP_0_10_CLASS_STREAM: - dissect_amqp_0_10_stream(tvb, pinfo, amqp_tree, - offset, length); + dissect_amqp_0_10_stream(next_tvb, pinfo, amqp_tree); break; default: expert_add_info_format(pinfo, amqp_tree, &ei_amqp_unknown_command_class, "Unknown command/control class %d", tvb_get_guint8(tvb, offset + 0)); @@ -7386,16 +6605,26 @@ dissect_amqp_0_10_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, voi case AMQP_0_10_FRAME_HEADER: col_append_str(pinfo->cinfo, COL_INFO, "header "); col_set_fence(pinfo->cinfo, COL_INFO); - do { - struct_length = amqp_0_10_get_32bit_size(tvb, offset); - AMQP_INCREMENT(offset, 4, length); + while (tvb_reported_length_remaining(tvb, offset) > 0) + { + struct_length = amqp_0_10_get_32bit_size_new(amqp_tree, pinfo, tvb, hf_amqp_0_10_struct32_size, offset); + offset += 4; ti = proto_tree_add_item(amqp_tree, - hf_amqp_0_10_undissected_struct32, - tvb, offset, struct_length, ENC_NA); - dissect_amqp_0_10_struct32(tvb, pinfo, ti, offset, struct_length); - AMQP_INCREMENT(offset, struct_length, length); - } while (offset < length); + hf_amqp_0_10_struct32, + tvb, offset, 2, ENC_BIG_ENDIAN); + proto_item_set_len(ti, struct_length); + if (struct_length > (guint32)tvb_reported_length_remaining(tvb, offset)) + { + next_tvb = tvb_new_subset_remaining(tvb, offset); + } + else + { + next_tvb = tvb_new_subset_length(tvb, offset, struct_length); + } + dissect_amqp_0_10_struct32(next_tvb, pinfo, ti); + offset += struct_length; + } break; case AMQP_0_10_FRAME_BODY: @@ -7413,702 +6642,6 @@ dissect_amqp_0_10_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, voi return tvb_reported_length(tvb); } -/* Dissection routine for AMQP 0-9 frames */ - -static int -dissect_amqp_0_9_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) -{ - proto_item *ti; - proto_item *amqp_tree = NULL; - proto_item *args_tree; - proto_item *prop_tree; - guint length; - guint8 frame_type; - guint16 channel_num, class_id, method_id; - - /* Heuristic - protocol initialisation frame starts with 'AMQP' */ - if (tvb_memeql(tvb, 0, "AMQP", 4) == 0) { - guint8 proto_id, proto_major, proto_minor; - wmem_strbuf_t *strbuf; - - proto_id = tvb_get_guint8(tvb, 5); - proto_major = tvb_get_guint8(tvb, 6); - proto_minor = tvb_get_guint8(tvb, 7); - strbuf = wmem_strbuf_new_label(wmem_packet_scope()); - wmem_strbuf_append_printf(strbuf, - "Protocol-Header %u-%u-%u", - proto_id, - proto_major, - proto_minor); - col_append_str(pinfo->cinfo, COL_INFO, wmem_strbuf_get_str(strbuf)); - col_set_fence(pinfo->cinfo, COL_INFO); - - if (tree) { - ti = proto_tree_add_item(tree, proto_amqp, tvb, 0, -1, ENC_NA); - amqp_tree = proto_item_add_subtree(ti, ett_amqp_init); - proto_tree_add_item(amqp_tree, hf_amqp_init_protocol, tvb, 0, 4, ENC_ASCII|ENC_NA); - proto_tree_add_item(amqp_tree, hf_amqp_init_id_major, tvb, 4, 1, ENC_BIG_ENDIAN); - proto_tree_add_item(amqp_tree, hf_amqp_init_id_minor, tvb, 5, 1, ENC_BIG_ENDIAN); - proto_tree_add_item(amqp_tree, hf_amqp_init_version_major, tvb, 6, 1, ENC_BIG_ENDIAN); - proto_tree_add_item(amqp_tree, hf_amqp_init_version_minor, tvb, 7, 1, ENC_BIG_ENDIAN); - } - return 8; - } - - if (tree) { - ti = proto_tree_add_item(tree, proto_amqp, tvb, 0, -1, ENC_NA); - amqp_tree = proto_item_add_subtree(ti, ett_amqp); - proto_tree_add_item(amqp_tree, hf_amqp_0_9_type, tvb, 0, 1, ENC_BIG_ENDIAN); - proto_tree_add_item(amqp_tree, hf_amqp_channel, tvb, 1, 2, ENC_BIG_ENDIAN); - proto_tree_add_item(amqp_tree, hf_amqp_0_9_length, tvb, 3, 4, ENC_BIG_ENDIAN); - } - - frame_type = tvb_get_guint8(tvb, 0); - channel_num = tvb_get_ntohs(tvb, 1); - length = tvb_get_ntohl(tvb, 3); - - switch (frame_type) { - case AMQP_0_9_FRAME_TYPE_METHOD: - class_id = tvb_get_ntohs(tvb, 7); - proto_tree_add_item(amqp_tree, hf_amqp_0_9_method_class_id, - tvb, 7, 2, ENC_BIG_ENDIAN); - switch (class_id) { - case AMQP_0_9_CLASS_CONNECTION: - method_id = tvb_get_ntohs(tvb, 9); - proto_tree_add_item(amqp_tree, hf_amqp_method_connection_method_id, - tvb, 9, 2, ENC_BIG_ENDIAN); - ti = proto_tree_add_item(amqp_tree, hf_amqp_method_arguments, - tvb, 11, length - 4, ENC_NA); - args_tree = proto_item_add_subtree(ti, ett_args); - col_append_fstr(pinfo->cinfo, COL_INFO, "Connection.%s ", - val_to_str( method_id, amqp_method_connection_methods, "Unknown (%u)")); - switch (method_id) { - case AMQP_0_9_METHOD_CONNECTION_START: - dissect_amqp_0_9_method_connection_start(tvb, - pinfo, 11, args_tree); - break; - case AMQP_0_9_METHOD_CONNECTION_START_OK: - dissect_amqp_0_9_method_connection_start_ok(tvb, - pinfo, 11, args_tree); - break; - case AMQP_0_9_METHOD_CONNECTION_SECURE: - dissect_amqp_0_9_method_connection_secure(tvb, - 11, args_tree); - break; - case AMQP_0_9_METHOD_CONNECTION_SECURE_OK: - dissect_amqp_0_9_method_connection_secure_ok(tvb, - 11, args_tree); - break; - case AMQP_0_9_METHOD_CONNECTION_TUNE: - dissect_amqp_0_9_method_connection_tune(tvb, - 11, args_tree); - break; - case AMQP_0_9_METHOD_CONNECTION_TUNE_OK: - dissect_amqp_0_9_method_connection_tune_ok(tvb, - 11, args_tree); - break; - case AMQP_0_9_METHOD_CONNECTION_OPEN: - dissect_amqp_0_9_method_connection_open(tvb, - pinfo, 11, args_tree); - break; - case AMQP_0_9_METHOD_CONNECTION_OPEN_OK: - dissect_amqp_0_9_method_connection_open_ok(tvb, - 11, args_tree); - break; - case AMQP_0_9_METHOD_CONNECTION_REDIRECT: - dissect_amqp_0_9_method_connection_redirect(tvb, - 11, args_tree); - break; - case AMQP_0_9_METHOD_CONNECTION_CLOSE: - dissect_amqp_0_9_method_connection_close(tvb, - pinfo, 11, args_tree); - break; - case AMQP_0_9_METHOD_CONNECTION_CLOSE_OK: - dissect_amqp_0_9_method_connection_close_ok(tvb, - 11, args_tree); - break; - case AMQP_0_9_METHOD_CONNECTION_BLOCKED: - dissect_amqp_0_9_method_connection_blocked(tvb, - 11, args_tree); - break; - case AMQP_0_9_METHOD_CONNECTION_UNBLOCKED: - dissect_amqp_0_9_method_connection_unblocked(tvb, - 11, args_tree); - break; - default: - expert_add_info_format(pinfo, amqp_tree, &ei_amqp_unknown_connection_method, "Unknown connection method %u", method_id); - } - break; - case AMQP_0_9_CLASS_CHANNEL: - method_id = tvb_get_ntohs(tvb, 9); - proto_tree_add_item(amqp_tree, hf_amqp_method_channel_method_id, - tvb, 9, 2, ENC_BIG_ENDIAN); - ti = proto_tree_add_item(amqp_tree, hf_amqp_method_arguments, - tvb, 11, length - 4, ENC_NA); - args_tree = proto_item_add_subtree(ti, ett_args); - - col_append_fstr(pinfo->cinfo, COL_INFO, "Channel.%s ", - val_to_str( method_id, amqp_method_channel_methods, "Unknown (%u)")); - - switch (method_id) { - case AMQP_0_9_METHOD_CHANNEL_OPEN: - dissect_amqp_0_9_method_channel_open(tvb, - 11, args_tree); - break; - case AMQP_0_9_METHOD_CHANNEL_OPEN_OK: - dissect_amqp_0_9_method_channel_open_ok(tvb, - 11, args_tree); - break; - case AMQP_0_9_METHOD_CHANNEL_FLOW: - dissect_amqp_0_9_method_channel_flow(tvb, - 11, args_tree); - break; - case AMQP_0_9_METHOD_CHANNEL_FLOW_OK: - dissect_amqp_0_9_method_channel_flow_ok(tvb, - 11, args_tree); - break; - case AMQP_0_9_METHOD_CHANNEL_CLOSE: - dissect_amqp_0_9_method_channel_close(channel_num, tvb, - pinfo, 11, args_tree); - break; - case AMQP_0_9_METHOD_CHANNEL_CLOSE_OK: - dissect_amqp_0_9_method_channel_close_ok(tvb, - 11, args_tree); - break; - case AMQP_0_9_METHOD_CHANNEL_RESUME: - dissect_amqp_0_9_method_channel_resume(tvb, - 11, args_tree); - break; - case AMQP_0_9_METHOD_CHANNEL_PING: - dissect_amqp_0_9_method_channel_ping(tvb, - 11, args_tree); - break; - case AMQP_0_9_METHOD_CHANNEL_PONG: - dissect_amqp_0_9_method_channel_pong(tvb, - 11, args_tree); - break; - case AMQP_0_9_METHOD_CHANNEL_OK: - dissect_amqp_0_9_method_channel_ok(tvb, - 11, args_tree); - break; - default: - expert_add_info_format(pinfo, amqp_tree, &ei_amqp_unknown_channel_method, "Unknown channel method %u", method_id); - } - break; - case AMQP_0_9_CLASS_ACCESS: - method_id = tvb_get_ntohs(tvb, 9); - proto_tree_add_item(amqp_tree, hf_amqp_method_access_method_id, - tvb, 9, 2, ENC_BIG_ENDIAN); - ti = proto_tree_add_item(amqp_tree, hf_amqp_method_arguments, - tvb, 11, length - 4, ENC_NA); - args_tree = proto_item_add_subtree(ti, ett_args); - switch (method_id) { - case AMQP_0_9_METHOD_ACCESS_REQUEST: - dissect_amqp_0_9_method_access_request(tvb, - 11, args_tree); - col_append_str(pinfo->cinfo, COL_INFO, - "Access.Request "); - break; - case AMQP_0_9_METHOD_ACCESS_REQUEST_OK: - dissect_amqp_0_9_method_access_request_ok(tvb, - 11, args_tree); - col_append_str(pinfo->cinfo, COL_INFO, - "Access.Request-Ok "); - break; - default: - expert_add_info_format(pinfo, amqp_tree, &ei_amqp_unknown_access_method, "Unknown access method %u", method_id); - } - break; - case AMQP_0_9_CLASS_EXCHANGE: - method_id = tvb_get_ntohs(tvb, 9); - proto_tree_add_item(amqp_tree, hf_amqp_method_exchange_method_id, - tvb, 9, 2, ENC_BIG_ENDIAN); - ti = proto_tree_add_item(amqp_tree, hf_amqp_method_arguments, - tvb, 11, length - 4, ENC_NA); - args_tree = proto_item_add_subtree(ti, ett_args); - col_append_fstr(pinfo->cinfo, COL_INFO, "Exchange.%s ", - val_to_str( method_id, amqp_method_exchange_methods, "Unknown (%u)")); - switch (method_id) { - case AMQP_0_9_METHOD_EXCHANGE_DECLARE: - dissect_amqp_0_9_method_exchange_declare(tvb, - pinfo, 11, args_tree); - break; - case AMQP_0_9_METHOD_EXCHANGE_DECLARE_OK: - dissect_amqp_0_9_method_exchange_declare_ok(tvb, - 11, args_tree); - break; - case AMQP_0_9_METHOD_EXCHANGE_BIND: - dissect_amqp_0_9_method_exchange_bind(tvb, - pinfo, 11, args_tree); - break; - case AMQP_0_9_METHOD_EXCHANGE_BIND_OK: - dissect_amqp_0_9_method_exchange_bind_ok(tvb, - 11, args_tree); - break; - case AMQP_0_9_METHOD_EXCHANGE_DELETE: - dissect_amqp_0_9_method_exchange_delete(tvb, - pinfo, 11, args_tree); - break; - case AMQP_0_9_METHOD_EXCHANGE_DELETE_OK: - dissect_amqp_0_9_method_exchange_delete_ok(tvb, - 11, args_tree); - break; - case AMQP_0_9_METHOD_EXCHANGE_UNBIND: - /* the same parameters as in bind */ - dissect_amqp_0_9_method_exchange_bind(tvb, - pinfo, 11, args_tree); - break; - case AMQP_0_9_METHOD_EXCHANGE_UNBIND_OK: - /* the same parameters as in bind-ok */ - dissect_amqp_0_9_method_exchange_bind_ok(tvb, - 11, args_tree); - break; - default: - expert_add_info_format(pinfo, amqp_tree, &ei_amqp_unknown_exchange_method, "Unknown exchange method %u", method_id); - } - break; - case AMQP_0_9_CLASS_QUEUE: - method_id = tvb_get_ntohs(tvb, 9); - proto_tree_add_item(amqp_tree, hf_amqp_method_queue_method_id, - tvb, 9, 2, ENC_BIG_ENDIAN); - ti = proto_tree_add_item(amqp_tree, hf_amqp_method_arguments, - tvb, 11, length - 4, ENC_NA); - args_tree = proto_item_add_subtree(ti, ett_args); - col_append_fstr(pinfo->cinfo, COL_INFO, "Queue.%s ", - val_to_str( method_id, amqp_method_queue_methods, "Unknown (%u)")); - - switch (method_id) { - case AMQP_0_9_METHOD_QUEUE_DECLARE: - dissect_amqp_0_9_method_queue_declare(tvb, - pinfo, 11, args_tree); - break; - case AMQP_0_9_METHOD_QUEUE_DECLARE_OK: - dissect_amqp_0_9_method_queue_declare_ok(tvb, - pinfo, 11, args_tree); - break; - case AMQP_0_9_METHOD_QUEUE_BIND: - dissect_amqp_0_9_method_queue_bind(tvb, - pinfo, 11, args_tree); - break; - case AMQP_0_9_METHOD_QUEUE_BIND_OK: - dissect_amqp_0_9_method_queue_bind_ok(tvb, - 11, args_tree); - break; - case AMQP_0_9_METHOD_QUEUE_UNBIND: - dissect_amqp_0_9_method_queue_unbind(tvb, - pinfo, 11, args_tree); - break; - case AMQP_0_9_METHOD_QUEUE_UNBIND_OK: - dissect_amqp_0_9_method_queue_unbind_ok(tvb, - 11, args_tree); - break; - case AMQP_0_9_METHOD_QUEUE_PURGE: - dissect_amqp_0_9_method_queue_purge(tvb, - pinfo, 11, args_tree); - break; - case AMQP_0_9_METHOD_QUEUE_PURGE_OK: - dissect_amqp_0_9_method_queue_purge_ok(tvb, - 11, args_tree); - break; - case AMQP_0_9_METHOD_QUEUE_DELETE: - dissect_amqp_0_9_method_queue_delete(tvb, - pinfo, 11, args_tree); - break; - case AMQP_0_9_METHOD_QUEUE_DELETE_OK: - dissect_amqp_0_9_method_queue_delete_ok(tvb, - 11, args_tree); - break; - default: - expert_add_info_format(pinfo, amqp_tree, &ei_amqp_unknown_queue_method, "Unknown queue method %u", method_id); - } - break; - case AMQP_0_9_CLASS_BASIC: - method_id = tvb_get_ntohs(tvb, 9); - proto_tree_add_item(amqp_tree, hf_amqp_method_basic_method_id, - tvb, 9, 2, ENC_BIG_ENDIAN); - ti = proto_tree_add_item(amqp_tree, hf_amqp_method_arguments, - tvb, 11, length - 4, ENC_NA); - args_tree = proto_item_add_subtree(ti, ett_args); - - col_append_fstr(pinfo->cinfo, COL_INFO, "Basic.%s ", - val_to_str( method_id, amqp_method_basic_methods, "Unknown (%u)")); - - switch (method_id) { - case AMQP_0_9_METHOD_BASIC_QOS: - dissect_amqp_0_9_method_basic_qos(tvb, - 11, args_tree); - break; - case AMQP_0_9_METHOD_BASIC_QOS_OK: - dissect_amqp_0_9_method_basic_qos_ok(tvb, - 11, args_tree); - break; - case AMQP_0_9_METHOD_BASIC_CONSUME: - dissect_amqp_0_9_method_basic_consume(tvb, - pinfo, 11, args_tree); - break; - case AMQP_0_9_METHOD_BASIC_CONSUME_OK: - dissect_amqp_0_9_method_basic_consume_ok(tvb, - 11, args_tree); - break; - case AMQP_0_9_METHOD_BASIC_CANCEL: - dissect_amqp_0_9_method_basic_cancel(tvb, - 11, args_tree); - break; - case AMQP_0_9_METHOD_BASIC_CANCEL_OK: - dissect_amqp_0_9_method_basic_cancel_ok(tvb, - 11, args_tree); - break; - case AMQP_0_9_METHOD_BASIC_PUBLISH: - dissect_amqp_0_9_method_basic_publish(channel_num, tvb, - pinfo, 11, args_tree); - generate_ack_reference(tvb, pinfo, amqp_tree); - break; - case AMQP_0_9_METHOD_BASIC_RETURN: - dissect_amqp_0_9_method_basic_return(tvb, - pinfo, 11, args_tree); - break; - case AMQP_0_9_METHOD_BASIC_DELIVER: - dissect_amqp_0_9_method_basic_deliver(channel_num, tvb, - pinfo, 11, args_tree); - generate_ack_reference(tvb, pinfo, amqp_tree); - break; - case AMQP_0_9_METHOD_BASIC_GET: - dissect_amqp_0_9_method_basic_get(tvb, - pinfo, 11, args_tree); - break; - case AMQP_0_9_METHOD_BASIC_GET_OK: - dissect_amqp_0_9_method_basic_get_ok(channel_num, tvb, - pinfo, 11, args_tree); - generate_ack_reference(tvb, pinfo, amqp_tree); - break; - case AMQP_0_9_METHOD_BASIC_GET_EMPTY: - dissect_amqp_0_9_method_basic_get_empty(tvb, - 11, args_tree); - break; - case AMQP_0_9_METHOD_BASIC_ACK: - dissect_amqp_0_9_method_basic_ack(channel_num, tvb, - pinfo, 11, args_tree); - generate_msg_reference(tvb, pinfo, amqp_tree); - break; - case AMQP_0_9_METHOD_BASIC_REJECT: - dissect_amqp_0_9_method_basic_reject(channel_num, tvb, - pinfo, 11, args_tree); - generate_msg_reference(tvb, pinfo, amqp_tree); - break; - case AMQP_0_9_METHOD_BASIC_RECOVER_ASYNC: - dissect_amqp_0_9_method_basic_recover_async(tvb, - 11, args_tree); - break; - case AMQP_0_9_METHOD_BASIC_RECOVER: - dissect_amqp_0_9_method_basic_recover(tvb, - 11, args_tree); - break; - case AMQP_0_9_METHOD_BASIC_RECOVER_OK: - dissect_amqp_0_9_method_basic_recover_ok(tvb, - 11, args_tree); - break; - case AMQP_0_9_METHOD_BASIC_NACK: - dissect_amqp_0_9_method_basic_nack(channel_num, tvb, - pinfo, 11, args_tree); - generate_msg_reference(tvb, pinfo, amqp_tree); - break; - default: - expert_add_info_format(pinfo, amqp_tree, &ei_amqp_unknown_basic_method, "Unknown basic method %u", method_id); - } - break; - case AMQP_0_9_CLASS_FILE: - method_id = tvb_get_ntohs(tvb, 9); - proto_tree_add_item(amqp_tree, hf_amqp_method_file_method_id, - tvb, 9, 2, ENC_BIG_ENDIAN); - ti = proto_tree_add_item(amqp_tree, hf_amqp_method_arguments, - tvb, 11, length - 4, ENC_NA); - args_tree = proto_item_add_subtree(ti, ett_args); - - col_append_fstr(pinfo->cinfo, COL_INFO, "File.%s ", - val_to_str( method_id, amqp_method_file_methods, "Unknown (%u)")); - - switch (method_id) { - case AMQP_0_9_METHOD_FILE_QOS: - dissect_amqp_0_9_method_file_qos(tvb, - 11, args_tree); - break; - case AMQP_0_9_METHOD_FILE_QOS_OK: - dissect_amqp_0_9_method_file_qos_ok(tvb, - 11, args_tree); - break; - case AMQP_0_9_METHOD_FILE_CONSUME: - dissect_amqp_0_9_method_file_consume(tvb, - pinfo, 11, args_tree); - break; - case AMQP_0_9_METHOD_FILE_CONSUME_OK: - dissect_amqp_0_9_method_file_consume_ok(tvb, - 11, args_tree); - break; - case AMQP_0_9_METHOD_FILE_CANCEL: - dissect_amqp_0_9_method_file_cancel(tvb, - 11, args_tree); - break; - case AMQP_0_9_METHOD_FILE_CANCEL_OK: - dissect_amqp_0_9_method_file_cancel_ok(tvb, - 11, args_tree); - break; - case AMQP_0_9_METHOD_FILE_OPEN: - dissect_amqp_0_9_method_file_open(tvb, - 11, args_tree); - break; - case AMQP_0_9_METHOD_FILE_OPEN_OK: - dissect_amqp_0_9_method_file_open_ok(tvb, - 11, args_tree); - break; - case AMQP_0_9_METHOD_FILE_STAGE: - dissect_amqp_0_9_method_file_stage(tvb, - 11, args_tree); - break; - case AMQP_0_9_METHOD_FILE_PUBLISH: - dissect_amqp_0_9_method_file_publish(tvb, - 11, args_tree); - break; - case AMQP_0_9_METHOD_FILE_RETURN: - dissect_amqp_0_9_method_file_return(tvb, - 11, args_tree); - break; - case AMQP_0_9_METHOD_FILE_DELIVER: - dissect_amqp_0_9_method_file_deliver(tvb, - 11, args_tree); - break; - case AMQP_0_9_METHOD_FILE_ACK: - dissect_amqp_0_9_method_file_ack(tvb, - 11, args_tree); - break; - case AMQP_0_9_METHOD_FILE_REJECT: - dissect_amqp_0_9_method_file_reject(tvb, - 11, args_tree); - break; - default: - expert_add_info_format(pinfo, amqp_tree, &ei_amqp_unknown_file_method, "Unknown file method %u", method_id); - } - break; - case AMQP_0_9_CLASS_STREAM: - method_id = tvb_get_ntohs(tvb, 9); - proto_tree_add_item(amqp_tree, hf_amqp_method_stream_method_id, - tvb, 9, 2, ENC_BIG_ENDIAN); - ti = proto_tree_add_item(amqp_tree, hf_amqp_method_arguments, - tvb, 11, length - 4, ENC_NA); - args_tree = proto_item_add_subtree(ti, ett_args); - - col_append_fstr(pinfo->cinfo, COL_INFO, "Stream.%s ", - val_to_str( method_id, amqp_method_stream_methods, "Unknown (%u)")); - - switch (method_id) { - case AMQP_0_9_METHOD_STREAM_QOS: - dissect_amqp_0_9_method_stream_qos(tvb, - 11, args_tree); - break; - case AMQP_0_9_METHOD_STREAM_QOS_OK: - dissect_amqp_0_9_method_stream_qos_ok(tvb, - 11, args_tree); - break; - case AMQP_0_9_METHOD_STREAM_CONSUME: - dissect_amqp_0_9_method_stream_consume(tvb, - pinfo, 11, args_tree); - break; - case AMQP_0_9_METHOD_STREAM_CONSUME_OK: - dissect_amqp_0_9_method_stream_consume_ok(tvb, - 11, args_tree); - break; - case AMQP_0_9_METHOD_STREAM_CANCEL: - dissect_amqp_0_9_method_stream_cancel(tvb, - 11, args_tree); - break; - case AMQP_0_9_METHOD_STREAM_CANCEL_OK: - dissect_amqp_0_9_method_stream_cancel_ok(tvb, - 11, args_tree); - break; - case AMQP_0_9_METHOD_STREAM_PUBLISH: - dissect_amqp_0_9_method_stream_publish(tvb, - 11, args_tree); - break; - case AMQP_0_9_METHOD_STREAM_RETURN: - dissect_amqp_0_9_method_stream_return(tvb, - 11, args_tree); - break; - case AMQP_0_9_METHOD_STREAM_DELIVER: - dissect_amqp_0_9_method_stream_deliver(tvb, - 11, args_tree); - break; - default: - expert_add_info_format(pinfo, amqp_tree, &ei_amqp_unknown_stream_method, "Unknown stream method %u", method_id); - } - break; - case AMQP_0_9_CLASS_TX: - method_id = tvb_get_ntohs(tvb, 9); - proto_tree_add_item(amqp_tree, hf_amqp_method_tx_method_id, - tvb, 9, 2, ENC_BIG_ENDIAN); - ti = proto_tree_add_item(amqp_tree, hf_amqp_method_arguments, - tvb, 11, length - 4, ENC_NA); - args_tree = proto_item_add_subtree(ti, ett_args); - - col_append_fstr(pinfo->cinfo, COL_INFO, "Tx.%s ", - val_to_str( method_id, amqp_method_tx_methods, "Unknown (%u)")); - - switch (method_id) { - case AMQP_0_9_METHOD_TX_SELECT: - dissect_amqp_0_9_method_tx_select(tvb, - 11, args_tree); - break; - case AMQP_0_9_METHOD_TX_SELECT_OK: - dissect_amqp_0_9_method_tx_select_ok(tvb, - 11, args_tree); - break; - case AMQP_0_9_METHOD_TX_COMMIT: - dissect_amqp_0_9_method_tx_commit(tvb, - 11, args_tree); - break; - case AMQP_0_9_METHOD_TX_COMMIT_OK: - dissect_amqp_0_9_method_tx_commit_ok(tvb, - 11, args_tree); - break; - case AMQP_0_9_METHOD_TX_ROLLBACK: - dissect_amqp_0_9_method_tx_rollback(tvb, - 11, args_tree); - break; - case AMQP_0_9_METHOD_TX_ROLLBACK_OK: - dissect_amqp_0_9_method_tx_rollback_ok(tvb, - 11, args_tree); - break; - default: - expert_add_info_format(pinfo, amqp_tree, &ei_amqp_unknown_tx_method, "Unknown tx method %u", method_id); - } - break; - case AMQP_0_9_CLASS_DTX: - method_id = tvb_get_ntohs(tvb, 9); - proto_tree_add_item(amqp_tree, hf_amqp_method_dtx_method_id, - tvb, 9, 2, ENC_BIG_ENDIAN); - ti = proto_tree_add_item(amqp_tree, hf_amqp_method_arguments, - tvb, 11, length - 4, ENC_NA); - args_tree = proto_item_add_subtree(ti, ett_args); - - col_append_fstr(pinfo->cinfo, COL_INFO, "Dtx.%s ", - val_to_str( method_id, amqp_method_dtx_methods, "Unknown (%u)")); - - switch (method_id) { - case AMQP_0_9_METHOD_DTX_SELECT: - dissect_amqp_0_9_method_dtx_select(tvb, - 11, args_tree); - break; - case AMQP_0_9_METHOD_DTX_SELECT_OK: - dissect_amqp_0_9_method_dtx_select_ok(tvb, - 11, args_tree); - break; - case AMQP_0_9_METHOD_DTX_START: - dissect_amqp_0_9_method_dtx_start(tvb, - 11, args_tree); - break; - case AMQP_0_9_METHOD_DTX_START_OK: - dissect_amqp_0_9_method_dtx_start_ok(tvb, - 11, args_tree); - break; - default: - expert_add_info_format(pinfo, amqp_tree, &ei_amqp_unknown_dtx_method, "Unknown dtx method %u", method_id); - } - break; - case AMQP_0_9_CLASS_TUNNEL: - method_id = tvb_get_ntohs(tvb, 9); - proto_tree_add_item(amqp_tree, hf_amqp_method_tunnel_method_id, - tvb, 9, 2, ENC_BIG_ENDIAN); - ti = proto_tree_add_item(amqp_tree, hf_amqp_method_arguments, - tvb, 11, length - 4, ENC_NA); - args_tree = proto_item_add_subtree(ti, ett_args); - switch (method_id) { - case AMQP_0_9_METHOD_TUNNEL_REQUEST: - dissect_amqp_0_9_method_tunnel_request(tvb, - pinfo, 11, args_tree); - col_append_str(pinfo->cinfo, COL_INFO, - "Tunnel.Request "); - break; - default: - expert_add_info_format(pinfo, amqp_tree, &ei_amqp_unknown_tunnel_method, "Unknown tunnel method %u", method_id); - } - break; - case AMQP_0_9_CLASS_CONFIRM: - method_id = tvb_get_ntohs(tvb, 9); - proto_tree_add_item(amqp_tree, hf_amqp_method_confirm_method_id, - tvb, 9, 2, ENC_BIG_ENDIAN); - ti = proto_tree_add_item(amqp_tree, hf_amqp_method_arguments, - tvb, 11, length - 4, ENC_NA); - args_tree = proto_item_add_subtree(ti, ett_args); - switch (method_id) { - case AMQP_0_9_METHOD_CONFIRM_SELECT: - dissect_amqp_0_9_method_confirm_select(tvb, - 11, args_tree); - col_append_str(pinfo->cinfo, COL_INFO, - "Confirm.Select "); - break; - case AMQP_0_9_METHOD_CONFIRM_SELECT_OK: - dissect_amqp_0_9_method_confirm_select_ok(channel_num, tvb, pinfo, - 11, args_tree); - col_append_str(pinfo->cinfo, COL_INFO, - "Confirm.Select-Ok "); - break; - default: - expert_add_info_format(pinfo, amqp_tree, &ei_amqp_unknown_confirm_method, "Unknown confirm method %u", method_id); - } - break; - default: - expert_add_info_format(pinfo, amqp_tree, &ei_amqp_unknown_method_class, "Unknown method class %u", class_id); - } - break; - case AMQP_0_9_FRAME_TYPE_CONTENT_HEADER: - class_id = tvb_get_ntohs(tvb, 7); - proto_tree_add_item(amqp_tree, hf_amqp_header_class_id, - tvb, 7, 2, ENC_BIG_ENDIAN); - proto_tree_add_item(amqp_tree, hf_amqp_header_weight, - tvb, 9, 2, ENC_BIG_ENDIAN); - proto_tree_add_item(amqp_tree, hf_amqp_header_body_size, - tvb, 11, 8, ENC_BIG_ENDIAN); - proto_tree_add_item(amqp_tree, hf_amqp_header_property_flags, - tvb, 19, 2, ENC_BIG_ENDIAN); - ti = proto_tree_add_item(amqp_tree, hf_amqp_header_properties, - tvb, 21, length - 14, ENC_NA); - prop_tree = proto_item_add_subtree(ti, ett_props); - col_append_str(pinfo->cinfo, COL_INFO, "Content-Header "); - switch (class_id) { - case AMQP_0_9_CLASS_BASIC: - dissect_amqp_0_9_content_header_basic(tvb, - pinfo, 21, prop_tree); - break; - case AMQP_0_9_CLASS_FILE: - dissect_amqp_0_9_content_header_file(tvb, - pinfo, 21, prop_tree); - break; - case AMQP_0_9_CLASS_STREAM: - dissect_amqp_0_9_content_header_stream(tvb, - pinfo, 21, prop_tree); - break; - case AMQP_0_9_CLASS_TUNNEL: - dissect_amqp_0_9_content_header_tunnel(tvb, - pinfo, 21, prop_tree); - break; - default: - expert_add_info_format(pinfo, amqp_tree, &ei_amqp_unknown_header_class, "Unknown header class %u", class_id); - } - break; - case AMQP_0_9_FRAME_TYPE_CONTENT_BODY: - proto_tree_add_item(amqp_tree, hf_amqp_payload, - tvb, 7, length, ENC_NA); - col_append_str(pinfo->cinfo, COL_INFO, "Content-Body "); - break; - case AMQP_0_9_FRAME_TYPE_HEARTBEAT: - col_append_str(pinfo->cinfo, COL_INFO, - "Heartbeat "); - break; - default: - expert_add_info_format(pinfo, amqp_tree, &ei_amqp_unknown_frame_type, "Unknown frame type %u", frame_type); - } - - col_set_fence(pinfo->cinfo, COL_INFO); - return tvb_reported_length(tvb); -} /* Dissection routine for method Connection.Start */ @@ -8165,18 +6698,18 @@ dissect_amqp_0_9_method_connection_start_ok(tvbuff_t *tvb, packet_info *pinfo, /* mechanism (shortstr) */ proto_tree_add_item(args_tree, hf_amqp_method_connection_start_ok_mechanism, - tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA); - offset += 1 + tvb_get_guint8(tvb, offset); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + offset += (1 + tvb_get_guint8(tvb, offset)); /* response (longstr) */ proto_tree_add_item(args_tree, hf_amqp_method_connection_start_ok_response, - tvb, offset + 4, tvb_get_ntohl(tvb, offset), ENC_NA); - offset += 4 + tvb_get_ntohl(tvb, offset); + tvb, offset, 4, ENC_BIG_ENDIAN); + offset += (4 + tvb_get_ntohl(tvb, offset)); /* locale (shortstr) */ proto_tree_add_item(args_tree, hf_amqp_method_connection_start_ok_locale, - tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA); - offset += 1 + tvb_get_guint8(tvb, offset); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + offset += (1 + tvb_get_guint8(tvb, offset)); return offset; } @@ -8189,8 +6722,8 @@ dissect_amqp_0_9_method_connection_secure(tvbuff_t *tvb, { /* challenge (longstr) */ proto_tree_add_item(args_tree, hf_amqp_method_connection_secure_challenge, - tvb, offset + 4, tvb_get_ntohl(tvb, offset), ENC_NA); - offset += 4 + tvb_get_ntohl(tvb, offset); + tvb, offset, 4, ENC_BIG_ENDIAN); + offset += (4 + tvb_get_ntohl(tvb, offset)); return offset; } @@ -8203,8 +6736,8 @@ dissect_amqp_0_9_method_connection_secure_ok(tvbuff_t *tvb, { /* response (longstr) */ proto_tree_add_item(args_tree, hf_amqp_method_connection_secure_ok_response, - tvb, offset + 4, tvb_get_ntohl(tvb, offset), ENC_NA); - offset += 4 + tvb_get_ntohl(tvb, offset); + tvb, offset, 4, ENC_BIG_ENDIAN); + offset += (4 + tvb_get_ntohl(tvb, offset)); return offset; } @@ -8266,9 +6799,9 @@ dissect_amqp_0_9_method_connection_open(tvbuff_t *tvb, packet_info *pinfo, const guint8* vhost; /* virtual-host (shortstr) */ proto_tree_add_item_ret_string(args_tree, hf_amqp_method_connection_open_virtual_host, - tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA, wmem_packet_scope(), &vhost); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN, wmem_packet_scope(), &vhost); col_append_fstr(pinfo->cinfo, COL_INFO, "vhost=%s ", vhost); - offset += 1 + tvb_get_guint8(tvb, offset); + offset += (1 + tvb_get_guint8(tvb, offset)); /* capabilities (shortstr) */ proto_tree_add_item(args_tree, hf_amqp_0_9_method_connection_open_capabilities, @@ -8304,8 +6837,8 @@ dissect_amqp_0_9_method_connection_redirect(tvbuff_t *tvb, { /* host (shortstr) */ proto_tree_add_item(args_tree, hf_amqp_method_connection_redirect_host, - tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA); - offset += 1 + tvb_get_guint8(tvb, offset); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); + offset += (1 + tvb_get_guint8(tvb, offset)); /* known-hosts (shortstr) */ proto_tree_add_item(args_tree, hf_amqp_0_9_method_connection_redirect_known_hosts, @@ -8333,9 +6866,9 @@ dissect_amqp_0_9_method_connection_close(tvbuff_t *tvb, packet_info *pinfo, /* reply-text (shortstr) */ proto_tree_add_item_ret_string(args_tree, hf_amqp_method_connection_close_reply_text, - tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA, wmem_packet_scope(), &reply); + tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN, wmem_packet_scope(), &reply); col_append_fstr(pinfo->cinfo, COL_INFO, "reply=%s ", reply); - offset += 1 + tvb_get_guint8(tvb, offset); + offset += (1 + tvb_get_guint8(tvb, offset)); /* class-id (short) */ proto_tree_add_item(args_tree, hf_amqp_method_connection_close_class_id, @@ -10488,6 +9021,699 @@ dissect_amqp_0_9_content_header_tunnel(tvbuff_t *tvb, packet_info *pinfo, return offset; } +/* Dissection routine for AMQP 0-9 frames */ + +static int +dissect_amqp_0_9_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) +{ + proto_item *ti; + proto_item *amqp_tree = NULL; + proto_item *args_tree; + proto_item *prop_tree; + guint length; + guint8 frame_type; + guint16 channel_num, class_id, method_id; + + /* Heuristic - protocol initialisation frame starts with 'AMQP' */ + if (tvb_memeql(tvb, 0, "AMQP", 4) == 0) { + guint8 proto_id, proto_major, proto_minor; + + proto_id = tvb_get_guint8(tvb, 5); + proto_major = tvb_get_guint8(tvb, 6); + proto_minor = tvb_get_guint8(tvb, 7); + col_append_fstr(pinfo->cinfo, COL_INFO, "Protocol-Header %u-%u-%u", + proto_id, + proto_major, + proto_minor); + col_set_fence(pinfo->cinfo, COL_INFO); + + if (tree) { + ti = proto_tree_add_item(tree, proto_amqp, tvb, 0, -1, ENC_NA); + amqp_tree = proto_item_add_subtree(ti, ett_amqp_init); + proto_tree_add_item(amqp_tree, hf_amqp_init_protocol, tvb, 0, 4, ENC_ASCII|ENC_NA); + proto_tree_add_item(amqp_tree, hf_amqp_init_id_major, tvb, 4, 1, ENC_BIG_ENDIAN); + proto_tree_add_item(amqp_tree, hf_amqp_init_id_minor, tvb, 5, 1, ENC_BIG_ENDIAN); + proto_tree_add_item(amqp_tree, hf_amqp_init_version_major, tvb, 6, 1, ENC_BIG_ENDIAN); + proto_tree_add_item(amqp_tree, hf_amqp_init_version_minor, tvb, 7, 1, ENC_BIG_ENDIAN); + } + return 8; + } + + if (tree) { + ti = proto_tree_add_item(tree, proto_amqp, tvb, 0, -1, ENC_NA); + amqp_tree = proto_item_add_subtree(ti, ett_amqp); + proto_tree_add_item(amqp_tree, hf_amqp_0_9_type, tvb, 0, 1, ENC_BIG_ENDIAN); + proto_tree_add_item(amqp_tree, hf_amqp_channel, tvb, 1, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(amqp_tree, hf_amqp_0_9_length, tvb, 3, 4, ENC_BIG_ENDIAN); + } + + frame_type = tvb_get_guint8(tvb, 0); + channel_num = tvb_get_ntohs(tvb, 1); + length = tvb_get_ntohl(tvb, 3); + + switch (frame_type) { + case AMQP_0_9_FRAME_TYPE_METHOD: + class_id = tvb_get_ntohs(tvb, 7); + proto_tree_add_item(amqp_tree, hf_amqp_0_9_method_class_id, + tvb, 7, 2, ENC_BIG_ENDIAN); + switch (class_id) { + case AMQP_0_9_CLASS_CONNECTION: + method_id = tvb_get_ntohs(tvb, 9); + proto_tree_add_item(amqp_tree, hf_amqp_method_connection_method_id, + tvb, 9, 2, ENC_BIG_ENDIAN); + ti = proto_tree_add_item(amqp_tree, hf_amqp_method_arguments, + tvb, 11, length - 4, ENC_NA); + args_tree = proto_item_add_subtree(ti, ett_args); + col_append_fstr(pinfo->cinfo, COL_INFO, "Connection.%s ", + val_to_str( method_id, amqp_method_connection_methods, "Unknown (%u)")); + switch (method_id) { + case AMQP_0_9_METHOD_CONNECTION_START: + dissect_amqp_0_9_method_connection_start(tvb, + pinfo, 11, args_tree); + break; + case AMQP_0_9_METHOD_CONNECTION_START_OK: + dissect_amqp_0_9_method_connection_start_ok(tvb, + pinfo, 11, args_tree); + break; + case AMQP_0_9_METHOD_CONNECTION_SECURE: + dissect_amqp_0_9_method_connection_secure(tvb, + 11, args_tree); + break; + case AMQP_0_9_METHOD_CONNECTION_SECURE_OK: + dissect_amqp_0_9_method_connection_secure_ok(tvb, + 11, args_tree); + break; + case AMQP_0_9_METHOD_CONNECTION_TUNE: + dissect_amqp_0_9_method_connection_tune(tvb, + 11, args_tree); + break; + case AMQP_0_9_METHOD_CONNECTION_TUNE_OK: + dissect_amqp_0_9_method_connection_tune_ok(tvb, + 11, args_tree); + break; + case AMQP_0_9_METHOD_CONNECTION_OPEN: + dissect_amqp_0_9_method_connection_open(tvb, + pinfo, 11, args_tree); + break; + case AMQP_0_9_METHOD_CONNECTION_OPEN_OK: + dissect_amqp_0_9_method_connection_open_ok(tvb, + 11, args_tree); + break; + case AMQP_0_9_METHOD_CONNECTION_REDIRECT: + dissect_amqp_0_9_method_connection_redirect(tvb, + 11, args_tree); + break; + case AMQP_0_9_METHOD_CONNECTION_CLOSE: + dissect_amqp_0_9_method_connection_close(tvb, + pinfo, 11, args_tree); + break; + case AMQP_0_9_METHOD_CONNECTION_CLOSE_OK: + dissect_amqp_0_9_method_connection_close_ok(tvb, + 11, args_tree); + break; + case AMQP_0_9_METHOD_CONNECTION_BLOCKED: + dissect_amqp_0_9_method_connection_blocked(tvb, + 11, args_tree); + break; + case AMQP_0_9_METHOD_CONNECTION_UNBLOCKED: + dissect_amqp_0_9_method_connection_unblocked(tvb, + 11, args_tree); + break; + default: + expert_add_info_format(pinfo, amqp_tree, &ei_amqp_unknown_connection_method, "Unknown connection method %u", method_id); + } + break; + case AMQP_0_9_CLASS_CHANNEL: + method_id = tvb_get_ntohs(tvb, 9); + proto_tree_add_item(amqp_tree, hf_amqp_method_channel_method_id, + tvb, 9, 2, ENC_BIG_ENDIAN); + ti = proto_tree_add_item(amqp_tree, hf_amqp_method_arguments, + tvb, 11, length - 4, ENC_NA); + args_tree = proto_item_add_subtree(ti, ett_args); + + col_append_fstr(pinfo->cinfo, COL_INFO, "Channel.%s ", + val_to_str( method_id, amqp_method_channel_methods, "Unknown (%u)")); + + switch (method_id) { + case AMQP_0_9_METHOD_CHANNEL_OPEN: + dissect_amqp_0_9_method_channel_open(tvb, + 11, args_tree); + break; + case AMQP_0_9_METHOD_CHANNEL_OPEN_OK: + dissect_amqp_0_9_method_channel_open_ok(tvb, + 11, args_tree); + break; + case AMQP_0_9_METHOD_CHANNEL_FLOW: + dissect_amqp_0_9_method_channel_flow(tvb, + 11, args_tree); + break; + case AMQP_0_9_METHOD_CHANNEL_FLOW_OK: + dissect_amqp_0_9_method_channel_flow_ok(tvb, + 11, args_tree); + break; + case AMQP_0_9_METHOD_CHANNEL_CLOSE: + dissect_amqp_0_9_method_channel_close(channel_num, tvb, + pinfo, 11, args_tree); + break; + case AMQP_0_9_METHOD_CHANNEL_CLOSE_OK: + dissect_amqp_0_9_method_channel_close_ok(tvb, + 11, args_tree); + break; + case AMQP_0_9_METHOD_CHANNEL_RESUME: + dissect_amqp_0_9_method_channel_resume(tvb, + 11, args_tree); + break; + case AMQP_0_9_METHOD_CHANNEL_PING: + dissect_amqp_0_9_method_channel_ping(tvb, + 11, args_tree); + break; + case AMQP_0_9_METHOD_CHANNEL_PONG: + dissect_amqp_0_9_method_channel_pong(tvb, + 11, args_tree); + break; + case AMQP_0_9_METHOD_CHANNEL_OK: + dissect_amqp_0_9_method_channel_ok(tvb, + 11, args_tree); + break; + default: + expert_add_info_format(pinfo, amqp_tree, &ei_amqp_unknown_channel_method, "Unknown channel method %u", method_id); + } + break; + case AMQP_0_9_CLASS_ACCESS: + method_id = tvb_get_ntohs(tvb, 9); + proto_tree_add_item(amqp_tree, hf_amqp_method_access_method_id, + tvb, 9, 2, ENC_BIG_ENDIAN); + ti = proto_tree_add_item(amqp_tree, hf_amqp_method_arguments, + tvb, 11, length - 4, ENC_NA); + args_tree = proto_item_add_subtree(ti, ett_args); + switch (method_id) { + case AMQP_0_9_METHOD_ACCESS_REQUEST: + dissect_amqp_0_9_method_access_request(tvb, + 11, args_tree); + col_append_str(pinfo->cinfo, COL_INFO, + "Access.Request "); + break; + case AMQP_0_9_METHOD_ACCESS_REQUEST_OK: + dissect_amqp_0_9_method_access_request_ok(tvb, + 11, args_tree); + col_append_str(pinfo->cinfo, COL_INFO, + "Access.Request-Ok "); + break; + default: + expert_add_info_format(pinfo, amqp_tree, &ei_amqp_unknown_access_method, "Unknown access method %u", method_id); + } + break; + case AMQP_0_9_CLASS_EXCHANGE: + method_id = tvb_get_ntohs(tvb, 9); + proto_tree_add_item(amqp_tree, hf_amqp_method_exchange_method_id, + tvb, 9, 2, ENC_BIG_ENDIAN); + ti = proto_tree_add_item(amqp_tree, hf_amqp_method_arguments, + tvb, 11, length - 4, ENC_NA); + args_tree = proto_item_add_subtree(ti, ett_args); + col_append_fstr(pinfo->cinfo, COL_INFO, "Exchange.%s ", + val_to_str( method_id, amqp_method_exchange_methods, "Unknown (%u)")); + switch (method_id) { + case AMQP_0_9_METHOD_EXCHANGE_DECLARE: + dissect_amqp_0_9_method_exchange_declare(tvb, + pinfo, 11, args_tree); + break; + case AMQP_0_9_METHOD_EXCHANGE_DECLARE_OK: + dissect_amqp_0_9_method_exchange_declare_ok(tvb, + 11, args_tree); + break; + case AMQP_0_9_METHOD_EXCHANGE_BIND: + dissect_amqp_0_9_method_exchange_bind(tvb, + pinfo, 11, args_tree); + break; + case AMQP_0_9_METHOD_EXCHANGE_BIND_OK: + dissect_amqp_0_9_method_exchange_bind_ok(tvb, + 11, args_tree); + break; + case AMQP_0_9_METHOD_EXCHANGE_DELETE: + dissect_amqp_0_9_method_exchange_delete(tvb, + pinfo, 11, args_tree); + break; + case AMQP_0_9_METHOD_EXCHANGE_DELETE_OK: + dissect_amqp_0_9_method_exchange_delete_ok(tvb, + 11, args_tree); + break; + case AMQP_0_9_METHOD_EXCHANGE_UNBIND: + /* the same parameters as in bind */ + dissect_amqp_0_9_method_exchange_bind(tvb, + pinfo, 11, args_tree); + break; + case AMQP_0_9_METHOD_EXCHANGE_UNBIND_OK: + /* the same parameters as in bind-ok */ + dissect_amqp_0_9_method_exchange_bind_ok(tvb, + 11, args_tree); + break; + default: + expert_add_info_format(pinfo, amqp_tree, &ei_amqp_unknown_exchange_method, "Unknown exchange method %u", method_id); + } + break; + case AMQP_0_9_CLASS_QUEUE: + method_id = tvb_get_ntohs(tvb, 9); + proto_tree_add_item(amqp_tree, hf_amqp_method_queue_method_id, + tvb, 9, 2, ENC_BIG_ENDIAN); + ti = proto_tree_add_item(amqp_tree, hf_amqp_method_arguments, + tvb, 11, length - 4, ENC_NA); + args_tree = proto_item_add_subtree(ti, ett_args); + col_append_fstr(pinfo->cinfo, COL_INFO, "Queue.%s ", + val_to_str( method_id, amqp_method_queue_methods, "Unknown (%u)")); + + switch (method_id) { + case AMQP_0_9_METHOD_QUEUE_DECLARE: + dissect_amqp_0_9_method_queue_declare(tvb, + pinfo, 11, args_tree); + break; + case AMQP_0_9_METHOD_QUEUE_DECLARE_OK: + dissect_amqp_0_9_method_queue_declare_ok(tvb, + pinfo, 11, args_tree); + break; + case AMQP_0_9_METHOD_QUEUE_BIND: + dissect_amqp_0_9_method_queue_bind(tvb, + pinfo, 11, args_tree); + break; + case AMQP_0_9_METHOD_QUEUE_BIND_OK: + dissect_amqp_0_9_method_queue_bind_ok(tvb, + 11, args_tree); + break; + case AMQP_0_9_METHOD_QUEUE_UNBIND: + dissect_amqp_0_9_method_queue_unbind(tvb, + pinfo, 11, args_tree); + break; + case AMQP_0_9_METHOD_QUEUE_UNBIND_OK: + dissect_amqp_0_9_method_queue_unbind_ok(tvb, + 11, args_tree); + break; + case AMQP_0_9_METHOD_QUEUE_PURGE: + dissect_amqp_0_9_method_queue_purge(tvb, + pinfo, 11, args_tree); + break; + case AMQP_0_9_METHOD_QUEUE_PURGE_OK: + dissect_amqp_0_9_method_queue_purge_ok(tvb, + 11, args_tree); + break; + case AMQP_0_9_METHOD_QUEUE_DELETE: + dissect_amqp_0_9_method_queue_delete(tvb, + pinfo, 11, args_tree); + break; + case AMQP_0_9_METHOD_QUEUE_DELETE_OK: + dissect_amqp_0_9_method_queue_delete_ok(tvb, + 11, args_tree); + break; + default: + expert_add_info_format(pinfo, amqp_tree, &ei_amqp_unknown_queue_method, "Unknown queue method %u", method_id); + } + break; + case AMQP_0_9_CLASS_BASIC: + method_id = tvb_get_ntohs(tvb, 9); + proto_tree_add_item(amqp_tree, hf_amqp_method_basic_method_id, + tvb, 9, 2, ENC_BIG_ENDIAN); + ti = proto_tree_add_item(amqp_tree, hf_amqp_method_arguments, + tvb, 11, length - 4, ENC_NA); + args_tree = proto_item_add_subtree(ti, ett_args); + + col_append_fstr(pinfo->cinfo, COL_INFO, "Basic.%s ", + val_to_str( method_id, amqp_method_basic_methods, "Unknown (%u)")); + + switch (method_id) { + case AMQP_0_9_METHOD_BASIC_QOS: + dissect_amqp_0_9_method_basic_qos(tvb, + 11, args_tree); + break; + case AMQP_0_9_METHOD_BASIC_QOS_OK: + dissect_amqp_0_9_method_basic_qos_ok(tvb, + 11, args_tree); + break; + case AMQP_0_9_METHOD_BASIC_CONSUME: + dissect_amqp_0_9_method_basic_consume(tvb, + pinfo, 11, args_tree); + break; + case AMQP_0_9_METHOD_BASIC_CONSUME_OK: + dissect_amqp_0_9_method_basic_consume_ok(tvb, + 11, args_tree); + break; + case AMQP_0_9_METHOD_BASIC_CANCEL: + dissect_amqp_0_9_method_basic_cancel(tvb, + 11, args_tree); + break; + case AMQP_0_9_METHOD_BASIC_CANCEL_OK: + dissect_amqp_0_9_method_basic_cancel_ok(tvb, + 11, args_tree); + break; + case AMQP_0_9_METHOD_BASIC_PUBLISH: + dissect_amqp_0_9_method_basic_publish(channel_num, tvb, + pinfo, 11, args_tree); + generate_ack_reference(tvb, pinfo, amqp_tree); + break; + case AMQP_0_9_METHOD_BASIC_RETURN: + dissect_amqp_0_9_method_basic_return(tvb, + pinfo, 11, args_tree); + break; + case AMQP_0_9_METHOD_BASIC_DELIVER: + dissect_amqp_0_9_method_basic_deliver(channel_num, tvb, + pinfo, 11, args_tree); + generate_ack_reference(tvb, pinfo, amqp_tree); + break; + case AMQP_0_9_METHOD_BASIC_GET: + dissect_amqp_0_9_method_basic_get(tvb, + pinfo, 11, args_tree); + break; + case AMQP_0_9_METHOD_BASIC_GET_OK: + dissect_amqp_0_9_method_basic_get_ok(channel_num, tvb, + pinfo, 11, args_tree); + generate_ack_reference(tvb, pinfo, amqp_tree); + break; + case AMQP_0_9_METHOD_BASIC_GET_EMPTY: + dissect_amqp_0_9_method_basic_get_empty(tvb, + 11, args_tree); + break; + case AMQP_0_9_METHOD_BASIC_ACK: + dissect_amqp_0_9_method_basic_ack(channel_num, tvb, + pinfo, 11, args_tree); + generate_msg_reference(tvb, pinfo, amqp_tree); + break; + case AMQP_0_9_METHOD_BASIC_REJECT: + dissect_amqp_0_9_method_basic_reject(channel_num, tvb, + pinfo, 11, args_tree); + generate_msg_reference(tvb, pinfo, amqp_tree); + break; + case AMQP_0_9_METHOD_BASIC_RECOVER_ASYNC: + dissect_amqp_0_9_method_basic_recover_async(tvb, + 11, args_tree); + break; + case AMQP_0_9_METHOD_BASIC_RECOVER: + dissect_amqp_0_9_method_basic_recover(tvb, + 11, args_tree); + break; + case AMQP_0_9_METHOD_BASIC_RECOVER_OK: + dissect_amqp_0_9_method_basic_recover_ok(tvb, + 11, args_tree); + break; + case AMQP_0_9_METHOD_BASIC_NACK: + dissect_amqp_0_9_method_basic_nack(channel_num, tvb, + pinfo, 11, args_tree); + generate_msg_reference(tvb, pinfo, amqp_tree); + break; + default: + expert_add_info_format(pinfo, amqp_tree, &ei_amqp_unknown_basic_method, "Unknown basic method %u", method_id); + } + break; + case AMQP_0_9_CLASS_FILE: + method_id = tvb_get_ntohs(tvb, 9); + proto_tree_add_item(amqp_tree, hf_amqp_method_file_method_id, + tvb, 9, 2, ENC_BIG_ENDIAN); + ti = proto_tree_add_item(amqp_tree, hf_amqp_method_arguments, + tvb, 11, length - 4, ENC_NA); + args_tree = proto_item_add_subtree(ti, ett_args); + + col_append_fstr(pinfo->cinfo, COL_INFO, "File.%s ", + val_to_str( method_id, amqp_method_file_methods, "Unknown (%u)")); + + switch (method_id) { + case AMQP_0_9_METHOD_FILE_QOS: + dissect_amqp_0_9_method_file_qos(tvb, + 11, args_tree); + break; + case AMQP_0_9_METHOD_FILE_QOS_OK: + dissect_amqp_0_9_method_file_qos_ok(tvb, + 11, args_tree); + break; + case AMQP_0_9_METHOD_FILE_CONSUME: + dissect_amqp_0_9_method_file_consume(tvb, + pinfo, 11, args_tree); + break; + case AMQP_0_9_METHOD_FILE_CONSUME_OK: + dissect_amqp_0_9_method_file_consume_ok(tvb, + 11, args_tree); + break; + case AMQP_0_9_METHOD_FILE_CANCEL: + dissect_amqp_0_9_method_file_cancel(tvb, + 11, args_tree); + break; + case AMQP_0_9_METHOD_FILE_CANCEL_OK: + dissect_amqp_0_9_method_file_cancel_ok(tvb, + 11, args_tree); + break; + case AMQP_0_9_METHOD_FILE_OPEN: + dissect_amqp_0_9_method_file_open(tvb, + 11, args_tree); + break; + case AMQP_0_9_METHOD_FILE_OPEN_OK: + dissect_amqp_0_9_method_file_open_ok(tvb, + 11, args_tree); + break; + case AMQP_0_9_METHOD_FILE_STAGE: + dissect_amqp_0_9_method_file_stage(tvb, + 11, args_tree); + break; + case AMQP_0_9_METHOD_FILE_PUBLISH: + dissect_amqp_0_9_method_file_publish(tvb, + 11, args_tree); + break; + case AMQP_0_9_METHOD_FILE_RETURN: + dissect_amqp_0_9_method_file_return(tvb, + 11, args_tree); + break; + case AMQP_0_9_METHOD_FILE_DELIVER: + dissect_amqp_0_9_method_file_deliver(tvb, + 11, args_tree); + break; + case AMQP_0_9_METHOD_FILE_ACK: + dissect_amqp_0_9_method_file_ack(tvb, + 11, args_tree); + break; + case AMQP_0_9_METHOD_FILE_REJECT: + dissect_amqp_0_9_method_file_reject(tvb, + 11, args_tree); + break; + default: + expert_add_info_format(pinfo, amqp_tree, &ei_amqp_unknown_file_method, "Unknown file method %u", method_id); + } + break; + case AMQP_0_9_CLASS_STREAM: + method_id = tvb_get_ntohs(tvb, 9); + proto_tree_add_item(amqp_tree, hf_amqp_method_stream_method_id, + tvb, 9, 2, ENC_BIG_ENDIAN); + ti = proto_tree_add_item(amqp_tree, hf_amqp_method_arguments, + tvb, 11, length - 4, ENC_NA); + args_tree = proto_item_add_subtree(ti, ett_args); + + col_append_fstr(pinfo->cinfo, COL_INFO, "Stream.%s ", + val_to_str( method_id, amqp_method_stream_methods, "Unknown (%u)")); + + switch (method_id) { + case AMQP_0_9_METHOD_STREAM_QOS: + dissect_amqp_0_9_method_stream_qos(tvb, + 11, args_tree); + break; + case AMQP_0_9_METHOD_STREAM_QOS_OK: + dissect_amqp_0_9_method_stream_qos_ok(tvb, + 11, args_tree); + break; + case AMQP_0_9_METHOD_STREAM_CONSUME: + dissect_amqp_0_9_method_stream_consume(tvb, + pinfo, 11, args_tree); + break; + case AMQP_0_9_METHOD_STREAM_CONSUME_OK: + dissect_amqp_0_9_method_stream_consume_ok(tvb, + 11, args_tree); + break; + case AMQP_0_9_METHOD_STREAM_CANCEL: + dissect_amqp_0_9_method_stream_cancel(tvb, + 11, args_tree); + break; + case AMQP_0_9_METHOD_STREAM_CANCEL_OK: + dissect_amqp_0_9_method_stream_cancel_ok(tvb, + 11, args_tree); + break; + case AMQP_0_9_METHOD_STREAM_PUBLISH: + dissect_amqp_0_9_method_stream_publish(tvb, + 11, args_tree); + break; + case AMQP_0_9_METHOD_STREAM_RETURN: + dissect_amqp_0_9_method_stream_return(tvb, + 11, args_tree); + break; + case AMQP_0_9_METHOD_STREAM_DELIVER: + dissect_amqp_0_9_method_stream_deliver(tvb, + 11, args_tree); + break; + default: + expert_add_info_format(pinfo, amqp_tree, &ei_amqp_unknown_stream_method, "Unknown stream method %u", method_id); + } + break; + case AMQP_0_9_CLASS_TX: + method_id = tvb_get_ntohs(tvb, 9); + proto_tree_add_item(amqp_tree, hf_amqp_method_tx_method_id, + tvb, 9, 2, ENC_BIG_ENDIAN); + ti = proto_tree_add_item(amqp_tree, hf_amqp_method_arguments, + tvb, 11, length - 4, ENC_NA); + args_tree = proto_item_add_subtree(ti, ett_args); + + col_append_fstr(pinfo->cinfo, COL_INFO, "Tx.%s ", + val_to_str( method_id, amqp_method_tx_methods, "Unknown (%u)")); + + switch (method_id) { + case AMQP_0_9_METHOD_TX_SELECT: + dissect_amqp_0_9_method_tx_select(tvb, + 11, args_tree); + break; + case AMQP_0_9_METHOD_TX_SELECT_OK: + dissect_amqp_0_9_method_tx_select_ok(tvb, + 11, args_tree); + break; + case AMQP_0_9_METHOD_TX_COMMIT: + dissect_amqp_0_9_method_tx_commit(tvb, + 11, args_tree); + break; + case AMQP_0_9_METHOD_TX_COMMIT_OK: + dissect_amqp_0_9_method_tx_commit_ok(tvb, + 11, args_tree); + break; + case AMQP_0_9_METHOD_TX_ROLLBACK: + dissect_amqp_0_9_method_tx_rollback(tvb, + 11, args_tree); + break; + case AMQP_0_9_METHOD_TX_ROLLBACK_OK: + dissect_amqp_0_9_method_tx_rollback_ok(tvb, + 11, args_tree); + break; + default: + expert_add_info_format(pinfo, amqp_tree, &ei_amqp_unknown_tx_method, "Unknown tx method %u", method_id); + } + break; + case AMQP_0_9_CLASS_DTX: + method_id = tvb_get_ntohs(tvb, 9); + proto_tree_add_item(amqp_tree, hf_amqp_method_dtx_method_id, + tvb, 9, 2, ENC_BIG_ENDIAN); + ti = proto_tree_add_item(amqp_tree, hf_amqp_method_arguments, + tvb, 11, length - 4, ENC_NA); + args_tree = proto_item_add_subtree(ti, ett_args); + + col_append_fstr(pinfo->cinfo, COL_INFO, "Dtx.%s ", + val_to_str( method_id, amqp_method_dtx_methods, "Unknown (%u)")); + + switch (method_id) { + case AMQP_0_9_METHOD_DTX_SELECT: + dissect_amqp_0_9_method_dtx_select(tvb, + 11, args_tree); + break; + case AMQP_0_9_METHOD_DTX_SELECT_OK: + dissect_amqp_0_9_method_dtx_select_ok(tvb, + 11, args_tree); + break; + case AMQP_0_9_METHOD_DTX_START: + dissect_amqp_0_9_method_dtx_start(tvb, + 11, args_tree); + break; + case AMQP_0_9_METHOD_DTX_START_OK: + dissect_amqp_0_9_method_dtx_start_ok(tvb, + 11, args_tree); + break; + default: + expert_add_info_format(pinfo, amqp_tree, &ei_amqp_unknown_dtx_method, "Unknown dtx method %u", method_id); + } + break; + case AMQP_0_9_CLASS_TUNNEL: + method_id = tvb_get_ntohs(tvb, 9); + proto_tree_add_item(amqp_tree, hf_amqp_method_tunnel_method_id, + tvb, 9, 2, ENC_BIG_ENDIAN); + ti = proto_tree_add_item(amqp_tree, hf_amqp_method_arguments, + tvb, 11, length - 4, ENC_NA); + args_tree = proto_item_add_subtree(ti, ett_args); + switch (method_id) { + case AMQP_0_9_METHOD_TUNNEL_REQUEST: + dissect_amqp_0_9_method_tunnel_request(tvb, + pinfo, 11, args_tree); + col_append_str(pinfo->cinfo, COL_INFO, + "Tunnel.Request "); + break; + default: + expert_add_info_format(pinfo, amqp_tree, &ei_amqp_unknown_tunnel_method, "Unknown tunnel method %u", method_id); + } + break; + case AMQP_0_9_CLASS_CONFIRM: + method_id = tvb_get_ntohs(tvb, 9); + proto_tree_add_item(amqp_tree, hf_amqp_method_confirm_method_id, + tvb, 9, 2, ENC_BIG_ENDIAN); + ti = proto_tree_add_item(amqp_tree, hf_amqp_method_arguments, + tvb, 11, length - 4, ENC_NA); + args_tree = proto_item_add_subtree(ti, ett_args); + switch (method_id) { + case AMQP_0_9_METHOD_CONFIRM_SELECT: + dissect_amqp_0_9_method_confirm_select(tvb, + 11, args_tree); + col_append_str(pinfo->cinfo, COL_INFO, + "Confirm.Select "); + break; + case AMQP_0_9_METHOD_CONFIRM_SELECT_OK: + dissect_amqp_0_9_method_confirm_select_ok(channel_num, tvb, pinfo, + 11, args_tree); + col_append_str(pinfo->cinfo, COL_INFO, + "Confirm.Select-Ok "); + break; + default: + expert_add_info_format(pinfo, amqp_tree, &ei_amqp_unknown_confirm_method, "Unknown confirm method %u", method_id); + } + break; + default: + expert_add_info_format(pinfo, amqp_tree, &ei_amqp_unknown_method_class, "Unknown method class %u", class_id); + } + break; + case AMQP_0_9_FRAME_TYPE_CONTENT_HEADER: + class_id = tvb_get_ntohs(tvb, 7); + proto_tree_add_item(amqp_tree, hf_amqp_header_class_id, + tvb, 7, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(amqp_tree, hf_amqp_header_weight, + tvb, 9, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(amqp_tree, hf_amqp_header_body_size, + tvb, 11, 8, ENC_BIG_ENDIAN); + proto_tree_add_item(amqp_tree, hf_amqp_header_property_flags, + tvb, 19, 2, ENC_BIG_ENDIAN); + ti = proto_tree_add_item(amqp_tree, hf_amqp_header_properties, + tvb, 21, length - 14, ENC_NA); + prop_tree = proto_item_add_subtree(ti, ett_props); + col_append_str(pinfo->cinfo, COL_INFO, "Content-Header "); + switch (class_id) { + case AMQP_0_9_CLASS_BASIC: + dissect_amqp_0_9_content_header_basic(tvb, + pinfo, 21, prop_tree); + break; + case AMQP_0_9_CLASS_FILE: + dissect_amqp_0_9_content_header_file(tvb, + pinfo, 21, prop_tree); + break; + case AMQP_0_9_CLASS_STREAM: + dissect_amqp_0_9_content_header_stream(tvb, + pinfo, 21, prop_tree); + break; + case AMQP_0_9_CLASS_TUNNEL: + dissect_amqp_0_9_content_header_tunnel(tvb, + pinfo, 21, prop_tree); + break; + default: + expert_add_info_format(pinfo, amqp_tree, &ei_amqp_unknown_header_class, "Unknown header class %u", class_id); + } + break; + case AMQP_0_9_FRAME_TYPE_CONTENT_BODY: + proto_tree_add_item(amqp_tree, hf_amqp_payload, + tvb, 7, length, ENC_NA); + col_append_str(pinfo->cinfo, COL_INFO, "Content-Body "); + break; + case AMQP_0_9_FRAME_TYPE_HEARTBEAT: + col_append_str(pinfo->cinfo, COL_INFO, + "Heartbeat "); + break; + default: + expert_add_info_format(pinfo, amqp_tree, &ei_amqp_unknown_frame_type, "Unknown frame type %u", frame_type); + } + + col_set_fence(pinfo->cinfo, COL_INFO); + return tvb_reported_length(tvb); +} + static amqp_channel_t* get_conversation_channel(conversation_t *conv, guint16 channel_num) { @@ -10658,7 +9884,6 @@ get_amqp_1_0_value_formatter(tvbuff_t *tvb, packet_info *pinfo, guint8 code, int offset, - int bound, int hf_amqp_type, const char *name, guint32 hf_amqp_subtype_count, @@ -10701,7 +9926,7 @@ get_amqp_1_0_value_formatter(tvbuff_t *tvb, { /* we know the field as well its type, use native dissectors */ *length_size = element_type->dissector(tvb, pinfo, - offset, bound, + offset, element_type->known_size, item, hf_amqp_type); } @@ -10723,7 +9948,7 @@ get_amqp_1_0_value_formatter(tvbuff_t *tvb, else { /* multi-type and custom fileds must be converted to a string */ - *length_size = element_type->formatter(tvb, offset, bound, element_type->known_size, &value); + *length_size = element_type->formatter(tvb, offset, element_type->known_size, &value); if (code/16 > 0x9) /* variable width code is 0xa[0-9] or 0xb[0-9] */ /* shift to right to skip the variable length indicator */ @@ -10749,7 +9974,6 @@ get_amqp_1_0_value_formatter(tvbuff_t *tvb, *length_size = dissect_amqp_1_0_list(tvb, pinfo, offset-1, /* "-1" due to decode type again in the method */ - bound, item, hf_amqp_type, hf_amqp_subtype_count, @@ -10758,14 +9982,13 @@ get_amqp_1_0_value_formatter(tvbuff_t *tvb, case AMQP_1_0_TYPE_MAP8: case AMQP_1_0_TYPE_MAP32: /* "-1" due to decode type again in the method */ - *length_size = dissect_amqp_1_0_map(tvb, pinfo, offset-1, bound, item, hf_amqp_type, name)-1; + *length_size = dissect_amqp_1_0_map(tvb, pinfo, offset-1, item, hf_amqp_type, name)-1; break; case AMQP_1_0_TYPE_ARRAY8: case AMQP_1_0_TYPE_ARRAY32: *length_size = dissect_amqp_1_0_array(tvb, pinfo, offset-1, /* "-1" due to decode type again in the method */ - bound, item, hf_amqp_type, hf_amqp_subtype_count, @@ -10778,7 +10001,7 @@ get_amqp_1_0_value_formatter(tvbuff_t *tvb, "Unknown AMQP type %d (0x%x) of field \"%s\"", code, code, name ? name : proto_registrar_get_name(hf_amqp_type)); - *length_size = bound-offset; /* to stop dissecting */ + *length_size = tvb_reported_length_remaining(tvb, offset); /* to stop dissecting */ break; } } @@ -10791,7 +10014,6 @@ get_amqp_1_0_value_formatter(tvbuff_t *tvb, static guint get_amqp_1_0_type_formatter(tvbuff_t *tvb, int offset, - int bound, int *hf_amqp_type, const char **name, guint32 *hf_amqp_subtype_count, @@ -10805,12 +10027,12 @@ get_amqp_1_0_type_formatter(tvbuff_t *tvb, guint orig_offset = offset; code = tvb_get_guint8(tvb, offset); - AMQP_INCREMENT(offset, 1, bound); + offset += 1; if (code == AMQP_1_0_TYPE_DESCRIPTOR_CONSTRUCTOR) { format_code_type = tvb_get_guint8(tvb, offset); - AMQP_INCREMENT(offset, 1, bound); + offset += 1; if (format_code_type%16==0xf) { /* i.e. format codes like %x5F %x00-FF */ - AMQP_INCREMENT(offset, 1, bound); + offset += 1; } switch (format_code_type/16) { case 4: /* empty */ @@ -10839,14 +10061,14 @@ get_amqp_1_0_type_formatter(tvbuff_t *tvb, /* TODO: somehow set code = next_128_bytes */ break; case 0xa: /* variable-one */ - format_len = format_amqp_1_0_str(tvb, offset, bound, 1, name); + format_len = format_amqp_1_0_str(tvb, offset, 1, name); break; case 0xb: /* variable-four */ - format_len = format_amqp_1_0_str(tvb, offset, bound, 4, name); + format_len = format_amqp_1_0_str(tvb, offset, 4, name); break; /* TODO: could be type compound? or array? */ } - AMQP_INCREMENT(offset, format_len, bound); + offset += format_len; for (i = 0; amqp_1_0_defined_types[i].format_code != 0x00; ++i) { if (amqp_1_0_defined_types[i].format_code == code) { *hf_amqp_type = *(amqp_1_0_defined_types[i].hf_amqp_type); @@ -10856,7 +10078,7 @@ get_amqp_1_0_type_formatter(tvbuff_t *tvb, } /* now take the real primitive format code */ code = tvb_get_guint8(tvb, offset); - AMQP_INCREMENT(offset, 1, bound); + offset += 1; } *length_size = (offset-orig_offset); return code; @@ -10870,7 +10092,6 @@ static void get_amqp_1_0_type_value_formatter(tvbuff_t *tvb, packet_info *pinfo, int offset, - int bound, int hf_amqp_type, /* what to print in GUI if name==NULL */ const char *name, /* what to print in GUI */ guint *length_size, /* decoded length */ @@ -10885,7 +10106,6 @@ get_amqp_1_0_type_value_formatter(tvbuff_t *tvb, code = get_amqp_1_0_type_formatter(tvb, offset, - bound, &hf_amqp_type, &type_name, &hf_amqp_subtype_count, @@ -10902,12 +10122,11 @@ get_amqp_1_0_type_value_formatter(tvbuff_t *tvb, format_name = wmem_strdup_printf(wmem_packet_scope(), "%s : %s", name, type_name); } } - AMQP_INCREMENT(offset, type_length_size, bound); + offset += type_length_size; get_amqp_1_0_value_formatter(tvb, pinfo, code, offset, - bound, hf_amqp_type, format_name, hf_amqp_subtype_count, @@ -10929,7 +10148,7 @@ get_amqp_timestamp(nstime_t *nstime, tvbuff_t *tvb, guint offset) static int dissect_amqp_1_0_fixed(tvbuff_t *tvb, packet_info *pinfo _U_, - guint offset, guint bound _U_, guint length, + guint offset, guint length, proto_item *item, int hf_amqp_type) { proto_tree_add_item(item, hf_amqp_type, tvb, offset, length, ENC_BIG_ENDIAN); @@ -10938,7 +10157,7 @@ dissect_amqp_1_0_fixed(tvbuff_t *tvb, packet_info *pinfo _U_, static int dissect_amqp_1_0_variable(tvbuff_t *tvb, packet_info *pinfo, - guint offset, guint bound, guint length, + guint offset, guint length, proto_item *item, int hf_amqp_type) { guint bin_length; @@ -10952,7 +10171,7 @@ dissect_amqp_1_0_variable(tvbuff_t *tvb, packet_info *pinfo, "Invalid size of length indicator %d!", length); return length; } - AMQP_INCREMENT(offset, length, bound); + offset += length; proto_tree_add_item(item, hf_amqp_type, tvb, offset, bin_length, ENC_NA); return length+bin_length; @@ -10960,7 +10179,7 @@ dissect_amqp_1_0_variable(tvbuff_t *tvb, packet_info *pinfo, static int dissect_amqp_1_0_timestamp(tvbuff_t *tvb, packet_info *pinfo _U_, - guint offset, guint bound _U_, guint length, + guint offset, guint length, proto_item *item, int hf_amqp_type) { nstime_t nstime; @@ -10972,7 +10191,7 @@ dissect_amqp_1_0_timestamp(tvbuff_t *tvb, packet_info *pinfo _U_, static int dissect_amqp_1_0_skip(tvbuff_t *tvb _U_, packet_info *pinfo _U_, - guint offset _U_, guint bound _U_, guint length _U_, + guint offset _U_, guint length _U_, proto_item *item _U_, int hf_amqp_type _U_) { /* null value means the respective field is omitted */ @@ -10981,7 +10200,7 @@ dissect_amqp_1_0_skip(tvbuff_t *tvb _U_, packet_info *pinfo _U_, static int dissect_amqp_1_0_zero(tvbuff_t *tvb, packet_info *pinfo, - guint offset, guint bound _U_, guint length _U_, + guint offset, guint length _U_, proto_item *item, int hf_amqp_type) { switch(proto_registrar_get_ftype(hf_amqp_type)) @@ -11022,7 +10241,7 @@ dissect_amqp_1_0_zero(tvbuff_t *tvb, packet_info *pinfo, static int dissect_amqp_1_0_true(tvbuff_t *tvb, packet_info *pinfo _U_, - guint offset, guint bound _U_, guint length _U_, + guint offset, guint length _U_, proto_item *item, int hf_amqp_type) { proto_tree_add_boolean(item, hf_amqp_type, tvb, offset-1, 1, TRUE); @@ -11031,7 +10250,7 @@ dissect_amqp_1_0_true(tvbuff_t *tvb, packet_info *pinfo _U_, static int dissect_amqp_1_0_false(tvbuff_t *tvb, packet_info *pinfo _U_, - guint offset, guint bound _U_, guint length _U_, + guint offset, guint length _U_, proto_item *item, int hf_amqp_type) { proto_tree_add_boolean(item, hf_amqp_type, tvb, offset-1, 1, FALSE); @@ -11040,7 +10259,7 @@ dissect_amqp_1_0_false(tvbuff_t *tvb, packet_info *pinfo _U_, static int format_amqp_1_0_null(tvbuff_t *tvb _U_, - guint offset _U_, guint bound _U_, guint length _U_, + guint offset _U_, guint length _U_, const char **value) { *value = "(null)"; @@ -11049,7 +10268,7 @@ format_amqp_1_0_null(tvbuff_t *tvb _U_, static int format_amqp_1_0_boolean_true(tvbuff_t *tvb _U_, - guint offset _U_, guint bound _U_, guint length _U_, + guint offset _U_, guint length _U_, const char **value) { *value = wmem_strdup(wmem_packet_scope(), "true"); @@ -11058,7 +10277,7 @@ format_amqp_1_0_boolean_true(tvbuff_t *tvb _U_, static int format_amqp_1_0_boolean_false(tvbuff_t *tvb _U_, - guint offset _U_, guint bound _U_, guint length _U_, + guint offset _U_, guint length _U_, const char **value) { *value = wmem_strdup(wmem_packet_scope(), "false"); @@ -11067,7 +10286,7 @@ format_amqp_1_0_boolean_false(tvbuff_t *tvb _U_, static int format_amqp_1_0_boolean(tvbuff_t *tvb, - guint offset, guint bound _U_, guint length _U_, + guint offset, guint length _U_, const char **value) { guint8 val; @@ -11080,7 +10299,7 @@ format_amqp_1_0_boolean(tvbuff_t *tvb, /* this covers ubyte, ushort, uint and ulong */ static int format_amqp_1_0_uint(tvbuff_t *tvb, - guint offset, guint bound _U_, guint length, + guint offset, guint length, const char **value) { guint64 val; @@ -11106,7 +10325,7 @@ format_amqp_1_0_uint(tvbuff_t *tvb, /* this covers byte, short, int and long */ static int format_amqp_1_0_int(tvbuff_t *tvb, - guint offset, guint bound _U_, guint length, + guint offset, guint length, const char **value) { gint64 val; @@ -11128,8 +10347,7 @@ format_amqp_1_0_int(tvbuff_t *tvb, } static int -format_amqp_1_0_float(tvbuff_t *tvb, - guint offset, guint bound _U_, guint length _U_, +format_amqp_1_0_float(tvbuff_t *tvb, guint offset, guint length _U_, const char **value) { float floatval; @@ -11139,8 +10357,7 @@ format_amqp_1_0_float(tvbuff_t *tvb, } static int -format_amqp_1_0_double(tvbuff_t *tvb, - guint offset, guint bound _U_, guint length _U_, +format_amqp_1_0_double(tvbuff_t *tvb, guint offset, guint length _U_, const char **value) { double doubleval; @@ -11150,8 +10367,7 @@ format_amqp_1_0_double(tvbuff_t *tvb, } static int -format_amqp_1_0_decimal(tvbuff_t *tvb _U_, - guint offset _U_, guint bound _U_, guint length, +format_amqp_1_0_decimal(tvbuff_t *tvb _U_, guint offset _U_, guint length, const char **value) { /* TODO: this requires the _Decimal32 datatype from ISO/IEC TR 24732 @@ -11162,8 +10378,7 @@ format_amqp_1_0_decimal(tvbuff_t *tvb _U_, } static int -format_amqp_1_0_char(tvbuff_t *tvb, - guint offset, guint bound _U_, guint length _U_, +format_amqp_1_0_char(tvbuff_t *tvb, guint offset, guint length _U_, const char **value) { /* one UTF-32BE encoded Unicode character */ @@ -11172,8 +10387,7 @@ format_amqp_1_0_char(tvbuff_t *tvb, } static int -format_amqp_1_0_timestamp(tvbuff_t *tvb, - guint offset, guint bound _U_, guint length _U_, +format_amqp_1_0_timestamp(tvbuff_t *tvb, guint offset, guint length _U_, const char **value) { nstime_t nstime; @@ -11184,8 +10398,7 @@ format_amqp_1_0_timestamp(tvbuff_t *tvb, } static int -format_amqp_1_0_uuid(tvbuff_t *tvb, - guint offset, guint bound _U_, guint length _U_, +format_amqp_1_0_uuid(tvbuff_t *tvb, guint offset, guint length _U_, const char **value) { e_guid_t uuid; @@ -11196,7 +10409,7 @@ format_amqp_1_0_uuid(tvbuff_t *tvb, static int format_amqp_1_0_bin(tvbuff_t *tvb, - guint offset, guint bound, guint length, + guint offset, guint length, const char **value) { guint bin_length; @@ -11209,14 +10422,14 @@ format_amqp_1_0_bin(tvbuff_t *tvb, *value = wmem_strdup_printf(wmem_packet_scope(), "Invalid binary length size %d!", length); return length; } - AMQP_INCREMENT(offset, length, bound); + offset += length; *value = tvb_bytes_to_str(wmem_packet_scope(), tvb, offset, bin_length); return (length+bin_length); } static int format_amqp_1_0_str(tvbuff_t *tvb, - guint offset, guint bound, guint length, + guint offset, guint length, const char **value) { guint string_length; @@ -11229,15 +10442,15 @@ format_amqp_1_0_str(tvbuff_t *tvb, *value = wmem_strdup_printf(wmem_packet_scope(), "Invalid string length size %d!", length); return length; } - AMQP_INCREMENT(offset, length, bound); + offset += length; *value = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, string_length, ENC_UTF_8|ENC_NA); - AMQP_INCREMENT(offset, string_length, bound); + /* offset += string_length; */ return (string_length + length); } static int format_amqp_1_0_symbol(tvbuff_t *tvb, - guint offset, guint bound, guint length, + guint offset, guint length, const char **value) { guint symbol_length; @@ -11249,9 +10462,9 @@ format_amqp_1_0_symbol(tvbuff_t *tvb, *value = wmem_strdup_printf(wmem_packet_scope(), "Invalid symbol length size %d!", length); return length; } - AMQP_INCREMENT(offset, length, bound); + offset += length; *value = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, symbol_length, ENC_ASCII|ENC_NA); - AMQP_INCREMENT(offset, symbol_length, bound); + /* offset += symbol_length; */ return (symbol_length + length); } @@ -11284,7 +10497,7 @@ get_amqp_0_10_type_formatter(guint8 code, static int format_amqp_0_10_bin(tvbuff_t *tvb, - guint offset, guint bound _U_, guint length, + guint offset, guint length, const char **value) { *value = tvb_bytes_to_str(wmem_packet_scope(), tvb, offset, length); @@ -11293,7 +10506,7 @@ format_amqp_0_10_bin(tvbuff_t *tvb, static int format_amqp_0_10_int(tvbuff_t *tvb, - guint offset, guint bound _U_, guint length, + guint offset, guint length, const char **value) { int val; @@ -11314,7 +10527,7 @@ format_amqp_0_10_int(tvbuff_t *tvb, static int format_amqp_0_10_uint(tvbuff_t *tvb, - guint offset, guint bound _U_, guint length, + guint offset, guint length, const char **value) { unsigned int val; @@ -11335,7 +10548,7 @@ format_amqp_0_10_uint(tvbuff_t *tvb, static int format_amqp_0_10_char(tvbuff_t *tvb, - guint offset, guint bound _U_, guint length _U_, + guint offset, guint length _U_, const char **value) { *value = tvb_format_text(tvb, offset, 1); @@ -11344,7 +10557,7 @@ format_amqp_0_10_char(tvbuff_t *tvb, static int format_amqp_0_10_boolean(tvbuff_t *tvb, - guint offset, guint bound _U_, guint length _U_, + guint offset, guint length _U_, const char **value) { guint8 val; @@ -11356,7 +10569,7 @@ format_amqp_0_10_boolean(tvbuff_t *tvb, static int format_amqp_0_10_vbin(tvbuff_t *tvb, - guint offset, guint bound, guint length, + guint offset, guint length, const char **value) { guint bin_length; @@ -11371,15 +10584,15 @@ format_amqp_0_10_vbin(tvbuff_t *tvb, *value = wmem_strdup_printf(wmem_packet_scope(), "Invalid vbin length size %d!", length); return length; } - AMQP_INCREMENT(offset, length, bound); + offset += length; *value = tvb_bytes_to_str(wmem_packet_scope(), tvb, offset, bin_length); - AMQP_INCREMENT(offset, bin_length, bound); + /* offset += bin_length; */ return (bin_length + length); } static int format_amqp_0_10_str(tvbuff_t *tvb, - guint offset, guint bound, guint length, + guint offset, guint length, const char **value) { guint string_length; @@ -11394,9 +10607,9 @@ format_amqp_0_10_str(tvbuff_t *tvb, *value = wmem_strdup_printf(wmem_packet_scope(), "Invalid string length size %d!", length); return length; } - AMQP_INCREMENT(offset, length, bound); + offset += length; *value = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, string_length, ENC_UTF_8|ENC_NA); - AMQP_INCREMENT(offset, string_length, bound); + /* offset += string_length; */ return (string_length + length); } @@ -11404,7 +10617,7 @@ static void format_amqp_0_10_sequence_set(tvbuff_t *tvb, guint offset, guint length, proto_item *item) { - gint values; + guint i, values; /* Must be 4-byte values */ if ((length % 4) != 0) { @@ -11419,17 +10632,66 @@ format_amqp_0_10_sequence_set(tvbuff_t *tvb, guint offset, guint length, values); } proto_item_append_text(item, " ["); - while(values > 0) { + for (i = 0; i < values; i += 2) { proto_item_append_text(item, "(%u, %u)%s", tvb_get_ntohl(tvb, offset), tvb_get_ntohl(tvb, offset + 4), - values > 2 ? ", " : ""); + (i < (values - 2)) ? ", " : ""); offset += 8; - values -= 2; + length -= 8; } proto_item_append_text(item, "]"); } +/* Main dissection routine */ + +static int +dissect_amqp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data) +{ + conversation_t *conv; + amqp_conv *conn; + + col_set_str(pinfo->cinfo, COL_PROTOCOL, "AMQP"); + col_clear(pinfo->cinfo, COL_INFO); + + /* We need at least 8 bytes to check the protocol and get the frame size */ + if (tvb_reported_length (tvb) < 8) { + /* But at this moment we don't know how much we will need */ + pinfo->desegment_len = DESEGMENT_ONE_MORE_SEGMENT; + return -1; /* need more data */ + } + + /* Find (or build) conversation to remember the protocol version */ + conv = find_or_create_conversation(pinfo); + conn = (amqp_conv *)conversation_get_proto_data(conv, proto_amqp); + if (conn == NULL) { + conn = wmem_new0(wmem_file_scope(), amqp_conv); + conn->channels = wmem_map_new(wmem_file_scope(), g_direct_hash, g_direct_equal); + conversation_add_proto_data(conv, proto_amqp, conn); + } + check_amqp_version(tvb, conn); + switch(conn->version) { + case AMQP_V0_9: + tcp_dissect_pdus(tvb, pinfo, tree, TRUE, 7, get_amqp_0_9_message_len, + dissect_amqp_0_9_frame, data); + break; + case AMQP_V0_10: + tcp_dissect_pdus(tvb, pinfo, tree, TRUE, 8, get_amqp_0_10_message_len, + dissect_amqp_0_10_frame, data); + break; + case AMQP_V1_0: + tcp_dissect_pdus(tvb, pinfo, tree, TRUE, 8, get_amqp_1_0_message_len, + dissect_amqp_1_0_frame, data); + break; + default: + col_append_str(pinfo->cinfo, COL_INFO, "AMQP (unknown version)"); + col_set_fence(pinfo->cinfo, COL_INFO); + break; + } + + return tvb_captured_length(tvb); +} + /* Basic registration functions */ void @@ -12082,16 +11344,44 @@ proto_register_amqp(void) "Implementation-specific xid format code", HFILL}}, {&hf_amqp_0_10_dtx_xid_global_id, { "Global-id", "amqp.dtx.xid.global-id", - FT_BYTES, BASE_NONE, NULL, 0x0, + FT_UINT_BYTES, BASE_NONE, NULL, 0x0, "Global transaction id", HFILL}}, {&hf_amqp_0_10_dtx_xid_branch_id, { "Branch-id", "amqp.dtx.xid.branch-id", - FT_BYTES, BASE_NONE, NULL, 0x0, + FT_UINT_BYTES, BASE_NONE, NULL, 0x0, "Transaction branch qualifier", HFILL}}, - {&hf_amqp_0_10_undissected_struct32, { - "(undissected struct)", "amqp.undissected", - FT_NONE, BASE_NONE, NULL, 0x0, - "Message header struct not yet dissected", HFILL}}, + {&hf_amqp_0_10_struct32_size, { + "Size", "amqp.struct32_size", + FT_UINT32, BASE_DEC, NULL, 0x0, + NULL, HFILL}}, + {&hf_amqp_0_10_struct32, { + "struct", "amqp.struct32", + FT_UINT16, BASE_HEX, VALS(amqp_0_10_struct32_vals), 0x0, + NULL, HFILL}}, + {&hf_amqp_0_10_struct32_class, { + "Class", "amqp.struct32.class", + FT_UINT8, BASE_DEC, VALS(amqp_0_10_class), 0x0, + NULL, HFILL}}, + {&hf_amqp_0_10_struct32_struct, { + "Struct", "amqp.struct32.struct", + FT_UINT8, BASE_DEC, NULL, 0x0, + NULL, HFILL}}, + {&hf_amqp_0_10_struct32_padding, { + "Padding", "amqp.struct32.padding", + FT_BYTES, BASE_NONE, NULL, 0x0, + NULL, HFILL}}, + {&hf_amqp_0_10_array_type, { + "Type", "amqp.array.type", + FT_UINT8, BASE_DEC, VALS(amqp_0_10_array_type_vals), 0x0, + NULL, HFILL}}, + {&hf_amqp_0_10_array_element_count, { + "Element count", "amqp.array.element_count", + FT_UINT32, BASE_DEC, NULL, 0x0, + NULL, HFILL}}, + {&hf_amqp_0_10_array_string, { + "String", "amqp.array.string", + FT_UINT_STRING, BASE_NONE, NULL, 0x0, + NULL, HFILL}}, {&hf_amqp_0_10_struct_delivery_properties_discard_unroutable, { "Discard-unroutable", "amqp.message.delivery-properties.discard-unroutable", FT_BOOLEAN, 8, TFS(&tfs_yes_no), 0x01, @@ -12126,11 +11416,11 @@ proto_register_amqp(void) "Expiration time calculated by broker", HFILL}}, {&hf_amqp_0_10_struct_delivery_properties_exchange, { "Exchange", "amqp.message.delivery-properties.exchange", - FT_STRING, BASE_NONE, NULL, 0x0, + FT_UINT_STRING, BASE_NONE, NULL, 0x0, "Originating exchange", HFILL}}, {&hf_amqp_0_10_struct_delivery_properties_routing_key, { "Routing-key", "amqp.message.delivery-properties.routing-key", - FT_STRING, BASE_NONE, NULL, 0x0, + FT_UINT_STRING, BASE_NONE, NULL, 0x0, "Message routing key", HFILL}}, {&hf_amqp_0_10_struct_delivery_properties_resume_ttl, { "Resume-ttl", "amqp.message.delivery-properties.resume-ttl", @@ -12164,7 +11454,7 @@ proto_register_amqp(void) NULL, HFILL}}, {&hf_amqp_0_10_struct_message_properties_correlation, { "Correlation-id", "amqp.message.message-properties.correlation-id", - FT_BYTES, BASE_NONE, NULL, 0x0, + FT_UINT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}}, {&hf_amqp_0_10_struct_message_properties_reply_to, { "Reply-to", "amqp.message.message-properties.reply-to", @@ -12172,19 +11462,19 @@ proto_register_amqp(void) "Address to reply to", HFILL}}, {&hf_amqp_0_10_struct_message_properties_content_type, { "Content-type", "amqp.message.message-properties.content-type", - FT_STRING, BASE_NONE, NULL, 0x0, + FT_UINT_STRING, BASE_NONE, NULL, 0x0, "MIME content type", HFILL}}, {&hf_amqp_0_10_struct_message_properties_content_encoding, { "Content-encoding", "amqp.message.message-properties.content-encoding", - FT_STRING, BASE_NONE, NULL, 0x0, + FT_UINT_STRING, BASE_NONE, NULL, 0x0, "MIME content encoding method", HFILL}}, {&hf_amqp_0_10_struct_message_properties_user_id, { "User-id", "amqp.message.message-properties.user-id", - FT_BYTES, BASE_NONE, NULL, 0x0, + FT_UINT_BYTES, BASE_NONE, NULL, 0x0, "Creating user id", HFILL}}, {&hf_amqp_0_10_struct_message_properties_app_id, { "App-id", "amqp.message.message-properties.app-id", - FT_BYTES, BASE_NONE, NULL, 0x0, + FT_UINT_BYTES, BASE_NONE, NULL, 0x0, "Creating user id", HFILL}}, {&hf_amqp_0_10_struct_message_properties_application_headers, { "Application-headers", "amqp.message.message-properties.application-headers", @@ -12192,11 +11482,11 @@ proto_register_amqp(void) "Application-private headers", HFILL}}, {&hf_amqp_0_10_struct_reply_to_exchange, { "Exchange", "amqp.message.message-properties.reply-to.exchange", - FT_STRING, BASE_NONE, NULL, 0x0, + FT_UINT_STRING, BASE_NONE, NULL, 0x0, "Exchange to reply to", HFILL}}, {&hf_amqp_0_10_struct_reply_to_routing_key, { "Routing-key", "amqp.message.message-properties.reply-to.routing-key", - FT_STRING, BASE_NONE, NULL, 0x0, + FT_UINT_STRING, BASE_NONE, NULL, 0x0, "Routing key to reply with", HFILL}}, {&hf_amqp_0_10_struct_acquired_transfers, { "Transfers", "amqp.message.acquired.transfers", @@ -12256,11 +11546,11 @@ proto_register_amqp(void) "Number of subscribers for the queue", HFILL}}, {&hf_amqp_0_10_struct_file_properties_content_type, { "Content-type", "amqp.file.file-properties.content-type", - FT_STRING, BASE_NONE, NULL, 0x0, + FT_UINT_STRING, BASE_NONE, NULL, 0x0, "MIME content type", HFILL}}, {&hf_amqp_0_10_struct_file_properties_content_encoding, { "Content-encoding", "amqp.file.file-properties.content-encoding", - FT_STRING, BASE_NONE, NULL, 0x0, + FT_UINT_STRING, BASE_NONE, NULL, 0x0, "MIME content encoding", HFILL}}, {&hf_amqp_0_10_struct_file_properties_headers, { "Headers", "amqp.file.file-properties.headers", @@ -12272,15 +11562,15 @@ proto_register_amqp(void) "Message priority, 0 to 9", HFILL}}, {&hf_amqp_0_10_struct_file_properties_reply_to, { "Reply-to", "amqp.file.file-properties.reply-to", - FT_STRING, BASE_NONE, NULL, 0x0, + FT_UINT_STRING, BASE_NONE, NULL, 0x0, "Destination to reply to", HFILL}}, {&hf_amqp_0_10_struct_file_properties_message_id, { "Message-id", "amqp.file.file-properties.message-id", - FT_STRING, BASE_NONE, NULL, 0x0, + FT_UINT_STRING, BASE_NONE, NULL, 0x0, "Application message identifier", HFILL}}, {&hf_amqp_0_10_struct_file_properties_filename, { "Filename", "amqp.file.file-properties.filename", - FT_STRING, BASE_NONE, NULL, 0x0, + FT_UINT_STRING, BASE_NONE, NULL, 0x0, "Message filename", HFILL}}, {&hf_amqp_0_10_struct_file_properties_timestamp, { "Timestamp", "amqp.file.file-properties.timestamp", @@ -12288,15 +11578,15 @@ proto_register_amqp(void) "Message timestamp", HFILL}}, {&hf_amqp_0_10_struct_file_properties_cluster_id, { "Cluster-id", "amqp.file.file-properties.cluster-id", - FT_STRING, BASE_NONE, NULL, 0x0, + FT_UINT_STRING, BASE_NONE, NULL, 0x0, "Intra-cluster routing identifier", HFILL}}, {&hf_amqp_0_10_struct_stream_properties_content_type, { "Content-type", "amqp.stream.stream-properties.content-type", - FT_STRING, BASE_NONE, NULL, 0x0, + FT_UINT_STRING, BASE_NONE, NULL, 0x0, "MIME content type", HFILL}}, {&hf_amqp_0_10_struct_stream_properties_content_encoding, { "Content-encoding", "amqp.stream.stream-properties.content-encoding", - FT_STRING, BASE_NONE, NULL, 0x0, + FT_UINT_STRING, BASE_NONE, NULL, 0x0, "MIME content encoding", HFILL}}, {&hf_amqp_0_10_struct_stream_properties_headers, { "Headers", "amqp.stream.stream-properties.headers", @@ -12323,13 +11613,17 @@ proto_register_amqp(void) FT_BOOLEAN, 8, TFS(&amqp_0_10_session_header_sync), 0x01, "Sync requested", HFILL}}, {&hf_amqp_0_10_method_session_attach_name, { - "Name", "amqp.session.attach.name", + "Session Name", "amqp.session.attach.name", FT_BYTES, BASE_NONE, NULL, 0x0, - "Session name", HFILL}}, + NULL, HFILL}}, + {&hf_amqp_0_10_method_session_attach_name_size, { + "Size", "amqp.session.attach.name.size", + FT_UINT16, BASE_DEC, NULL, 0x0, + NULL, HFILL}}, {&hf_amqp_0_10_method_session_attach_force, { - "Force", "amqp.session.attach.force", + "Session forced", "amqp.session.attach.force", FT_BOOLEAN, 8, TFS(&tfs_yes_no), 0x02, - "Session forced", HFILL}}, + NULL, HFILL}}, {&hf_amqp_0_10_method_session_detached_code, { "Code", "amqp.session.detached.code", FT_UINT8, BASE_DEC, VALS(amqp_0_10_method_session_detached_codes), 0x0, @@ -12384,7 +11678,7 @@ proto_register_amqp(void) "0-based index of exceptional field", HFILL}}, {&hf_amqp_0_10_method_execution_description, { "Description", "amqp.execution.exception.description", - FT_STRING, BASE_NONE, NULL, 0, + FT_UINT_STRING, BASE_NONE, NULL, 0, "Description of exception", HFILL}}, {&hf_amqp_0_10_method_execution_error_info, { "Error-info", "amqp.execution.exception.error-info", @@ -12392,7 +11686,7 @@ proto_register_amqp(void) "client-properties", HFILL}}, {&hf_amqp_0_10_method_message_transfer_destination, { "Description", "amqp.message.transfer.destination", - FT_STRING, BASE_NONE, NULL, 0, + FT_UINT_STRING, BASE_NONE, NULL, 0, "Message destination", HFILL}}, {&hf_amqp_0_10_method_message_transfer_accept_mode, { "Accept-mode", "amqp.message.transfer.accept-mode", @@ -12412,7 +11706,7 @@ proto_register_amqp(void) "Message reject code", HFILL}}, {&hf_amqp_0_10_method_message_reject_text, { "Text", "amqp.message.reject.text", - FT_STRING, BASE_NONE, NULL, 0, + FT_UINT_STRING, BASE_NONE, NULL, 0, "Reject description", HFILL}}, {&hf_amqp_0_10_method_message_release_set_redelivered, { "Set-redelivered", "amqp.message.release.set-redelivered", @@ -12420,15 +11714,15 @@ proto_register_amqp(void) "Mark redelivered on next transfer from queue", HFILL}}, {&hf_amqp_0_10_method_message_dest, { "Destination", "amqp.message.destination", - FT_STRING, BASE_NONE, NULL, 0, + FT_UINT_STRING, BASE_NONE, NULL, 0, "Message destination", HFILL}}, {&hf_amqp_0_10_method_message_resume_id, { "Resume-Id", "amqp.message.resume.id", - FT_STRING, BASE_NONE, NULL, 0, + FT_UINT_STRING, BASE_NONE, NULL, 0, "Message id to resume", HFILL}}, {&hf_amqp_0_10_method_message_subscribe_queue, { "Queue", "amqp.message.subscribe.queue", - FT_STRING, BASE_NONE, NULL, 0, + FT_UINT_STRING, BASE_NONE, NULL, 0, "Queue to subscribe to", HFILL}}, {&hf_amqp_0_10_method_message_subscribe_exclusive, { "Exclusive", "amqp.message.subscribe.exclusive", @@ -12480,15 +11774,15 @@ proto_register_amqp(void) "Transaction timeout value in seconds", HFILL}}, {&hf_amqp_0_10_method_exchange_declare_exchange, { "Exchange", "amqp.exchange.declare.exchange", - FT_STRING, BASE_NONE, NULL, 0, + FT_UINT_STRING, BASE_NONE, NULL, 0, "Exchange to declare", HFILL}}, {&hf_amqp_0_10_method_exchange_declare_type, { "Type", "amqp.exchange.declare.type", - FT_STRING, BASE_NONE, NULL, 0, + FT_UINT_STRING, BASE_NONE, NULL, 0, "Type of exchange to declare", HFILL}}, {&hf_amqp_0_10_method_exchange_declare_alt_exchange, { "Alternate-exchange", "amqp.exchange.declare.alternate-exchange", - FT_STRING, BASE_NONE, NULL, 0, + FT_UINT_STRING, BASE_NONE, NULL, 0, "Alternate exchange for unroutable messages", HFILL}}, {&hf_amqp_0_10_method_exchange_declare_passive, { "Passive", "amqp.exchange.declare.passive", @@ -12512,7 +11806,7 @@ proto_register_amqp(void) "Delete exchange only if it has no queue bindings", HFILL}}, {&hf_amqp_0_10_method_exchange_bind_queue, { "Queue", "amqp.exchange.bind.queue", - FT_STRING, BASE_NONE, NULL, 0, + FT_UINT_STRING, BASE_NONE, NULL, 0, "Queue to bind to", HFILL}}, {&hf_amqp_0_10_method_exchange_binding_key, { "Binding-key", "amqp.exchange.bind.binding-key", @@ -12520,11 +11814,11 @@ proto_register_amqp(void) "Binding between exchange and queue", HFILL}}, {&hf_amqp_0_10_method_queue_name, { "Queue", "amqp.queue.declare.queue", - FT_STRING, BASE_NONE, NULL, 0, + FT_UINT_STRING, BASE_NONE, NULL, 0, "Queue name", HFILL}}, {&hf_amqp_0_10_method_queue_alt_exchange, { "Alternate-exchange", "amqp.queue.declare.alternate-exchange", - FT_STRING, BASE_NONE, NULL, 0, + FT_UINT_STRING, BASE_NONE, NULL, 0, NULL, HFILL}}, {&hf_amqp_0_10_method_queue_declare_passive, { "Passive", "amqp.queue.declare.passive", @@ -12568,7 +11862,7 @@ proto_register_amqp(void) "Apply QoS to entire connection", HFILL}}, {&hf_amqp_0_10_method_file_consumer_tag, { "Consumer-tag", "amqp.file.consumer-tag", - FT_STRING, BASE_NONE, NULL, 0, + FT_UINT_STRING, BASE_NONE, NULL, 0, "Consumer tag", HFILL}}, {&hf_amqp_0_10_method_file_consume_no_local, { "No-local", "amqp.file.consume.no-local", @@ -12592,7 +11886,7 @@ proto_register_amqp(void) "Arguments for consuming", HFILL}}, {&hf_amqp_0_10_method_file_identifier, { "Identifier", "amqp.file.identifier", - FT_STRING, BASE_NONE, NULL, 0, + FT_UINT_STRING, BASE_NONE, NULL, 0, "Staging identifier", HFILL}}, {&hf_amqp_0_10_method_file_open_content_size, { "Content-size", "amqp.file.open.content-size", @@ -12604,11 +11898,11 @@ proto_register_amqp(void) "Amount of previously staged content in octets", HFILL}}, {&hf_amqp_0_10_method_file_publish_exchange, { "Exchange", "amqp.file.publish.exchange", - FT_STRING, BASE_NONE, NULL, 0, + FT_UINT_STRING, BASE_NONE, NULL, 0, "Exchange to publish to", HFILL}}, {&hf_amqp_0_10_method_file_publish_routing_key, { "Routing-key", "amqp.file.publish.routing-key", - FT_STRING, BASE_NONE, NULL, 0, + FT_UINT_STRING, BASE_NONE, NULL, 0, "Message routing key", HFILL}}, {&hf_amqp_0_10_method_file_publish_mandatory, { "Mandatory", "amqp.file.publish.mandatory", @@ -12624,19 +11918,19 @@ proto_register_amqp(void) NULL, HFILL}}, {&hf_amqp_0_10_method_file_return_reply_text, { "Reply-text", "amqp.file.return.reply-text", - FT_STRING, BASE_NONE, NULL, 0, + FT_UINT_STRING, BASE_NONE, NULL, 0, "Localized reply text", HFILL}}, {&hf_amqp_0_10_method_file_return_exchange, { "Exchange", "amqp.file.return.exchange", - FT_STRING, BASE_NONE, NULL, 0, + FT_UINT_STRING, BASE_NONE, NULL, 0, "Exchange the original message was published to", HFILL}}, {&hf_amqp_0_10_method_file_return_routing_key, { "Routing-key", "amqp.file.return.routing-key", - FT_STRING, BASE_NONE, NULL, 0, + FT_UINT_STRING, BASE_NONE, NULL, 0, "Message routing key", HFILL}}, {&hf_amqp_0_10_method_file_deliver_consumer_tag, { "Consumer-tag", "amqp.file.deliver.consumer-tag", - FT_STRING, BASE_NONE, NULL, 0, + FT_UINT_STRING, BASE_NONE, NULL, 0, NULL, HFILL}}, {&hf_amqp_0_10_method_file_deliver_delivery_tag, { "Delivery-tag", "amqp.file.deliver.delivery-tag", @@ -12648,11 +11942,11 @@ proto_register_amqp(void) "Possible duplicate delivery", HFILL}}, {&hf_amqp_0_10_method_file_deliver_exchange, { "Exchange", "amqp.file.deliver.exchange", - FT_STRING, BASE_NONE, NULL, 0, + FT_UINT_STRING, BASE_NONE, NULL, 0, "Exchange the original message was published to", HFILL}}, {&hf_amqp_0_10_method_file_deliver_routing_key, { "Routing-key", "amqp.file.deliver.routing-key", - FT_STRING, BASE_NONE, NULL, 0, + FT_UINT_STRING, BASE_NONE, NULL, 0, "Message routing key", HFILL}}, {&hf_amqp_0_10_method_file_ack_delivery_tag, { "Delivery-tag", "amqp.file.ack.delivery-tag", @@ -12690,7 +11984,7 @@ proto_register_amqp(void) "Apply QoS to entire connection", HFILL}}, {&hf_amqp_0_10_method_stream_consumer_tag, { "Consumer-tag", "amqp.stream.consumer-tag", - FT_STRING, BASE_NONE, NULL, 0, + FT_UINT_STRING, BASE_NONE, NULL, 0, NULL, HFILL}}, {&hf_amqp_0_10_method_stream_consume_no_local, { "No-local", "amqp.stream.consume.no-local", @@ -12710,11 +12004,11 @@ proto_register_amqp(void) "Arguments for consuming", HFILL}}, {&hf_amqp_0_10_method_stream_publish_exchange, { "Exchange", "amqp.stream.publish.exchange", - FT_STRING, BASE_NONE, NULL, 0, + FT_UINT_STRING, BASE_NONE, NULL, 0, "Exchange to publish to", HFILL}}, {&hf_amqp_0_10_method_stream_publish_routing_key, { "Routing-key", "amqp.stream.publish.routing-key", - FT_STRING, BASE_NONE, NULL, 0, + FT_UINT_STRING, BASE_NONE, NULL, 0, "Message routing key", HFILL}}, {&hf_amqp_0_10_method_stream_publish_mandatory, { "Mandatory", "amqp.stream.publish.mandatory", @@ -12730,19 +12024,19 @@ proto_register_amqp(void) NULL, HFILL}}, {&hf_amqp_0_10_method_stream_return_reply_text, { "Reply-text", "amqp.stream.return.reply-text", - FT_STRING, BASE_NONE, NULL, 0, + FT_UINT_STRING, BASE_NONE, NULL, 0, "Localized reply text", HFILL}}, {&hf_amqp_0_10_method_stream_return_exchange, { "Exchange", "amqp.stream.return.exchange", - FT_STRING, BASE_NONE, NULL, 0, + FT_UINT_STRING, BASE_NONE, NULL, 0, "Exchange the original message was published to", HFILL}}, {&hf_amqp_0_10_method_stream_return_routing_key, { "Routing-key", "amqp.stream.return.routing-key", - FT_STRING, BASE_NONE, NULL, 0, + FT_UINT_STRING, BASE_NONE, NULL, 0, "Message routing key", HFILL}}, {&hf_amqp_0_10_method_stream_deliver_consumer_tag, { "Consumer-tag", "amqp.stream.deliver.consumer-tag", - FT_STRING, BASE_NONE, NULL, 0, + FT_UINT_STRING, BASE_NONE, NULL, 0, NULL, HFILL}}, {&hf_amqp_0_10_method_stream_deliver_delivery_tag, { "Delivery-tag", "amqp.stream.deliver.delivery-tag", @@ -12750,16 +12044,20 @@ proto_register_amqp(void) "Server-assigned, session-specific delivery tag", HFILL}}, {&hf_amqp_0_10_method_stream_deliver_exchange, { "Exchange", "amqp.stream.deliver.exchange", - FT_STRING, BASE_NONE, NULL, 0, + FT_UINT_STRING, BASE_NONE, NULL, 0, "Exchange the original message was published to", HFILL}}, {&hf_amqp_0_10_method_stream_deliver_queue, { "Queue", "amqp.stream.deliver.queue", - FT_STRING, BASE_NONE, NULL, 0, + FT_UINT_STRING, BASE_NONE, NULL, 0, "Name of the queue the message came from", HFILL}}, {&hf_amqp_channel, { "Channel", "amqp.channel", FT_UINT16, BASE_DEC, NULL, 0x0, "Channel ID", HFILL}}, + {&hf_amqp_reserved, { + "Reserved", "amqp.reserved", + FT_UINT32, BASE_HEX, NULL, 0x0, + NULL, HFILL}}, {&hf_amqp_0_9_type, { "Type", "amqp.type", FT_UINT8, BASE_DEC, VALS(amqp_0_9_frame_types), 0x0, @@ -12858,23 +12156,23 @@ proto_register_amqp(void) NULL, HFILL}}, {&hf_amqp_method_connection_start_ok_mechanism, { "Mechanism", "amqp.method.arguments.mechanism", - FT_STRING, BASE_NONE, NULL, 0, + FT_UINT_STRING, BASE_NONE, NULL, 0, NULL, HFILL}}, {&hf_amqp_method_connection_start_ok_response, { "Response", "amqp.method.arguments.response", - FT_BYTES, BASE_NONE, NULL, 0, + FT_UINT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL}}, {&hf_amqp_method_connection_start_ok_locale, { "Locale", "amqp.method.arguments.locale", - FT_STRING, BASE_NONE, NULL, 0, + FT_UINT_STRING, BASE_NONE, NULL, 0, NULL, HFILL}}, {&hf_amqp_method_connection_secure_challenge, { "Challenge", "amqp.method.arguments.challenge", - FT_BYTES, BASE_NONE, NULL, 0, + FT_UINT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL}}, {&hf_amqp_method_connection_secure_ok_response, { "Response", "amqp.method.arguments.response", - FT_BYTES, BASE_NONE, NULL, 0, + FT_UINT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL}}, {&hf_amqp_method_connection_tune_channel_max, { "Channel-Max", "amqp.method.arguments.channel_max", @@ -12918,7 +12216,7 @@ proto_register_amqp(void) NULL, HFILL}}, {&hf_amqp_method_connection_open_virtual_host, { "Virtual-Host", "amqp.method.arguments.virtual_host", - FT_STRING, BASE_NONE, NULL, 0, + FT_UINT_STRING, BASE_NONE, NULL, 0, NULL, HFILL}}, {&hf_amqp_0_9_method_connection_open_capabilities, { "Capabilities", "amqp.method.arguments.capabilities", @@ -12946,7 +12244,7 @@ proto_register_amqp(void) "Equivalent or alternate hosts for reconnection", HFILL}}, {&hf_amqp_method_connection_redirect_host, { "Host", "amqp.method.arguments.host", - FT_STRING, BASE_NONE, NULL, 0, + FT_UINT_STRING, BASE_NONE, NULL, 0, NULL, HFILL}}, {&hf_amqp_0_9_method_connection_redirect_known_hosts, { "Known-Hosts", "amqp.method.arguments.known_hosts", @@ -12967,7 +12265,7 @@ proto_register_amqp(void) "Close reason", HFILL}}, {&hf_amqp_method_connection_close_reply_text, { "Reply-Text", "amqp.method.arguments.reply_text", - FT_STRING, BASE_NONE, NULL, 0, + FT_UINT_STRING, BASE_NONE, NULL, 0, NULL, HFILL}}, {&hf_amqp_method_connection_close_class_id, { "Class-Id", "amqp.method.arguments.class_id", @@ -13873,6 +13171,10 @@ proto_register_amqp(void) "Broadcast", "amqp.method.properties.broadcast", FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL}}, + {&hf_amqp_0_10_dtx_xa_status, { + "dtx.xa-status", "amqp.method.properties.broadcast", + FT_UINT16, BASE_DEC, VALS(amqp_0_10_xa_status), 0, + NULL, HFILL}}, {&hf_amqp_payload, { "Payload", "amqp.payload", FT_BYTES, BASE_NONE, NULL, 0, @@ -13912,7 +13214,71 @@ proto_register_amqp(void) {&hf_amqp_ack_in, { "Ack in frame", "amqp.ack_in", FT_FRAMENUM, BASE_NONE, NULL, 0, - NULL, HFILL}} + NULL, HFILL}}, + {&hf_amqp_method_connection_start_server_properties_size, { + "Size", "amqp.method.connection_start.server_properties.size", + FT_UINT32, BASE_DEC, NULL, 0, + NULL, HFILL}}, + {&hf_amqp_0_10_method_connection_start_mechanisms_size, { + "Size", "amqp.method.connection_start.server_properties.size", + FT_UINT32, BASE_DEC, NULL, 0, + NULL, HFILL}}, + {&hf_amqp_0_10_method_connection_start_locales_size, { + "Size", "amqp.method.connection_start.locales.size", + FT_UINT32, BASE_DEC, NULL, 0, + NULL, HFILL}}, + {&hf_amqp_method_connection_start_ok_client_properties_size, { + "Size", "amqp.method.connection_start.ok_client_properties.size", + FT_UINT32, BASE_DEC, NULL, 0, + NULL, HFILL}}, + {&hf_amqp_0_10_method_connection_open_capabilities_size, { + "Size", "amqp.method.connection_open.capabilities.size", + FT_UINT32, BASE_DEC, NULL, 0, + NULL, HFILL}}, + {&hf_amqp_0_10_method_connection_open_ok_known_hosts_size, { + "Size", "amqp.method.connection_open.ok_known_hosts.size", + FT_UINT32, BASE_DEC, NULL, 0, + NULL, HFILL}}, + {&hf_amqp_0_10_method_connection_redirect_known_hosts_size, { + "Size", "amqp.method.connection_redirect.known_hosts.size", + FT_UINT32, BASE_DEC, NULL, 0, + NULL, HFILL}}, + {&hf_amqp_0_10_method_execution_error_info_size, { + "Size", "amqp.method.execution.error_info.size", + FT_UINT32, BASE_DEC, NULL, 0, + NULL, HFILL}}, + {&hf_amqp_0_10_method_exchange_declare_arguments_size, { + "Size", "amqp.method.exchange.declare_argument.size", + FT_UINT32, BASE_DEC, NULL, 0, + NULL, HFILL}}, + {&hf_amqp_0_10_method_queue_declare_arguments_size, { + "Size", "amqp.method.queue.declare_argument.size", + FT_UINT32, BASE_DEC, NULL, 0, + NULL, HFILL}}, + {&hf_amqp_0_10_method_file_consume_arguments_size, { + "Size", "amqp.method.file.consume_arguments.size", + FT_UINT32, BASE_DEC, NULL, 0, + NULL, HFILL}}, + {&hf_amqp_0_10_method_stream_consume_arguments_size, { + "Size", "amqp.method.stream.consume_arguments.size", + FT_UINT32, BASE_DEC, NULL, 0, + NULL, HFILL}}, + {&hf_amqp_0_10_struct_message_properties_application_headers_size, { + "Size", "amqp.struct.message_properties.application_headers.size", + FT_UINT32, BASE_DEC, NULL, 0, + NULL, HFILL}}, + {&hf_amqp_0_10_struct_file_properties_headers_size, { + "Size", "amqp.struct.file.properties_headers.size", + FT_UINT32, BASE_DEC, NULL, 0, + NULL, HFILL}}, + {&hf_amqp_0_10_struct_stream_properties_headers_size, { + "Size", "amqp.struct.stream.properties_headers.size", + FT_UINT32, BASE_DEC, NULL, 0, + NULL, HFILL}}, + {&hf_amqp_0_10_struct_dtx_recover_result_size, { + "Size", "amqp.struct.dtx_recover.result.size", + FT_UINT32, BASE_DEC, NULL, 0, + NULL, HFILL}}, }; /* Setup of protocol subtree array */ @@ -13926,6 +13292,7 @@ proto_register_amqp(void) &ett_amqp_init, &ett_amqp_0_10_map, &ett_amqp_0_10_array, + &ett_amqp_0_10_struct, &ett_amqp_1_0_array, &ett_amqp_1_0_map, &ett_amqp_1_0_list @@ -13936,9 +13303,7 @@ proto_register_amqp(void) { &ei_amqp_channel_error, { "amqp.channel.error", PI_RESPONSE_CODE, PI_WARN, "Channel error", EXPFILL }}, { &ei_amqp_message_undeliverable, { "amqp.message.undeliverable", PI_RESPONSE_CODE, PI_WARN, "Message was not delivered", EXPFILL }}, { &ei_amqp_bad_flag_value, { "amqp.bad_flag_value", PI_PROTOCOL, PI_WARN, "Bad flag value", EXPFILL }}, -#if 0 { &ei_amqp_bad_length, { "amqp.bad_length", PI_MALFORMED, PI_ERROR, "Bad frame length", EXPFILL }}, -#endif { &ei_amqp_field_short, { "amqp.field_short", PI_PROTOCOL, PI_ERROR, "Field is cut off by the end of the field table", EXPFILL }}, { &ei_amqp_invalid_class_code, { "amqp.unknown.class_code", PI_PROTOCOL, PI_WARN, "Invalid class code", EXPFILL }}, { &ei_amqp_unknown_command_class, { "amqp.unknown.command_class", PI_PROTOCOL, PI_ERROR, "Unknown command/control class", EXPFILL }}, @@ -13962,6 +13327,8 @@ proto_register_amqp(void) { &ei_amqp_unknown_amqp_type, { "amqp.unknown.amqp_type", PI_PROTOCOL, PI_ERROR, "Unknown AMQP type", EXPFILL }}, { &ei_amqp_invalid_number_of_params, { "amqp.invalid.params_number", PI_PROTOCOL, PI_ERROR, "Invalid number of parameters", EXPFILL }}, { &ei_amqp_amqp_1_0_frame_length_exceeds_65K, { "amqp.amqp_1_0_frame_length_exceeds_65K", PI_PROTOCOL, PI_WARN, "Frame length exceeds 65K; Dissection limited to 65K", EXPFILL}}, + { &ei_amqp_size_exceeds_65K, { "amqp.size_exceeds_65K", PI_PROTOCOL, PI_WARN, "Size field exceeds 65K; Dissection limited to 65K", EXPFILL}}, + { &ei_amqp_array_type_unknown, { "amqp.array_type_unknown", PI_PROTOCOL, PI_WARN, "Array type unknown", EXPFILL}}, }; expert_module_t* expert_amqp; |