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