diff options
author | sahlberg <sahlberg@f5534014-38df-0310-8fa8-9805f1628bb7> | 2006-06-09 21:41:02 +0000 |
---|---|---|
committer | sahlberg <sahlberg@f5534014-38df-0310-8fa8-9805f1628bb7> | 2006-06-09 21:41:02 +0000 |
commit | 5042b225a656552589c528e46d59d5e2e73ef0fc (patch) | |
tree | 858e92894c53f216a5bac1e1c7f5b52058a3ff9f | |
parent | f830f31f4dd212e84a28b054b7a99185e330fa3d (diff) |
From Thomas Dreibholz
RSerPool protocol stack and four new protocols
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@18409 f5534014-38df-0310-8fa8-9805f1628bb7
-rw-r--r-- | AUTHORS | 4 | ||||
-rw-r--r-- | epan/dissectors/Makefile.common | 4 | ||||
-rw-r--r-- | epan/dissectors/packet-calcappprotocol.c | 172 | ||||
-rw-r--r-- | epan/dissectors/packet-componentstatus.c | 294 | ||||
-rw-r--r-- | epan/dissectors/packet-fractalgeneratorprotocol.c | 243 | ||||
-rw-r--r-- | epan/dissectors/packet-pingpongprotocol.c | 206 |
6 files changed, 923 insertions, 0 deletions
@@ -2482,6 +2482,10 @@ Kees Cook <kees [AT] outflux.net> { TiVoConnect Discovery Protocol } +Thomas Dreibholz <dreibh [AT] exp-math.uni-essen.de> { + RSerPol protocol stack +} + And assorted fixes and enhancements by the people listed above and by: diff --git a/epan/dissectors/Makefile.common b/epan/dissectors/Makefile.common index 29cf64efb8..62d83ea3df 100644 --- a/epan/dissectors/Makefile.common +++ b/epan/dissectors/Makefile.common @@ -139,6 +139,7 @@ DISSECTOR_SRC = \ packet-btrfcomm.c \ packet-btsdp.c \ packet-bvlc.c \ + packet-calcappprotocol.c \ packet-camel.c \ packet-cast.c \ packet-catapult-dct2000.c \ @@ -158,6 +159,7 @@ DISSECTOR_SRC = \ packet-cmip.c \ packet-cmp.c \ packet-cms.c \ + packet-componentstatus.c \ packet-cops.c \ packet-cosine.c \ packet-cpfi.c \ @@ -303,6 +305,7 @@ DISSECTOR_SRC = \ packet-fddi.c \ packet-fix.c \ packet-fr.c \ + packet-fractalgeneratorprotocol.c \ packet-frame.c \ packet-ftam.c \ packet-ftbp.c \ @@ -490,6 +493,7 @@ DISSECTOR_SRC = \ packet-pflog.c \ packet-pgm.c \ packet-pim.c \ + packet-pingpongprotocol.c \ packet-pn-rt.c \ packet-pkcs1.c \ packet-pkix1explicit.c \ diff --git a/epan/dissectors/packet-calcappprotocol.c b/epan/dissectors/packet-calcappprotocol.c new file mode 100644 index 0000000000..1dc5c4bab9 --- /dev/null +++ b/epan/dissectors/packet-calcappprotocol.c @@ -0,0 +1,172 @@ +/* packet-calcappprotocol.c + * Routines for the Calculation Application Protocol, a test application of the + * rsplib RSerPool implementation + * http://tdrwww.exp-math.uni-essen.de/dreibholz/rserpool/ + * + * Copyright 2006 by Thomas Dreibholz <dreibh [AT] exp-math.uni-essen.de> + * + * $Id: x.c 15844 2005-09-17 00:02:31Z x $ + * + * Wireshark - Network traffic analyzer + * By Gerald Combs <gerald@wireshark.org> + * Copyright 1998 Gerald Combs + * + * Copied from README.developer + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include <epan/packet.h> + + +#define CALCAPPPROTOCOL_PAYLOAD_PROTOCOL_ID 0x29097603 + + +/* Initialize the protocol and registered fields */ +static int proto_calcappprotocol = -1; +static int hf_message_type = -1; +static int hf_message_flags = -1; +static int hf_message_length = -1; +static int hf_message_jobid = -1; +static int hf_message_jobsize = -1; +static int hf_message_completed = -1; + +/* Initialize the subtree pointers */ +static gint ett_calcappprotocol = -1; + +static void +dissect_calcappprotocol_message(tvbuff_t *, packet_info *, proto_tree *); + + +/* Dissectors for messages. This is specific to CalcAppProtocol */ +#define MESSAGE_TYPE_LENGTH 1 +#define MESSAGE_FLAGS_LENGTH 1 +#define MESSAGE_LENGTH_LENGTH 2 +#define MESSAGE_JOBID_LENGTH 4 +#define MESSAGE_JOBSIZE_LENGTH 8 +#define MESSAGE_COMPLETED_LENGTH 8 + +#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_JOBID_OFFSET (MESSAGE_LENGTH_OFFSET + MESSAGE_LENGTH_LENGTH) +#define MESSAGE_JOBSIZE_OFFSET (MESSAGE_JOBID_OFFSET + MESSAGE_JOBID_OFFSET) +#define MESSAGE_COMPLETED_OFFSET (MESSAGE_JOBSIZE_OFFSET + MESSAGE_JOBSIZE_OFFSET) + + +#define CALCAPP_REQUEST_MESSAGE_TYPE 1 +#define CALCAPP_ACCEPT_MESSAGE_TYPE 2 +#define CALCAPP_REJECT_MESSAGE_TYPE 3 +#define CALCAPP_ABORT_MESSAGE_TYPE 4 +#define CALCAPP_COMPLETE_MESSAGE_TYPE 5 +#define CALCAPP_KEEPALIVE_MESSAGE_TYPE 6 +#define CALCAPP_KEEPALIVE_ACK_MESSAGE_TYPE 7 + + +static const value_string message_type_values[] = { + { CALCAPP_REQUEST_MESSAGE_TYPE, "CalcApp Request" }, + { CALCAPP_ACCEPT_MESSAGE_TYPE, "CalcApp Accept" }, + { CALCAPP_REJECT_MESSAGE_TYPE, "CalcApp Reject" }, + { CALCAPP_ABORT_MESSAGE_TYPE, "CalcApp Abort" }, + { CALCAPP_COMPLETE_MESSAGE_TYPE, "CalcApp Complete" }, + { CALCAPP_KEEPALIVE_MESSAGE_TYPE, "CalcApp Keep-Alive" }, + { CALCAPP_KEEPALIVE_ACK_MESSAGE_TYPE, "CalcApp Keep-Alive Ack" }, + { 0, NULL } +}; + + +static void +dissect_calcappprotocol_message(tvbuff_t *message_tvb, packet_info *pinfo, proto_tree *calcappprotocol_tree) +{ + guint8 type; + + 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 CalcAppProtocol type")); + } + proto_tree_add_item(calcappprotocol_tree, hf_message_type, message_tvb, MESSAGE_TYPE_OFFSET, MESSAGE_TYPE_LENGTH, FALSE); + proto_tree_add_item(calcappprotocol_tree, hf_message_flags, message_tvb, MESSAGE_FLAGS_OFFSET, MESSAGE_FLAGS_LENGTH, FALSE); + proto_tree_add_item(calcappprotocol_tree, hf_message_length, message_tvb, MESSAGE_LENGTH_OFFSET, MESSAGE_LENGTH_LENGTH, FALSE); + proto_tree_add_item(calcappprotocol_tree, hf_message_jobid, message_tvb, MESSAGE_JOBID_OFFSET, MESSAGE_JOBID_LENGTH, FALSE); + proto_tree_add_item(calcappprotocol_tree, hf_message_jobsize, message_tvb, MESSAGE_JOBSIZE_OFFSET, MESSAGE_JOBSIZE_LENGTH, FALSE); + proto_tree_add_item(calcappprotocol_tree, hf_message_completed, message_tvb, MESSAGE_COMPLETED_OFFSET, MESSAGE_COMPLETED_LENGTH, FALSE); +} + + +static int +dissect_calcappprotocol(tvbuff_t *message_tvb, packet_info *pinfo, proto_tree *tree) +{ + proto_item *calcappprotocol_item; + proto_tree *calcappprotocol_tree; + + /* pinfo is NULL only if dissect_calcappprotocol_message is called from dissect_error cause */ + if (pinfo && (check_col(pinfo->cinfo, COL_PROTOCOL))) + col_set_str(pinfo->cinfo, COL_PROTOCOL, "CalcAppProtocol"); + + /* In the interest of speed, if "tree" is NULL, don't do any work not + necessary to generate protocol tree items. */ + if (tree) { + /* create the calcappprotocol protocol tree */ + calcappprotocol_item = proto_tree_add_item(tree, proto_calcappprotocol, message_tvb, 0, -1, FALSE); + calcappprotocol_tree = proto_item_add_subtree(calcappprotocol_item, ett_calcappprotocol); + } else { + calcappprotocol_tree = NULL; + }; + /* dissect the message */ + dissect_calcappprotocol_message(message_tvb, pinfo, calcappprotocol_tree); + return(TRUE); +} + + +/* Register the protocol with Wireshark */ +void +proto_register_calcappprotocol(void) +{ + + /* Setup list of header fields */ + static hf_register_info hf[] = { + { &hf_message_type, { "Type", "calcappprotocol.message_type", FT_UINT8, BASE_DEC, VALS(message_type_values), 0x0, "", HFILL } }, + { &hf_message_flags, { "Flags", "calcppprotocol.message_flags", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL } }, + { &hf_message_length, { "Length", "calcappprotocol.message_length", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL } }, + { &hf_message_jobid, { "JobID", "calcappprotocol.message_jobid", FT_UINT32, BASE_DEC, NULL, 0x0, "", HFILL } }, + { &hf_message_jobsize, { "JobSize", "calcappprotocol.message_jobsize", FT_UINT64, BASE_DEC, NULL, 0x0, "", HFILL } }, + { &hf_message_completed, { "Completed", "calcappprotocol.message_completed", FT_UINT64, BASE_DEC, NULL, 0x0, "", HFILL } }, + }; + + /* Setup protocol subtree array */ + static gint *ett[] = { + &ett_calcappprotocol + }; + + /* Register the protocol name and description */ + proto_calcappprotocol = proto_register_protocol("Calculation Application Protocol", "CalcAppProtocol", "calcappprotocol"); + + /* Required function calls to register the header fields and subtrees used */ + proto_register_field_array(proto_calcappprotocol, hf, array_length(hf)); + proto_register_subtree_array(ett, array_length(ett)); +} + +void +proto_reg_handoff_calcappprotocol(void) +{ + dissector_handle_t calcappprotocol_handle; + + calcappprotocol_handle = new_create_dissector_handle(dissect_calcappprotocol, proto_calcappprotocol); + dissector_add("sctp.ppi", CALCAPPPROTOCOL_PAYLOAD_PROTOCOL_ID, calcappprotocol_handle); +} diff --git a/epan/dissectors/packet-componentstatus.c b/epan/dissectors/packet-componentstatus.c new file mode 100644 index 0000000000..ba03a246c0 --- /dev/null +++ b/epan/dissectors/packet-componentstatus.c @@ -0,0 +1,294 @@ +/* packet-componentstatus.c + * Routines for the Component Status Protocol of the rsplib RSerPool implementation + * http://tdrwww.exp-math.uni-essen.de/dreibholz/rserpool/ + * + * Copyright 2006 by Thomas Dreibholz <dreibh [AT] exp-math.uni-essen.de> + * + * $Id: x.c 15844 2005-09-17 00:02:31Z x $ + * + * Wireshark - Network traffic analyzer + * By Gerald Combs <gerald@wireshark.org> + * Copyright 1998 Gerald Combs + * + * Copied from README.developer + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include <epan/packet.h> + + +#define CSP_VERSION 0x0200 + +#define CID_GROUP(id) (((uint64_t) id >> 56) & (0xffffULL) +#define CID_OBJECT(id) (((uint64_t) id & 0xffffffffffffffULL) + +#define CID_GROUP_REGISTRAR 0x0001 +#define CID_GROUP_POOLELEMENT 0x0002 +#define CID_GROUP_POOLUSER 0x0003 + +#define CID_COMPOUND(group, object) (((uint64_t) (group & 0xffff) << 56) | CID_OBJECT((uint64_t)object)) + +#define CSPT_REPORT + + +/* Initialize the protocol and registered fields */ +static int proto_componentstatusprotocol = -1; +static int hf_message_type = -1; +static int hf_message_flags = -1; +static int hf_message_length = -1; +static int hf_message_version = -1; +static int hf_message_senderid = -1; +static int hf_message_sendertimestamp = -1; +static int hf_componentstatusreport_reportinterval = -1; +static int hf_componentstatusreport_location = -1; +static int hf_componentstatusreport_status = -1; +static int hf_componentstatusreport_workload = -1; +static int hf_componentstatusreport_associations = -1; +static int hf_componentstatusreport_associationarray = -1; +static int hf_componentassociation_receiverid = -1; +static int hf_componentassociation_duration = -1; +static int hf_componentassociation_flags = -1; +static int hf_componentassociation_protocolid = -1; +static int hf_componentassociation_ppid = -1; + + +/* Initialize the subtree pointers */ +static gint ett_componentstatusprotocol = -1; +static gint ett_association = -1; + + +static void +dissect_componentstatusprotocol_message(tvbuff_t *, packet_info *, proto_tree *); + + +#define COMPONENTSTATUSPROTOCOL_PORT 2960 +#define COMPONENTSTATUSPROTOCOL_VERSION 0x0200 + + +/* Dissectors for messages. This is specific to ComponentStatusProtocol */ +#define MESSAGE_TYPE_LENGTH 1 +#define MESSAGE_FLAGS_LENGTH 1 +#define MESSAGE_LENGTH_LENGTH 2 +#define MESSAGE_VERSION_LENGTH 4 +#define MESSAGE_SENDERID_LENGTH 8 +#define MESSAGE_SENDERTIMESTAMP_LENGTH 8 + + +#define MESSAGE_TYPE_OFFSET 0 +#define MESSAGE_FLAGS_OFFSET (MESSAGE_TYPE_OFFSET + MESSAGE_TYPE_LENGTH) +#define MESSAGE_LENGTH_OFFSET (MESSAGE_FLAGS_OFFSET + MESSAGE_FLAGS_OFFSET) +#define MESSAGE_VERSION_OFFSET (MESSAGE_LENGTH_OFFSET + MESSAGE_LENGTH_OFFSET) +#define MESSAGE_SENDERID_OFFSET (MESSAGE_VERSION_OFFSET + MESSAGE_VERSION_OFFSET) +#define MESSAGE_SENDERTIMESTAMP_OFFSET (MESSAGE_SENDERID_OFFSET + MESSAGE_SENDERID_OFFSET) +#define MESSAGE_VALUE_OFFSET (MESSAGE_SENDERTIMESTAMP_OFFSET + MESSAGE_SENDERTIMESTAMP_LENGTH) + + +#define COMPONENTSTATUSREPORT_REPORTINTERVAL_LENGTH 4 +#define COMPONENTSTATUSREPORT_WORKLOAD_LENGTH 2 +#define COMPONENTSTATUSREPORT_ASSOCIATIONS_LENGTH 2 +#define COMPONENTSTATUSREPORT_LOCATION_LENGTH 128 +#define COMPONENTSTATUSREPORT_STATUS_LENGTH 128 + + +#define COMPONENTSTATUSREPORT_REPORTINTERVAL_OFFSET MESSAGE_VALUE_OFFSET +#define COMPONENTSTATUSREPORT_LOCATION_OFFSET (COMPONENTSTATUSREPORT_REPORTINTERVAL_OFFSET + COMPONENTSTATUSREPORT_REPORTINTERVAL_LENGTH) +#define COMPONENTSTATUSREPORT_STATUS_OFFSET (COMPONENTSTATUSREPORT_LOCATION_OFFSET + COMPONENTSTATUSREPORT_LOCATION_LENGTH) +#define COMPONENTSTATUSREPORT_WORKLOAD_OFFSET (COMPONENTSTATUSREPORT_STATUS_OFFSET + COMPONENTSTATUSREPORT_STATUS_LENGTH) +#define COMPONENTSTATUSREPORT_ASSOCIATIONS_OFFSET (COMPONENTSTATUSREPORT_WORKLOAD_OFFSET + COMPONENTSTATUSREPORT_WORKLOAD_LENGTH) +#define COMPONENTSTATUSREPORT_ASSOCIATIONARRAY_OFFSET (COMPONENTSTATUSREPORT_ASSOCIATIONS_OFFSET + COMPONENTSTATUSREPORT_ASSOCIATIONS_LENGTH) + + +#define COMPONENTASSOCIATION_RECEIVERID_LENGTH 8 +#define COMPONENTASSOCIATION_DURATION_LENGTH 8 +#define COMPONENTASSOCIATION_FLAGS_LENGTH 2 +#define COMPONENTASSOCIATION_PROTOCOLID_LENGTH 2 +#define COMPONENTASSOCIATION_PPID_LENGTH 4 + +#define COMPONENTASSOCIATION_RECEIVERID_OFFSET 0 +#define COMPONENTASSOCIATION_DURATION_OFFSET (COMPONENTASSOCIATION_RECEIVERID_OFFSET + COMPONENTASSOCIATION_RECEIVERID_LENGTH) +#define COMPONENTASSOCIATION_FLAGS_OFFSET (COMPONENTASSOCIATION_DURATION_OFFSET + COMPONENTASSOCIATION_DURATION_LENGTH) +#define COMPONENTASSOCIATION_PROTOCOLID_OFFSET (COMPONENTASSOCIATION_FLAGS_OFFSET + COMPONENTASSOCIATION_FLAGS_LENGTH) +#define COMPONENTASSOCIATION_PPID_OFFSET (COMPONENTASSOCIATION_PROTOCOLID_OFFSET + COMPONENTASSOCIATION_PROTOCOLID_LENGTH) +#define COMPONENTASSOCIATION_LENGTH (COMPONENTASSOCIATION_PPID_OFFSET + COMPONENTASSOCIATION_PPID_LENGTH) + + +#define COMPONENTSTATUS_COMPONENTSTATUSREPORT_MESSAGE_TYPE 0x01 + + + + +static const value_string message_type_values[] = { + { COMPONENTSTATUS_COMPONENTSTATUSREPORT_MESSAGE_TYPE, "ComponentStatus Report" }, + { 0, NULL } +}; + + +static void +dissect_componentstatusprotocol_componentassociation_message(tvbuff_t *message_tvb, proto_tree *message_tree) +{ + proto_tree_add_item(message_tree, hf_componentassociation_receiverid, message_tvb, COMPONENTASSOCIATION_RECEIVERID_OFFSET, COMPONENTASSOCIATION_RECEIVERID_LENGTH, FALSE); + proto_tree_add_item(message_tree, hf_componentassociation_duration, message_tvb, COMPONENTASSOCIATION_DURATION_OFFSET, COMPONENTASSOCIATION_DURATION_LENGTH, FALSE); + proto_tree_add_item(message_tree, hf_componentassociation_flags, message_tvb, COMPONENTASSOCIATION_FLAGS_OFFSET, COMPONENTASSOCIATION_FLAGS_LENGTH, FALSE); + proto_tree_add_item(message_tree, hf_componentassociation_protocolid, message_tvb, COMPONENTASSOCIATION_PROTOCOLID_OFFSET, COMPONENTASSOCIATION_PROTOCOLID_LENGTH, FALSE); + proto_tree_add_item(message_tree, hf_componentassociation_ppid, message_tvb, COMPONENTASSOCIATION_PPID_OFFSET, COMPONENTASSOCIATION_PPID_LENGTH, FALSE); +} + + +static void +dissect_componentstatusprotocol_componentstatusreport_message(tvbuff_t *message_tvb, proto_tree *message_tree) +{ + tvbuff_t *association_tvb; + proto_item *association_item; + proto_tree *association_tree; + gint associations; + size_t i; + gint offset; + gint remaining_length; + char title[64]; + + proto_tree_add_item(message_tree, hf_componentstatusreport_reportinterval, message_tvb, COMPONENTSTATUSREPORT_REPORTINTERVAL_OFFSET, COMPONENTSTATUSREPORT_REPORTINTERVAL_LENGTH, FALSE); + proto_tree_add_item(message_tree, hf_componentstatusreport_location, message_tvb, COMPONENTSTATUSREPORT_LOCATION_OFFSET, COMPONENTSTATUSREPORT_LOCATION_LENGTH, FALSE); + proto_tree_add_item(message_tree, hf_componentstatusreport_status, message_tvb, COMPONENTSTATUSREPORT_STATUS_OFFSET, COMPONENTSTATUSREPORT_STATUS_LENGTH, FALSE); + proto_tree_add_item(message_tree, hf_componentstatusreport_workload, message_tvb, COMPONENTSTATUSREPORT_WORKLOAD_OFFSET, COMPONENTSTATUSREPORT_WORKLOAD_LENGTH, FALSE); + proto_tree_add_item(message_tree, hf_componentstatusreport_associations, message_tvb, COMPONENTSTATUSREPORT_ASSOCIATIONS_OFFSET, COMPONENTSTATUSREPORT_ASSOCIATIONS_LENGTH, FALSE); + + associations = tvb_get_ntohs(message_tvb, COMPONENTSTATUSREPORT_ASSOCIATIONS_OFFSET); + offset = COMPONENTSTATUSREPORT_ASSOCIATIONARRAY_OFFSET; + i = 1; + while((remaining_length = tvb_length_remaining(message_tvb, offset)) >= COMPONENTASSOCIATION_LENGTH) { + snprintf((char*)&title, sizeof(title), "Association #%d", i++); + association_item = proto_tree_add_text(message_tree, message_tvb, offset, COMPONENTASSOCIATION_LENGTH, title); + association_tree = proto_item_add_subtree(association_item, ett_association); + association_tvb = tvb_new_subset(message_tvb, offset, COMPONENTASSOCIATION_LENGTH, COMPONENTASSOCIATION_LENGTH); + + dissect_componentstatusprotocol_componentassociation_message(association_tvb, association_tree); + offset += COMPONENTASSOCIATION_LENGTH; + } +} + + +static void +dissect_componentstatusprotocol_message(tvbuff_t *message_tvb, packet_info *pinfo, proto_tree *componentstatusprotocol_tree) +{ + guint8 type; + + 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 ComponentStatusProtocol type")); + } + proto_tree_add_item(componentstatusprotocol_tree, hf_message_type, message_tvb, MESSAGE_TYPE_OFFSET, MESSAGE_TYPE_LENGTH, FALSE); + proto_tree_add_item(componentstatusprotocol_tree, hf_message_flags, message_tvb, MESSAGE_FLAGS_OFFSET, MESSAGE_FLAGS_LENGTH, FALSE); + proto_tree_add_item(componentstatusprotocol_tree, hf_message_length, message_tvb, MESSAGE_LENGTH_OFFSET, MESSAGE_LENGTH_LENGTH, FALSE); + proto_tree_add_item(componentstatusprotocol_tree, hf_message_version, message_tvb, MESSAGE_VERSION_OFFSET, MESSAGE_VERSION_LENGTH, FALSE); + proto_tree_add_item(componentstatusprotocol_tree, hf_message_senderid, message_tvb, MESSAGE_SENDERID_OFFSET, MESSAGE_SENDERID_LENGTH, FALSE); + proto_tree_add_item(componentstatusprotocol_tree, hf_message_sendertimestamp, message_tvb, MESSAGE_SENDERTIMESTAMP_OFFSET, MESSAGE_SENDERTIMESTAMP_LENGTH, FALSE); + switch (type) { + case COMPONENTSTATUS_COMPONENTSTATUSREPORT_MESSAGE_TYPE: + dissect_componentstatusprotocol_componentstatusreport_message(message_tvb, componentstatusprotocol_tree); + break; + } +} + + +static int +dissect_componentstatusprotocol(tvbuff_t *message_tvb, packet_info *pinfo, proto_tree *tree) +{ + proto_item *componentstatusprotocol_item; + proto_tree *componentstatusprotocol_tree; + gint8 type; + gint32 version; + + /* Check, if this packet really contains a ComponentStatusProtocol message */ + type = tvb_get_guint8(message_tvb, MESSAGE_TYPE_OFFSET); + if (type != COMPONENTSTATUS_COMPONENTSTATUSREPORT_MESSAGE_TYPE) { + return(FALSE); + } + version = tvb_get_ntohl(message_tvb, MESSAGE_VERSION_OFFSET); + if (version != COMPONENTSTATUSPROTOCOL_VERSION) { + return(FALSE); + } + + /* pinfo is NULL only if dissect_componentstatusprotocol_message is called from dissect_error cause */ + if (pinfo && (check_col(pinfo->cinfo, COL_PROTOCOL))) + col_set_str(pinfo->cinfo, COL_PROTOCOL, "ComponentStatusProtocol"); + + /* In the interest of speed, if "tree" is NULL, don't do any work not + necessary to generate protocol tree items. */ + if (tree) { + /* create the componentstatusprotocol protocol tree */ + componentstatusprotocol_item = proto_tree_add_item(tree, proto_componentstatusprotocol, message_tvb, 0, -1, FALSE); + componentstatusprotocol_tree = proto_item_add_subtree(componentstatusprotocol_item, ett_componentstatusprotocol); + } else { + componentstatusprotocol_tree = NULL; + }; + /* dissect the message */ + dissect_componentstatusprotocol_message(message_tvb, pinfo, componentstatusprotocol_tree); + return(TRUE); +} + + +/* Register the protocol with Wireshark */ +void +proto_register_componentstatusprotocol(void) +{ + + /* Setup list of header fields */ + static hf_register_info hf[] = { + { &hf_message_type, { "Type", "componentstatusprotocol.message_type", FT_UINT8, BASE_DEC, VALS(message_type_values), 0x0, "", HFILL } }, + { &hf_message_flags, { "Flags", "componentstatusprotocol.message_flags", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL } }, + { &hf_message_length, { "Length", "componentstatusprotocol.message_length", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL } }, + { &hf_message_version, { "Version", "componentstatusprotocol.message_version", FT_UINT32, BASE_HEX, NULL, 0x0, "", HFILL } }, + { &hf_message_senderid, { "SenderID", "componentstatusprotocol.message_senderid", FT_UINT64, BASE_HEX, NULL, 0x0, "", HFILL } }, + { &hf_message_sendertimestamp, { "SenderTimeStamp", "componentstatusprotocol.message_sendertimestamp", FT_UINT64, BASE_DEC, NULL, 0x0, "", HFILL } }, + { &hf_componentstatusreport_reportinterval, { "ReportInterval", "componentstatusprotocol.componentstatusreport_reportinterval", FT_UINT32, BASE_DEC, NULL, 0x0, "", HFILL } }, + { &hf_componentstatusreport_location, { "Location", "componentstatusprotocol.componentstatusreport_location", FT_STRING, 0, NULL, 0x0, "", HFILL } }, + { &hf_componentstatusreport_status, { "Status", "componentstatusprotocol.componentstatusreport_status", FT_STRING, 0, NULL, 0x0, "", HFILL } }, + { &hf_componentstatusreport_workload, { "Workload", "componentstatusprotocol.componentstatusreport_workload", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL } }, + { &hf_componentstatusreport_associations, { "Associations", "componentstatusprotocol.componentstatusreport_associations", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL } }, + { &hf_componentstatusreport_associationarray, { "AssociationArray", "componentstatusprotocol.componentstatusreport_AssociationArray", FT_UINT32, BASE_DEC, NULL, 0x0, "", HFILL } }, + { &hf_componentassociation_receiverid, { "ReceiverID", "componentstatusprotocol.componentassociation_receiverid", FT_UINT64, BASE_HEX, NULL, 0x0, "", HFILL } }, + { &hf_componentassociation_duration, { "Duration", "componentstatusprotocol.componentassociation_duration", FT_UINT64, BASE_DEC, NULL, 0x0, "", HFILL } }, + { &hf_componentassociation_flags, { "Flags", "componentstatusprotocol.componentassociation_flags", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL } }, + { &hf_componentassociation_protocolid, { "ProtocolID", "componentstatusprotocol.componentassociation_protocolid", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL } }, + { &hf_componentassociation_ppid, { "PPID", "componentstatusprotocol.componentassociation_ppid", FT_UINT32, BASE_DEC, NULL, 0x0, "", HFILL } }, + }; + + /* Setup protocol subtree array */ + static gint *ett[] = { + &ett_componentstatusprotocol, + &ett_association + }; + + /* Register the protocol name and description */ + proto_componentstatusprotocol = proto_register_protocol("Component Status Protocol", "ComponentStatusProtocol", "componentstatusprotocol"); + + /* Required function calls to register the header fields and subtrees used */ + proto_register_field_array(proto_componentstatusprotocol, hf, array_length(hf)); + proto_register_subtree_array(ett, array_length(ett)); +} + +void +proto_reg_handoff_componentstatusprotocol(void) +{ + dissector_handle_t componentstatusprotocol_handle; + + componentstatusprotocol_handle = new_create_dissector_handle(dissect_componentstatusprotocol, proto_componentstatusprotocol); + dissector_add("udp.port", COMPONENTSTATUSPROTOCOL_PORT, componentstatusprotocol_handle); +} diff --git a/epan/dissectors/packet-fractalgeneratorprotocol.c b/epan/dissectors/packet-fractalgeneratorprotocol.c new file mode 100644 index 0000000000..668600282d --- /dev/null +++ b/epan/dissectors/packet-fractalgeneratorprotocol.c @@ -0,0 +1,243 @@ +/* packet-fractalgeneratorprotocol.c + * Routines for the Fractal Generator Protocol, a test application of the + * rsplib RSerPool implementation + * http://tdrwww.exp-math.uni-essen.de/dreibholz/rserpool/ + * + * Copyright 2006 by Thomas Dreibholz <dreibh [AT] exp-math.uni-essen.de> + * + * $Id: x.c 15844 2005-09-17 00:02:31Z x $ + * + * Wireshark - Network traffic analyzer + * By Gerald Combs <gerald@wireshark.org> + * Copyright 1998 Gerald Combs + * + * Copied from README.developer + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include <epan/packet.h> + + +#define FRACTALGENERATORPROTOCOL_PAYLOAD_PROTOCOL_ID 0x29097601 + + +/* Initialize the protocol and registered fields */ +static int proto_fractalgeneratorprotocol = -1; +static int hf_message_type = -1; +static int hf_message_flags = -1; +static int hf_message_length = -1; +static int hf_data_start_x = -1; +static int hf_data_start_y = -1; +static int hf_data_points = -1; +static int hf_parameter_width = -1; +static int hf_parameter_height = -1; +static int hf_parameter_maxiterations = -1; +static int hf_parameter_algorithmid = -1; +static int hf_parameter_c1real = -1; +static int hf_parameter_c1imag = -1; +static int hf_parameter_c2real = -1; +static int hf_parameter_c2imag = -1; +static int hf_parameter_n = -1; +static int hf_buffer = -1; + +/* Initialize the subtree pointers */ +static gint ett_fractalgeneratorprotocol = -1; + +static void +dissect_fractalgeneratorprotocol_message(tvbuff_t *, packet_info *, proto_tree *); + + +/* Dissectors for messages. This is specific to FractalGeneratorProtocol */ +#define MESSAGE_TYPE_LENGTH 1 +#define MESSAGE_FLAGS_LENGTH 1 +#define MESSAGE_LENGTH_LENGTH 2 + +#define MESSAGE_TYPE_OFFSET 0 +#define MESSAGE_FLAGS_OFFSET (MESSAGE_TYPE_OFFSET + MESSAGE_TYPE_LENGTH) +#define MESSAGE_LENGTH_OFFSET (MESSAGE_FLAGS_OFFSET + MESSAGE_FLAGS_OFFSET) +#define MESSAGE_VALUE_OFFSET (MESSAGE_LENGTH_OFFSET + MESSAGE_LENGTH_LENGTH) + + +#define DATA_STARTX_LENGTH 4 +#define DATA_STARTY_LENGTH 4 +#define DATA_POINTS_LENGTH 4 +#define DATA_BUFFER_LENGTH 4 + +#define DATA_STARTX_OFFSET MESSAGE_VALUE_OFFSET +#define DATA_STARTY_OFFSET (DATA_STARTX_OFFSET + DATA_STARTX_LENGTH) +#define DATA_POINTS_OFFSET (DATA_STARTY_OFFSET + DATA_STARTY_LENGTH) +#define DATA_BUFFER_OFFSET (DATA_POINTS_OFFSET + DATA_POINTS_LENGTH) + + +#define PARAMETER_WIDTH_LENGTH 4 +#define PARAMETER_HEIGHT_LENGTH 4 +#define PARAMETER_MAXITERATIONS_LENGTH 4 +#define PARAMETER_ALGORITHMID_LENGTH 4 +#define PARAMETER_C1REAL_LENGTH 8 +#define PARAMETER_C1IMAG_LENGTH 8 +#define PARAMETER_C2REAL_LENGTH 8 +#define PARAMETER_C2IMAG_LENGTH 8 +#define PARAMETER_N_LENGTH 8 + +#define PARAMETER_WIDTH_OFFSET MESSAGE_VALUE_OFFSET +#define PARAMETER_HEIGHT_OFFSET (PARAMETER_WIDTH_OFFSET + PARAMETER_WIDTH_LENGTH) +#define PARAMETER_MAXITERATIONS_OFFSET (PARAMETER_HEIGHT_OFFSET + PARAMETER_HEIGHT_LENGTH) +#define PARAMETER_ALGORITHMID_OFFSET (PARAMETER_MAXITERATIONS_OFFSET + PARAMETER_MAXITERATIONS_LENGTH) +#define PARAMETER_C1REAL_OFFSET (PARAMETER_ALGORITHMID_OFFSET + PARAMETER_ALGORITHMID_LENGTH) +#define PARAMETER_C1IMAG_OFFSET (PARAMETER_C1REAL_OFFSET + PARAMETER_C1REAL_LENGTH) +#define PARAMETER_C2REAL_OFFSET (PARAMETER_C1IMAG_OFFSET + PARAMETER_C1IMAG_LENGTH) +#define PARAMETER_C2IMAG_OFFSET (PARAMETER_C2REAL_OFFSET + PARAMETER_C2REAL_LENGTH) +#define PARAMETER_N_OFFSET (PARAMETER_C2IMAG_OFFSET + PARAMETER_C2IMAG_LENGTH) + +#define FRACTALGENERATOR_PARAMETER_MESSAGE_TYPE 0x01 +#define FRACTALGENERATOR_DATA_MESSAGE_TYPE 0x02 + + +static const value_string message_type_values[] = { + { FRACTALGENERATOR_PARAMETER_MESSAGE_TYPE, "FractalGenerator Parameter" }, + { FRACTALGENERATOR_DATA_MESSAGE_TYPE, "FractalGenerator Data" }, + { 0, NULL } +}; + + +static void +dissect_fractalgeneratorprotocol_parameter_message(tvbuff_t *message_tvb, proto_tree *message_tree) +{ + proto_tree_add_item(message_tree, hf_parameter_width, message_tvb, PARAMETER_WIDTH_OFFSET, PARAMETER_WIDTH_LENGTH, FALSE); + proto_tree_add_item(message_tree, hf_parameter_height, message_tvb, PARAMETER_HEIGHT_OFFSET, PARAMETER_HEIGHT_LENGTH, FALSE); + proto_tree_add_item(message_tree, hf_parameter_maxiterations, message_tvb, PARAMETER_MAXITERATIONS_OFFSET, PARAMETER_MAXITERATIONS_LENGTH, FALSE); + proto_tree_add_item(message_tree, hf_parameter_algorithmid, message_tvb, PARAMETER_ALGORITHMID_OFFSET, PARAMETER_ALGORITHMID_LENGTH, FALSE); + proto_tree_add_item(message_tree, hf_parameter_c1real, message_tvb, PARAMETER_C1REAL_OFFSET, PARAMETER_C1REAL_LENGTH, FALSE); + proto_tree_add_item(message_tree, hf_parameter_c1imag, message_tvb, PARAMETER_C1IMAG_OFFSET, PARAMETER_C1IMAG_LENGTH, FALSE); + proto_tree_add_item(message_tree, hf_parameter_c2real, message_tvb, PARAMETER_C2REAL_OFFSET, PARAMETER_C2REAL_LENGTH, FALSE); + proto_tree_add_item(message_tree, hf_parameter_c2imag, message_tvb, PARAMETER_C2IMAG_OFFSET, PARAMETER_C2IMAG_LENGTH, FALSE); + proto_tree_add_item(message_tree, hf_parameter_n, message_tvb, PARAMETER_N_OFFSET, PARAMETER_N_LENGTH, FALSE); +} + + +static void +dissect_fractalgeneratorprotocol_data_message(tvbuff_t *message_tvb, proto_tree *message_tree) +{ + guint16 buffer_length; + + proto_tree_add_item(message_tree, hf_data_start_x, message_tvb, DATA_STARTX_OFFSET, DATA_STARTX_LENGTH, FALSE); + proto_tree_add_item(message_tree, hf_data_start_y, message_tvb, DATA_STARTY_OFFSET, DATA_STARTY_LENGTH, FALSE); + proto_tree_add_item(message_tree, hf_data_points, message_tvb, DATA_POINTS_OFFSET, DATA_POINTS_LENGTH, FALSE); + + buffer_length = tvb_get_ntohl(message_tvb, DATA_POINTS_OFFSET)*4; + if (buffer_length > 0) { + proto_tree_add_item(message_tree, hf_buffer, message_tvb, DATA_BUFFER_OFFSET, buffer_length, FALSE); + } +} + + +static void +dissect_fractalgeneratorprotocol_message(tvbuff_t *message_tvb, packet_info *pinfo, proto_tree *fractalgeneratorprotocol_tree) +{ + guint8 type; + + 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 FractalGeneratorProtocol type")); + } + proto_tree_add_item(fractalgeneratorprotocol_tree, hf_message_type, message_tvb, MESSAGE_TYPE_OFFSET, MESSAGE_TYPE_LENGTH, FALSE); + proto_tree_add_item(fractalgeneratorprotocol_tree, hf_message_flags, message_tvb, MESSAGE_FLAGS_OFFSET, MESSAGE_FLAGS_LENGTH, FALSE); + proto_tree_add_item(fractalgeneratorprotocol_tree, hf_message_length, message_tvb, MESSAGE_LENGTH_OFFSET, MESSAGE_LENGTH_LENGTH, FALSE); + switch (type) { + case FRACTALGENERATOR_PARAMETER_MESSAGE_TYPE: + dissect_fractalgeneratorprotocol_parameter_message(message_tvb, fractalgeneratorprotocol_tree); + break; + case FRACTALGENERATOR_DATA_MESSAGE_TYPE: + dissect_fractalgeneratorprotocol_data_message(message_tvb, fractalgeneratorprotocol_tree); + break; + } +} + +static int +dissect_fractalgeneratorprotocol(tvbuff_t *message_tvb, packet_info *pinfo, proto_tree *tree) +{ + proto_item *fractalgeneratorprotocol_item; + proto_tree *fractalgeneratorprotocol_tree; + + /* pinfo is NULL only if dissect_fractalgeneratorprotocol_message is called from dissect_error cause */ + if (pinfo && (check_col(pinfo->cinfo, COL_PROTOCOL))) + col_set_str(pinfo->cinfo, COL_PROTOCOL, "FractalGeneratorProtocol"); + + /* In the interest of speed, if "tree" is NULL, don't do any work not + necessary to generate protocol tree items. */ + if (tree) { + /* create the fractalgeneratorprotocol protocol tree */ + fractalgeneratorprotocol_item = proto_tree_add_item(tree, proto_fractalgeneratorprotocol, message_tvb, 0, -1, FALSE); + fractalgeneratorprotocol_tree = proto_item_add_subtree(fractalgeneratorprotocol_item, ett_fractalgeneratorprotocol); + } else { + fractalgeneratorprotocol_tree = NULL; + }; + /* dissect the message */ + dissect_fractalgeneratorprotocol_message(message_tvb, pinfo, fractalgeneratorprotocol_tree); + return(TRUE); +} + +/* Register the protocol with Wireshark */ +void +proto_register_fractalgeneratorprotocol(void) +{ + + /* Setup list of header fields */ + static hf_register_info hf[] = { + { &hf_message_type, { "Type", "fractalgeneratorprotocol.message_type", FT_UINT8, BASE_DEC, VALS(message_type_values), 0x0, "", HFILL } }, + { &hf_message_flags, { "Flags", "fractalgeneratorprotocol.message_flags", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL } }, + { &hf_message_length, { "Length", "fractalgeneratorprotocol.message_length", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL } }, + { &hf_data_start_x, { "StartX", "fractalgeneratorprotocol.data_start_x", FT_UINT32, BASE_DEC, NULL, 0x0, "", HFILL } }, + { &hf_data_start_y, { "StartY", "fractalgeneratorprotocol.data_start_y", FT_UINT32, BASE_DEC, NULL, 0x0, "", HFILL } }, + { &hf_data_points, { "Points", "fractalgeneratorprotocol.data_points", FT_UINT32, BASE_DEC, NULL, 0x0, "", HFILL } }, + { &hf_parameter_width, { "Width", "fractalgeneratorprotocol.parameter_width", FT_UINT32, BASE_DEC, NULL, 0x0, "", HFILL } }, + { &hf_parameter_height, { "Height", "fractalgeneratorprotocol.parameter_height", FT_UINT32, BASE_DEC, NULL, 0x0, "", HFILL } }, + { &hf_parameter_maxiterations, { "MaxIterations", "fractalgeneratorprotocol.parameter_maxiterations", FT_UINT32, BASE_DEC, NULL, 0x0, "", HFILL } }, + { &hf_parameter_algorithmid, { "AlgorithmID", "fractalgeneratorprotocol.parameter_algorithmid", FT_UINT32, BASE_DEC, NULL, 0x0, "", HFILL } }, + { &hf_parameter_c1real, { "C1Real", "fractalgeneratorprotocol.parameter_c1real", FT_DOUBLE, BASE_DEC, NULL, 0x0, "", HFILL } }, + { &hf_parameter_c1imag, { "C1Imag", "fractalgeneratorprotocol.parameter_c1imag", FT_DOUBLE, BASE_DEC, NULL, 0x0, "", HFILL } }, + { &hf_parameter_c2real, { "C2Real", "fractalgeneratorprotocol.parameter_c2real", FT_DOUBLE, BASE_DEC, NULL, 0x0, "", HFILL } }, + { &hf_parameter_c2imag, { "C2Imag", "fractalgeneratorprotocol.parameter_c2imag", FT_DOUBLE, BASE_DEC, NULL, 0x0, "", HFILL } }, + { &hf_parameter_n, { "N", "fractalgeneratorprotocol.parameter_n", FT_DOUBLE, BASE_DEC, NULL, 0x0, "", HFILL } }, + { &hf_buffer, { "Buffer", "fractalgeneratorprotocol.buffer", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL } }, + }; + + /* Setup protocol subtree array */ + static gint *ett[] = { + &ett_fractalgeneratorprotocol + }; + + /* Register the protocol name and description */ + proto_fractalgeneratorprotocol = proto_register_protocol("Fractal Generator Protocol", "FractalGeneratorProtocol", "fractalgeneratorprotocol"); + + /* Required function calls to register the header fields and subtrees used */ + proto_register_field_array(proto_fractalgeneratorprotocol, hf, array_length(hf)); + proto_register_subtree_array(ett, array_length(ett)); + +} + +void +proto_reg_handoff_fractalgeneratorprotocol(void) +{ + dissector_handle_t fractalgeneratorprotocol_handle; + + fractalgeneratorprotocol_handle = new_create_dissector_handle(dissect_fractalgeneratorprotocol, proto_fractalgeneratorprotocol); + dissector_add("sctp.ppi", FRACTALGENERATORPROTOCOL_PAYLOAD_PROTOCOL_ID, fractalgeneratorprotocol_handle); +} diff --git a/epan/dissectors/packet-pingpongprotocol.c b/epan/dissectors/packet-pingpongprotocol.c new file mode 100644 index 0000000000..1e80b609c4 --- /dev/null +++ b/epan/dissectors/packet-pingpongprotocol.c @@ -0,0 +1,206 @@ +/* packet-pingpongprotocol.c + * Routines for the Ping Pong Protocol, a test application of the + * rsplib RSerPool implementation + * http://tdrwww.exp-math.uni-essen.de/dreibholz/rserpool/ + * + * Copyright 2006 by Thomas Dreibholz <dreibh [AT] exp-math.uni-essen.de> + * + * $Id: x.c 15844 2005-09-17 00:02:31Z x $ + * + * Wireshark - Network traffic analyzer + * By Gerald Combs <gerald@wireshark.org> + * Copyright 1998 Gerald Combs + * + * Copied from README.developer + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include <epan/packet.h> + + +#define PINGPONGPROTOCOL_PAYLOAD_PROTOCOL_ID 0x29097602 + + +/* Initialize the protocol and registered fields */ +static int proto_pingpongprotocol = -1; +static int hf_message_type = -1; +static int hf_message_flags = -1; +static int hf_message_length = -1; +static int hf_ping_messageno = -1; +static int hf_ping_data = -1; +static int hf_pong_messageno = -1; +static int hf_pong_replyno = -1; +static int hf_pong_data = -1; + + +/* Initialize the subtree pointers */ +static gint ett_pingpongprotocol = -1; + +static void +dissect_pingpongprotocol_message(tvbuff_t *, packet_info *, proto_tree *); + + +/* Dissectors for messages. This is specific to PingPongProtocol */ +#define MESSAGE_TYPE_LENGTH 1 +#define MESSAGE_FLAGS_LENGTH 1 +#define MESSAGE_LENGTH_LENGTH 2 + +#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_VALUE_OFFSET (MESSAGE_LENGTH_OFFSET + MESSAGE_LENGTH_LENGTH) + + +#define PING_MESSAGENO_LENGTH 8 + +#define PING_MESSAGENO_OFFSET MESSAGE_VALUE_OFFSET +#define PING_DATA_OFFSET (PING_MESSAGENO_OFFSET + PING_MESSAGENO_LENGTH) + +#define PONG_MESSAGENO_LENGTH 8 +#define PONG_REPLYNO_LENGTH 8 + +#define PONG_MESSAGENO_OFFSET MESSAGE_VALUE_OFFSET +#define PONG_REPLYNO_OFFSET (PONG_MESSAGENO_OFFSET + PONG_MESSAGENO_LENGTH) +#define PONG_DATA_OFFSET (PONG_REPLYNO_OFFSET + PONG_REPLYNO_LENGTH) + + +#define PINGPONG_PING_MESSAGE_TYPE 0x01 +#define PINGPONG_PONG_MESSAGE_TYPE 0x02 + + + +static const value_string message_type_values[] = { + { PINGPONG_PONG_MESSAGE_TYPE, "PingPongProtocol Pong" }, + { PINGPONG_PING_MESSAGE_TYPE, "PingPongProtocol Ping" }, + { 0, NULL } +}; + + +static void +dissect_pingpongprotocol_ping_message(tvbuff_t *message_tvb, proto_tree *message_tree) +{ + guint16 ping_data_length; + + proto_tree_add_item(message_tree, hf_ping_messageno, message_tvb, PING_MESSAGENO_OFFSET, PING_MESSAGENO_LENGTH, FALSE); + + ping_data_length = tvb_get_ntohs(message_tvb, MESSAGE_LENGTH_OFFSET) - PING_DATA_OFFSET; + if (ping_data_length > 0) + proto_tree_add_item(message_tree, hf_ping_data, message_tvb, PING_DATA_OFFSET, ping_data_length, FALSE); +} + +static void +dissect_pingpongprotocol_pong_message(tvbuff_t *message_tvb, proto_tree *message_tree) +{ + guint16 pong_data_length; + + proto_tree_add_item(message_tree, hf_pong_messageno, message_tvb, PONG_MESSAGENO_OFFSET, PONG_MESSAGENO_LENGTH, FALSE); + proto_tree_add_item(message_tree, hf_pong_replyno, message_tvb, PONG_REPLYNO_OFFSET, PONG_REPLYNO_LENGTH, FALSE); + + pong_data_length = tvb_get_ntohs(message_tvb, MESSAGE_LENGTH_OFFSET) - PONG_DATA_OFFSET; + if (pong_data_length > 0) { + proto_tree_add_item(message_tree, hf_pong_data, message_tvb, PONG_DATA_OFFSET, pong_data_length, FALSE); + } +} + + +static void +dissect_pingpongprotocol_message(tvbuff_t *message_tvb, packet_info *pinfo, proto_tree *pingpongprotocol_tree) +{ + guint8 type; + + 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 PingPongProtocol type")); + } + proto_tree_add_item(pingpongprotocol_tree, hf_message_type, message_tvb, MESSAGE_TYPE_OFFSET, MESSAGE_TYPE_LENGTH, FALSE); + proto_tree_add_item(pingpongprotocol_tree, hf_message_flags, message_tvb, MESSAGE_FLAGS_OFFSET, MESSAGE_FLAGS_LENGTH, FALSE); + proto_tree_add_item(pingpongprotocol_tree, hf_message_length, message_tvb, MESSAGE_LENGTH_OFFSET, MESSAGE_LENGTH_LENGTH, FALSE); + switch (type) { + case PINGPONG_PING_MESSAGE_TYPE: + dissect_pingpongprotocol_ping_message(message_tvb, pingpongprotocol_tree); + break; + case PINGPONG_PONG_MESSAGE_TYPE: + dissect_pingpongprotocol_pong_message(message_tvb, pingpongprotocol_tree); + break; + } +} + +static int +dissect_pingpongprotocol(tvbuff_t *message_tvb, packet_info *pinfo, proto_tree *tree) +{ + proto_item *pingpongprotocol_item; + proto_tree *pingpongprotocol_tree; + + /* pinfo is NULL only if dissect_pingpongprotocol_message is called from dissect_error cause */ + if (pinfo && (check_col(pinfo->cinfo, COL_PROTOCOL))) + col_set_str(pinfo->cinfo, COL_PROTOCOL, "PingPongProtocol"); + + /* In the interest of speed, if "tree" is NULL, don't do any work not + necessary to generate protocol tree items. */ + if (tree) { + /* create the pingpongprotocol protocol tree */ + pingpongprotocol_item = proto_tree_add_item(tree, proto_pingpongprotocol, message_tvb, 0, -1, FALSE); + pingpongprotocol_tree = proto_item_add_subtree(pingpongprotocol_item, ett_pingpongprotocol); + } else { + pingpongprotocol_tree = NULL; + }; + /* dissect the message */ + dissect_pingpongprotocol_message(message_tvb, pinfo, pingpongprotocol_tree); + return(TRUE); +} + +/* Register the protocol with Wireshark */ +void +proto_register_pingpongprotocol(void) +{ + + /* Setup list of header fields */ + static hf_register_info hf[] = { + { &hf_message_type, { "Type", "pingpongprotocol.message_type", FT_UINT8, BASE_DEC, VALS(message_type_values), 0x0, "", HFILL } }, + { &hf_message_flags, { "Flags", "pingpongprotocol.message_flags", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL } }, + { &hf_message_length, { "Length", "pingpongprotocol.message_length", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL } }, + { &hf_ping_messageno, { "MessageNo", "pingpongprotocol.ping_messageno", FT_UINT64, BASE_DEC, NULL, 0x0, "", HFILL } }, + { &hf_ping_data, { "Ping_Data", "pingpongprotocol.ping_data", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL } }, + { &hf_pong_messageno, { "MessageNo", "pingpongprotocol.pong_messageno", FT_UINT64, BASE_DEC, NULL, 0x0, "", HFILL } }, + { &hf_pong_replyno, { "ReplyNo", "pingpongprotocol.pong_replyno", FT_UINT64, BASE_DEC, NULL, 0x0, "", HFILL } }, + { &hf_pong_data, { "Pong_Data", "pingpongprotocol.pong_data", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL } }, + }; + + /* Setup protocol subtree array */ + static gint *ett[] = { + &ett_pingpongprotocol + }; + + /* Register the protocol name and description */ + proto_pingpongprotocol = proto_register_protocol("Ping Pong Protocol", "PingPongProtocol", "pingpongprotocol"); + + /* Required function calls to register the header fields and subtrees used */ + proto_register_field_array(proto_pingpongprotocol, hf, array_length(hf)); + proto_register_subtree_array(ett, array_length(ett)); +} + +void +proto_reg_handoff_pingpongprotocol(void) +{ + dissector_handle_t pingpongprotocol_handle; + + pingpongprotocol_handle = new_create_dissector_handle(dissect_pingpongprotocol, proto_pingpongprotocol); + dissector_add("sctp.ppi", PINGPONGPROTOCOL_PAYLOAD_PROTOCOL_ID, pingpongprotocol_handle); +} |