diff options
Diffstat (limited to 'epan/dissectors/packet-scriptingservice.c')
-rw-r--r-- | epan/dissectors/packet-scriptingservice.c | 103 |
1 files changed, 68 insertions, 35 deletions
diff --git a/epan/dissectors/packet-scriptingservice.c b/epan/dissectors/packet-scriptingservice.c index aa0978a21c..2e074ff26a 100644 --- a/epan/dissectors/packet-scriptingservice.c +++ b/epan/dissectors/packet-scriptingservice.c @@ -43,81 +43,114 @@ static int hf_message_flags = -1; static int hf_message_length = -1; static int hf_message_status = -1; static int hf_message_data = -1; +static int hf_message_reason = -1; static int hf_message_info = -1; /* Initialize the subtree pointers */ static gint ett_ssprotocol = -1; -static void +static guint dissect_ssprotocol_message(tvbuff_t *, packet_info *, proto_tree *); /* Dissectors for messages. This is specific to ScriptingServiceProtocol */ -#define MESSAGE_TYPE_LENGTH 1 -#define MESSAGE_FLAGS_LENGTH 1 -#define MESSAGE_LENGTH_LENGTH 2 -#define MESSAGE_STATUS_LENGTH 4 - -#define MESSAGE_TYPE_OFFSET 0 -#define MESSAGE_FLAGS_OFFSET (MESSAGE_TYPE_OFFSET + MESSAGE_TYPE_LENGTH) -#define MESSAGE_LENGTH_OFFSET (MESSAGE_FLAGS_OFFSET + MESSAGE_FLAGS_LENGTH) -#define MESSAGE_STATUS_OFFSET (MESSAGE_LENGTH_OFFSET + MESSAGE_LENGTH_LENGTH) -#define MESSAGE_DATA_OFFSET (MESSAGE_LENGTH_OFFSET + MESSAGE_LENGTH_LENGTH) -#define MESSAGE_INFO_OFFSET (MESSAGE_LENGTH_OFFSET + MESSAGE_LENGTH_LENGTH) - - +#define MESSAGE_TYPE_LENGTH 1 +#define MESSAGE_FLAGS_LENGTH 1 +#define MESSAGE_LENGTH_LENGTH 2 +#define MESSAGE_STATUS_LENGTH 4 +#define MESSAGE_NOTRDY_REASON_LENGTH 4 + +#define MESSAGE_TYPE_OFFSET 0 +#define MESSAGE_FLAGS_OFFSET (MESSAGE_TYPE_OFFSET + MESSAGE_TYPE_LENGTH) +#define MESSAGE_LENGTH_OFFSET (MESSAGE_FLAGS_OFFSET + MESSAGE_FLAGS_LENGTH) +#define MESSAGE_STATUS_OFFSET (MESSAGE_LENGTH_OFFSET + MESSAGE_LENGTH_LENGTH) +#define MESSAGE_DATA_OFFSET (MESSAGE_LENGTH_OFFSET + MESSAGE_LENGTH_LENGTH) +#define MESSAGE_RDY_INFO_OFFSET (MESSAGE_LENGTH_OFFSET + MESSAGE_LENGTH_LENGTH) +#define MESSAGE_NOTRDY_REASON_OFFSET (MESSAGE_LENGTH_OFFSET + MESSAGE_LENGTH_LENGTH) +#define MESSAGE_NOTRDY_INFO_OFFSET (MESSAGE_NOTRDY_REASON_OFFSET + MESSAGE_NOTRDY_REASON_LENGTH) + + +#define SS_NOTREADY_TYPE 0 #define SS_READY_TYPE 1 #define SS_UPLOAD_TYPE 2 #define SS_DOWNLOAD_TYPE 3 #define SS_KEEPALIVE_TYPE 4 -#define SS_KAEEPALIVE_ACK_TYPE 5 +#define SS_KEEPALIVE_ACK_TYPE 5 #define SS_STATUS_TYPE 6 static const value_string message_type_values[] = { + { SS_NOTREADY_TYPE, "Not Ready" }, { SS_READY_TYPE, "Ready" }, { SS_UPLOAD_TYPE, "Upload" }, { SS_DOWNLOAD_TYPE, "Download" }, { SS_KEEPALIVE_TYPE, "Keep-Alive" }, - { SS_KAEEPALIVE_ACK_TYPE, "Keep-Alive Ack" }, + { SS_KEEPALIVE_ACK_TYPE, "Keep-Alive Ack" }, { SS_STATUS_TYPE, "Status" }, { 0, NULL } }; -static void +static const value_string notrdy_reason_values[] = { + { 0x00000001, "Fully Loaded" }, + { 0x00000002, "Out of Resources" }, + { 0, NULL } +}; + + +static guint dissect_ssprotocol_message(tvbuff_t *message_tvb, packet_info *pinfo, proto_tree *ssprotocol_tree) { guint8 type; guint16 data_length; guint16 info_length; - + guint total_length; + type = tvb_get_guint8(message_tvb, MESSAGE_TYPE_OFFSET); if (pinfo && (check_col(pinfo->cinfo, COL_INFO))) { - col_add_fstr(pinfo->cinfo, COL_INFO, "%s ", val_to_str(type, message_type_values, "Unknown SSP type")); + col_add_fstr(pinfo->cinfo, COL_INFO, "%s ", val_to_str(type, message_type_values, "Unknown SSP type: %u")); } proto_tree_add_item(ssprotocol_tree, hf_message_type, message_tvb, MESSAGE_TYPE_OFFSET, MESSAGE_TYPE_LENGTH, FALSE); proto_tree_add_item(ssprotocol_tree, hf_message_flags, message_tvb, MESSAGE_FLAGS_OFFSET, MESSAGE_FLAGS_LENGTH, FALSE); proto_tree_add_item(ssprotocol_tree, hf_message_length, message_tvb, MESSAGE_LENGTH_OFFSET, MESSAGE_LENGTH_LENGTH, FALSE); + total_length = MESSAGE_LENGTH_OFFSET + MESSAGE_LENGTH_LENGTH; switch (type) { - case SS_KAEEPALIVE_ACK_TYPE: + case SS_KEEPALIVE_ACK_TYPE: case SS_STATUS_TYPE: - proto_tree_add_item(ssprotocol_tree, hf_message_status, message_tvb, MESSAGE_STATUS_OFFSET, MESSAGE_STATUS_LENGTH, FALSE); - break; + info_length = tvb_get_ntohs(message_tvb, MESSAGE_LENGTH_OFFSET) - MESSAGE_STATUS_OFFSET; + if (info_length == MESSAGE_STATUS_LENGTH) { + proto_tree_add_item(ssprotocol_tree, hf_message_status, message_tvb, MESSAGE_STATUS_OFFSET, MESSAGE_STATUS_LENGTH, FALSE); + total_length += MESSAGE_STATUS_LENGTH; + } + break; case SS_UPLOAD_TYPE: case SS_DOWNLOAD_TYPE: - data_length = tvb_get_ntohs(message_tvb, MESSAGE_LENGTH_OFFSET) - 4; + data_length = tvb_get_ntohs(message_tvb, MESSAGE_LENGTH_OFFSET) - MESSAGE_DATA_OFFSET; if (data_length > 0) { proto_tree_add_item(ssprotocol_tree, hf_message_data, message_tvb, MESSAGE_DATA_OFFSET, data_length, FALSE); + total_length += data_length; } - break; + break; case SS_READY_TYPE: - info_length = tvb_get_ntohs(message_tvb, MESSAGE_LENGTH_OFFSET) - 4; + info_length = tvb_get_ntohs(message_tvb, MESSAGE_LENGTH_OFFSET) - MESSAGE_RDY_INFO_OFFSET; if (info_length > 0) { - proto_tree_add_item(ssprotocol_tree, hf_message_info, message_tvb, MESSAGE_INFO_OFFSET, info_length, FALSE); + proto_tree_add_item(ssprotocol_tree, hf_message_info, message_tvb, MESSAGE_RDY_INFO_OFFSET, info_length, FALSE); + total_length += info_length; } - break; + break; + case SS_NOTREADY_TYPE: + info_length = tvb_get_ntohs(message_tvb, MESSAGE_LENGTH_OFFSET) - MESSAGE_NOTRDY_INFO_OFFSET; + if (info_length > 0) { + proto_tree_add_item(ssprotocol_tree, hf_message_reason, message_tvb, MESSAGE_NOTRDY_REASON_OFFSET, MESSAGE_NOTRDY_REASON_LENGTH, FALSE); + proto_tree_add_item(ssprotocol_tree, hf_message_info, message_tvb, MESSAGE_NOTRDY_INFO_OFFSET, info_length, FALSE); + total_length += info_length; + } + break; + default: + break; } + + return total_length; } @@ -141,8 +174,7 @@ dissect_ssprotocol(tvbuff_t *message_tvb, packet_info *pinfo, proto_tree *tree) ssprotocol_tree = NULL; }; /* dissect the message */ - dissect_ssprotocol_message(message_tvb, pinfo, ssprotocol_tree); - return(TRUE); + return dissect_ssprotocol_message(message_tvb, pinfo, ssprotocol_tree); } @@ -153,12 +185,13 @@ proto_register_ssprotocol(void) /* Setup list of header fields */ static hf_register_info hf[] = { - { &hf_message_type, { "Type", "ssprotocol.message_type", FT_UINT8, BASE_DEC, VALS(message_type_values), 0x0, NULL, HFILL } }, - { &hf_message_flags, { "Flags", "ssprotocol.message_flags", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL } }, - { &hf_message_length, { "Length", "ssprotocol.message_length", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL } }, - { &hf_message_status, { "Status", "ssprotocol.message_status", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL } }, - { &hf_message_data, { "Data", "ssprotocol.message_data", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } }, - { &hf_message_info, { "Info", "ssprotocol.message_info", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL } } + { &hf_message_type, { "Type", "ssprotocol.message_type", FT_UINT8, BASE_DEC, VALS(message_type_values), 0x0, NULL, HFILL } }, + { &hf_message_flags, { "Flags", "ssprotocol.message_flags", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL } }, + { &hf_message_length, { "Length", "ssprotocol.message_length", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL } }, + { &hf_message_status, { "Status", "ssprotocol.message_status", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL } }, + { &hf_message_reason, { "Reason", "ssprotocol.message_reason", FT_UINT32, BASE_DEC, VALS(notrdy_reason_values), 0x0, NULL, HFILL } }, + { &hf_message_info, { "Info", "ssprotocol.message_info", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL } }, + { &hf_message_data, { "Data", "ssprotocol.message_data", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } } }; /* Setup protocol subtree array */ |