HACK: 2nd try to match RowsetProperties
[wireshark-wip.git] / epan / dissectors / packet-calcappprotocol.c
blobffa5e5c5ec003e9c0c5166d496ea19de222db9ab
1 /* packet-calcappprotocol.c
2 * Routines for the Calculation Application Protocol, a test application of the
3 * rsplib RSerPool implementation
4 * http://www.tdr.wiwi.uni-due.de/forschung/forschungsprojekte/reliable-server-pooling//
6 * Copyright 2006 by Thomas Dreibholz <dreibh [AT] exp-math.uni-essen.de>
8 * $Id$
10 * Wireshark - Network traffic analyzer
11 * By Gerald Combs <gerald@wireshark.org>
12 * Copyright 1998 Gerald Combs
14 * Copied from README.developer
16 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License
18 * as published by the Free Software Foundation; either version 2
19 * of the License, or (at your option) any later version.
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
31 #include "config.h"
33 #include <epan/packet.h>
34 #include <epan/sctpppids.h>
37 #define CALCAPPPROTOCOL_PAYLOAD_PROTOCOL_ID_LEGACY 0x29097603
39 void proto_register_calcappprotocol(void);
40 void proto_reg_handoff_calcappprotocol(void);
42 /* Initialize the protocol and registered fields */
43 static int proto_calcappprotocol = -1;
44 static int hf_message_type = -1;
45 static int hf_message_flags = -1;
46 static int hf_message_length = -1;
47 static int hf_message_jobid = -1;
48 static int hf_message_jobsize = -1;
49 static int hf_message_completed = -1;
51 /* Initialize the subtree pointers */
52 static gint ett_calcappprotocol = -1;
54 /* Dissectors for messages. This is specific to CalcAppProtocol */
55 #define MESSAGE_TYPE_LENGTH 1
56 #define MESSAGE_FLAGS_LENGTH 1
57 #define MESSAGE_LENGTH_LENGTH 2
58 #define MESSAGE_JOBID_LENGTH 4
59 #define MESSAGE_JOBSIZE_LENGTH 8
60 #define MESSAGE_COMPLETED_LENGTH 8
62 #define MESSAGE_TYPE_OFFSET 0
63 #define MESSAGE_FLAGS_OFFSET (MESSAGE_TYPE_OFFSET + MESSAGE_TYPE_LENGTH)
64 #define MESSAGE_LENGTH_OFFSET (MESSAGE_FLAGS_OFFSET + MESSAGE_FLAGS_LENGTH)
65 #define MESSAGE_JOBID_OFFSET (MESSAGE_LENGTH_OFFSET + MESSAGE_LENGTH_LENGTH)
66 #define MESSAGE_JOBSIZE_OFFSET (MESSAGE_JOBID_OFFSET + MESSAGE_JOBID_OFFSET)
67 #define MESSAGE_COMPLETED_OFFSET (MESSAGE_JOBSIZE_OFFSET + MESSAGE_JOBSIZE_OFFSET)
70 #define CALCAPP_REQUEST_MESSAGE_TYPE 1
71 #define CALCAPP_ACCEPT_MESSAGE_TYPE 2
72 #define CALCAPP_REJECT_MESSAGE_TYPE 3
73 #define CALCAPP_ABORT_MESSAGE_TYPE 4
74 #define CALCAPP_COMPLETE_MESSAGE_TYPE 5
75 #define CALCAPP_KEEPALIVE_MESSAGE_TYPE 6
76 #define CALCAPP_KEEPALIVE_ACK_MESSAGE_TYPE 7
79 static const value_string message_type_values[] = {
80 { CALCAPP_REQUEST_MESSAGE_TYPE, "CalcApp Request" },
81 { CALCAPP_ACCEPT_MESSAGE_TYPE, "CalcApp Accept" },
82 { CALCAPP_REJECT_MESSAGE_TYPE, "CalcApp Reject" },
83 { CALCAPP_ABORT_MESSAGE_TYPE, "CalcApp Abort" },
84 { CALCAPP_COMPLETE_MESSAGE_TYPE, "CalcApp Complete" },
85 { CALCAPP_KEEPALIVE_MESSAGE_TYPE, "CalcApp Keep-Alive" },
86 { CALCAPP_KEEPALIVE_ACK_MESSAGE_TYPE, "CalcApp Keep-Alive Ack" },
87 { 0, NULL }
91 static void
92 dissect_calcappprotocol_message(tvbuff_t *message_tvb, packet_info *pinfo, proto_tree *calcappprotocol_tree)
94 guint8 type;
96 type = tvb_get_guint8(message_tvb, MESSAGE_TYPE_OFFSET);
97 col_add_fstr(pinfo->cinfo, COL_INFO, "%s ", val_to_str_const(type, message_type_values, "Unknown CalcAppProtocol type"));
99 proto_tree_add_item(calcappprotocol_tree, hf_message_type, message_tvb, MESSAGE_TYPE_OFFSET, MESSAGE_TYPE_LENGTH, ENC_BIG_ENDIAN);
100 proto_tree_add_item(calcappprotocol_tree, hf_message_flags, message_tvb, MESSAGE_FLAGS_OFFSET, MESSAGE_FLAGS_LENGTH, ENC_BIG_ENDIAN);
101 proto_tree_add_item(calcappprotocol_tree, hf_message_length, message_tvb, MESSAGE_LENGTH_OFFSET, MESSAGE_LENGTH_LENGTH, ENC_BIG_ENDIAN);
102 proto_tree_add_item(calcappprotocol_tree, hf_message_jobid, message_tvb, MESSAGE_JOBID_OFFSET, MESSAGE_JOBID_LENGTH, ENC_BIG_ENDIAN);
103 proto_tree_add_item(calcappprotocol_tree, hf_message_jobsize, message_tvb, MESSAGE_JOBSIZE_OFFSET, MESSAGE_JOBSIZE_LENGTH, ENC_BIG_ENDIAN);
104 proto_tree_add_item(calcappprotocol_tree, hf_message_completed, message_tvb, MESSAGE_COMPLETED_OFFSET, MESSAGE_COMPLETED_LENGTH, ENC_BIG_ENDIAN);
108 static int
109 dissect_calcappprotocol(tvbuff_t *message_tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
111 proto_item *calcappprotocol_item;
112 proto_tree *calcappprotocol_tree;
114 col_set_str(pinfo->cinfo, COL_PROTOCOL, "CalcAppProtocol");
116 /* In the interest of speed, if "tree" is NULL, don't do any work not
117 necessary to generate protocol tree items. */
118 if (tree) {
119 /* create the calcappprotocol protocol tree */
120 calcappprotocol_item = proto_tree_add_item(tree, proto_calcappprotocol, message_tvb, 0, -1, ENC_NA);
121 calcappprotocol_tree = proto_item_add_subtree(calcappprotocol_item, ett_calcappprotocol);
122 } else {
123 calcappprotocol_tree = NULL;
125 /* dissect the message */
126 dissect_calcappprotocol_message(message_tvb, pinfo, calcappprotocol_tree);
127 return(TRUE);
131 /* Register the protocol with Wireshark */
132 void
133 proto_register_calcappprotocol(void)
136 /* Setup list of header fields */
137 static hf_register_info hf[] = {
138 { &hf_message_type, { "Type", "calcappprotocol.message_type", FT_UINT8, BASE_DEC, VALS(message_type_values), 0x0, NULL, HFILL } },
139 { &hf_message_flags, { "Flags", "calcappprotocol.message_flags", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL } },
140 { &hf_message_length, { "Length", "calcappprotocol.message_length", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL } },
141 { &hf_message_jobid, { "JobID", "calcappprotocol.message_jobid", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL } },
142 { &hf_message_jobsize, { "JobSize", "calcappprotocol.message_jobsize", FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL } },
143 { &hf_message_completed, { "Completed", "calcappprotocol.message_completed", FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL } },
146 /* Setup protocol subtree array */
147 static gint *ett[] = {
148 &ett_calcappprotocol
151 /* Register the protocol name and description */
152 proto_calcappprotocol = proto_register_protocol("Calculation Application Protocol", "CalcAppProtocol", "calcappprotocol");
154 /* Required function calls to register the header fields and subtrees used */
155 proto_register_field_array(proto_calcappprotocol, hf, array_length(hf));
156 proto_register_subtree_array(ett, array_length(ett));
159 void
160 proto_reg_handoff_calcappprotocol(void)
162 dissector_handle_t calcappprotocol_handle;
164 calcappprotocol_handle = new_create_dissector_handle(dissect_calcappprotocol, proto_calcappprotocol);
165 dissector_add_uint("sctp.ppi", CALCAPPPROTOCOL_PAYLOAD_PROTOCOL_ID_LEGACY, calcappprotocol_handle);
166 dissector_add_uint("sctp.ppi", CALCAPP_PAYLOAD_PROTOCOL_ID, calcappprotocol_handle);