2004-03-25 11:21:07 +00:00
|
|
|
/* packet-rudp.c
|
|
|
|
* Routines for Reliable UDP Protocol.
|
|
|
|
* Copyright 2004, Duncan Sargeant <dunc-ethereal@rcpt.to>
|
|
|
|
*
|
2004-07-18 00:24:25 +00:00
|
|
|
* $Id$
|
2004-03-25 11:21:07 +00:00
|
|
|
*
|
2006-05-21 05:12:17 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
2004-03-25 11:21:07 +00:00
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
|
|
|
* Copied from packet-data.c, README.developer, and various other files.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
|
|
|
|
|
|
|
|
* Reliable UDP is a lightweight protocol for providing TCP-like flow
|
|
|
|
* control over UDP. Cisco published an PFC a long time ago, and
|
|
|
|
* their actual implementation is slightly different, having no
|
|
|
|
* checksum field.
|
|
|
|
*
|
|
|
|
* I've cheated here - RUDP could be used for anything, but I've only
|
|
|
|
* seen it used to switched telephony calls, so we just call the Cisco SM
|
|
|
|
* dissector from here.
|
|
|
|
*
|
|
|
|
* Here are some links:
|
2011-10-21 02:10:19 +00:00
|
|
|
*
|
2004-03-25 11:21:07 +00:00
|
|
|
* http://www.watersprings.org/pub/id/draft-ietf-sigtran-reliable-udp-00.txt
|
|
|
|
* http://www.javvin.com/protocolRUDP.html
|
|
|
|
* http://www.cisco.com/univercd/cc/td/doc/product/access/sc/rel7/omts/omts_apb.htm#30052
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2006-04-22 20:26:16 +00:00
|
|
|
#include <glib.h>
|
2004-03-25 11:21:07 +00:00
|
|
|
#include <epan/packet.h>
|
2006-08-10 01:59:41 +00:00
|
|
|
#include <epan/prefs.h>
|
|
|
|
|
|
|
|
/* Disable rudp by default. The previously hardcoded value of
|
|
|
|
* 7000 (used by Cisco) collides with afs and as the draft states:
|
2011-10-21 02:10:19 +00:00
|
|
|
* "RUDP doesn't place any restrictions on which UDP port numbers are used.
|
2006-08-10 01:59:41 +00:00
|
|
|
* Valid port numbers are ports not defined in RFC 1700."
|
|
|
|
*/
|
|
|
|
/* FIXME: The proper solution would be to convert this dissector into
|
|
|
|
* heuristic dissector, but it isn't complete anyway.
|
|
|
|
*/
|
|
|
|
static guint udp_port = 0;
|
|
|
|
|
|
|
|
void proto_reg_handoff_rudp(void);
|
2004-03-25 11:21:07 +00:00
|
|
|
|
|
|
|
static int proto_rudp = -1;
|
|
|
|
|
|
|
|
static int hf_rudp_flags = -1;
|
|
|
|
static int hf_rudp_flags_syn = -1;
|
|
|
|
static int hf_rudp_flags_ack = -1;
|
|
|
|
static int hf_rudp_flags_eak = -1;
|
|
|
|
static int hf_rudp_flags_rst = -1;
|
|
|
|
static int hf_rudp_flags_nul = -1;
|
|
|
|
static int hf_rudp_flags_chk = -1;
|
|
|
|
static int hf_rudp_flags_tcs = -1;
|
|
|
|
static int hf_rudp_flags_0 = -1;
|
|
|
|
static int hf_rudp_hlen = -1;
|
|
|
|
static int hf_rudp_seq = -1;
|
|
|
|
static int hf_rudp_ack = -1;
|
2008-10-13 12:55:16 +00:00
|
|
|
static int hf_rudp_cksum = -1;
|
2004-03-25 11:21:07 +00:00
|
|
|
|
|
|
|
static gint ett_rudp = -1;
|
|
|
|
static gint ett_rudp_flags = -1;
|
|
|
|
|
2008-10-13 12:55:16 +00:00
|
|
|
static dissector_handle_t sm_handle = NULL;
|
|
|
|
static dissector_handle_t data_handle = NULL;
|
|
|
|
|
2004-03-25 11:21:07 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
dissect_rudp(tvbuff_t *tvb, packet_info *pinfo _U_ , proto_tree *tree)
|
|
|
|
{
|
|
|
|
tvbuff_t * next_tvb = NULL;
|
|
|
|
proto_tree *rudp_tree = NULL, *flags_tree;
|
|
|
|
proto_item *ti = NULL;
|
2004-03-30 19:36:50 +00:00
|
|
|
int flags[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
|
2004-03-25 11:21:07 +00:00
|
|
|
int i;
|
|
|
|
guint8 hlen;
|
|
|
|
|
2004-03-30 19:36:50 +00:00
|
|
|
flags[0] = hf_rudp_flags_syn;
|
|
|
|
flags[1] = hf_rudp_flags_ack;
|
|
|
|
flags[2] = hf_rudp_flags_eak;
|
|
|
|
flags[3] = hf_rudp_flags_rst;
|
|
|
|
flags[4] = hf_rudp_flags_nul;
|
|
|
|
flags[5] = hf_rudp_flags_chk;
|
|
|
|
flags[6] = hf_rudp_flags_tcs;
|
|
|
|
flags[7] = hf_rudp_flags_0;
|
|
|
|
|
2004-03-25 11:21:07 +00:00
|
|
|
hlen = tvb_get_guint8(tvb, 1);
|
|
|
|
|
2009-08-09 06:26:46 +00:00
|
|
|
col_set_str(pinfo->cinfo, COL_PROTOCOL, "RUDP");
|
2009-08-09 07:36:13 +00:00
|
|
|
col_clear(pinfo->cinfo, COL_INFO);
|
2004-03-25 11:21:07 +00:00
|
|
|
|
|
|
|
if (tree) {
|
2011-10-21 02:10:19 +00:00
|
|
|
ti = proto_tree_add_item(tree, proto_rudp, tvb, 0, hlen, ENC_NA);
|
2004-03-25 11:21:07 +00:00
|
|
|
rudp_tree = proto_item_add_subtree(ti, ett_rudp);
|
|
|
|
|
2011-10-06 03:35:44 +00:00
|
|
|
ti = proto_tree_add_item(rudp_tree, hf_rudp_flags, tvb, 0, 1, ENC_BIG_ENDIAN);
|
2004-03-25 11:21:07 +00:00
|
|
|
flags_tree = proto_item_add_subtree(ti, ett_rudp_flags);
|
|
|
|
|
|
|
|
for (i = 0; i < 8; i++)
|
2011-11-09 17:33:18 +00:00
|
|
|
proto_tree_add_item(flags_tree, flags[i], tvb, 0, 1, ENC_BIG_ENDIAN);
|
2004-03-25 11:21:07 +00:00
|
|
|
|
2011-10-06 03:35:44 +00:00
|
|
|
proto_tree_add_item(rudp_tree, hf_rudp_hlen, tvb, 1, 1, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(rudp_tree, hf_rudp_seq, tvb, 2, 1, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(rudp_tree, hf_rudp_ack, tvb, 3, 1, ENC_BIG_ENDIAN);
|
2008-10-13 12:55:16 +00:00
|
|
|
|
|
|
|
/* If the header is more than 4 bytes the next 2 bytes are the checksum */
|
|
|
|
if (hlen > 4) {
|
2011-10-06 03:35:44 +00:00
|
|
|
proto_tree_add_item(rudp_tree, hf_rudp_cksum, tvb, 4, 2, ENC_BIG_ENDIAN);
|
2008-10-13 12:55:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* If we have even more bytes their meaning is unknown - we have seen this
|
|
|
|
* in live captures */
|
|
|
|
if (hlen > 6) {
|
|
|
|
next_tvb = tvb_new_subset(tvb, 6, hlen-6, hlen-6);
|
|
|
|
call_dissector(data_handle, next_tvb, pinfo, rudp_tree);
|
|
|
|
}
|
2004-03-25 11:21:07 +00:00
|
|
|
}
|
|
|
|
|
2009-08-16 12:36:22 +00:00
|
|
|
next_tvb = tvb_new_subset_remaining(tvb, hlen);
|
2008-10-13 12:55:16 +00:00
|
|
|
if (tvb_length(next_tvb) && sm_handle)
|
|
|
|
call_dissector(sm_handle, next_tvb, pinfo, tree);
|
2004-03-25 11:21:07 +00:00
|
|
|
}
|
|
|
|
|
2004-04-25 11:14:01 +00:00
|
|
|
void
|
2004-04-25 11:20:43 +00:00
|
|
|
proto_register_rudp(void)
|
2004-03-25 11:21:07 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
static hf_register_info hf[] = {
|
|
|
|
{ &hf_rudp_flags,
|
|
|
|
{ "RUDP Header flags", "rudp.flags",
|
|
|
|
FT_UINT8, BASE_DEC, NULL, 0x0,
|
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
|
|
|
NULL, HFILL }
|
2004-03-25 11:21:07 +00:00
|
|
|
},
|
|
|
|
{ &hf_rudp_flags_syn,
|
|
|
|
{ "Syn", "rudp.flags.syn",
|
|
|
|
FT_BOOLEAN, 8, NULL, 0x80,
|
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
|
|
|
NULL, HFILL }
|
2004-03-25 11:21:07 +00:00
|
|
|
},
|
|
|
|
{ &hf_rudp_flags_ack,
|
|
|
|
{ "Ack", "rudp.flags.ack",
|
2004-03-25 23:09:18 +00:00
|
|
|
FT_BOOLEAN, 8, NULL, 0x40,
|
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
|
|
|
NULL, HFILL }
|
2004-03-25 11:21:07 +00:00
|
|
|
},
|
|
|
|
{ &hf_rudp_flags_eak,
|
|
|
|
{ "Eak", "rudp.flags.eak",
|
2004-03-25 23:09:18 +00:00
|
|
|
FT_BOOLEAN, 8, NULL, 0x20,
|
|
|
|
"Extended Ack", HFILL }
|
2004-03-25 11:21:07 +00:00
|
|
|
},
|
|
|
|
{ &hf_rudp_flags_rst,
|
|
|
|
{ "RST", "rudp.flags.rst",
|
2004-03-25 23:09:18 +00:00
|
|
|
FT_BOOLEAN, 8, NULL, 0x10,
|
|
|
|
"Reset flag", HFILL }
|
2004-03-25 11:21:07 +00:00
|
|
|
},
|
|
|
|
{ &hf_rudp_flags_nul,
|
|
|
|
{ "NULL", "rudp.flags.nul",
|
2004-03-25 23:09:18 +00:00
|
|
|
FT_BOOLEAN, 8, NULL, 0x08,
|
|
|
|
"Null flag", HFILL }
|
2004-03-25 11:21:07 +00:00
|
|
|
},
|
|
|
|
{ &hf_rudp_flags_chk,
|
|
|
|
{ "CHK", "rudp.flags.chk",
|
2004-03-25 23:09:18 +00:00
|
|
|
FT_BOOLEAN, 8, NULL, 0x04,
|
|
|
|
"Checksum is on header or body", HFILL }
|
2004-03-25 11:21:07 +00:00
|
|
|
},
|
|
|
|
{ &hf_rudp_flags_tcs,
|
|
|
|
{ "TCS", "rudp.flags.tcs",
|
2004-03-25 23:09:18 +00:00
|
|
|
FT_BOOLEAN, 8, NULL, 0x02,
|
|
|
|
"Transfer Connection System", HFILL }
|
2004-03-25 11:21:07 +00:00
|
|
|
},
|
|
|
|
{ &hf_rudp_flags_0,
|
|
|
|
{ "0", "rudp.flags.0",
|
2004-03-25 23:09:18 +00:00
|
|
|
FT_BOOLEAN, 8, NULL, 0x01,
|
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
|
|
|
NULL, HFILL }
|
2004-03-25 11:21:07 +00:00
|
|
|
},
|
|
|
|
{ &hf_rudp_hlen,
|
|
|
|
{ "Header Length", "rudp.hlen",
|
2004-03-25 23:09:18 +00:00
|
|
|
FT_UINT8, BASE_DEC, NULL, 0x0,
|
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
|
|
|
NULL, HFILL }
|
2004-03-25 11:21:07 +00:00
|
|
|
},
|
|
|
|
{ &hf_rudp_seq,
|
|
|
|
{ "Seq", "rudp.seq",
|
2004-03-25 23:09:18 +00:00
|
|
|
FT_UINT8, BASE_DEC, NULL, 0x0,
|
|
|
|
"Sequence Number", HFILL }
|
2004-03-25 11:21:07 +00:00
|
|
|
},
|
|
|
|
{ &hf_rudp_ack,
|
|
|
|
{ "Ack", "rudp.ack",
|
2004-03-25 23:09:18 +00:00
|
|
|
FT_UINT8, BASE_DEC, NULL, 0x0,
|
|
|
|
"Acknowledgement Number", HFILL }
|
2004-03-25 11:21:07 +00:00
|
|
|
},
|
|
|
|
{ &hf_rudp_cksum,
|
|
|
|
{ "Checksum", "rudp.cksum",
|
2008-10-13 12:55:16 +00:00
|
|
|
FT_UINT16, BASE_HEX, NULL, 0x0,
|
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
|
|
|
NULL, HFILL }
|
2004-03-25 11:21:07 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* Setup protocol subtree array */
|
|
|
|
static gint *ett[] = {
|
|
|
|
&ett_rudp,
|
|
|
|
&ett_rudp_flags,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-10-28 00:29:15 +00:00
|
|
|
proto_rudp = proto_register_protocol (
|
2004-03-25 11:21:07 +00:00
|
|
|
"Reliable UDP", /* name */
|
|
|
|
"RUDP", /* short name */
|
|
|
|
"rudp" /* abbrev */
|
|
|
|
);
|
|
|
|
|
|
|
|
proto_register_field_array(proto_rudp, hf, array_length(hf));
|
|
|
|
proto_register_subtree_array(ett, array_length(ett));
|
2006-08-10 01:59:41 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
module_t *rudp_module;
|
|
|
|
rudp_module = prefs_register_protocol(proto_rudp, proto_reg_handoff_rudp);
|
|
|
|
prefs_register_uint_preference(rudp_module,
|
|
|
|
"udp.port",
|
|
|
|
"UDP port for RUDP",
|
|
|
|
"Set the UDP port for Reliable UDP traffic",
|
|
|
|
10,
|
|
|
|
&udp_port);
|
|
|
|
}
|
|
|
|
|
2004-03-25 11:21:07 +00:00
|
|
|
}
|
|
|
|
|
2004-04-25 11:14:01 +00:00
|
|
|
void
|
|
|
|
proto_reg_handoff_rudp(void) {
|
2004-03-25 11:21:07 +00:00
|
|
|
|
2008-10-28 00:29:15 +00:00
|
|
|
static gboolean initialized = FALSE;
|
|
|
|
static dissector_handle_t rudp_handle;
|
|
|
|
static guint saved_udp_port;
|
|
|
|
|
|
|
|
if (!initialized) {
|
2004-03-25 11:21:07 +00:00
|
|
|
rudp_handle = create_dissector_handle(dissect_rudp, proto_rudp);
|
2008-10-28 00:29:15 +00:00
|
|
|
dissector_add_handle("udp.port", rudp_handle); /* for "decode as" */
|
|
|
|
sm_handle = find_dissector("sm");
|
|
|
|
data_handle = find_dissector("data");
|
|
|
|
initialized = TRUE;
|
|
|
|
} else {
|
|
|
|
if (saved_udp_port != 0) {
|
2010-12-20 05:35:29 +00:00
|
|
|
dissector_delete_uint("udp.port", saved_udp_port, rudp_handle);
|
2008-10-28 00:29:15 +00:00
|
|
|
}
|
2004-03-25 11:21:07 +00:00
|
|
|
}
|
|
|
|
|
2008-10-28 00:29:15 +00:00
|
|
|
if (udp_port != 0) {
|
2010-12-20 05:35:29 +00:00
|
|
|
dissector_add_uint("udp.port", udp_port, rudp_handle);
|
2008-10-28 00:29:15 +00:00
|
|
|
}
|
|
|
|
saved_udp_port = udp_port;
|
2004-03-25 11:21:07 +00:00
|
|
|
}
|