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