As with "file_write_error_message()", so with
[obnox/wireshark/wip.git] / packet-quake.c
1 /* packet-quake.c
2  * Routines for Quake packet dissection
3  *
4  * Uwe Girlich <uwe@planetquake.com>
5  *      http://www.idsoftware.com/q1source/q1source.zip
6  *
7  * $Id: packet-quake.c,v 1.30 2003/06/12 08:33:29 guy Exp $
8  *
9  * Ethereal - Network traffic analyzer
10  * By Gerald Combs <gerald@ethereal.com>
11  * Copyright 1998 Gerald Combs
12  *
13  * Copied from packet-tftp.c
14  *
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.
19  *
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.
24  *
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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
28  */
29
30 #ifdef HAVE_CONFIG_H
31 # include "config.h"
32 #endif
33
34 #include <glib.h>
35 #include <epan/packet.h>
36 #include <epan/conversation.h>
37 #include "prefs.h"
38
39 static int proto_quake = -1;
40 static int hf_quake_header_flags = -1;
41 static int hf_quake_header_length = -1;
42 static int hf_quake_header_sequence = -1;
43 static int hf_quake_control_command = -1;
44
45 static int hf_quake_CCREQ_CONNECT_game = -1;
46 static int hf_quake_CCREQ_CONNECT_version = -1;
47 static int hf_quake_CCREQ_SERVER_INFO_game = -1;
48 static int hf_quake_CCREQ_SERVER_INFO_version = -1;
49 static int hf_quake_CCREQ_PLAYER_INFO_player = -1;
50 static int hf_quake_CCREQ_RULE_INFO_lastrule = -1;
51
52 static int hf_quake_CCREP_ACCEPT_port = -1;
53 static int hf_quake_CCREP_REJECT_reason = -1;
54 static int hf_quake_CCREP_SERVER_INFO_address = -1;
55 static int hf_quake_CCREP_SERVER_INFO_server = -1;
56 static int hf_quake_CCREP_SERVER_INFO_map = -1;
57 static int hf_quake_CCREP_SERVER_INFO_num_player = -1;
58 static int hf_quake_CCREP_SERVER_INFO_max_player = -1;
59 static int hf_quake_CCREP_PLAYER_INFO_name = -1;
60 static int hf_quake_CCREP_PLAYER_INFO_colors = -1;
61 static int hf_quake_CCREP_PLAYER_INFO_colors_shirt = -1;
62 static int hf_quake_CCREP_PLAYER_INFO_colors_pants = -1;
63 static int hf_quake_CCREP_PLAYER_INFO_frags = -1;
64 static int hf_quake_CCREP_PLAYER_INFO_connect_time = -1;
65 static int hf_quake_CCREP_PLAYER_INFO_address = -1;
66 static int hf_quake_CCREP_RULE_INFO_rule = -1;
67 static int hf_quake_CCREP_RULE_INFO_value = -1;
68
69
70 static gint ett_quake = -1;
71 static gint ett_quake_control = -1;
72 static gint ett_quake_control_colors = -1;
73 static gint ett_quake_flags = -1;
74
75 static dissector_handle_t quake_handle;
76 static dissector_handle_t data_handle;
77
78 /* I took these names directly out of the Q1 source. */
79 #define NETFLAG_LENGTH_MASK 0x0000ffff
80 #define NET_HEADERSIZE 8
81 #define DEFAULTnet_hostport 26000
82 static unsigned int gbl_quakeServerPort=DEFAULTnet_hostport;
83
84 #define NETFLAG_LENGTH_MASK     0x0000ffff
85 #define NETFLAG_DATA            0x00010000
86 #define NETFLAG_ACK                     0x00020000
87 #define NETFLAG_NAK                     0x00040000
88 #define NETFLAG_EOM                     0x00080000
89 #define NETFLAG_UNRELIABLE      0x00100000
90 #define NETFLAG_CTL                     0x80000000
91
92
93 #define CCREQ_CONNECT           0x01
94 #define CCREQ_SERVER_INFO       0x02
95 #define CCREQ_PLAYER_INFO       0x03
96 #define CCREQ_RULE_INFO         0x04
97
98 #define CCREP_ACCEPT            0x81
99 #define CCREP_REJECT            0x82
100 #define CCREP_SERVER_INFO       0x83
101 #define CCREP_PLAYER_INFO       0x84
102 #define CCREP_RULE_INFO         0x85
103
104 static const value_string names_control_command[] = {
105         {       CCREQ_CONNECT, "connect" },
106         {       CCREQ_SERVER_INFO, "server_info" },
107         {       CCREQ_PLAYER_INFO, "player_info" },
108         {       CCREQ_RULE_INFO, "rule_info" },
109         {       CCREP_ACCEPT, "accept" },
110         {       CCREP_REJECT, "reject" },
111         {       CCREP_SERVER_INFO, "server_info" },
112         {       CCREP_PLAYER_INFO, "player_info" },
113         {       CCREP_RULE_INFO, "rule_info" },
114         { 0, NULL }
115 };
116
117 #define CCREQ 0x00
118 #define CCREP 0x80
119
120 #define QUAKE_MAXSTRING 0x800
121
122 static const value_string names_control_direction[] = {
123         { CCREQ, "Request" },
124         { CCREP, "Reply" },
125         { 0, NULL }
126 };
127
128
129 static const value_string names_colors[] = {
130         {  0, "White" },
131         {  1, "Brown" },
132         {  2, "Lavender" },
133         {  3, "Khaki" },
134         {  4, "Red" },
135         {  5, "Lt Brown" },
136         {  6, "Peach" },
137         {  7, "Lt Peach" },
138         {  8, "Purple" },
139         {  9, "Dk Purple" },
140         { 10, "Tan" },
141         { 11, "Green" },
142         { 12, "Yellow" },
143         { 13, "Blue" },
144         { 14, "Blue" },
145         { 15, "Blue" },
146         {  0, NULL }
147 };
148
149
150 static void dissect_quake(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
151
152
153
154 static void
155 dissect_quake_CCREQ_CONNECT
156 (tvbuff_t *tvb, proto_tree *tree)
157 {
158         gint offset;
159         proto_item *ti;
160
161         offset = 0;
162
163         if (tree) {
164                 ti = proto_tree_add_item(tree, hf_quake_CCREQ_CONNECT_game,
165                         tvb, offset, -1, TRUE);
166                 offset += proto_item_get_len(ti);
167
168                 proto_tree_add_item(tree, hf_quake_CCREQ_CONNECT_version,
169                         tvb, offset, 1, TRUE);
170         }
171 }
172
173
174 static void
175 dissect_quake_CCREQ_SERVER_INFO
176 (tvbuff_t *tvb, proto_tree *tree)
177 {
178         gint offset;
179         proto_item *ti;
180
181         offset = 0;
182
183         if (tree) {
184                 ti = proto_tree_add_item(tree, hf_quake_CCREQ_SERVER_INFO_game,
185                         tvb, offset, -1, TRUE);
186                 offset += proto_item_get_len(ti);
187                 proto_tree_add_item(tree, hf_quake_CCREQ_SERVER_INFO_version,
188                         tvb, offset, 1, TRUE);
189         }
190 }
191
192
193 static void
194 dissect_quake_CCREQ_PLAYER_INFO
195 (tvbuff_t *tvb, proto_tree *tree)
196 {
197         if (tree) {
198                  proto_tree_add_item(tree, hf_quake_CCREQ_PLAYER_INFO_player,
199                         tvb, 0, 1, TRUE);
200         }
201 }
202
203
204 static void
205 dissect_quake_CCREQ_RULE_INFO
206 (tvbuff_t *tvb, proto_tree *tree)
207 {
208         if (tree) {
209                 proto_tree_add_item(tree, hf_quake_CCREQ_RULE_INFO_lastrule,
210                         tvb, 0, -1, TRUE);
211         }
212 }
213
214
215 static void
216 dissect_quake_CCREP_ACCEPT
217 (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
218 {
219         guint32 port;
220         conversation_t *c;
221
222         port = tvb_get_letohl(tvb, 0);
223         c = conversation_new( &pinfo->src, &pinfo->dst, PT_UDP, port,
224             pinfo->destport, 0);
225         if (c) {
226                 conversation_set_dissector(c, quake_handle);
227         }
228         if (tree) {
229                 proto_tree_add_uint(tree, hf_quake_CCREP_ACCEPT_port,
230                         tvb, 0, 4, port);
231         }
232 }
233
234
235 static void
236 dissect_quake_CCREP_REJECT
237 (tvbuff_t *tvb, proto_tree *tree)
238 {
239         if (tree) {
240                 proto_tree_add_item(tree, hf_quake_CCREP_REJECT_reason,
241                         tvb, 0, -1, TRUE);
242         }
243 }
244
245
246 static void
247 dissect_quake_CCREP_SERVER_INFO
248 (tvbuff_t *tvb, proto_tree *tree)
249 {
250         gint offset;
251         proto_item *ti;
252
253         offset = 0;
254
255         if (tree) {
256                 ti = proto_tree_add_item(tree,
257                         hf_quake_CCREP_SERVER_INFO_address, tvb, offset, -1,
258                         TRUE);
259                 offset += proto_item_get_len(ti);
260
261                 ti = proto_tree_add_item(tree,
262                         hf_quake_CCREP_SERVER_INFO_server, tvb, offset, -1,
263                         TRUE);
264                 offset += proto_item_get_len(ti);
265
266                 ti = proto_tree_add_item(tree, hf_quake_CCREP_SERVER_INFO_map,
267                         tvb, offset, -1, TRUE);
268                 offset += proto_item_get_len(ti);
269
270                 proto_tree_add_item(tree, hf_quake_CCREP_SERVER_INFO_num_player,
271                         tvb, offset, 1, TRUE);
272                 offset += 1;
273                 proto_tree_add_item(tree, hf_quake_CCREP_SERVER_INFO_max_player,
274                         tvb, offset, 1, TRUE);
275                 offset += 1;
276                 proto_tree_add_item(tree, hf_quake_CCREQ_SERVER_INFO_version,
277                         tvb, offset, 1, TRUE);
278         }
279 }
280
281
282 static void
283 dissect_quake_CCREP_PLAYER_INFO
284 (tvbuff_t *tvb, proto_tree *tree)
285 {
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;
293
294         offset = 0;
295
296         if (tree) {
297                 proto_tree_add_item(tree, hf_quake_CCREQ_PLAYER_INFO_player,
298                         tvb, offset, 1, TRUE);
299                 offset += 1;
300
301                 ti = proto_tree_add_item(tree, hf_quake_CCREP_PLAYER_INFO_name,
302                         tvb, offset, -1, TRUE);
303                 offset += proto_item_get_len(ti);
304
305                 colors       = tvb_get_letohl(tvb, offset + 0);
306                 color_shirt = (colors >> 4) & 0x0f;
307                 color_pants = (colors     ) & 0x0f;
308
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, TRUE);
323                 offset += 4;
324                 proto_tree_add_item(tree, hf_quake_CCREP_PLAYER_INFO_connect_time,
325                         tvb, offset, 4, TRUE);
326                 offset += 4;
327
328                 proto_tree_add_item(tree, hf_quake_CCREP_PLAYER_INFO_address,
329                         tvb, offset, -1, TRUE);
330         }
331 }
332
333
334 static void
335 dissect_quake_CCREP_RULE_INFO
336 (tvbuff_t *tvb, proto_tree *tree)
337 {
338         gint offset;
339         proto_item *ti;
340
341         if (tvb_reported_length(tvb) == 0) return;
342
343         offset = 0;
344
345         if (tree) {
346                 ti = proto_tree_add_item(tree, hf_quake_CCREP_RULE_INFO_rule,
347                         tvb, offset, -1, TRUE);
348                 offset += proto_item_get_len(ti);
349
350                 proto_tree_add_item(tree, hf_quake_CCREP_RULE_INFO_value,
351                         tvb, offset, -1, TRUE);
352         }
353 }
354
355
356 static void
357 dissect_quake_control(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
358 {
359         guint8          command;
360         int             direction;
361         proto_item      *control_item = NULL;
362         proto_tree      *control_tree = NULL;
363         guint           rest_length;
364         tvbuff_t        *next_tvb;
365
366         command = tvb_get_guint8(tvb, 0);
367         direction = (command & 0x80) ? CCREP : CCREQ;
368
369         if (check_col(pinfo->cinfo, COL_INFO)) {
370                 col_add_fstr(pinfo->cinfo, COL_INFO, "%s %s",
371                         val_to_str(command,names_control_command, "%u"),
372                         val_to_str(direction,names_control_direction,"%u"));
373         }
374
375         if (tree) {
376                 control_item = proto_tree_add_text(tree, tvb,
377                                 0, -1, "Control %s: %s",
378                                 val_to_str(direction, names_control_direction, "%u"),
379                                 val_to_str(command, names_control_command, "%u"));
380                 if (control_item)
381                         control_tree = proto_item_add_subtree(control_item,
382                                                 ett_quake_control);
383                 proto_tree_add_uint(control_tree, hf_quake_control_command,
384                                         tvb, 0, 1, command);
385         }
386
387         rest_length = tvb_reported_length(tvb) - 1;
388         next_tvb = tvb_new_subset(tvb, 1, rest_length , rest_length);
389         switch (command) {
390                 case CCREQ_CONNECT:
391                         dissect_quake_CCREQ_CONNECT
392                         (next_tvb, control_tree);
393                 break;
394                 case CCREQ_SERVER_INFO:
395                         dissect_quake_CCREQ_SERVER_INFO
396                         (next_tvb, control_tree);
397                 break;
398                 case CCREQ_PLAYER_INFO:
399                         dissect_quake_CCREQ_PLAYER_INFO
400                         (next_tvb, control_tree);
401                 break;
402                 case CCREQ_RULE_INFO:
403                         dissect_quake_CCREQ_RULE_INFO
404                         (next_tvb, control_tree);
405                 break;
406                 case CCREP_ACCEPT:
407                         dissect_quake_CCREP_ACCEPT
408                         (next_tvb, pinfo, control_tree);
409                 break;
410                 case CCREP_REJECT:
411                         dissect_quake_CCREP_REJECT
412                         (next_tvb, control_tree);
413                 break;
414                 case CCREP_SERVER_INFO:
415                         dissect_quake_CCREP_SERVER_INFO
416                         (next_tvb, control_tree);
417                 break;
418                 case CCREP_PLAYER_INFO:
419                         dissect_quake_CCREP_PLAYER_INFO
420                         (next_tvb, control_tree);
421                 break;
422                 case CCREP_RULE_INFO:
423                         dissect_quake_CCREP_RULE_INFO
424                         (next_tvb, control_tree);
425                 break;
426                 default:
427                         call_dissector(data_handle,next_tvb, pinfo, control_tree);
428                 break;
429         }
430 }
431
432
433 static void
434 dissect_quake(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
435 {
436         proto_tree      *quake_tree = NULL;
437         proto_item      *quake_item = NULL;
438         guint32         length;
439         guint32         flags;
440         guint32         sequence = 0;
441         guint           rest_length;
442         tvbuff_t        *next_tvb;
443
444         if (check_col(pinfo->cinfo, COL_PROTOCOL))
445                 col_set_str(pinfo->cinfo, COL_PROTOCOL, "QUAKE");
446         if (check_col(pinfo->cinfo, COL_INFO))
447                 col_clear(pinfo->cinfo, COL_INFO);
448
449         length = tvb_get_ntohl(tvb, 0);
450         flags = length & (~NETFLAG_LENGTH_MASK);
451         length &= NETFLAG_LENGTH_MASK;
452
453         if (tree) {
454                 quake_item = proto_tree_add_item(tree, proto_quake,
455                                 tvb, 0, -1, FALSE);
456                 if (quake_item)
457                         quake_tree = proto_item_add_subtree(quake_item, ett_quake);
458         }
459
460         if (quake_tree) {
461                 proto_item* flags_item = NULL;
462                 proto_tree* flags_tree = NULL;
463
464                 flags_item = proto_tree_add_uint(quake_tree, hf_quake_header_flags,
465                         tvb, 0, 2, flags);
466                 if (flags_item) {
467                         flags_tree = proto_item_add_subtree(flags_item, ett_quake_flags);
468                 }
469
470                 if (flags_tree) {
471                         proto_tree_add_text(flags_tree, tvb, 0, 2,
472                                 decode_boolean_bitfield(flags, NETFLAG_DATA, 32,
473                                 "Data","-"));
474                         proto_tree_add_text(flags_tree, tvb, 0, 2,
475                                 decode_boolean_bitfield(flags, NETFLAG_ACK, 32,
476                                 "Acknowledgment","-"));
477                         proto_tree_add_text(flags_tree, tvb, 0, 2,
478                                 decode_boolean_bitfield(flags, NETFLAG_NAK, 32,
479                                 "No Acknowledgment","-"));
480                         proto_tree_add_text(flags_tree, tvb, 0, 2,
481                                 decode_boolean_bitfield(flags, NETFLAG_EOM, 32,
482                                 "End Of Message","-"));
483                         proto_tree_add_text(flags_tree, tvb, 0, 2,
484                                 decode_boolean_bitfield(flags, NETFLAG_UNRELIABLE, 32,
485                                 "Unreliable","-"));
486                         proto_tree_add_text(flags_tree, tvb, 0, 2,
487                                 decode_boolean_bitfield(flags, NETFLAG_CTL, 32,
488                                 "Control","-"));
489                 }
490                 proto_tree_add_uint(quake_tree, hf_quake_header_length,
491                         tvb, 2, 2, length);
492         }
493
494         if (flags == NETFLAG_CTL) {
495                 rest_length = tvb_reported_length(tvb) - 4;
496                 next_tvb = tvb_new_subset(tvb, 4, rest_length , rest_length);
497                 dissect_quake_control(next_tvb, pinfo, quake_tree);
498                 return;
499         }
500
501         sequence = tvb_get_ntohl(tvb, 4);
502         if (check_col(pinfo->cinfo, COL_INFO)) {
503                 col_add_fstr(pinfo->cinfo, COL_INFO, "seq 0x%x", sequence);
504         }
505         if (quake_tree) {
506                 proto_tree_add_uint(quake_tree, hf_quake_header_sequence,
507                         tvb, 4, 4, sequence);
508         }
509
510         rest_length = tvb_reported_length(tvb) - 8;
511         next_tvb = tvb_new_subset(tvb, 8, rest_length , rest_length);
512         call_dissector(data_handle,next_tvb, pinfo, quake_tree);
513 }
514
515
516 void
517 proto_reg_handoff_quake(void)
518 {
519         static int Initialized=FALSE;
520         static int ServerPort=0;
521
522         if (Initialized) {
523                 dissector_delete("udp.port", ServerPort, quake_handle);
524         } else {
525                 Initialized=TRUE;
526         }
527
528         /* set port for future deletes */
529         ServerPort=gbl_quakeServerPort;
530
531         dissector_add("udp.port", gbl_quakeServerPort, quake_handle);
532         data_handle = find_dissector("data");
533 }
534
535
536 void
537 proto_register_quake(void)
538 {
539   static hf_register_info hf[] = {
540     { &hf_quake_header_flags,
541       { "Flags", "quake.header.flags",
542         FT_UINT16, BASE_HEX, NULL, 0x0,
543         "Flags", HFILL }},
544     { &hf_quake_header_length,
545       { "Length", "quake.header.length",
546         FT_UINT16, BASE_DEC, NULL, 0x0,
547         "full data length", HFILL }},
548     { &hf_quake_header_sequence,
549       { "Sequence", "quake.header.sequence",
550         FT_UINT32, BASE_HEX, NULL, 0x0,
551         "Sequence Number", HFILL }},
552     { &hf_quake_control_command,
553       { "Command", "quake.control.command",
554         FT_UINT8, BASE_HEX, VALS(names_control_command), 0x0,
555         "Control Command", HFILL }},
556     { &hf_quake_CCREQ_CONNECT_game,
557       { "Game", "quake.control.connect.game",
558         FT_STRINGZ, BASE_NONE, NULL, 0x0,
559         "Game Name", HFILL }},
560     { &hf_quake_CCREQ_CONNECT_version,
561       { "Version", "quake.control.connect.version",
562         FT_UINT8, BASE_DEC, NULL, 0x0,
563         "Game Protocol Version Number", HFILL }},
564     { &hf_quake_CCREQ_SERVER_INFO_game,
565       { "Game", "quake.control.server_info.game",
566         FT_STRINGZ, BASE_NONE, NULL, 0x0,
567         "Game Name", HFILL }},
568     { &hf_quake_CCREQ_SERVER_INFO_version,
569       { "Version", "quake.control.server_info.version",
570         FT_UINT8, BASE_DEC, NULL, 0x0,
571         "Game Protocol Version Number", HFILL }},
572     { &hf_quake_CCREQ_PLAYER_INFO_player,
573       { "Player", "quake.control.player_info.player",
574         FT_UINT8, BASE_DEC, NULL, 0x0,
575         "Player", HFILL }},
576     { &hf_quake_CCREQ_RULE_INFO_lastrule,
577       { "Last Rule", "quake.control.rule_info.lastrule",
578         FT_STRINGZ, BASE_NONE, NULL, 0x0,
579         "Last Rule Name", HFILL }},
580     { &hf_quake_CCREP_ACCEPT_port,
581       { "Port", "quake.control.accept.port",
582         FT_UINT32, BASE_DEC, NULL, 0x0,
583         "Game Data Port", HFILL }},
584     { &hf_quake_CCREP_REJECT_reason,
585       { "Reason", "quake.control.reject.reason",
586         FT_STRINGZ, BASE_NONE, NULL, 0x0,
587         "Reject Reason", HFILL }},
588     { &hf_quake_CCREP_SERVER_INFO_address,
589       { "Address", "quake.control.server_info.address",
590         FT_STRINGZ, BASE_NONE, NULL, 0x0,
591         "Server Address", HFILL }},
592     { &hf_quake_CCREP_SERVER_INFO_server,
593       { "Server", "quake.control.server_info.server",
594         FT_STRINGZ, BASE_NONE, NULL, 0x0,
595         "Server Name", HFILL }},
596     { &hf_quake_CCREP_SERVER_INFO_map,
597       { "Map", "quake.control.server_info.map",
598         FT_STRINGZ, BASE_NONE, NULL, 0x0,
599         "Map Name", HFILL }},
600     { &hf_quake_CCREP_SERVER_INFO_num_player,
601       { "Number of Players", "quake.control.server_info.num_player",
602         FT_UINT8, BASE_DEC, NULL, 0x0,
603         "Current Number of Players", HFILL }},
604     { &hf_quake_CCREP_SERVER_INFO_max_player,
605       { "Maximal Number of Players", "quake.control.server_info.max_player",
606         FT_UINT8, BASE_DEC, NULL, 0x0,
607         "Maximal Number of Players", HFILL }},
608     { &hf_quake_CCREP_PLAYER_INFO_name,
609       { "Name", "quake.control.player_info.name",
610         FT_STRINGZ, BASE_NONE, NULL, 0x0,
611         "Player Name", HFILL }},
612     { &hf_quake_CCREP_PLAYER_INFO_colors,
613       { "Colors", "quake.control.player_info.colors",
614         FT_UINT32, BASE_HEX, NULL, 0x0,
615         "Player Colors", HFILL }},
616     { &hf_quake_CCREP_PLAYER_INFO_colors_shirt,
617       { "Shirt", "quake.control.player_info.colors.shirt",
618         FT_UINT8, BASE_DEC, VALS(names_colors), 0x0,
619         "Shirt Color", HFILL }},
620     { &hf_quake_CCREP_PLAYER_INFO_colors_pants,
621       { "Pants", "quake.control.player_info.colors.pants",
622         FT_UINT8, BASE_DEC, VALS(names_colors), 0x0,
623         "Pants Color", HFILL }},
624     { &hf_quake_CCREP_PLAYER_INFO_frags,
625       { "Frags", "quake.control.player_info.frags",
626         FT_UINT32, BASE_DEC, NULL, 0x0,
627         "Player Frags", HFILL }},
628     { &hf_quake_CCREP_PLAYER_INFO_connect_time,
629       { "Connect Time", "quake.control.player_info.connect_time",
630         FT_UINT32, BASE_DEC, NULL, 0x0,
631         "Player Connect Time", HFILL }},
632     { &hf_quake_CCREP_PLAYER_INFO_address,
633       { "Address", "quake.control.player_info.address",
634         FT_STRINGZ, BASE_NONE, NULL, 0x0,
635         "Player Address", HFILL }},
636     { &hf_quake_CCREP_RULE_INFO_rule,
637       { "Rule", "quake.control.rule_info.rule",
638         FT_STRINGZ, BASE_NONE, NULL, 0x0,
639         "Rule Name", HFILL }},
640     { &hf_quake_CCREP_RULE_INFO_value,
641       { "Value", "quake.control.rule_info.value",
642         FT_STRINGZ, BASE_NONE, NULL, 0x0,
643         "Rule Value", HFILL }},
644   };
645         static gint *ett[] = {
646                 &ett_quake,
647                 &ett_quake_control,
648                 &ett_quake_control_colors,
649                 &ett_quake_flags,
650         };
651         module_t *quake_module;
652
653         proto_quake = proto_register_protocol("Quake Network Protocol",
654                                         "QUAKE", "quake");
655         proto_register_field_array(proto_quake, hf, array_length(hf));
656         proto_register_subtree_array(ett, array_length(ett));
657
658         quake_handle = create_dissector_handle(dissect_quake, proto_quake);
659
660         /* Register a configuration option for port */
661         quake_module = prefs_register_protocol(proto_quake,
662                 proto_reg_handoff_quake);
663         prefs_register_uint_preference(quake_module, "udp.port",
664                                         "Quake Server UDP Port",
665                                         "Set the UDP port for the Quake Server",
666                                         10, &gbl_quakeServerPort);
667 }