Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-rudp.c
blob96bfe054e500e49a84e95a40937d4b062a9f5158
1 /* packet-rudp.c
2 * Routines for Reliable UDP Protocol.
3 * Copyright 2004, Duncan Sargeant <dunc-ethereal@rcpt.to>
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * Copied from packet-data.c, README.developer, and various other files.
11 * SPDX-License-Identifier: GPL-2.0-or-later
14 * Reliable UDP is a lightweight protocol for providing TCP-like flow
15 * control over UDP. Cisco published an PFC a long time ago, and
16 * their actual implementation is slightly different, having no
17 * checksum field.
19 * I've cheated here - RUDP could be used for anything, but I've only
20 * seen it used to switched telephony calls, so we just call the Cisco SM
21 * dissector from here.
23 * Here are some links:
25 * http://www.watersprings.org/pub/id/draft-ietf-sigtran-reliable-udp-00.txt
26 * http://www.javvin.com/protocolRUDP.html
27 * http://www.cisco.com/univercd/cc/td/doc/product/access/sc/rel7/omts/omts_apb.htm#30052
31 #include "config.h"
33 #include <epan/packet.h>
36 void proto_register_rudp(void);
38 void proto_reg_handoff_rudp(void);
40 static dissector_handle_t rudp_handle;
42 static int proto_rudp;
44 static int hf_rudp_flags;
45 static int hf_rudp_flags_syn;
46 static int hf_rudp_flags_ack;
47 static int hf_rudp_flags_eak;
48 static int hf_rudp_flags_rst;
49 static int hf_rudp_flags_nul;
50 static int hf_rudp_flags_chk;
51 static int hf_rudp_flags_tcs;
52 static int hf_rudp_flags_0;
53 static int hf_rudp_hlen;
54 static int hf_rudp_seq;
55 static int hf_rudp_ack;
56 static int hf_rudp_cksum;
58 static int ett_rudp;
59 static int ett_rudp_flags;
61 static dissector_handle_t sm_handle;
63 static int
64 dissect_rudp(tvbuff_t *tvb, packet_info *pinfo _U_ , proto_tree *tree, void* data _U_)
66 tvbuff_t * next_tvb;
67 proto_tree *rudp_tree;
68 proto_item *ti;
69 uint8_t hlen;
70 static int * const flags[] = {
71 &hf_rudp_flags_syn,
72 &hf_rudp_flags_ack,
73 &hf_rudp_flags_eak,
74 &hf_rudp_flags_rst,
75 &hf_rudp_flags_nul,
76 &hf_rudp_flags_chk,
77 &hf_rudp_flags_tcs,
78 &hf_rudp_flags_0,
79 NULL
82 hlen = tvb_get_uint8(tvb, 1);
84 col_set_str(pinfo->cinfo, COL_PROTOCOL, "RUDP");
85 col_clear(pinfo->cinfo, COL_INFO);
87 ti = proto_tree_add_item(tree, proto_rudp, tvb, 0, hlen, ENC_NA);
88 rudp_tree = proto_item_add_subtree(ti, ett_rudp);
90 proto_tree_add_bitmask(rudp_tree, tvb, 0, hf_rudp_flags, ett_rudp_flags, flags, ENC_BIG_ENDIAN);
92 proto_tree_add_item(rudp_tree, hf_rudp_hlen, tvb, 1, 1, ENC_BIG_ENDIAN);
93 proto_tree_add_item(rudp_tree, hf_rudp_seq, tvb, 2, 1, ENC_BIG_ENDIAN);
94 proto_tree_add_item(rudp_tree, hf_rudp_ack, tvb, 3, 1, ENC_BIG_ENDIAN);
96 /* If the header is more than 4 bytes the next 2 bytes are the checksum */
97 if (hlen > 4) {
98 proto_tree_add_checksum(rudp_tree, tvb, 4, hf_rudp_cksum, -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
101 /* If we have even more bytes their meaning is unknown - we have seen this
102 * in live captures */
103 if (hlen > 6) {
104 next_tvb = tvb_new_subset_length(tvb, 6, hlen-6);
105 call_data_dissector(next_tvb, pinfo, rudp_tree);
108 next_tvb = tvb_new_subset_remaining(tvb, hlen);
109 if (tvb_captured_length(next_tvb) && sm_handle)
110 call_dissector(sm_handle, next_tvb, pinfo, tree);
112 return tvb_captured_length(tvb);
115 void
116 proto_register_rudp(void)
119 static hf_register_info hf[] = {
120 { &hf_rudp_flags,
121 { "RUDP Header flags", "rudp.flags",
122 FT_UINT8, BASE_DEC, NULL, 0x0,
123 NULL, HFILL }
125 { &hf_rudp_flags_syn,
126 { "Syn", "rudp.flags.syn",
127 FT_BOOLEAN, 8, NULL, 0x80,
128 NULL, HFILL }
130 { &hf_rudp_flags_ack,
131 { "Ack", "rudp.flags.ack",
132 FT_BOOLEAN, 8, NULL, 0x40,
133 NULL, HFILL }
135 { &hf_rudp_flags_eak,
136 { "Eak", "rudp.flags.eak",
137 FT_BOOLEAN, 8, NULL, 0x20,
138 "Extended Ack", HFILL }
140 { &hf_rudp_flags_rst,
141 { "RST", "rudp.flags.rst",
142 FT_BOOLEAN, 8, NULL, 0x10,
143 "Reset flag", HFILL }
145 { &hf_rudp_flags_nul,
146 { "NULL", "rudp.flags.nul",
147 FT_BOOLEAN, 8, NULL, 0x08,
148 "Null flag", HFILL }
150 { &hf_rudp_flags_chk,
151 { "CHK", "rudp.flags.chk",
152 FT_BOOLEAN, 8, NULL, 0x04,
153 "Checksum is on header or body", HFILL }
155 { &hf_rudp_flags_tcs,
156 { "TCS", "rudp.flags.tcs",
157 FT_BOOLEAN, 8, NULL, 0x02,
158 "Transfer Connection System", HFILL }
160 { &hf_rudp_flags_0,
161 { "0", "rudp.flags.0",
162 FT_BOOLEAN, 8, NULL, 0x01,
163 NULL, HFILL }
165 { &hf_rudp_hlen,
166 { "Header Length", "rudp.hlen",
167 FT_UINT8, BASE_DEC, NULL, 0x0,
168 NULL, HFILL }
170 { &hf_rudp_seq,
171 { "Seq", "rudp.seq",
172 FT_UINT8, BASE_DEC, NULL, 0x0,
173 "Sequence Number", HFILL }
175 { &hf_rudp_ack,
176 { "Ack", "rudp.ack",
177 FT_UINT8, BASE_DEC, NULL, 0x0,
178 "Acknowledgement Number", HFILL }
180 { &hf_rudp_cksum,
181 { "Checksum", "rudp.cksum",
182 FT_UINT16, BASE_HEX, NULL, 0x0,
183 NULL, HFILL }
188 /* Setup protocol subtree array */
189 static int *ett[] = {
190 &ett_rudp,
191 &ett_rudp_flags,
195 proto_rudp = proto_register_protocol ("Reliable UDP", "RUDP", "rudp");
197 proto_register_field_array(proto_rudp, hf, array_length(hf));
198 proto_register_subtree_array(ett, array_length(ett));
200 rudp_handle = register_dissector("rudp", dissect_rudp, proto_rudp);
203 void
204 proto_reg_handoff_rudp(void) {
206 /* Disable rudp by default. The previously hardcoded value of
207 * 7000 (used by Cisco) collides with afs and as the draft states:
208 * "RUDP doesn't place any restrictions on which UDP port numbers are used.
209 * Valid port numbers are ports not defined in RFC 1700."
211 /* FIXME: The proper solution would be to convert this dissector into
212 * heuristic dissector, but it isn't complete anyway.
215 dissector_add_for_decode_as_with_preference("udp.port", rudp_handle);
216 sm_handle = find_dissector_add_dependency("sm", proto_rudp);
220 * Editor modelines - https://www.wireshark.org/tools/modelines.html
222 * Local variables:
223 * c-basic-offset: 8
224 * tab-width: 8
225 * indent-tabs-mode: t
226 * End:
228 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
229 * :indentSize=8:tabSize=8:noTabs=false: