MSWSP: fix dissect_mswsp_smb()
[wireshark-wip.git] / epan / dissectors / packet-quake.c
blob6c368fdeaf3fa1cd3b26c7c2693a5745f8f7fde8
1 /* packet-quake.c
2 * Routines for Quake packet dissection
4 * Uwe Girlich <uwe@planetquake.com>
5 * http://www.idsoftware.com/q1source/q1source.zip
7 * $Id$
9 * Wireshark - Network traffic analyzer
10 * By Gerald Combs <gerald@wireshark.org>
11 * Copyright 1998 Gerald Combs
13 * Copied from packet-tftp.c
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version 2
18 * of the License, or (at your option) any later version.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
30 #include "config.h"
32 #include <glib.h>
33 #include <epan/packet.h>
34 #include <epan/conversation.h>
35 #include <epan/prefs.h>
37 static int proto_quake = -1;
38 static int hf_quake_header_flags = -1;
39 static int hf_quake_header_flags_data = -1;
40 static int hf_quake_header_flags_ack = -1;
41 static int hf_quake_header_flags_no_ack = -1;
42 static int hf_quake_header_flags_endmsg = -1;
43 static int hf_quake_header_flags_unreliable = -1;
44 static int hf_quake_header_flags_control = -1;
45 static int hf_quake_header_length = -1;
46 static int hf_quake_header_sequence = -1;
47 static int hf_quake_control_command = -1;
49 static int hf_quake_CCREQ_CONNECT_game = -1;
50 static int hf_quake_CCREQ_CONNECT_version = -1;
51 static int hf_quake_CCREQ_SERVER_INFO_game = -1;
52 static int hf_quake_CCREQ_SERVER_INFO_version = -1;
53 static int hf_quake_CCREQ_PLAYER_INFO_player = -1;
54 static int hf_quake_CCREQ_RULE_INFO_lastrule = -1;
56 static int hf_quake_CCREP_ACCEPT_port = -1;
57 static int hf_quake_CCREP_REJECT_reason = -1;
58 static int hf_quake_CCREP_SERVER_INFO_address = -1;
59 static int hf_quake_CCREP_SERVER_INFO_server = -1;
60 static int hf_quake_CCREP_SERVER_INFO_map = -1;
61 static int hf_quake_CCREP_SERVER_INFO_num_player = -1;
62 static int hf_quake_CCREP_SERVER_INFO_max_player = -1;
63 static int hf_quake_CCREP_PLAYER_INFO_name = -1;
64 static int hf_quake_CCREP_PLAYER_INFO_colors = -1;
65 static int hf_quake_CCREP_PLAYER_INFO_colors_shirt = -1;
66 static int hf_quake_CCREP_PLAYER_INFO_colors_pants = -1;
67 static int hf_quake_CCREP_PLAYER_INFO_frags = -1;
68 static int hf_quake_CCREP_PLAYER_INFO_connect_time = -1;
69 static int hf_quake_CCREP_PLAYER_INFO_address = -1;
70 static int hf_quake_CCREP_RULE_INFO_rule = -1;
71 static int hf_quake_CCREP_RULE_INFO_value = -1;
74 static gint ett_quake = -1;
75 static gint ett_quake_control = -1;
76 static gint ett_quake_control_colors = -1;
77 static gint ett_quake_flags = -1;
79 static dissector_handle_t quake_handle;
80 static dissector_handle_t data_handle;
82 /* I took these names directly out of the Q1 source. */
83 #define NET_HEADERSIZE 8
84 #define DEFAULTnet_hostport 26000
85 static guint gbl_quakeServerPort=DEFAULTnet_hostport;
87 #define NETFLAG_DATA 0x0001
88 #define NETFLAG_ACK 0x0002
89 #define NETFLAG_NAK 0x0004
90 #define NETFLAG_EOM 0x0008
91 #define NETFLAG_UNRELIABLE 0x0010
92 #define NETFLAG_CTL 0x8000
95 #define CCREQ_CONNECT 0x01
96 #define CCREQ_SERVER_INFO 0x02
97 #define CCREQ_PLAYER_INFO 0x03
98 #define CCREQ_RULE_INFO 0x04
100 #define CCREP_ACCEPT 0x81
101 #define CCREP_REJECT 0x82
102 #define CCREP_SERVER_INFO 0x83
103 #define CCREP_PLAYER_INFO 0x84
104 #define CCREP_RULE_INFO 0x85
106 static const value_string names_control_command[] = {
107 { CCREQ_CONNECT, "connect" },
108 { CCREQ_SERVER_INFO, "server_info" },
109 { CCREQ_PLAYER_INFO, "player_info" },
110 { CCREQ_RULE_INFO, "rule_info" },
111 { CCREP_ACCEPT, "accept" },
112 { CCREP_REJECT, "reject" },
113 { CCREP_SERVER_INFO, "server_info" },
114 { CCREP_PLAYER_INFO, "player_info" },
115 { CCREP_RULE_INFO, "rule_info" },
116 { 0, NULL }
119 #define CCREQ 0x00
120 #define CCREP 0x80
122 #define QUAKE_MAXSTRING 0x800
124 static const value_string names_control_direction[] = {
125 { CCREQ, "Request" },
126 { CCREP, "Reply" },
127 { 0, NULL }
131 static const value_string names_colors[] = {
132 { 0, "White" },
133 { 1, "Brown" },
134 { 2, "Lavender" },
135 { 3, "Khaki" },
136 { 4, "Red" },
137 { 5, "Lt Brown" },
138 { 6, "Peach" },
139 { 7, "Lt Peach" },
140 { 8, "Purple" },
141 { 9, "Dk Purple" },
142 { 10, "Tan" },
143 { 11, "Green" },
144 { 12, "Yellow" },
145 { 13, "Blue" },
146 { 14, "Blue" },
147 { 15, "Blue" },
148 { 0, NULL }
152 static void dissect_quake(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
156 static void
157 dissect_quake_CCREQ_CONNECT
158 (tvbuff_t *tvb, proto_tree *tree)
160 gint offset;
161 proto_item *ti;
163 offset = 0;
165 if (tree) {
166 ti = proto_tree_add_item(tree, hf_quake_CCREQ_CONNECT_game,
167 tvb, offset, -1, ENC_ASCII|ENC_NA);
168 offset += proto_item_get_len(ti);
170 proto_tree_add_item(tree, hf_quake_CCREQ_CONNECT_version,
171 tvb, offset, 1, ENC_LITTLE_ENDIAN);
176 static void
177 dissect_quake_CCREQ_SERVER_INFO
178 (tvbuff_t *tvb, proto_tree *tree)
180 gint offset;
181 proto_item *ti;
183 offset = 0;
185 if (tree) {
186 ti = proto_tree_add_item(tree, hf_quake_CCREQ_SERVER_INFO_game,
187 tvb, offset, -1, ENC_ASCII|ENC_NA);
188 offset += proto_item_get_len(ti);
189 proto_tree_add_item(tree, hf_quake_CCREQ_SERVER_INFO_version,
190 tvb, offset, 1, ENC_LITTLE_ENDIAN);
195 static void
196 dissect_quake_CCREQ_PLAYER_INFO
197 (tvbuff_t *tvb, proto_tree *tree)
199 if (tree) {
200 proto_tree_add_item(tree, hf_quake_CCREQ_PLAYER_INFO_player,
201 tvb, 0, 1, ENC_LITTLE_ENDIAN);
206 static void
207 dissect_quake_CCREQ_RULE_INFO
208 (tvbuff_t *tvb, proto_tree *tree)
210 if (tree) {
211 proto_tree_add_item(tree, hf_quake_CCREQ_RULE_INFO_lastrule,
212 tvb, 0, -1, ENC_ASCII|ENC_NA);
217 static void
218 dissect_quake_CCREP_ACCEPT
219 (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
221 guint32 port;
222 conversation_t *c;
224 port = tvb_get_letohl(tvb, 0);
225 c = find_or_create_conversation(pinfo);
226 conversation_set_dissector(c, quake_handle);
228 if (tree) {
229 proto_tree_add_uint(tree, hf_quake_CCREP_ACCEPT_port,
230 tvb, 0, 4, port);
235 static void
236 dissect_quake_CCREP_REJECT
237 (tvbuff_t *tvb, proto_tree *tree)
239 if (tree) {
240 proto_tree_add_item(tree, hf_quake_CCREP_REJECT_reason,
241 tvb, 0, -1, ENC_ASCII|ENC_NA);
246 static void
247 dissect_quake_CCREP_SERVER_INFO
248 (tvbuff_t *tvb, proto_tree *tree)
250 gint offset;
251 proto_item *ti;
253 offset = 0;
255 if (tree) {
256 ti = proto_tree_add_item(tree,
257 hf_quake_CCREP_SERVER_INFO_address, tvb, offset, -1,
258 ENC_ASCII|ENC_NA);
259 offset += proto_item_get_len(ti);
261 ti = proto_tree_add_item(tree,
262 hf_quake_CCREP_SERVER_INFO_server, tvb, offset, -1,
263 ENC_ASCII|ENC_NA);
264 offset += proto_item_get_len(ti);
266 ti = proto_tree_add_item(tree, hf_quake_CCREP_SERVER_INFO_map,
267 tvb, offset, -1, ENC_ASCII|ENC_NA);
268 offset += proto_item_get_len(ti);
270 proto_tree_add_item(tree, hf_quake_CCREP_SERVER_INFO_num_player,
271 tvb, offset, 1, ENC_LITTLE_ENDIAN);
272 offset += 1;
273 proto_tree_add_item(tree, hf_quake_CCREP_SERVER_INFO_max_player,
274 tvb, offset, 1, ENC_LITTLE_ENDIAN);
275 offset += 1;
276 proto_tree_add_item(tree, hf_quake_CCREQ_SERVER_INFO_version,
277 tvb, offset, 1, ENC_LITTLE_ENDIAN);
282 static void
283 dissect_quake_CCREP_PLAYER_INFO
284 (tvbuff_t *tvb, proto_tree *tree)
286 gint offset;
287 proto_item *ti;
288 guint32 colors;
289 guint32 color_shirt;
290 guint32 color_pants;
291 proto_item *colors_item;
292 proto_tree *colors_tree;
294 offset = 0;
296 if (tree) {
297 proto_tree_add_item(tree, hf_quake_CCREQ_PLAYER_INFO_player,
298 tvb, offset, 1, ENC_LITTLE_ENDIAN);
299 offset += 1;
301 ti = proto_tree_add_item(tree, hf_quake_CCREP_PLAYER_INFO_name,
302 tvb, offset, -1, ENC_ASCII|ENC_NA);
303 offset += proto_item_get_len(ti);
305 colors = tvb_get_letohl(tvb, offset + 0);
306 color_shirt = (colors >> 4) & 0x0f;
307 color_pants = (colors ) & 0x0f;
309 colors_item = proto_tree_add_uint(tree,
310 hf_quake_CCREP_PLAYER_INFO_colors,
311 tvb, offset, 4, colors);
312 colors_tree = proto_item_add_subtree(colors_item,
313 ett_quake_control_colors);
314 proto_tree_add_uint(colors_tree,
315 hf_quake_CCREP_PLAYER_INFO_colors_shirt,
316 tvb, offset, 1, color_shirt);
317 proto_tree_add_uint(colors_tree,
318 hf_quake_CCREP_PLAYER_INFO_colors_pants,
319 tvb, offset, 1, color_pants);
320 offset += 4;
321 proto_tree_add_item(tree, hf_quake_CCREP_PLAYER_INFO_frags,
322 tvb, offset, 4, ENC_LITTLE_ENDIAN);
323 offset += 4;
324 proto_tree_add_item(tree, hf_quake_CCREP_PLAYER_INFO_connect_time,
325 tvb, offset, 4, ENC_LITTLE_ENDIAN);
326 offset += 4;
328 proto_tree_add_item(tree, hf_quake_CCREP_PLAYER_INFO_address,
329 tvb, offset, -1, ENC_ASCII|ENC_NA);
334 static void
335 dissect_quake_CCREP_RULE_INFO
336 (tvbuff_t *tvb, proto_tree *tree)
338 gint offset;
339 proto_item *ti;
341 if (tvb_reported_length(tvb) == 0) return;
343 offset = 0;
345 if (tree) {
346 ti = proto_tree_add_item(tree, hf_quake_CCREP_RULE_INFO_rule,
347 tvb, offset, -1, ENC_ASCII|ENC_NA);
348 offset += proto_item_get_len(ti);
350 proto_tree_add_item(tree, hf_quake_CCREP_RULE_INFO_value,
351 tvb, offset, -1, ENC_ASCII|ENC_NA);
356 static void
357 dissect_quake_control(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
359 guint8 command;
360 int direction;
361 proto_tree *control_tree = NULL;
362 guint rest_length;
363 tvbuff_t *next_tvb;
365 command = tvb_get_guint8(tvb, 0);
366 direction = (command & 0x80) ? CCREP : CCREQ;
368 col_add_fstr(pinfo->cinfo, COL_INFO, "%s %s",
369 val_to_str(command,names_control_command, "%u"),
370 val_to_str(direction,names_control_direction,"%u"));
372 if (tree) {
373 proto_item *control_item;
374 control_item = proto_tree_add_text(tree, tvb,
375 0, -1, "Control %s: %s",
376 val_to_str(direction, names_control_direction, "%u"),
377 val_to_str(command, names_control_command, "%u"));
378 control_tree = proto_item_add_subtree(control_item, ett_quake_control);
379 proto_tree_add_uint(control_tree, hf_quake_control_command,
380 tvb, 0, 1, command);
383 rest_length = tvb_reported_length(tvb) - 1;
384 next_tvb = tvb_new_subset(tvb, 1, rest_length , rest_length);
385 switch (command) {
386 case CCREQ_CONNECT:
387 dissect_quake_CCREQ_CONNECT
388 (next_tvb, control_tree);
389 break;
390 case CCREQ_SERVER_INFO:
391 dissect_quake_CCREQ_SERVER_INFO
392 (next_tvb, control_tree);
393 break;
394 case CCREQ_PLAYER_INFO:
395 dissect_quake_CCREQ_PLAYER_INFO
396 (next_tvb, control_tree);
397 break;
398 case CCREQ_RULE_INFO:
399 dissect_quake_CCREQ_RULE_INFO
400 (next_tvb, control_tree);
401 break;
402 case CCREP_ACCEPT:
403 dissect_quake_CCREP_ACCEPT
404 (next_tvb, pinfo, control_tree);
405 break;
406 case CCREP_REJECT:
407 dissect_quake_CCREP_REJECT
408 (next_tvb, control_tree);
409 break;
410 case CCREP_SERVER_INFO:
411 dissect_quake_CCREP_SERVER_INFO
412 (next_tvb, control_tree);
413 break;
414 case CCREP_PLAYER_INFO:
415 dissect_quake_CCREP_PLAYER_INFO
416 (next_tvb, control_tree);
417 break;
418 case CCREP_RULE_INFO:
419 dissect_quake_CCREP_RULE_INFO
420 (next_tvb, control_tree);
421 break;
422 default:
423 call_dissector(data_handle,next_tvb, pinfo, control_tree);
424 break;
429 static void
430 dissect_quake(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
432 proto_tree *quake_tree = NULL;
433 guint16 flags;
434 guint32 sequence = 0;
435 guint rest_length;
436 tvbuff_t *next_tvb;
438 col_set_str(pinfo->cinfo, COL_PROTOCOL, "QUAKE");
439 col_clear(pinfo->cinfo, COL_INFO);
441 flags = tvb_get_ntohs(tvb, 2);
443 if (tree) {
444 proto_item *quake_item;
445 quake_item = proto_tree_add_item(tree, proto_quake,
446 tvb, 0, -1, ENC_NA);
447 quake_tree = proto_item_add_subtree(quake_item, ett_quake);
450 if (quake_tree) {
451 proto_item* flags_item;
452 proto_tree* flags_tree;
454 flags_item = proto_tree_add_item(quake_tree, hf_quake_header_flags,
455 tvb, 2, 2, ENC_BIG_ENDIAN);
456 flags_tree = proto_item_add_subtree(flags_item, ett_quake_flags);
457 proto_tree_add_item(flags_tree, hf_quake_header_flags_data, tvb, 2, 2, ENC_BIG_ENDIAN);
458 proto_tree_add_item(flags_tree, hf_quake_header_flags_ack, tvb, 2, 2, ENC_BIG_ENDIAN);
459 proto_tree_add_item(flags_tree, hf_quake_header_flags_no_ack, tvb, 2, 2, ENC_BIG_ENDIAN);
460 proto_tree_add_item(flags_tree, hf_quake_header_flags_endmsg, tvb, 2, 2, ENC_BIG_ENDIAN);
461 proto_tree_add_item(flags_tree, hf_quake_header_flags_unreliable, tvb, 2, 2, ENC_BIG_ENDIAN);
462 proto_tree_add_item(flags_tree, hf_quake_header_flags_control, tvb, 2, 2, ENC_BIG_ENDIAN);
464 proto_tree_add_item(quake_tree, hf_quake_header_length,
465 tvb, 0, 2, ENC_BIG_ENDIAN);
468 if (flags == NETFLAG_CTL) {
469 rest_length = tvb_reported_length(tvb) - 4;
470 next_tvb = tvb_new_subset(tvb, 4, rest_length , rest_length);
471 dissect_quake_control(next_tvb, pinfo, quake_tree);
472 return;
475 sequence = tvb_get_ntohl(tvb, 4);
476 col_add_fstr(pinfo->cinfo, COL_INFO, "seq 0x%x", sequence);
477 proto_tree_add_uint(quake_tree, hf_quake_header_sequence,
478 tvb, 4, 4, sequence);
480 rest_length = tvb_reported_length(tvb) - 8;
481 next_tvb = tvb_new_subset(tvb, 8, rest_length , rest_length);
482 call_dissector(data_handle,next_tvb, pinfo, quake_tree);
486 void proto_reg_handoff_quake(void);
488 void
489 proto_register_quake(void)
491 static hf_register_info hf[] = {
492 { &hf_quake_header_flags,
493 { "Flags", "quake.header.flags",
494 FT_UINT16, BASE_HEX, NULL, 0x0,
495 NULL, HFILL }},
496 { &hf_quake_header_flags_data,
497 { "Data", "quake.header.flags.data",
498 FT_BOOLEAN, 16, TFS(&tfs_set_notset), NETFLAG_DATA,
499 NULL, HFILL }},
500 { &hf_quake_header_flags_ack,
501 { "Acknowledgment", "quake.header.flags.ack",
502 FT_BOOLEAN, 16, TFS(&tfs_set_notset), NETFLAG_ACK,
503 NULL, HFILL }},
504 { &hf_quake_header_flags_no_ack,
505 { "No Acknowledgment", "quake.header.flags.no_ack",
506 FT_BOOLEAN, 16, TFS(&tfs_set_notset), NETFLAG_NAK,
507 NULL, HFILL }},
508 { &hf_quake_header_flags_endmsg,
509 { "End Of Message", "quake.header.flags.endmsg",
510 FT_BOOLEAN, 16, TFS(&tfs_set_notset), NETFLAG_EOM,
511 NULL, HFILL }},
512 { &hf_quake_header_flags_unreliable,
513 { "Unreliable", "quake.header.flags.unreliable",
514 FT_BOOLEAN, 16, TFS(&tfs_set_notset), NETFLAG_UNRELIABLE,
515 NULL, HFILL }},
516 { &hf_quake_header_flags_control,
517 { "Control", "quake.header.flags.control",
518 FT_BOOLEAN, 16, TFS(&tfs_set_notset), NETFLAG_CTL,
519 NULL, HFILL }},
520 { &hf_quake_header_length,
521 { "Length", "quake.header.length",
522 FT_UINT16, BASE_DEC, NULL, 0x0,
523 "full data length", HFILL }},
524 { &hf_quake_header_sequence,
525 { "Sequence", "quake.header.sequence",
526 FT_UINT32, BASE_HEX, NULL, 0x0,
527 "Sequence Number", HFILL }},
528 { &hf_quake_control_command,
529 { "Command", "quake.control.command",
530 FT_UINT8, BASE_HEX, VALS(names_control_command), 0x0,
531 "Control Command", HFILL }},
532 { &hf_quake_CCREQ_CONNECT_game,
533 { "Game", "quake.control.connect.game",
534 FT_STRINGZ, BASE_NONE, NULL, 0x0,
535 "Game Name", HFILL }},
536 { &hf_quake_CCREQ_CONNECT_version,
537 { "Version", "quake.control.connect.version",
538 FT_UINT8, BASE_DEC, NULL, 0x0,
539 "Game Protocol Version Number", HFILL }},
540 { &hf_quake_CCREQ_SERVER_INFO_game,
541 { "Game", "quake.control.server_info.game",
542 FT_STRINGZ, BASE_NONE, NULL, 0x0,
543 "Game Name", HFILL }},
544 { &hf_quake_CCREQ_SERVER_INFO_version,
545 { "Version", "quake.control.server_info.version",
546 FT_UINT8, BASE_DEC, NULL, 0x0,
547 "Game Protocol Version Number", HFILL }},
548 { &hf_quake_CCREQ_PLAYER_INFO_player,
549 { "Player", "quake.control.player_info.player",
550 FT_UINT8, BASE_DEC, NULL, 0x0,
551 NULL, HFILL }},
552 { &hf_quake_CCREQ_RULE_INFO_lastrule,
553 { "Last Rule", "quake.control.rule_info.lastrule",
554 FT_STRINGZ, BASE_NONE, NULL, 0x0,
555 "Last Rule Name", HFILL }},
556 { &hf_quake_CCREP_ACCEPT_port,
557 { "Port", "quake.control.accept.port",
558 FT_UINT32, BASE_DEC, NULL, 0x0,
559 "Game Data Port", HFILL }},
560 { &hf_quake_CCREP_REJECT_reason,
561 { "Reason", "quake.control.reject.reason",
562 FT_STRINGZ, BASE_NONE, NULL, 0x0,
563 "Reject Reason", HFILL }},
564 { &hf_quake_CCREP_SERVER_INFO_address,
565 { "Address", "quake.control.server_info.address",
566 FT_STRINGZ, BASE_NONE, NULL, 0x0,
567 "Server Address", HFILL }},
568 { &hf_quake_CCREP_SERVER_INFO_server,
569 { "Server", "quake.control.server_info.server",
570 FT_STRINGZ, BASE_NONE, NULL, 0x0,
571 "Server Name", HFILL }},
572 { &hf_quake_CCREP_SERVER_INFO_map,
573 { "Map", "quake.control.server_info.map",
574 FT_STRINGZ, BASE_NONE, NULL, 0x0,
575 "Map Name", HFILL }},
576 { &hf_quake_CCREP_SERVER_INFO_num_player,
577 { "Number of Players", "quake.control.server_info.num_player",
578 FT_UINT8, BASE_DEC, NULL, 0x0,
579 "Current Number of Players", HFILL }},
580 { &hf_quake_CCREP_SERVER_INFO_max_player,
581 { "Maximal Number of Players", "quake.control.server_info.max_player",
582 FT_UINT8, BASE_DEC, NULL, 0x0,
583 NULL, HFILL }},
584 { &hf_quake_CCREP_PLAYER_INFO_name,
585 { "Name", "quake.control.player_info.name",
586 FT_STRINGZ, BASE_NONE, NULL, 0x0,
587 "Player Name", HFILL }},
588 { &hf_quake_CCREP_PLAYER_INFO_colors,
589 { "Colors", "quake.control.player_info.colors",
590 FT_UINT32, BASE_HEX, NULL, 0x0,
591 "Player Colors", HFILL }},
592 { &hf_quake_CCREP_PLAYER_INFO_colors_shirt,
593 { "Shirt", "quake.control.player_info.colors.shirt",
594 FT_UINT8, BASE_DEC, VALS(names_colors), 0x0,
595 "Shirt Color", HFILL }},
596 { &hf_quake_CCREP_PLAYER_INFO_colors_pants,
597 { "Pants", "quake.control.player_info.colors.pants",
598 FT_UINT8, BASE_DEC, VALS(names_colors), 0x0,
599 "Pants Color", HFILL }},
600 { &hf_quake_CCREP_PLAYER_INFO_frags,
601 { "Frags", "quake.control.player_info.frags",
602 FT_UINT32, BASE_DEC, NULL, 0x0,
603 "Player Frags", HFILL }},
604 { &hf_quake_CCREP_PLAYER_INFO_connect_time,
605 { "Connect Time", "quake.control.player_info.connect_time",
606 FT_UINT32, BASE_DEC, NULL, 0x0,
607 "Player Connect Time", HFILL }},
608 { &hf_quake_CCREP_PLAYER_INFO_address,
609 { "Address", "quake.control.player_info.address",
610 FT_STRINGZ, BASE_NONE, NULL, 0x0,
611 "Player Address", HFILL }},
612 { &hf_quake_CCREP_RULE_INFO_rule,
613 { "Rule", "quake.control.rule_info.rule",
614 FT_STRINGZ, BASE_NONE, NULL, 0x0,
615 "Rule Name", HFILL }},
616 { &hf_quake_CCREP_RULE_INFO_value,
617 { "Value", "quake.control.rule_info.value",
618 FT_STRINGZ, BASE_NONE, NULL, 0x0,
619 "Rule Value", HFILL }},
621 static gint *ett[] = {
622 &ett_quake,
623 &ett_quake_control,
624 &ett_quake_control_colors,
625 &ett_quake_flags,
627 module_t *quake_module;
629 proto_quake = proto_register_protocol("Quake Network Protocol",
630 "QUAKE", "quake");
631 proto_register_field_array(proto_quake, hf, array_length(hf));
632 proto_register_subtree_array(ett, array_length(ett));
634 /* Register a configuration option for port */
635 quake_module = prefs_register_protocol(proto_quake,
636 proto_reg_handoff_quake);
637 prefs_register_uint_preference(quake_module, "udp.port",
638 "Quake Server UDP Port",
639 "Set the UDP port for the Quake Server",
640 10, &gbl_quakeServerPort);
644 void
645 proto_reg_handoff_quake(void)
647 static gboolean Initialized=FALSE;
648 static guint ServerPort;
650 if (!Initialized) {
651 quake_handle = create_dissector_handle(dissect_quake, proto_quake);
652 data_handle = find_dissector("data");
653 Initialized=TRUE;
654 } else {
655 dissector_delete_uint("udp.port", ServerPort, quake_handle);
658 /* set port for future deletes */
659 ServerPort=gbl_quakeServerPort;
661 dissector_add_uint("udp.port", gbl_quakeServerPort, quake_handle);