Change from Andreas Sikkema to change the "old" and "new" members of the
[metze/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.5 2000/08/21 18:36:34 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 static gint
158 tvb_get_stringz(tvbuff_t *tvb, gint offset, gint maxlength, guint8* buffer)
159 {
160         int i;
161         char* zeropos = NULL;
162         gint stringlen = 0;
163
164         if (maxlength == 0) {
165                 buffer[0] = 0;
166                 return 0;
167         }
168
169         tvb_memcpy(tvb, buffer, offset, maxlength);
170         for (i=0 ; i<maxlength ; i++) {
171                 if (buffer[i] == 0) {
172                         stringlen = i;
173                         zeropos = buffer+i;
174                         break;
175                 }
176         }
177         if (zeropos == NULL) {
178                 buffer[maxlength-1] = 0;
179                 return maxlength-1;
180         }
181         return stringlen;
182 }
183
184
185 static void
186 dissect_quake_CCREQ_CONNECT
187 (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
188 {
189         gint maxbufsize;
190         char game[QUAKE_MAXSTRING];
191         guint8 version;
192         gint len;
193
194         maxbufsize = MIN(sizeof(game), tvb_length(tvb));
195         len = tvb_get_stringz(tvb, 0, maxbufsize, game);
196         version = tvb_get_guint8(tvb, len + 1);
197
198         if (tree) {
199                 proto_tree_add_string(tree, hf_quake_CCREQ_CONNECT_game,
200                         tvb, 0, len + 1, game);
201                 proto_tree_add_uint(tree, hf_quake_CCREQ_CONNECT_version,
202                         tvb, len + 1, 1, version);
203         }
204 }
205
206
207 static void
208 dissect_quake_CCREQ_SERVER_INFO
209 (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
210 {
211         gint maxbufsize;
212         char game[QUAKE_MAXSTRING];
213         guint8 version;
214         gint len;
215
216         maxbufsize = MIN(sizeof(game), tvb_length(tvb));
217         len = tvb_get_stringz(tvb, 0, maxbufsize, game);
218         version = tvb_get_guint8(tvb, len + 1);
219
220         if (tree) {
221                 proto_tree_add_string(tree, hf_quake_CCREQ_SERVER_INFO_game,
222                         tvb, 0, len + 1, game);
223                 proto_tree_add_uint(tree, hf_quake_CCREQ_SERVER_INFO_version,
224                         tvb, len + 1, 1, version);
225         }
226 }
227
228
229 static void
230 dissect_quake_CCREQ_PLAYER_INFO
231 (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
232 {
233         guint8 player;
234
235         player = tvb_get_guint8(tvb, 0);
236         if (tree) {
237                  proto_tree_add_uint(tree, hf_quake_CCREQ_PLAYER_INFO_player,
238                         tvb, 0, 1, player);
239         }
240 }
241
242
243 static void
244 dissect_quake_CCREQ_RULE_INFO
245 (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
246 {
247         char rule[QUAKE_MAXSTRING];
248         gint maxbufsize;
249         gint len;
250
251         maxbufsize = MIN(sizeof(rule), tvb_length(tvb));
252         len = tvb_get_stringz(tvb, 0, maxbufsize, rule);
253         if (tree) {
254                 proto_tree_add_string(tree, hf_quake_CCREQ_RULE_INFO_lastrule,
255                         tvb, 0, len + 1, rule);
256         }
257 }
258
259
260 static void
261 dissect_quake_CCREP_ACCEPT
262 (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
263 {
264         guint32 port;
265         conversation_t *c;
266
267         port = tvb_get_letohl(tvb, 0);
268         c = conversation_new( &pi.src, &pi.dst, PT_UDP, port, pi.destport, NULL);
269         if (c) {
270                 conversation_set_dissector(c, dissect_quake);
271         }
272         if (tree) {
273                 proto_tree_add_uint(tree, hf_quake_CCREP_ACCEPT_port,
274                         tvb, 0, 4, port);
275         }
276 }
277
278
279 static void
280 dissect_quake_CCREP_REJECT
281 (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
282 {
283         gint maxbufsize;
284         char reason[QUAKE_MAXSTRING];
285         gint len;
286
287         maxbufsize = MIN(sizeof(reason), tvb_length(tvb));
288         len = tvb_get_stringz(tvb, 0, maxbufsize, reason);
289
290         if (tree) {
291                 proto_tree_add_string(tree, hf_quake_CCREP_REJECT_reason,
292                         tvb, 0, len + 1, reason);
293         }
294 }
295
296
297 static void
298 dissect_quake_CCREP_SERVER_INFO
299 (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
300 {
301         gint offset;
302         gint len;
303         gint maxbufsize;
304         char address[QUAKE_MAXSTRING];
305         char server[QUAKE_MAXSTRING];
306         char map[QUAKE_MAXSTRING];
307
308         guint8 num_player;
309         guint8 max_player;
310         guint8 version;
311
312         offset = 0;
313
314         maxbufsize = MIN(sizeof(address), tvb_length_remaining(tvb, offset));
315         len = tvb_get_stringz(tvb, offset, maxbufsize, address);
316         if (tree) {
317                 proto_tree_add_string(tree, hf_quake_CCREP_SERVER_INFO_address,
318                         tvb, offset, len + 1, address);
319         }
320         offset += len + 1;
321
322         maxbufsize = MIN(sizeof(server), tvb_length_remaining(tvb, offset));
323         len = tvb_get_stringz(tvb, offset, maxbufsize, server);
324         if (tree) {
325                 proto_tree_add_string(tree, hf_quake_CCREP_SERVER_INFO_server,
326                         tvb, offset, len + 1, server);
327         }
328         offset += len + 1;
329         
330         maxbufsize = MIN(sizeof(map), tvb_length_remaining(tvb, offset));
331         len = tvb_get_stringz(tvb, offset, maxbufsize, map);
332         if (tree) {
333                 proto_tree_add_string(tree, hf_quake_CCREP_SERVER_INFO_map,
334                         tvb, offset, len + 1, map);
335         }
336         offset += len + 1;
337
338         num_player = tvb_get_guint8(tvb, offset + 0);
339         max_player = tvb_get_guint8(tvb, offset + 1);
340         version    = tvb_get_guint8(tvb, offset + 2);
341
342         if (tree) {
343                 proto_tree_add_uint(tree, hf_quake_CCREP_SERVER_INFO_num_player,
344                         tvb, offset + 0, 1, num_player);
345                 proto_tree_add_uint(tree, hf_quake_CCREP_SERVER_INFO_max_player,
346                         tvb, offset + 1, 1, max_player);
347                 proto_tree_add_uint(tree, hf_quake_CCREQ_SERVER_INFO_version,
348                         tvb, offset + 2, 1, version);
349         }
350 }
351
352
353 static void
354 dissect_quake_CCREP_PLAYER_INFO
355 (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
356 {
357         gint offset;
358         guint8 player;
359         gint len;
360         gint maxbufsize;
361         char name[QUAKE_MAXSTRING];
362         guint32 colors;
363         guint32 color_shirt;
364         guint32 color_pants;
365         guint32 frags;
366         guint32 connect_time;
367         char address[QUAKE_MAXSTRING];
368
369         offset = 0;
370
371         player = tvb_get_guint8(tvb, offset);
372         if (tree) {
373                 proto_tree_add_uint(tree, hf_quake_CCREQ_PLAYER_INFO_player,
374                         tvb, offset, 1, player);
375         }
376         offset += 1;
377         
378         maxbufsize = MIN(sizeof(name), tvb_length_remaining(tvb, offset));
379         len = tvb_get_stringz(tvb, offset, maxbufsize, name);
380         if (tree) {
381                 proto_tree_add_string(tree, hf_quake_CCREP_PLAYER_INFO_name,
382                         tvb, offset, len + 1, name);
383         }
384         offset += len + 1;
385
386         colors       = tvb_get_letohl(tvb, offset + 0);
387         color_shirt = (colors >> 4) & 0x0f;
388         color_pants = (colors     ) & 0x0f;
389         frags        = tvb_get_letohl(tvb, offset + 4);
390         connect_time = tvb_get_letohl(tvb, offset + 8);
391         if (tree) {
392                 proto_item *colors_item;
393                 proto_tree *colors_tree;
394
395                 colors_item = proto_tree_add_uint(tree,
396                         hf_quake_CCREP_PLAYER_INFO_colors,
397                         tvb, offset + 0, 4, colors);
398                 if (colors_item) {
399                         colors_tree = proto_item_add_subtree(colors_item,
400                                         ett_quake_control_colors);
401                         proto_tree_add_uint(colors_tree,
402                                 hf_quake_CCREP_PLAYER_INFO_colors_shirt,
403                                 tvb, offset + 0, 1, color_shirt);
404                         proto_tree_add_uint(colors_tree,
405                                 hf_quake_CCREP_PLAYER_INFO_colors_pants,
406                                 tvb, offset + 0, 1, color_pants);
407                 }
408                 proto_tree_add_uint(tree, hf_quake_CCREP_PLAYER_INFO_frags,
409                         tvb, offset + 4, 4, frags);
410                 proto_tree_add_uint(tree, hf_quake_CCREP_PLAYER_INFO_connect_time,
411                         tvb, offset + 8, 4, connect_time);
412         }
413         offset += 3*4;
414
415         maxbufsize = MIN(sizeof(address), tvb_length_remaining(tvb, offset));
416         len = tvb_get_stringz(tvb, offset, maxbufsize, address);
417         if (tree) {
418                 proto_tree_add_string(tree, hf_quake_CCREP_PLAYER_INFO_address,
419                         tvb, offset, len + 1, address);
420         }
421         offset += len + 1;
422 }
423
424
425 static void
426 dissect_quake_CCREP_RULE_INFO
427 (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
428 {
429         char rule[QUAKE_MAXSTRING];
430         char value[QUAKE_MAXSTRING];
431         gint maxbufsize;
432         gint len;
433         gint offset;
434
435         if (tvb_length(tvb) == 0) return;
436
437         offset = 0;
438
439         maxbufsize = MIN(sizeof(rule), tvb_length_remaining(tvb, offset));
440         len = tvb_get_stringz(tvb, offset, maxbufsize, rule);
441         if (tree) {
442                 proto_tree_add_string(tree, hf_quake_CCREP_RULE_INFO_rule,
443                         tvb, offset, len + 1, rule);
444         }
445         offset += len + 1;
446
447         maxbufsize = MIN(sizeof(value), tvb_length_remaining(tvb, offset));
448         len = tvb_get_stringz(tvb, offset, maxbufsize, value);
449         if (tree) {
450                 proto_tree_add_string(tree, hf_quake_CCREP_RULE_INFO_value,
451                         tvb, offset, len + 1, value);
452         }
453         offset += len + 1;
454 }
455
456
457 static void
458 dissect_quake_control(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
459 {
460         guint8          command;
461         int             direction;
462         proto_item      *control_item = NULL;
463         proto_tree      *control_tree = NULL;
464         guint           rest_length;
465         tvbuff_t        *next_tvb;
466         
467         command = tvb_get_guint8(tvb, 0);
468         direction = (command & 0x80) ? CCREP : CCREQ;
469
470         if (check_col(pinfo->fd, COL_INFO)) {
471                 col_add_fstr(pinfo->fd, COL_INFO, "%s %s",
472                         val_to_str(command,names_control_command, "%u"),
473                         val_to_str(direction,names_control_direction,"%u"));
474         }
475
476         if (tree) {
477                 control_item = proto_tree_add_text(tree, tvb,
478                                 0, tvb_length(tvb), "Control %s: %s",
479                                 val_to_str(direction, names_control_direction, "%u"),
480                                 val_to_str(command, names_control_command, "%u"));
481                 if (control_item)
482                         control_tree = proto_item_add_subtree(control_item,
483                                                 ett_quake_control);
484                 proto_tree_add_uint(control_tree, hf_quake_control_command,
485                                         tvb, 0, 1, command);
486         }
487
488         rest_length = tvb_reported_length(tvb) - 1;
489         next_tvb = tvb_new_subset(tvb, 1, rest_length , rest_length);
490         switch (command) {
491                 case CCREQ_CONNECT:
492                         dissect_quake_CCREQ_CONNECT
493                         (next_tvb, pinfo, control_tree);
494                 break;
495                 case CCREQ_SERVER_INFO:
496                         dissect_quake_CCREQ_SERVER_INFO
497                         (next_tvb, pinfo, control_tree);
498                 break;
499                 case CCREQ_PLAYER_INFO:
500                         dissect_quake_CCREQ_PLAYER_INFO
501                         (next_tvb, pinfo, control_tree);
502                 break;
503                 case CCREQ_RULE_INFO:
504                         dissect_quake_CCREQ_RULE_INFO
505                         (next_tvb, pinfo, control_tree);
506                 break;
507                 case CCREP_ACCEPT:
508                         dissect_quake_CCREP_ACCEPT
509                         (next_tvb, pinfo, control_tree);
510                 break;
511                 case CCREP_REJECT:
512                         dissect_quake_CCREP_REJECT
513                         (next_tvb, pinfo, control_tree);
514                 break;
515                 case CCREP_SERVER_INFO:
516                         dissect_quake_CCREP_SERVER_INFO
517                         (next_tvb, pinfo, control_tree);
518                 break;
519                 case CCREP_PLAYER_INFO:
520                         dissect_quake_CCREP_PLAYER_INFO
521                         (next_tvb, pinfo, control_tree);
522                 break;
523                 case CCREP_RULE_INFO:
524                         dissect_quake_CCREP_RULE_INFO
525                         (next_tvb, pinfo, control_tree);
526                 break;
527                 default:
528                         dissect_data(next_tvb, pinfo, control_tree);
529                 break;
530         }
531 }
532
533
534 static void
535 dissect_quake(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
536 {
537         proto_tree      *quake_tree = NULL;
538         proto_item      *quake_item = NULL;
539         guint32         length;
540         guint32         flags;
541         guint32         sequence = 0;
542         guint           rest_length;
543         tvbuff_t        *next_tvb;
544
545         CHECK_DISPLAY_AS_DATA(proto_quake, tvb, pinfo, tree);
546
547         if (!tvb_bytes_exist(tvb, 0, 4)) return;
548
549         length = tvb_get_ntohl(tvb, 0);
550         flags = length & (~NETFLAG_LENGTH_MASK);
551         length &= NETFLAG_LENGTH_MASK;
552
553         if (check_col(pinfo->fd, COL_PROTOCOL))
554                 col_add_str(pinfo->fd, COL_PROTOCOL, "QUAKE");
555
556         if (tree) {
557                 quake_item = proto_tree_add_item(tree, proto_quake,
558                                 tvb, 0, tvb_length(tvb), FALSE);
559                 if (quake_item)
560                         quake_tree = proto_item_add_subtree(quake_item, ett_quake);
561         }
562
563         if (quake_tree) {
564                 proto_item* flags_item = NULL;
565                 proto_tree* flags_tree = NULL;
566
567                 flags_item = proto_tree_add_uint(quake_tree, hf_quake_header_flags,
568                         tvb, 0, 2, flags);
569                 if (flags_item) {
570                         flags_tree = proto_item_add_subtree(flags_item, ett_quake_flags);
571                 }
572
573                 if (flags_tree) {
574                         proto_tree_add_text(flags_tree, tvb, 0, 2,
575                                 decode_boolean_bitfield(flags, NETFLAG_DATA, 32,
576                                 "Data","-"));
577                         proto_tree_add_text(flags_tree, tvb, 0, 2,
578                                 decode_boolean_bitfield(flags, NETFLAG_ACK, 32,
579                                 "Acknowledgment","-"));
580                         proto_tree_add_text(flags_tree, tvb, 0, 2,
581                                 decode_boolean_bitfield(flags, NETFLAG_NAK, 32,
582                                 "No Acknowledgment","-"));
583                         proto_tree_add_text(flags_tree, tvb, 0, 2,
584                                 decode_boolean_bitfield(flags, NETFLAG_EOM, 32,
585                                 "End Of Message","-"));
586                         proto_tree_add_text(flags_tree, tvb, 0, 2,
587                                 decode_boolean_bitfield(flags, NETFLAG_UNRELIABLE, 32,
588                                 "Unreliable","-"));
589                         proto_tree_add_text(flags_tree, tvb, 0, 2,
590                                 decode_boolean_bitfield(flags, NETFLAG_CTL, 32,
591                                 "Control","-"));
592                 }
593                 proto_tree_add_uint(quake_tree, hf_quake_header_length,
594                         tvb, 2, 2, length);
595         }
596
597         if (flags == NETFLAG_CTL) {
598                 rest_length = tvb_reported_length(tvb) - 4;
599                 next_tvb = tvb_new_subset(tvb, 4, rest_length , rest_length);
600                 dissect_quake_control(next_tvb, pinfo, quake_tree);
601                 return;
602         }
603
604         sequence = tvb_get_ntohl(tvb, 4);
605         if (check_col(pinfo->fd, COL_INFO)) {
606                 col_add_fstr(pinfo->fd, COL_INFO, "seq 0x%x", sequence);
607         }
608         if (quake_tree) {
609                 proto_tree_add_uint(quake_tree, hf_quake_header_sequence,
610                         tvb, 4, 4, sequence);
611         }
612
613         rest_length = tvb_reported_length(tvb) - 8;
614         next_tvb = tvb_new_subset(tvb, 8, rest_length , rest_length);
615         dissect_data(next_tvb, pinfo, quake_tree);
616 }
617
618 void
619 proto_register_quake(void)
620 {
621
622   static hf_register_info hf[] = {
623     { &hf_quake_header_flags,
624       { "Flags", "quake.header.flags",
625         FT_UINT16, BASE_HEX, NULL, 0x0,
626         "Flags" }},
627     { &hf_quake_header_length,
628       { "Length", "quake.header.length",
629         FT_UINT16, BASE_DEC, NULL, 0x0,
630         "full data length" }},
631     { &hf_quake_header_sequence,
632       { "Sequence", "quake.header.sequence",
633         FT_UINT32, BASE_HEX, NULL, 0x0,
634         "Sequence Number" }},
635     { &hf_quake_control_command,
636       { "Command", "quake.control.command",
637         FT_UINT8, BASE_HEX, VALS(names_control_command), 0x0,
638         "Control Command" }},
639     { &hf_quake_CCREQ_CONNECT_game,
640       { "Game", "quake.control.connect.game",
641         FT_STRING, BASE_DEC, NULL, 0x0,
642         "Game Name" }},
643     { &hf_quake_CCREQ_CONNECT_version,
644       { "Version", "quake.control.connect.version",
645         FT_UINT8, BASE_DEC, NULL, 0x0,
646         "Game Protocol Version Number" }},
647     { &hf_quake_CCREQ_SERVER_INFO_game,
648       { "Game", "quake.control.server_info.game",
649         FT_STRING, BASE_DEC, NULL, 0x0,
650         "Game Name" }},
651     { &hf_quake_CCREQ_SERVER_INFO_version,
652       { "Version", "quake.control.server_info.version",
653         FT_UINT8, BASE_DEC, NULL, 0x0,
654         "Game Protocol Version Number" }},
655     { &hf_quake_CCREQ_PLAYER_INFO_player,
656       { "Player", "quake.control.player_info.player",
657         FT_UINT8, BASE_DEC, NULL, 0x0,
658         "Player" }},
659     { &hf_quake_CCREQ_RULE_INFO_lastrule,
660       { "Last Rule", "quake.control.rule_info.lastrule",
661         FT_STRING, BASE_DEC, NULL, 0x0,
662         "Last Rule Name" }},
663     { &hf_quake_CCREP_ACCEPT_port,
664       { "Port", "quake.control.accept.port",
665         FT_UINT32, BASE_DEC, NULL, 0x0,
666         "Game Data Port" }},
667     { &hf_quake_CCREP_REJECT_reason,
668       { "Reason", "quake.control.reject.reason",
669         FT_STRING, BASE_DEC, NULL, 0x0,
670         "Reject Reason" }},
671     { &hf_quake_CCREP_SERVER_INFO_address,
672       { "Address", "quake.control.server_info.address",
673         FT_STRING, BASE_DEC, NULL, 0x0,
674         "Server Address" }},
675     { &hf_quake_CCREP_SERVER_INFO_server,
676       { "Server", "quake.control.server_info.server",
677         FT_STRING, BASE_DEC, NULL, 0x0,
678         "Server Name" }},
679     { &hf_quake_CCREP_SERVER_INFO_map,
680       { "Map", "quake.control.server_info.map",
681         FT_STRING, BASE_DEC, NULL, 0x0,
682         "Map Name" }},
683     { &hf_quake_CCREP_SERVER_INFO_num_player,
684       { "Number of Players", "quake.control.server_info.num_player",
685         FT_UINT8, BASE_DEC, NULL, 0x0,
686         "Current Number of Players" }},
687     { &hf_quake_CCREP_SERVER_INFO_max_player,
688       { "Maximal Number of Players", "quake.control.server_info.max_player",
689         FT_UINT8, BASE_DEC, NULL, 0x0,
690         "Maximal Number of Players" }},
691     { &hf_quake_CCREP_PLAYER_INFO_name,
692       { "Name", "quake.control.player_info.name",
693         FT_STRING, BASE_DEC, NULL, 0x0,
694         "Player Name" }},
695     { &hf_quake_CCREP_PLAYER_INFO_colors,
696       { "Colors", "quake.control.player_info.colors",
697         FT_UINT32, BASE_HEX, NULL, 0x0,
698         "Player Colors" }},
699     { &hf_quake_CCREP_PLAYER_INFO_colors_shirt,
700       { "Shirt", "quake.control.player_info.colors.shirt",
701         FT_UINT8, BASE_DEC, VALS(names_colors), 0x0,
702         "Shirt Color" }},
703     { &hf_quake_CCREP_PLAYER_INFO_colors_pants,
704       { "Pants", "quake.control.player_info.colors.pants",
705         FT_UINT8, BASE_DEC, VALS(names_colors), 0x0,
706         "Pants Color" }},
707     { &hf_quake_CCREP_PLAYER_INFO_frags,
708       { "Frags", "quake.control.player_info.frags",
709         FT_UINT32, BASE_DEC, NULL, 0x0,
710         "Player Frags" }},
711     { &hf_quake_CCREP_PLAYER_INFO_connect_time,
712       { "Connect Time", "quake.control.player_info.connect_time",
713         FT_UINT32, BASE_DEC, NULL, 0x0,
714         "Player Connect Time" }},
715     { &hf_quake_CCREP_PLAYER_INFO_address,
716       { "Address", "quake.control.player_info.address",
717         FT_STRING, BASE_DEC, NULL, 0x0,
718         "Player Address" }},
719     { &hf_quake_CCREP_RULE_INFO_rule,
720       { "Rule", "quake.control.rule_info.rule",
721         FT_STRING, BASE_DEC, NULL, 0x0,
722         "Rule Name" }},
723     { &hf_quake_CCREP_RULE_INFO_value,
724       { "Value", "quake.control.rule_info.value",
725         FT_STRING, BASE_DEC, NULL, 0x0,
726         "Rule Value" }},
727   };
728   static gint *ett[] = {
729     &ett_quake,
730     &ett_quake_control,
731     &ett_quake_control_colors,
732     &ett_quake_flags,
733   };
734
735   proto_quake = proto_register_protocol("Quake Network Protocol", "quake");
736   proto_register_field_array(proto_quake, hf, array_length(hf));
737   proto_register_subtree_array(ett, array_length(ett));
738 }
739
740
741 void
742 proto_reg_handoff_quake(void)
743 {
744         dissector_add("udp.port", DEFAULTnet_hostport, dissect_quake);
745 }