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 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
10 * Copyright 1998 Gerald Combs
12 * Copied from README.developer
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
31 #include <epan/packet.h>
32 #include <epan/sctpppids.h>
35 #define CALCAPPPROTOCOL_PAYLOAD_PROTOCOL_ID_LEGACY 0x29097603
37 void proto_register_calcappprotocol(void);
38 void proto_reg_handoff_calcappprotocol(void);
40 /* Initialize the protocol and registered fields */
41 static int proto_calcappprotocol = -1;
42 static int hf_message_type = -1;
43 static int hf_message_flags = -1;
44 static int hf_message_length = -1;
45 static int hf_message_jobid = -1;
46 static int hf_message_jobsize = -1;
47 static int hf_message_completed = -1;
49 /* Initialize the subtree pointers */
50 static gint ett_calcappprotocol = -1;
52 /* Dissectors for messages. This is specific to CalcAppProtocol */
53 #define MESSAGE_TYPE_LENGTH 1
54 #define MESSAGE_FLAGS_LENGTH 1
55 #define MESSAGE_LENGTH_LENGTH 2
56 #define MESSAGE_JOBID_LENGTH 4
57 #define MESSAGE_JOBSIZE_LENGTH 8
58 #define MESSAGE_COMPLETED_LENGTH 8
60 #define MESSAGE_TYPE_OFFSET 0
61 #define MESSAGE_FLAGS_OFFSET (MESSAGE_TYPE_OFFSET + MESSAGE_TYPE_LENGTH)
62 #define MESSAGE_LENGTH_OFFSET (MESSAGE_FLAGS_OFFSET + MESSAGE_FLAGS_LENGTH)
63 #define MESSAGE_JOBID_OFFSET (MESSAGE_LENGTH_OFFSET + MESSAGE_LENGTH_LENGTH)
64 #define MESSAGE_JOBSIZE_OFFSET (MESSAGE_JOBID_OFFSET + MESSAGE_JOBID_OFFSET)
65 #define MESSAGE_COMPLETED_OFFSET (MESSAGE_JOBSIZE_OFFSET + MESSAGE_JOBSIZE_OFFSET)
68 #define CALCAPP_REQUEST_MESSAGE_TYPE 1
69 #define CALCAPP_ACCEPT_MESSAGE_TYPE 2
70 #define CALCAPP_REJECT_MESSAGE_TYPE 3
71 #define CALCAPP_ABORT_MESSAGE_TYPE 4
72 #define CALCAPP_COMPLETE_MESSAGE_TYPE 5
73 #define CALCAPP_KEEPALIVE_MESSAGE_TYPE 6
74 #define CALCAPP_KEEPALIVE_ACK_MESSAGE_TYPE 7
77 static const value_string message_type_values[] = {
78 { CALCAPP_REQUEST_MESSAGE_TYPE, "CalcApp Request" },
79 { CALCAPP_ACCEPT_MESSAGE_TYPE, "CalcApp Accept" },
80 { CALCAPP_REJECT_MESSAGE_TYPE, "CalcApp Reject" },
81 { CALCAPP_ABORT_MESSAGE_TYPE, "CalcApp Abort" },
82 { CALCAPP_COMPLETE_MESSAGE_TYPE, "CalcApp Complete" },
83 { CALCAPP_KEEPALIVE_MESSAGE_TYPE, "CalcApp Keep-Alive" },
84 { CALCAPP_KEEPALIVE_ACK_MESSAGE_TYPE, "CalcApp Keep-Alive Ack" },
90 dissect_calcappprotocol_message(tvbuff_t *message_tvb, packet_info *pinfo, proto_tree *calcappprotocol_tree)
94 type = tvb_get_guint8(message_tvb, MESSAGE_TYPE_OFFSET);
95 col_add_fstr(pinfo->cinfo, COL_INFO, "%s ", val_to_str_const(type, message_type_values, "Unknown CalcAppProtocol type"));
97 proto_tree_add_item(calcappprotocol_tree, hf_message_type, message_tvb, MESSAGE_TYPE_OFFSET, MESSAGE_TYPE_LENGTH, ENC_BIG_ENDIAN);
98 proto_tree_add_item(calcappprotocol_tree, hf_message_flags, message_tvb, MESSAGE_FLAGS_OFFSET, MESSAGE_FLAGS_LENGTH, ENC_BIG_ENDIAN);
99 proto_tree_add_item(calcappprotocol_tree, hf_message_length, message_tvb, MESSAGE_LENGTH_OFFSET, MESSAGE_LENGTH_LENGTH, ENC_BIG_ENDIAN);
100 proto_tree_add_item(calcappprotocol_tree, hf_message_jobid, message_tvb, MESSAGE_JOBID_OFFSET, MESSAGE_JOBID_LENGTH, ENC_BIG_ENDIAN);
101 proto_tree_add_item(calcappprotocol_tree, hf_message_jobsize, message_tvb, MESSAGE_JOBSIZE_OFFSET, MESSAGE_JOBSIZE_LENGTH, ENC_BIG_ENDIAN);
102 proto_tree_add_item(calcappprotocol_tree, hf_message_completed, message_tvb, MESSAGE_COMPLETED_OFFSET, MESSAGE_COMPLETED_LENGTH, ENC_BIG_ENDIAN);
107 dissect_calcappprotocol(tvbuff_t *message_tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
109 proto_item *calcappprotocol_item;
110 proto_tree *calcappprotocol_tree;
112 col_set_str(pinfo->cinfo, COL_PROTOCOL, "CalcAppProtocol");
114 /* In the interest of speed, if "tree" is NULL, don't do any work not
115 necessary to generate protocol tree items. */
117 /* create the calcappprotocol protocol tree */
118 calcappprotocol_item = proto_tree_add_item(tree, proto_calcappprotocol, message_tvb, 0, -1, ENC_NA);
119 calcappprotocol_tree = proto_item_add_subtree(calcappprotocol_item, ett_calcappprotocol);
121 calcappprotocol_tree = NULL;
123 /* dissect the message */
124 dissect_calcappprotocol_message(message_tvb, pinfo, calcappprotocol_tree);
129 /* Register the protocol with Wireshark */
131 proto_register_calcappprotocol(void)
134 /* Setup list of header fields */
135 static hf_register_info hf[] = {
136 { &hf_message_type, { "Type", "calcappprotocol.message_type", FT_UINT8, BASE_DEC, VALS(message_type_values), 0x0, NULL, HFILL } },
137 { &hf_message_flags, { "Flags", "calcappprotocol.message_flags", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL } },
138 { &hf_message_length, { "Length", "calcappprotocol.message_length", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL } },
139 { &hf_message_jobid, { "JobID", "calcappprotocol.message_jobid", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL } },
140 { &hf_message_jobsize, { "JobSize", "calcappprotocol.message_jobsize", FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL } },
141 { &hf_message_completed, { "Completed", "calcappprotocol.message_completed", FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL } },
144 /* Setup protocol subtree array */
145 static gint *ett[] = {
149 /* Register the protocol name and description */
150 proto_calcappprotocol = proto_register_protocol("Calculation Application Protocol", "CalcAppProtocol", "calcappprotocol");
152 /* Required function calls to register the header fields and subtrees used */
153 proto_register_field_array(proto_calcappprotocol, hf, array_length(hf));
154 proto_register_subtree_array(ett, array_length(ett));
158 proto_reg_handoff_calcappprotocol(void)
160 dissector_handle_t calcappprotocol_handle;
162 calcappprotocol_handle = new_create_dissector_handle(dissect_calcappprotocol, proto_calcappprotocol);
163 dissector_add_uint("sctp.ppi", CALCAPPPROTOCOL_PAYLOAD_PROTOCOL_ID_LEGACY, calcappprotocol_handle);
164 dissector_add_uint("sctp.ppi", CALCAPP_PAYLOAD_PROTOCOL_ID, calcappprotocol_handle);