Document the new Copy Profile button.
[obnox/wireshark/wip.git] / epan / dissectors / 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$
8  *
9  * Wireshark - Network traffic analyzer
10  * By Gerald Combs <gerald@wireshark.org>
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 <epan/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 guint 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->fd->num, &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         col_set_str(pinfo->cinfo, COL_PROTOCOL, "QUAKE");
445         col_clear(pinfo->cinfo, COL_INFO);
446
447         length = tvb_get_ntohl(tvb, 0);
448         flags = length & (~NETFLAG_LENGTH_MASK);
449         length &= NETFLAG_LENGTH_MASK;
450
451         if (tree) {
452                 quake_item = proto_tree_add_item(tree, proto_quake,
453                                 tvb, 0, -1, FALSE);
454                 if (quake_item)
455                         quake_tree = proto_item_add_subtree(quake_item, ett_quake);
456         }
457
458         if (quake_tree) {
459                 proto_item* flags_item = NULL;
460                 proto_tree* flags_tree = NULL;
461
462                 flags_item = proto_tree_add_uint(quake_tree, hf_quake_header_flags,
463                         tvb, 0, 2, flags);
464                 if (flags_item) {
465                         flags_tree = proto_item_add_subtree(flags_item, ett_quake_flags);
466                 }
467
468                 if (flags_tree) {
469                         proto_tree_add_text(flags_tree, tvb, 0, 2, "%s",
470                                 decode_boolean_bitfield(flags, NETFLAG_DATA, 32,
471                                 "Data","-"));
472                         proto_tree_add_text(flags_tree, tvb, 0, 2, "%s",
473                                 decode_boolean_bitfield(flags, NETFLAG_ACK, 32,
474                                 "Acknowledgment","-"));
475                         proto_tree_add_text(flags_tree, tvb, 0, 2, "%s",
476                                 decode_boolean_bitfield(flags, NETFLAG_NAK, 32,
477                                 "No Acknowledgment","-"));
478                         proto_tree_add_text(flags_tree, tvb, 0, 2, "%s",
479                                 decode_boolean_bitfield(flags, NETFLAG_EOM, 32,
480                                 "End Of Message","-"));
481                         proto_tree_add_text(flags_tree, tvb, 0, 2, "%s",
482                                 decode_boolean_bitfield(flags, NETFLAG_UNRELIABLE, 32,
483                                 "Unreliable","-"));
484                         proto_tree_add_text(flags_tree, tvb, 0, 2, "%s",
485                                 decode_boolean_bitfield(flags, NETFLAG_CTL, 32,
486                                 "Control","-"));
487                 }
488                 proto_tree_add_uint(quake_tree, hf_quake_header_length,
489                         tvb, 2, 2, length);
490         }
491
492         if (flags == NETFLAG_CTL) {
493                 rest_length = tvb_reported_length(tvb) - 4;
494                 next_tvb = tvb_new_subset(tvb, 4, rest_length , rest_length);
495                 dissect_quake_control(next_tvb, pinfo, quake_tree);
496                 return;
497         }
498
499         sequence = tvb_get_ntohl(tvb, 4);
500         if (check_col(pinfo->cinfo, COL_INFO)) {
501                 col_add_fstr(pinfo->cinfo, COL_INFO, "seq 0x%x", sequence);
502         }
503         if (quake_tree) {
504                 proto_tree_add_uint(quake_tree, hf_quake_header_sequence,
505                         tvb, 4, 4, sequence);
506         }
507
508         rest_length = tvb_reported_length(tvb) - 8;
509         next_tvb = tvb_new_subset(tvb, 8, rest_length , rest_length);
510         call_dissector(data_handle,next_tvb, pinfo, quake_tree);
511 }
512
513
514 void
515 proto_reg_handoff_quake(void)
516 {
517         static gboolean Initialized=FALSE;
518         static guint ServerPort;
519
520         if (!Initialized) {
521                 quake_handle = create_dissector_handle(dissect_quake, proto_quake);
522                 data_handle = find_dissector("data");
523                 Initialized=TRUE;
524         } else {
525                 dissector_delete("udp.port", ServerPort, quake_handle);
526         }
527
528         /* set port for future deletes */
529         ServerPort=gbl_quakeServerPort;
530
531         dissector_add("udp.port", gbl_quakeServerPort, quake_handle);
532 }
533
534
535 void
536 proto_register_quake(void)
537 {
538   static hf_register_info hf[] = {
539     { &hf_quake_header_flags,
540       { "Flags", "quake.header.flags",
541         FT_UINT16, BASE_HEX, NULL, 0x0,
542         NULL, HFILL }},
543     { &hf_quake_header_length,
544       { "Length", "quake.header.length",
545         FT_UINT16, BASE_DEC, NULL, 0x0,
546         "full data length", HFILL }},
547     { &hf_quake_header_sequence,
548       { "Sequence", "quake.header.sequence",
549         FT_UINT32, BASE_HEX, NULL, 0x0,
550         "Sequence Number", HFILL }},
551     { &hf_quake_control_command,
552       { "Command", "quake.control.command",
553         FT_UINT8, BASE_HEX, VALS(names_control_command), 0x0,
554         "Control Command", HFILL }},
555     { &hf_quake_CCREQ_CONNECT_game,
556       { "Game", "quake.control.connect.game",
557         FT_STRINGZ, BASE_NONE, NULL, 0x0,
558         "Game Name", HFILL }},
559     { &hf_quake_CCREQ_CONNECT_version,
560       { "Version", "quake.control.connect.version",
561         FT_UINT8, BASE_DEC, NULL, 0x0,
562         "Game Protocol Version Number", HFILL }},
563     { &hf_quake_CCREQ_SERVER_INFO_game,
564       { "Game", "quake.control.server_info.game",
565         FT_STRINGZ, BASE_NONE, NULL, 0x0,
566         "Game Name", HFILL }},
567     { &hf_quake_CCREQ_SERVER_INFO_version,
568       { "Version", "quake.control.server_info.version",
569         FT_UINT8, BASE_DEC, NULL, 0x0,
570         "Game Protocol Version Number", HFILL }},
571     { &hf_quake_CCREQ_PLAYER_INFO_player,
572       { "Player", "quake.control.player_info.player",
573         FT_UINT8, BASE_DEC, NULL, 0x0,
574         NULL, HFILL }},
575     { &hf_quake_CCREQ_RULE_INFO_lastrule,
576       { "Last Rule", "quake.control.rule_info.lastrule",
577         FT_STRINGZ, BASE_NONE, NULL, 0x0,
578         "Last Rule Name", HFILL }},
579     { &hf_quake_CCREP_ACCEPT_port,
580       { "Port", "quake.control.accept.port",
581         FT_UINT32, BASE_DEC, NULL, 0x0,
582         "Game Data Port", HFILL }},
583     { &hf_quake_CCREP_REJECT_reason,
584       { "Reason", "quake.control.reject.reason",
585         FT_STRINGZ, BASE_NONE, NULL, 0x0,
586         "Reject Reason", HFILL }},
587     { &hf_quake_CCREP_SERVER_INFO_address,
588       { "Address", "quake.control.server_info.address",
589         FT_STRINGZ, BASE_NONE, NULL, 0x0,
590         "Server Address", HFILL }},
591     { &hf_quake_CCREP_SERVER_INFO_server,
592       { "Server", "quake.control.server_info.server",
593         FT_STRINGZ, BASE_NONE, NULL, 0x0,
594         "Server Name", HFILL }},
595     { &hf_quake_CCREP_SERVER_INFO_map,
596       { "Map", "quake.control.server_info.map",
597         FT_STRINGZ, BASE_NONE, NULL, 0x0,
598         "Map Name", HFILL }},
599     { &hf_quake_CCREP_SERVER_INFO_num_player,
600       { "Number of Players", "quake.control.server_info.num_player",
601         FT_UINT8, BASE_DEC, NULL, 0x0,
602         "Current Number of Players", HFILL }},
603     { &hf_quake_CCREP_SERVER_INFO_max_player,
604       { "Maximal Number of Players", "quake.control.server_info.max_player",
605         FT_UINT8, BASE_DEC, NULL, 0x0,
606         NULL, HFILL }},
607     { &hf_quake_CCREP_PLAYER_INFO_name,
608       { "Name", "quake.control.player_info.name",
609         FT_STRINGZ, BASE_NONE, NULL, 0x0,
610         "Player Name", HFILL }},
611     { &hf_quake_CCREP_PLAYER_INFO_colors,
612       { "Colors", "quake.control.player_info.colors",
613         FT_UINT32, BASE_HEX, NULL, 0x0,
614         "Player Colors", HFILL }},
615     { &hf_quake_CCREP_PLAYER_INFO_colors_shirt,
616       { "Shirt", "quake.control.player_info.colors.shirt",
617         FT_UINT8, BASE_DEC, VALS(names_colors), 0x0,
618         "Shirt Color", HFILL }},
619     { &hf_quake_CCREP_PLAYER_INFO_colors_pants,
620       { "Pants", "quake.control.player_info.colors.pants",
621         FT_UINT8, BASE_DEC, VALS(names_colors), 0x0,
622         "Pants Color", HFILL }},
623     { &hf_quake_CCREP_PLAYER_INFO_frags,
624       { "Frags", "quake.control.player_info.frags",
625         FT_UINT32, BASE_DEC, NULL, 0x0,
626         "Player Frags", HFILL }},
627     { &hf_quake_CCREP_PLAYER_INFO_connect_time,
628       { "Connect Time", "quake.control.player_info.connect_time",
629         FT_UINT32, BASE_DEC, NULL, 0x0,
630         "Player Connect Time", HFILL }},
631     { &hf_quake_CCREP_PLAYER_INFO_address,
632       { "Address", "quake.control.player_info.address",
633         FT_STRINGZ, BASE_NONE, NULL, 0x0,
634         "Player Address", HFILL }},
635     { &hf_quake_CCREP_RULE_INFO_rule,
636       { "Rule", "quake.control.rule_info.rule",
637         FT_STRINGZ, BASE_NONE, NULL, 0x0,
638         "Rule Name", HFILL }},
639     { &hf_quake_CCREP_RULE_INFO_value,
640       { "Value", "quake.control.rule_info.value",
641         FT_STRINGZ, BASE_NONE, NULL, 0x0,
642         "Rule Value", HFILL }},
643   };
644         static gint *ett[] = {
645                 &ett_quake,
646                 &ett_quake_control,
647                 &ett_quake_control_colors,
648                 &ett_quake_flags,
649         };
650         module_t *quake_module;
651
652         proto_quake = proto_register_protocol("Quake Network Protocol",
653                                         "QUAKE", "quake");
654         proto_register_field_array(proto_quake, hf, array_length(hf));
655         proto_register_subtree_array(ett, array_length(ett));
656
657         /* Register a configuration option for port */
658         quake_module = prefs_register_protocol(proto_quake,
659                 proto_reg_handoff_quake);
660         prefs_register_uint_preference(quake_module, "udp.port",
661                                         "Quake Server UDP Port",
662                                         "Set the UDP port for the Quake Server",
663                                         10, &gbl_quakeServerPort);
664 }