Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-classicstun.c
blobf1a58e03a6087615dfaa8a01e7a5997b5f03ff65
1 /* packet-classicstun.c
2 * Routines for Simple Traversal of UDP Through NAT dissection
3 * Copyright 2003, Shiang-Ming Huang <smhuang@pcs.csie.nctu.edu.tw>
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * SPDX-License-Identifier: GPL-2.0-or-later
11 * Please refer to RFC 3489 for protocol detail.
12 * (supports extra message attributes described in draft-ietf-behave-rfc3489bis-00)
15 #include "config.h"
17 #include <epan/packet.h>
18 #include <epan/tfs.h>
19 #include <epan/conversation.h>
20 void proto_register_classicstun(void);
21 void proto_reg_handoff_classicstun(void);
23 /* heuristic subdissectors */
24 static heur_dissector_list_t heur_subdissector_list;
26 static dissector_handle_t data_handle;
28 /* Initialize the protocol and registered fields */
29 static int proto_classicstun;
31 static int hf_classicstun_type; /* CLASSIC-STUN message header */
32 static int hf_classicstun_length;
33 static int hf_classicstun_id;
34 static int hf_classicstun_att;
35 static int hf_classicstun_response_in;
36 static int hf_classicstun_response_to;
37 static int hf_classicstun_time;
40 static int hf_classicstun_att_type; /* CLASSIC-STUN attribute fields */
41 static int hf_classicstun_att_length;
42 static int hf_classicstun_att_value;
43 static int hf_classicstun_att_family;
44 static int hf_classicstun_att_ipv4;
45 static int hf_classicstun_att_ipv6;
46 static int hf_classicstun_att_port;
47 static int hf_classicstun_att_change_ip;
48 static int hf_classicstun_att_change_port;
49 static int hf_classicstun_att_unknown;
50 static int hf_classicstun_att_error_class;
51 static int hf_classicstun_att_error_number;
52 static int hf_classicstun_att_error_reason;
53 static int hf_classicstun_att_server_string;
54 static int hf_classicstun_att_xor_ipv4;
55 static int hf_classicstun_att_xor_ipv6;
56 static int hf_classicstun_att_xor_port;
57 static int hf_classicstun_att_lifetime;
58 static int hf_classicstun_att_magic_cookie;
59 static int hf_classicstun_att_bandwidth;
60 static int hf_classicstun_att_data;
61 static int hf_classicstun_att_connection_request_binding;
63 /* Structure containing transaction specific information */
64 typedef struct _classicstun_transaction_t {
65 uint32_t req_frame;
66 uint32_t rep_frame;
67 nstime_t req_time;
68 } classicstun_transaction_t;
70 /* Structure containing conversation specific information */
71 typedef struct _classicstun_conv_info_t {
72 wmem_tree_t *pdus;
73 } classicstun_conv_info_t;
76 /* Message Types */
77 #define BINDING_REQUEST 0x0001
78 #define BINDING_RESPONSE 0x0101
79 #define BINDING_ERROR_RESPONSE 0x0111
80 #define SHARED_SECRET_REQUEST 0x0002
81 #define SHARED_SECRET_RESPONSE 0x0102
82 #define SHARED_SECRET_ERROR_RESPONSE 0x1112
83 #define ALLOCATE_REQUEST 0x0003
84 #define ALLOCATE_RESPONSE 0x0103
85 #define ALLOCATE_ERROR_RESPONSE 0x0113
86 #define SEND_REQUEST 0x0004
87 #define SEND_RESPONSE 0x0104
88 #define SEND_ERROR_RESPONSE 0x0114
89 #define DATA_INDICATION 0x0115
90 #define SET_ACTIVE_DESTINATION_REQUEST 0x0006
91 #define SET_ACTIVE_DESTINATION_RESPONSE 0x0106
92 #define SET_ACTIVE_DESTINATION_ERROR_RESPONSE 0x0116
95 /* Message classes */
96 #define CLASS_MASK 0xC110
97 #define REQUEST 0x0000
98 #define INDICATION 0x0001
99 #define RESPONSE 0x0010
100 #define ERROR_RESPONSE 0x0011
102 /* Attribute Types */
103 #define MAPPED_ADDRESS 0x0001
104 #define RESPONSE_ADDRESS 0x0002
105 #define CHANGE_REQUEST 0x0003
106 #define SOURCE_ADDRESS 0x0004
107 #define CHANGED_ADDRESS 0x0005
108 #define USERNAME 0x0006
109 #define PASSWORD 0x0007
110 #define MESSAGE_INTEGRITY 0x0008
111 #define ERROR_CODE 0x0009
112 #define UNKNOWN_ATTRIBUTES 0x000a
113 #define REFLECTED_FROM 0x000b
114 #define LIFETIME 0x000d
115 #define ALTERNATE_SERVER 0x000e
116 #define MAGIC_COOKIE 0x000f
117 #define BANDWIDTH 0x0010
118 #define DESTINATION_ADDRESS 0x0011
119 #define REMOTE_ADDRESS 0x0012
120 #define DATA 0x0013
121 #define NONCE 0x0014
122 #define REALM 0x0015
123 #define REQUESTED_ADDRESS_TYPE 0x0016
124 #define XOR_MAPPED_ADDRESS 0x8020
125 #define XOR_ONLY 0x0021
126 #define SERVER 0x8022
127 #define CONNECTION_REQUEST_BINDING 0xc001
128 #define BINDING_CHANGE 0xc002
132 /* Initialize the subtree pointers */
133 static int ett_classicstun;
134 static int ett_classicstun_att_type;
135 static int ett_classicstun_att;
138 #define UDP_PORT_STUN 3478
139 #define TCP_PORT_STUN 3478
142 #define CLASSICSTUN_HDR_LEN ((unsigned)20) /* CLASSIC-STUN message header length */
143 #define ATTR_HDR_LEN 4 /* CLASSIC-STUN attribute header length */
146 static const value_string messages[] = {
147 {BINDING_REQUEST , "Binding Request"},
148 {BINDING_RESPONSE , "Binding Response"},
149 {BINDING_ERROR_RESPONSE , "Binding Error Response"},
150 {SHARED_SECRET_REQUEST , "Shared Secret Request"},
151 {SHARED_SECRET_RESPONSE , "Shared Secret Response"},
152 {SHARED_SECRET_ERROR_RESPONSE , "Shared Secret Error Response"},
153 {ALLOCATE_REQUEST , "Allocate Request"},
154 {ALLOCATE_RESPONSE , "Allocate Response"},
155 {ALLOCATE_ERROR_RESPONSE , "Allocate Error Response"},
156 {SEND_REQUEST , "Send Request"},
157 {SEND_RESPONSE , "Send Response"},
158 {SEND_ERROR_RESPONSE , "Send Error Response"},
159 {DATA_INDICATION , "Data Indication"},
160 {SET_ACTIVE_DESTINATION_REQUEST , "Set Active Destination Request"},
161 {SET_ACTIVE_DESTINATION_RESPONSE , "Set Active Destination Response"},
162 {SET_ACTIVE_DESTINATION_ERROR_RESPONSE , "Set Active Destination Error Response"},
163 {0x00 , NULL}
166 static const value_string attributes[] = {
167 {MAPPED_ADDRESS , "MAPPED-ADDRESS"},
168 {RESPONSE_ADDRESS , "RESPONSE-ADDRESS"},
169 {CHANGE_REQUEST , "CHANGE-REQUEST"},
170 {SOURCE_ADDRESS , "SOURCE-ADDRESS"},
171 {CHANGED_ADDRESS , "CHANGED-ADDRESS"},
172 {USERNAME , "USERNAME"},
173 {PASSWORD , "PASSWORD"},
174 {MESSAGE_INTEGRITY , "MESSAGE-INTEGRITY"},
175 {ERROR_CODE , "ERROR-CODE"},
176 {REFLECTED_FROM , "REFLECTED-FROM"},
177 {LIFETIME , "LIFETIME"},
178 {ALTERNATE_SERVER , "ALTERNATE_SERVER"},
179 {MAGIC_COOKIE , "MAGIC_COOKIE"},
180 {BANDWIDTH , "BANDWIDTH"},
181 {DESTINATION_ADDRESS , "DESTINATION_ADDRESS"},
182 {REMOTE_ADDRESS , "REMOTE_ADDRESS"},
183 {DATA , "DATA"},
184 {NONCE , "NONCE"},
185 {REALM , "REALM"},
186 {REQUESTED_ADDRESS_TYPE , "REQUESTED_ADDRESS_TYPE"},
187 {XOR_MAPPED_ADDRESS , "XOR_MAPPED_ADDRESS"},
188 {XOR_ONLY , "XOR_ONLY"},
189 {SERVER , "SERVER"},
190 {CONNECTION_REQUEST_BINDING , "CONNECTION-REQUEST-BINDING"},
191 {BINDING_CHANGE , "BINDING-CHANGE"},
192 {0x00 , NULL}
195 static const value_string attributes_family[] = {
196 {0x0001 , "IPv4"},
197 {0x0002 , "IPv6"},
198 {0x00 , NULL}
201 static int
202 dissect_classicstun(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
205 proto_item *ti;
206 proto_item *ta;
207 proto_tree *classicstun_tree;
208 proto_tree *att_type_tree;
209 proto_tree *att_tree;
210 uint16_t msg_type;
211 uint16_t msg_length;
212 const char *msg_type_str;
213 uint16_t att_type;
214 uint16_t att_length, clear_port;
215 uint32_t clear_ip;
216 uint16_t offset;
217 unsigned len;
218 unsigned i;
219 conversation_t *conversation;
220 classicstun_conv_info_t *classicstun_info;
221 classicstun_transaction_t *classicstun_trans;
222 wmem_tree_key_t transaction_id_key[2];
223 uint32_t transaction_id[4];
227 * First check if the frame is really meant for us.
229 len = tvb_captured_length(tvb);
230 /* First, make sure we have enough data to do the check. */
231 if (len < CLASSICSTUN_HDR_LEN)
232 return 0;
234 msg_type = tvb_get_ntohs(tvb, 0);
236 if (msg_type & 0xC000 || tvb_get_ntohl(tvb, 4) == 0x2112a442 /* New STUN */
237 || tvb_get_ntohl(tvb, 4) == 0x7f5a9bc7) /* XMCP */
238 return 0;
240 /* check if message type is correct */
241 msg_type_str = try_val_to_str(msg_type, messages);
242 if (msg_type_str == NULL)
243 return 0;
245 msg_length = tvb_get_ntohs(tvb, 2);
247 /* check if payload enough */
248 if (len != CLASSICSTUN_HDR_LEN+msg_length)
249 return 0;
251 /* The message seems to be a valid CLASSIC-STUN message! */
253 /* Create the transaction key which may be used
254 to track the conversation */
255 transaction_id[0] = tvb_get_ntohl(tvb, 4);
256 transaction_id[1] = tvb_get_ntohl(tvb, 8);
257 transaction_id[2] = tvb_get_ntohl(tvb, 12);
258 transaction_id[3] = tvb_get_ntohl(tvb, 16);
260 transaction_id_key[0].length = 4;
261 transaction_id_key[0].key = transaction_id;
262 transaction_id_key[1].length = 0;
263 transaction_id_key[1].key = NULL;
266 * Do we have a conversation for this connection?
268 conversation = find_or_create_conversation(pinfo);
271 * Do we already have a state structure for this conv
273 classicstun_info = (classicstun_conv_info_t *)conversation_get_proto_data(conversation, proto_classicstun);
274 if (!classicstun_info) {
275 /* No. Attach that information to the conversation, and add
276 * it to the list of information structures.
278 classicstun_info = wmem_new(wmem_file_scope(), classicstun_conv_info_t);
279 classicstun_info->pdus=wmem_tree_new(wmem_file_scope());
280 conversation_add_proto_data(conversation, proto_classicstun, classicstun_info);
283 if(!pinfo->fd->visited){
284 if (((msg_type & CLASS_MASK) >> 4) == REQUEST) {
285 /* This is a request */
286 classicstun_trans=wmem_new(wmem_file_scope(), classicstun_transaction_t);
287 classicstun_trans->req_frame=pinfo->num;
288 classicstun_trans->rep_frame=0;
289 classicstun_trans->req_time=pinfo->abs_ts;
290 wmem_tree_insert32_array(classicstun_info->pdus, transaction_id_key,
291 (void *)classicstun_trans);
292 } else {
293 classicstun_trans=(classicstun_transaction_t *)wmem_tree_lookup32_array(classicstun_info->pdus,
294 transaction_id_key);
295 if(classicstun_trans){
296 classicstun_trans->rep_frame=pinfo->num;
299 } else {
300 classicstun_trans=(classicstun_transaction_t *)wmem_tree_lookup32_array(classicstun_info->pdus, transaction_id_key);
302 if(!classicstun_trans){
303 /* create a "fake" pana_trans structure */
304 classicstun_trans=wmem_new(pinfo->pool, classicstun_transaction_t);
305 classicstun_trans->req_frame=0;
306 classicstun_trans->rep_frame=0;
307 classicstun_trans->req_time=pinfo->abs_ts;
312 col_set_str(pinfo->cinfo, COL_PROTOCOL, "CLASSIC-STUN");
314 col_add_fstr(pinfo->cinfo, COL_INFO, "Message: %s",
315 msg_type_str);
317 unsigned transaction_id_first_word;
319 ti = proto_tree_add_item(tree, proto_classicstun, tvb, 0, -1, ENC_NA);
321 classicstun_tree = proto_item_add_subtree(ti, ett_classicstun);
323 if (((msg_type & CLASS_MASK) >> 4) == REQUEST) {
324 if (classicstun_trans->rep_frame) {
325 proto_item *it;
326 it=proto_tree_add_uint(classicstun_tree, hf_classicstun_response_in,
327 tvb, 0, 0,
328 classicstun_trans->rep_frame);
329 proto_item_set_generated(it);
332 else if ((((msg_type & CLASS_MASK) >> 4) == RESPONSE) ||
333 (((msg_type & CLASS_MASK) >> 4) == ERROR_RESPONSE)) {
334 /* This is a response */
335 if(classicstun_trans->req_frame){
336 proto_item *it;
337 nstime_t ns;
339 it=proto_tree_add_uint(classicstun_tree, hf_classicstun_response_to, tvb, 0, 0, classicstun_trans->req_frame);
340 proto_item_set_generated(it);
342 nstime_delta(&ns, &pinfo->abs_ts, &classicstun_trans->req_time);
343 it=proto_tree_add_time(classicstun_tree, hf_classicstun_time, tvb, 0, 0, &ns);
344 proto_item_set_generated(it);
349 proto_tree_add_uint(classicstun_tree, hf_classicstun_type, tvb, 0, 2, msg_type);
350 proto_tree_add_uint(classicstun_tree, hf_classicstun_length, tvb, 2, 2, msg_length);
351 proto_tree_add_item(classicstun_tree, hf_classicstun_id, tvb, 4, 16, ENC_NA);
353 /* Remember this (in host order) so we can show clear xor'd addresses */
354 transaction_id_first_word = tvb_get_ntohl(tvb, 4);
356 if (msg_length > 0) {
357 ta = proto_tree_add_item(classicstun_tree, hf_classicstun_att, tvb, CLASSICSTUN_HDR_LEN, msg_length, ENC_NA);
358 att_type_tree = proto_item_add_subtree(ta, ett_classicstun_att_type);
360 offset = CLASSICSTUN_HDR_LEN;
362 while( msg_length > 0) {
363 att_type = tvb_get_ntohs(tvb, offset); /* Type field in attribute header */
364 att_length = tvb_get_ntohs(tvb, offset+2); /* Length field in attribute header */
366 att_tree = proto_tree_add_subtree_format(att_type_tree, tvb, offset,
367 ATTR_HDR_LEN+att_length, ett_classicstun_att, NULL,
368 "Attribute: %s",
369 val_to_str(att_type, attributes, "Unknown (0x%04x)"));
371 proto_tree_add_uint(att_tree, hf_classicstun_att_type, tvb,
372 offset, 2, att_type);
373 offset += 2;
374 if (ATTR_HDR_LEN+att_length > msg_length) {
375 proto_tree_add_uint_format_value(att_tree,
376 hf_classicstun_att_length, tvb, offset, 2,
377 att_length,
378 "%u (bogus, goes past the end of the message)",
379 att_length);
380 break;
382 proto_tree_add_uint(att_tree, hf_classicstun_att_length, tvb,
383 offset, 2, att_length);
384 offset += 2;
385 switch( att_type ){
386 case MAPPED_ADDRESS:
387 case RESPONSE_ADDRESS:
388 case SOURCE_ADDRESS:
389 case CHANGED_ADDRESS:
390 case REFLECTED_FROM:
391 case ALTERNATE_SERVER:
392 case DESTINATION_ADDRESS:
393 case REMOTE_ADDRESS:
394 if (att_length < 2)
395 break;
396 proto_tree_add_item(att_tree, hf_classicstun_att_family, tvb, offset+1, 1, ENC_BIG_ENDIAN);
397 if (att_length < 4)
398 break;
399 proto_tree_add_item(att_tree, hf_classicstun_att_port, tvb, offset+2, 2, ENC_BIG_ENDIAN);
400 switch( tvb_get_uint8(tvb, offset+1) ){
401 case 1:
402 if (att_length < 8)
403 break;
404 proto_tree_add_item(att_tree, hf_classicstun_att_ipv4, tvb, offset+4, 4, ENC_BIG_ENDIAN);
405 break;
407 case 2:
408 if (att_length < 20)
409 break;
410 proto_tree_add_item(att_tree, hf_classicstun_att_ipv6, tvb, offset+4, 16, ENC_NA);
411 break;
413 break;
415 case CHANGE_REQUEST:
416 if (att_length < 4)
417 break;
418 proto_tree_add_item(att_tree, hf_classicstun_att_change_ip, tvb, offset, 4, ENC_BIG_ENDIAN);
419 proto_tree_add_item(att_tree, hf_classicstun_att_change_port, tvb, offset, 4, ENC_BIG_ENDIAN);
420 break;
422 case USERNAME:
423 case PASSWORD:
424 case MESSAGE_INTEGRITY:
425 case NONCE:
426 case REALM:
427 if (att_length < 1)
428 break;
429 proto_tree_add_item(att_tree, hf_classicstun_att_value, tvb, offset, att_length, ENC_NA);
430 break;
432 case ERROR_CODE:
433 if (att_length < 3)
434 break;
435 proto_tree_add_item(att_tree, hf_classicstun_att_error_class, tvb, offset+2, 1, ENC_BIG_ENDIAN);
436 if (att_length < 4)
437 break;
438 proto_tree_add_item(att_tree, hf_classicstun_att_error_number, tvb, offset+3, 1, ENC_BIG_ENDIAN);
439 if (att_length < 5)
440 break;
441 proto_tree_add_item(att_tree, hf_classicstun_att_error_reason, tvb, offset+4, (att_length-4), ENC_UTF_8);
442 break;
444 case LIFETIME:
445 if (att_length < 4)
446 break;
447 proto_tree_add_item(att_tree, hf_classicstun_att_lifetime, tvb, offset, 4, ENC_BIG_ENDIAN);
448 break;
450 case MAGIC_COOKIE:
451 if (att_length < 4)
452 break;
453 proto_tree_add_item(att_tree, hf_classicstun_att_magic_cookie, tvb, offset, 4, ENC_BIG_ENDIAN);
454 break;
456 case BANDWIDTH:
457 if (att_length < 4)
458 break;
459 proto_tree_add_item(att_tree, hf_classicstun_att_bandwidth, tvb, offset, 4, ENC_BIG_ENDIAN);
460 break;
462 case DATA:
463 proto_tree_add_item(att_tree, hf_classicstun_att_data, tvb, offset, att_length, ENC_NA);
465 tvbuff_t *next_tvb;
466 heur_dtbl_entry_t *hdtbl_entry;
467 next_tvb = tvb_new_subset_length(tvb, offset, att_length);
469 if (!dissector_try_heuristic(heur_subdissector_list, next_tvb, pinfo, att_tree, &hdtbl_entry, NULL)) {
470 call_dissector_only(data_handle, next_tvb, pinfo, att_tree, NULL);
473 break;
475 case UNKNOWN_ATTRIBUTES:
476 for (i = 0; i < att_length; i += 4) {
477 proto_tree_add_item(att_tree, hf_classicstun_att_unknown, tvb, offset+i, 2, ENC_BIG_ENDIAN);
478 proto_tree_add_item(att_tree, hf_classicstun_att_unknown, tvb, offset+i+2, 2, ENC_BIG_ENDIAN);
480 break;
482 case SERVER:
483 proto_tree_add_item(att_tree, hf_classicstun_att_server_string, tvb, offset, att_length, ENC_UTF_8);
484 break;
486 case XOR_MAPPED_ADDRESS:
487 if (att_length < 2)
488 break;
489 proto_tree_add_item(att_tree, hf_classicstun_att_family, tvb, offset+1, 1, ENC_BIG_ENDIAN);
490 if (att_length < 4)
491 break;
492 proto_tree_add_item(att_tree, hf_classicstun_att_xor_port, tvb, offset+2, 2, ENC_BIG_ENDIAN);
494 /* Show the port 'in the clear'
495 XOR (host order) transid with (host order) xor-port.
496 Add host-order port into tree. */
497 clear_port = tvb_get_ntohs(tvb, offset+2) ^ (transaction_id_first_word >> 16);
498 ti = proto_tree_add_uint(att_tree, hf_classicstun_att_port, tvb, offset+2, 2, clear_port);
499 proto_item_set_generated(ti);
501 switch( tvb_get_uint8(tvb, offset+1) ){
502 case 1:
503 if (att_length < 8)
504 break;
505 proto_tree_add_item(att_tree, hf_classicstun_att_xor_ipv4, tvb, offset+4, 4, ENC_BIG_ENDIAN);
507 /* Show the address 'in the clear'.
508 XOR (host order) transid with (host order) xor-address.
509 Add in network order tree. */
510 clear_ip = tvb_get_ipv4(tvb, offset+4) ^ g_htonl(transaction_id_first_word);
511 ti = proto_tree_add_ipv4(att_tree, hf_classicstun_att_ipv4, tvb, offset+4, 4, clear_ip);
512 proto_item_set_generated(ti);
513 break;
515 case 2:
516 if (att_length < 20)
517 break;
518 proto_tree_add_item(att_tree, hf_classicstun_att_xor_ipv6, tvb, offset+4, 16, ENC_NA);
519 break;
521 break;
523 case REQUESTED_ADDRESS_TYPE:
524 if (att_length < 2)
525 break;
526 proto_tree_add_item(att_tree, hf_classicstun_att_family, tvb, offset+1, 1, ENC_BIG_ENDIAN);
527 break;
529 case CONNECTION_REQUEST_BINDING:
530 proto_tree_add_item(att_tree, hf_classicstun_att_connection_request_binding, tvb, offset, att_length, ENC_UTF_8);
531 break;
533 default:
534 break;
536 offset += att_length;
537 msg_length -= ATTR_HDR_LEN+att_length;
540 return tvb_reported_length(tvb);
543 static bool
544 dissect_classicstun_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
546 return dissect_classicstun(tvb, pinfo, tree, data) > 0;
551 void
552 proto_register_classicstun(void)
554 static hf_register_info hf[] = {
555 { &hf_classicstun_type,
556 { "Message Type", "classicstun.type", FT_UINT16,
557 BASE_HEX, VALS(messages), 0x0, NULL, HFILL }
559 { &hf_classicstun_length,
560 { "Message Length", "classicstun.length", FT_UINT16,
561 BASE_HEX, NULL, 0x0, NULL, HFILL }
563 { &hf_classicstun_id,
564 { "Message Transaction ID", "classicstun.id", FT_BYTES,
565 BASE_NONE, NULL, 0x0, NULL, HFILL }
567 { &hf_classicstun_att,
568 { "Attributes", "classicstun.att", FT_NONE,
569 BASE_NONE, NULL, 0x0, NULL, HFILL }
571 { &hf_classicstun_response_in,
572 { "Response In", "classicstun.response_in",
573 FT_FRAMENUM, BASE_NONE, FRAMENUM_TYPE(FT_FRAMENUM_RESPONSE), 0x0,
574 "The response to this CLASSICSTUN query is in this frame", HFILL }},
575 { &hf_classicstun_response_to,
576 { "Request In", "classicstun.response_to",
577 FT_FRAMENUM, BASE_NONE, FRAMENUM_TYPE(FT_FRAMENUM_REQUEST), 0x0,
578 "This is a response to the CLASSICSTUN Request in this frame", HFILL }},
579 { &hf_classicstun_time,
580 { "Time", "classicstun.time",
581 FT_RELATIVE_TIME, BASE_NONE, NULL, 0x0,
582 "The time between the Request and the Response", HFILL }},
584 /* ////////////////////////////////////// */
585 { &hf_classicstun_att_type,
586 { "Attribute Type", "classicstun.att.type", FT_UINT16,
587 BASE_HEX, VALS(attributes), 0x0, NULL, HFILL }
589 { &hf_classicstun_att_length,
590 { "Attribute Length", "classicstun.att.length", FT_UINT16,
591 BASE_DEC, NULL, 0x0, NULL, HFILL }
593 { &hf_classicstun_att_value,
594 { "Value", "classicstun.att.value", FT_BYTES,
595 BASE_NONE, NULL, 0x0, NULL, HFILL }
597 { &hf_classicstun_att_family,
598 { "Protocol Family", "classicstun.att.family", FT_UINT16,
599 BASE_HEX, VALS(attributes_family), 0x0, NULL, HFILL }
601 { &hf_classicstun_att_ipv4,
602 { "IP", "classicstun.att.ipv4", FT_IPv4,
603 BASE_NONE, NULL, 0x0, NULL, HFILL }
605 { &hf_classicstun_att_ipv6,
606 { "IP", "classicstun.att.ipv6", FT_IPv6,
607 BASE_NONE, NULL, 0x0, NULL, HFILL }
609 { &hf_classicstun_att_port,
610 { "Port", "classicstun.att.port", FT_UINT16,
611 BASE_DEC, NULL, 0x0, NULL, HFILL }
613 { &hf_classicstun_att_change_ip,
614 { "Change IP","classicstun.att.change.ip", FT_BOOLEAN,
615 16, TFS(&tfs_set_notset), 0x0004, NULL, HFILL}
617 { &hf_classicstun_att_change_port,
618 { "Change Port","classicstun.att.change.port", FT_BOOLEAN,
619 16, TFS(&tfs_set_notset), 0x0002, NULL, HFILL}
621 { &hf_classicstun_att_unknown,
622 { "Unknown Attribute","classicstun.att.unknown", FT_UINT16,
623 BASE_HEX, NULL, 0x0, NULL, HFILL}
625 { &hf_classicstun_att_error_class,
626 { "Error Class","classicstun.att.error.class", FT_UINT8,
627 BASE_DEC, NULL, 0x07, NULL, HFILL}
629 { &hf_classicstun_att_error_number,
630 { "Error Code","classicstun.att.error", FT_UINT8,
631 BASE_DEC, NULL, 0x0, NULL, HFILL}
633 { &hf_classicstun_att_error_reason,
634 { "Error Reason Phase","classicstun.att.error.reason", FT_STRING,
635 BASE_NONE, NULL, 0x0, NULL, HFILL}
637 { &hf_classicstun_att_xor_ipv4,
638 { "IP (XOR-d)", "classicstun.att.ipv4-xord", FT_IPv4,
639 BASE_NONE, NULL, 0x0, NULL, HFILL }
641 { &hf_classicstun_att_xor_ipv6,
642 { "IP (XOR-d)", "classicstun.att.ipv6-xord", FT_IPv6,
643 BASE_NONE, NULL, 0x0, NULL, HFILL }
645 { &hf_classicstun_att_xor_port,
646 { "Port (XOR-d)", "classicstun.att.port-xord", FT_UINT16,
647 BASE_DEC, NULL, 0x0, NULL, HFILL }
649 { &hf_classicstun_att_server_string,
650 { "Server version","classicstun.att.server", FT_STRING,
651 BASE_NONE, NULL, 0x0, NULL, HFILL}
653 { &hf_classicstun_att_lifetime,
654 { "Lifetime", "classicstun.att.lifetime", FT_UINT32,
655 BASE_DEC, NULL, 0x0, NULL, HFILL }
657 { &hf_classicstun_att_magic_cookie,
658 { "Magic Cookie", "classicstun.att.magic.cookie", FT_UINT32,
659 BASE_HEX, NULL, 0x0, NULL, HFILL }
661 { &hf_classicstun_att_bandwidth,
662 { "Bandwidth", "classicstun.att.bandwidth", FT_UINT32,
663 BASE_DEC, NULL, 0x0, NULL, HFILL }
665 { &hf_classicstun_att_data,
666 { "Data", "classicstun.att.data", FT_BYTES,
667 BASE_NONE, NULL, 0x0, NULL, HFILL }
669 { &hf_classicstun_att_connection_request_binding,
670 { "Connection Request Binding", "classicstun.att.connection_request_binding", FT_STRING,
671 BASE_NONE, NULL, 0x0, NULL, HFILL }
675 /* Setup protocol subtree array */
676 static int *ett[] = {
677 &ett_classicstun,
678 &ett_classicstun_att_type,
679 &ett_classicstun_att,
682 /* Register the protocol name and description */
683 proto_classicstun = proto_register_protocol("Simple Traversal of UDP Through NAT",
684 "CLASSICSTUN", "classicstun");
686 /* Required function calls to register the header fields and subtrees used */
687 proto_register_field_array(proto_classicstun, hf, array_length(hf));
688 proto_register_subtree_array(ett, array_length(ett));
690 /* heuristic subdissectors (used for the DATA field) */
691 heur_subdissector_list = register_heur_dissector_list_with_description("classicstun", "CLASSICSTUN DATA payload", proto_classicstun);
693 register_dissector("classicstun", dissect_classicstun, proto_classicstun);
697 void
698 proto_reg_handoff_classicstun(void)
700 #if 0 /* The stun dissector registers on these ports */
701 dissector_handle_t classicstun_handle;
703 classicstun_handle = find_dissector("classicstun");
705 dissector_add_uint_with_preference("tcp.port", TCP_PORT_STUN, classicstun_handle);
706 dissector_add_uint_with_preference("udp.port", UDP_PORT_STUN, classicstun_handle);
707 #endif
708 heur_dissector_add("udp", dissect_classicstun_heur, "Classic STUN over UDP", "classicstun_udp", proto_classicstun, HEURISTIC_ENABLE);
709 heur_dissector_add("tcp", dissect_classicstun_heur, "Classic STUN over TCP", "classicstun_tcp", proto_classicstun, HEURISTIC_ENABLE);
711 data_handle = find_dissector("data");
715 * Editor modelines - https://www.wireshark.org/tools/modelines.html
717 * Local variables:
718 * c-basic-offset: 4
719 * tab-width: 8
720 * indent-tabs-mode: nil
721 * End:
723 * vi: set shiftwidth=4 tabstop=8 expandtab:
724 * :indentSize=4:tabSize=8:noTabs=true: