summaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-quake.c
blob: ea9e5591013dabc565c5eb52e6035bb2340a43bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
/* packet-quake.c
 * Routines for Quake packet dissection
 *
 * Uwe Girlich <uwe@planetquake.com>
 *	http://www.idsoftware.com/q1source/q1source.zip
 *
 * Wireshark - Network traffic analyzer
 * By Gerald Combs <gerald@wireshark.org>
 * Copyright 1998 Gerald Combs
 *
 * Copied from packet-tftp.c
 *
 * SPDX-License-Identifier: GPL-2.0-or-later
 */

#include "config.h"

#include <epan/packet.h>
#include <epan/conversation.h>

void proto_register_quake(void);

static int proto_quake = -1;
static int hf_quake_header_flags = -1;
static int hf_quake_header_flags_data = -1;
static int hf_quake_header_flags_ack = -1;
static int hf_quake_header_flags_no_ack = -1;
static int hf_quake_header_flags_endmsg = -1;
static int hf_quake_header_flags_unreliable = -1;
static int hf_quake_header_flags_control = -1;
static int hf_quake_header_length = -1;
static int hf_quake_header_sequence = -1;
static int hf_quake_control_command = -1;

static int hf_quake_CCREQ_CONNECT_game = -1;
static int hf_quake_CCREQ_CONNECT_version = -1;
static int hf_quake_CCREQ_SERVER_INFO_game = -1;
static int hf_quake_CCREQ_SERVER_INFO_version = -1;
static int hf_quake_CCREQ_PLAYER_INFO_player = -1;
static int hf_quake_CCREQ_RULE_INFO_lastrule = -1;

static int hf_quake_CCREP_ACCEPT_port = -1;
static int hf_quake_CCREP_REJECT_reason = -1;
static int hf_quake_CCREP_SERVER_INFO_address = -1;
static int hf_quake_CCREP_SERVER_INFO_server = -1;
static int hf_quake_CCREP_SERVER_INFO_map = -1;
static int hf_quake_CCREP_SERVER_INFO_num_player = -1;
static int hf_quake_CCREP_SERVER_INFO_max_player = -1;
static int hf_quake_CCREP_PLAYER_INFO_name = -1;
static int hf_quake_CCREP_PLAYER_INFO_colors = -1;
static int hf_quake_CCREP_PLAYER_INFO_colors_shirt = -1;
static int hf_quake_CCREP_PLAYER_INFO_colors_pants = -1;
static int hf_quake_CCREP_PLAYER_INFO_frags = -1;
static int hf_quake_CCREP_PLAYER_INFO_connect_time = -1;
static int hf_quake_CCREP_PLAYER_INFO_address = -1;
static int hf_quake_CCREP_RULE_INFO_rule = -1;
static int hf_quake_CCREP_RULE_INFO_value = -1;


static gint ett_quake = -1;
static gint ett_quake_control = -1;
static gint ett_quake_control_colors = -1;
static gint ett_quake_flags = -1;

static dissector_handle_t quake_handle;

/* I took these names directly out of the Q1 source. */
#define NET_HEADERSIZE 8
#define DEFAULTnet_hostport 26000

#define NETFLAG_DATA            0x0001
#define NETFLAG_ACK             0x0002
#define NETFLAG_NAK             0x0004
#define NETFLAG_EOM             0x0008
#define NETFLAG_UNRELIABLE      0x0010
#define NETFLAG_CTL             0x8000


#define CCREQ_CONNECT           0x01
#define CCREQ_SERVER_INFO       0x02
#define CCREQ_PLAYER_INFO       0x03
#define CCREQ_RULE_INFO         0x04

#define CCREP_ACCEPT            0x81
#define CCREP_REJECT            0x82
#define CCREP_SERVER_INFO       0x83
#define CCREP_PLAYER_INFO       0x84
#define CCREP_RULE_INFO         0x85

static const value_string names_control_command[] = {
	{	CCREQ_CONNECT, "connect" },
	{	CCREQ_SERVER_INFO, "server_info" },
	{	CCREQ_PLAYER_INFO, "player_info" },
	{	CCREQ_RULE_INFO, "rule_info" },
	{	CCREP_ACCEPT, "accept" },
	{	CCREP_REJECT, "reject" },
	{	CCREP_SERVER_INFO, "server_info" },
	{	CCREP_PLAYER_INFO, "player_info" },
	{	CCREP_RULE_INFO, "rule_info" },
	{ 0, NULL }
};

#define CCREQ 0x00
#define CCREP 0x80

#define QUAKE_MAXSTRING 0x800

static const value_string names_control_direction[] = {
	{ CCREQ, "Request" },
	{ CCREP, "Reply" },
	{ 0, NULL }
};


static const value_string names_colors[] = {
	{  0, "White" },
	{  1, "Brown" },
	{  2, "Lavender" },
	{  3, "Khaki" },
	{  4, "Red" },
	{  5, "Lt Brown" },
	{  6, "Peach" },
	{  7, "Lt Peach" },
	{  8, "Purple" },
	{  9, "Dk Purple" },
	{ 10, "Tan" },
	{ 11, "Green" },
	{ 12, "Yellow" },
	{ 13, "Blue" },
	{ 14, "Fire" },
	{ 15, "Brights" },
	{  0, NULL }
};

static void
dissect_quake_CCREQ_CONNECT
(tvbuff_t *tvb, proto_tree *tree)
{
	gint offset = 0;
	gint item_len;

	proto_tree_add_item_ret_length(tree, hf_quake_CCREQ_CONNECT_game,
			tvb, offset, -1, ENC_ASCII|ENC_NA, &item_len);
	offset += item_len;

	proto_tree_add_item(tree, hf_quake_CCREQ_CONNECT_version,
			tvb, offset, 1, ENC_LITTLE_ENDIAN);
}


static void
dissect_quake_CCREQ_SERVER_INFO
(tvbuff_t *tvb, proto_tree *tree)
{
	gint offset = 0;
	gint item_len;

	proto_tree_add_item_ret_length(tree, hf_quake_CCREQ_SERVER_INFO_game,
			tvb, offset, -1, ENC_ASCII|ENC_NA, &item_len);
	offset += item_len;
	proto_tree_add_item(tree, hf_quake_CCREQ_SERVER_INFO_version,
			tvb, offset, 1, ENC_LITTLE_ENDIAN);
}


static void
dissect_quake_CCREQ_PLAYER_INFO
(tvbuff_t *tvb, proto_tree *tree)
{
	proto_tree_add_item(tree, hf_quake_CCREQ_PLAYER_INFO_player,
			tvb, 0, 1, ENC_LITTLE_ENDIAN);
}


static void
dissect_quake_CCREQ_RULE_INFO
(tvbuff_t *tvb, proto_tree *tree)
{
	proto_tree_add_item(tree, hf_quake_CCREQ_RULE_INFO_lastrule,
			tvb, 0, -1, ENC_ASCII);
}


static void
dissect_quake_CCREP_ACCEPT
(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
	guint32 port;
	conversation_t *c;

	port = tvb_get_letohl(tvb, 0);
	c = find_or_create_conversation(pinfo);
	conversation_set_dissector(c, quake_handle);

	proto_tree_add_uint(tree, hf_quake_CCREP_ACCEPT_port,
			tvb, 0, 4, port);
}


static void
dissect_quake_CCREP_REJECT
(tvbuff_t *tvb, proto_tree *tree)
{
	proto_tree_add_item(tree, hf_quake_CCREP_REJECT_reason,
			tvb, 0, -1, ENC_ASCII);
}


static void
dissect_quake_CCREP_SERVER_INFO
(tvbuff_t *tvb, proto_tree *tree)
{
	gint offset = 0;
	gint item_len;

	proto_tree_add_item_ret_length(tree,
			hf_quake_CCREP_SERVER_INFO_address, tvb, offset, -1,
			ENC_ASCII|ENC_NA, &item_len);
	offset += item_len;

	proto_tree_add_item_ret_length(tree,
			hf_quake_CCREP_SERVER_INFO_server, tvb, offset, -1,
			ENC_ASCII|ENC_NA, &item_len);
	offset += item_len;

	proto_tree_add_item_ret_length(tree,
			hf_quake_CCREP_SERVER_INFO_map, tvb, offset, -1,
			ENC_ASCII|ENC_NA, &item_len);
	offset += item_len;

	proto_tree_add_item(tree, hf_quake_CCREP_SERVER_INFO_num_player,
			tvb, offset, 1, ENC_LITTLE_ENDIAN);
	offset += 1;
	proto_tree_add_item(tree, hf_quake_CCREP_SERVER_INFO_max_player,
			tvb, offset, 1, ENC_LITTLE_ENDIAN);
	offset += 1;
	proto_tree_add_item(tree, hf_quake_CCREQ_SERVER_INFO_version,
			tvb, offset, 1, ENC_LITTLE_ENDIAN);
}


static void
dissect_quake_CCREP_PLAYER_INFO
(tvbuff_t *tvb, proto_tree *tree)
{
	gint offset = 0;
	guint32 colors;
	guint32 color_shirt;
	guint32 color_pants;
	proto_item *colors_item;
	proto_tree *colors_tree;
	gint item_len;

	proto_tree_add_item(tree, hf_quake_CCREQ_PLAYER_INFO_player,
			tvb, offset, 1, ENC_LITTLE_ENDIAN);
	offset += 1;

	proto_tree_add_item_ret_length(tree, hf_quake_CCREP_PLAYER_INFO_name,
			tvb, offset, -1, ENC_ASCII|ENC_NA, &item_len);
	offset += item_len;

	colors       = tvb_get_letohl(tvb, offset + 0);
	color_shirt = (colors >> 4) & 0x0f;
	color_pants = (colors     ) & 0x0f;

	colors_item = proto_tree_add_uint(tree,
			hf_quake_CCREP_PLAYER_INFO_colors,
			tvb, offset, 4, colors);
	colors_tree = proto_item_add_subtree(colors_item,
			ett_quake_control_colors);
	proto_tree_add_uint(colors_tree,
			hf_quake_CCREP_PLAYER_INFO_colors_shirt,
			tvb, offset, 1, color_shirt);
	proto_tree_add_uint(colors_tree,
			hf_quake_CCREP_PLAYER_INFO_colors_pants,
			tvb, offset, 1, color_pants);
	offset += 4;
	proto_tree_add_item(tree, hf_quake_CCREP_PLAYER_INFO_frags,
			tvb, offset, 4, ENC_LITTLE_ENDIAN);
	offset += 4;
	proto_tree_add_item(tree, hf_quake_CCREP_PLAYER_INFO_connect_time,
			tvb, offset, 4, ENC_LITTLE_ENDIAN);
	offset += 4;

	proto_tree_add_item(tree, hf_quake_CCREP_PLAYER_INFO_address,
			tvb, offset, -1, ENC_ASCII);
}


static void
dissect_quake_CCREP_RULE_INFO
(tvbuff_t *tvb, proto_tree *tree)
{
	gint offset = 0;
	gint item_len;

	if (tvb_reported_length(tvb) == 0) return;

	proto_tree_add_item_ret_length(tree, hf_quake_CCREP_RULE_INFO_rule,
			tvb, offset, -1, ENC_ASCII|ENC_NA, &item_len);
	offset += item_len;

	proto_tree_add_item(tree, hf_quake_CCREP_RULE_INFO_value,
			tvb, offset, -1, ENC_ASCII);
}


static void
dissect_quake_control(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
	guint8		command;
	int		direction;
	proto_tree	*control_tree;
	tvbuff_t	*next_tvb;

	command = tvb_get_guint8(tvb, 0);
	direction = (command & 0x80) ? CCREP : CCREQ;

	col_add_fstr(pinfo->cinfo, COL_INFO, "%s %s",
			val_to_str(command,names_control_command, "%u"),
			val_to_str(direction,names_control_direction,"%u"));

	control_tree = proto_tree_add_subtree_format(tree, tvb,
			0, -1, ett_quake_control, NULL, "Control %s: %s",
			val_to_str(direction, names_control_direction, "%u"),
			val_to_str(command, names_control_command, "%u"));
	proto_tree_add_uint(control_tree, hf_quake_control_command,
			tvb, 0, 1, command);

	next_tvb = tvb_new_subset_remaining(tvb, 1);
	switch (command) {
		case CCREQ_CONNECT:
			dissect_quake_CCREQ_CONNECT
				(next_tvb, control_tree);
		break;
		case CCREQ_SERVER_INFO:
			dissect_quake_CCREQ_SERVER_INFO
				(next_tvb, control_tree);
		break;
		case CCREQ_PLAYER_INFO:
			dissect_quake_CCREQ_PLAYER_INFO
				(next_tvb, control_tree);
		break;
		case CCREQ_RULE_INFO:
			dissect_quake_CCREQ_RULE_INFO
				(next_tvb, control_tree);
		break;
		case CCREP_ACCEPT:
			dissect_quake_CCREP_ACCEPT
				(next_tvb, pinfo, control_tree);
		break;
		case CCREP_REJECT:
			dissect_quake_CCREP_REJECT
				(next_tvb, control_tree);
		break;
		case CCREP_SERVER_INFO:
			dissect_quake_CCREP_SERVER_INFO
				(next_tvb, control_tree);
		break;
		case CCREP_PLAYER_INFO:
			dissect_quake_CCREP_PLAYER_INFO
				(next_tvb, control_tree);
		break;
		case CCREP_RULE_INFO:
			dissect_quake_CCREP_RULE_INFO
				(next_tvb, control_tree);
		break;
		default:
			call_data_dissector(next_tvb, pinfo, control_tree);
		break;
	}
}


static int
dissect_quake(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
	proto_tree	*quake_tree;
	proto_item	*quake_item;
	guint16		flags;
	proto_item	*flags_item;
	proto_tree	*flags_tree;
	guint32		sequence = 0;
	tvbuff_t	*next_tvb;

	col_set_str(pinfo->cinfo, COL_PROTOCOL, "QUAKE");
	col_clear(pinfo->cinfo, COL_INFO);

	flags = tvb_get_ntohs(tvb, 2);

	quake_item = proto_tree_add_item(tree, proto_quake, tvb, 0, -1, ENC_NA);
	quake_tree = proto_item_add_subtree(quake_item, ett_quake);

	flags_item = proto_tree_add_item(quake_tree, hf_quake_header_flags,
			tvb, 2, 2, ENC_BIG_ENDIAN);
	flags_tree = proto_item_add_subtree(flags_item, ett_quake_flags);
	proto_tree_add_item(flags_tree, hf_quake_header_flags_data,
			tvb, 2, 2, ENC_BIG_ENDIAN);
	proto_tree_add_item(flags_tree, hf_quake_header_flags_ack,
			tvb, 2, 2, ENC_BIG_ENDIAN);
	proto_tree_add_item(flags_tree, hf_quake_header_flags_no_ack,
			tvb, 2, 2, ENC_BIG_ENDIAN);
	proto_tree_add_item(flags_tree, hf_quake_header_flags_endmsg,
			tvb, 2, 2, ENC_BIG_ENDIAN);
	proto_tree_add_item(flags_tree, hf_quake_header_flags_unreliable,
			tvb, 2, 2, ENC_BIG_ENDIAN);
	proto_tree_add_item(flags_tree, hf_quake_header_flags_control,
			tvb, 2, 2, ENC_BIG_ENDIAN);

	proto_tree_add_item(quake_tree, hf_quake_header_length, tvb, 0, 2, ENC_BIG_ENDIAN);

	if (flags == NETFLAG_CTL) {
		next_tvb = tvb_new_subset_remaining(tvb, 4);
		dissect_quake_control(next_tvb, pinfo, quake_tree);
		return tvb_captured_length(tvb);
	}

	sequence = tvb_get_ntohl(tvb, 4);
	col_add_fstr(pinfo->cinfo, COL_INFO, "seq 0x%x", sequence);
	proto_tree_add_uint(quake_tree, hf_quake_header_sequence,
			tvb, 4, 4, sequence);

	next_tvb = tvb_new_subset_remaining(tvb, 8);
	call_data_dissector(next_tvb, pinfo, quake_tree);
	return tvb_captured_length(tvb);
}


void proto_reg_handoff_quake(void);

void
proto_register_quake(void)
{
	static hf_register_info hf[] = {
		{ &hf_quake_header_flags,
		  { "Flags", "quake.header.flags",
		    FT_UINT16, BASE_HEX, NULL, 0x0,
		    NULL, HFILL }},
		{ &hf_quake_header_flags_data,
		  { "Data", "quake.header.flags.data",
		    FT_BOOLEAN, 16, TFS(&tfs_set_notset), NETFLAG_DATA,
		    NULL, HFILL }},
		{ &hf_quake_header_flags_ack,
		  { "Acknowledgment", "quake.header.flags.ack",
		    FT_BOOLEAN, 16, TFS(&tfs_set_notset), NETFLAG_ACK,
		    NULL, HFILL }},
		{ &hf_quake_header_flags_no_ack,
		  { "No Acknowledgment", "quake.header.flags.no_ack",
		    FT_BOOLEAN, 16, TFS(&tfs_set_notset), NETFLAG_NAK,
		    NULL, HFILL }},
		{ &hf_quake_header_flags_endmsg,
		  { "End Of Message", "quake.header.flags.endmsg",
		    FT_BOOLEAN, 16, TFS(&tfs_set_notset), NETFLAG_EOM,
		    NULL, HFILL }},
		{ &hf_quake_header_flags_unreliable,
		  { "Unreliable", "quake.header.flags.unreliable",
		    FT_BOOLEAN, 16, TFS(&tfs_set_notset), NETFLAG_UNRELIABLE,
		    NULL, HFILL }},
		{ &hf_quake_header_flags_control,
		  { "Control", "quake.header.flags.control",
		    FT_BOOLEAN, 16, TFS(&tfs_set_notset), NETFLAG_CTL,
		    NULL, HFILL }},
		{ &hf_quake_header_length,
		  { "Length", "quake.header.length",
		    FT_UINT16, BASE_DEC, NULL, 0x0,
		    "full data length", HFILL }},
		{ &hf_quake_header_sequence,
		  { "Sequence", "quake.header.sequence",
		    FT_UINT32, BASE_HEX, NULL, 0x0,
		    "Sequence Number", HFILL }},
		{ &hf_quake_control_command,
		  { "Command", "quake.control.command",
		    FT_UINT8, BASE_HEX, VALS(names_control_command), 0x0,
		    "Control Command", HFILL }},
		{ &hf_quake_CCREQ_CONNECT_game,
		  { "Game", "quake.control.connect.game",
		    FT_STRINGZ, BASE_NONE, NULL, 0x0,
		    "Game Name", HFILL }},
		{ &hf_quake_CCREQ_CONNECT_version,
		  { "Version", "quake.control.connect.version",
		    FT_UINT8, BASE_DEC, NULL, 0x0,
		    "Game Protocol Version Number", HFILL }},
		{ &hf_quake_CCREQ_SERVER_INFO_game,
		  { "Game", "quake.control.server_info.game",
		    FT_STRINGZ, BASE_NONE, NULL, 0x0,
		    "Game Name", HFILL }},
		{ &hf_quake_CCREQ_SERVER_INFO_version,
		  { "Version", "quake.control.server_info.version",
		    FT_UINT8, BASE_DEC, NULL, 0x0,
		    "Game Protocol Version Number", HFILL }},
		{ &hf_quake_CCREQ_PLAYER_INFO_player,
		  { "Player", "quake.control.player_info.player",
		    FT_UINT8, BASE_DEC, NULL, 0x0,
		    NULL, HFILL }},
		{ &hf_quake_CCREQ_RULE_INFO_lastrule,
		  { "Last Rule", "quake.control.rule_info.lastrule",
		    FT_STRINGZ, BASE_NONE, NULL, 0x0,
		    "Last Rule Name", HFILL }},
		{ &hf_quake_CCREP_ACCEPT_port,
		  { "Port", "quake.control.accept.port",
		    FT_UINT32, BASE_DEC, NULL, 0x0,
		    "Game Data Port", HFILL }},
		{ &hf_quake_CCREP_REJECT_reason,
		  { "Reason", "quake.control.reject.reason",
		    FT_STRINGZ, BASE_NONE, NULL, 0x0,
		    "Reject Reason", HFILL }},
		{ &hf_quake_CCREP_SERVER_INFO_address,
		  { "Address", "quake.control.server_info.address",
		    FT_STRINGZ, BASE_NONE, NULL, 0x0,
		    "Server Address", HFILL }},
		{ &hf_quake_CCREP_SERVER_INFO_server,
		  { "Server", "quake.control.server_info.server",
		    FT_STRINGZ, BASE_NONE, NULL, 0x0,
		    "Server Name", HFILL }},
		{ &hf_quake_CCREP_SERVER_INFO_map,
		  { "Map", "quake.control.server_info.map",
		    FT_STRINGZ, BASE_NONE, NULL, 0x0,
		    "Map Name", HFILL }},
		{ &hf_quake_CCREP_SERVER_INFO_num_player,
		  { "Number of Players", "quake.control.server_info.num_player",
		    FT_UINT8, BASE_DEC, NULL, 0x0,
		    "Current Number of Players", HFILL }},
		{ &hf_quake_CCREP_SERVER_INFO_max_player,
		  { "Maximal Number of Players", "quake.control.server_info.max_player",
		    FT_UINT8, BASE_DEC, NULL, 0x0,
		    NULL, HFILL }},
		{ &hf_quake_CCREP_PLAYER_INFO_name,
		  { "Name", "quake.control.player_info.name",
		    FT_STRINGZ, BASE_NONE, NULL, 0x0,
		    "Player Name", HFILL }},
		{ &hf_quake_CCREP_PLAYER_INFO_colors,
		  { "Colors", "quake.control.player_info.colors",
		    FT_UINT32, BASE_HEX, NULL, 0x0,
		    "Player Colors", HFILL }},
		{ &hf_quake_CCREP_PLAYER_INFO_colors_shirt,
		  { "Shirt", "quake.control.player_info.colors.shirt",
		    FT_UINT8, BASE_DEC, VALS(names_colors), 0x0,
		    "Shirt Color", HFILL }},
		{ &hf_quake_CCREP_PLAYER_INFO_colors_pants,
		  { "Pants", "quake.control.player_info.colors.pants",
		    FT_UINT8, BASE_DEC, VALS(names_colors), 0x0,
		    "Pants Color", HFILL }},
		{ &hf_quake_CCREP_PLAYER_INFO_frags,
		  { "Frags", "quake.control.player_info.frags",
		    FT_UINT32, BASE_DEC, NULL, 0x0,
		    "Player Frags", HFILL }},
		{ &hf_quake_CCREP_PLAYER_INFO_connect_time,
		  { "Connect Time", "quake.control.player_info.connect_time",
		    FT_UINT32, BASE_DEC, NULL, 0x0,
		    "Player Connect Time", HFILL }},
		{ &hf_quake_CCREP_PLAYER_INFO_address,
		  { "Address", "quake.control.player_info.address",
		    FT_STRINGZ, BASE_NONE, NULL, 0x0,
		    "Player Address", HFILL }},
		{ &hf_quake_CCREP_RULE_INFO_rule,
		  { "Rule", "quake.control.rule_info.rule",
		    FT_STRINGZ, BASE_NONE, NULL, 0x0,
		    "Rule Name", HFILL }},
		{ &hf_quake_CCREP_RULE_INFO_value,
		  { "Value", "quake.control.rule_info.value",
		    FT_STRINGZ, BASE_NONE, NULL, 0x0,
		    "Rule Value", HFILL }},
	};
	static gint *ett[] = {
		&ett_quake,
		&ett_quake_control,
		&ett_quake_control_colors,
		&ett_quake_flags,
	};

	proto_quake = proto_register_protocol("Quake Network Protocol", "QUAKE", "quake");
	proto_register_field_array(proto_quake, hf, array_length(hf));
	proto_register_subtree_array(ett, array_length(ett));

	quake_handle = register_dissector("quake", dissect_quake, proto_quake);
}


void
proto_reg_handoff_quake(void)
{
	dissector_add_uint_with_preference("udp.port", DEFAULTnet_hostport, quake_handle);
}

/*
 * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
 *
 * Local variables:
 * c-basic-offset: 8
 * tab-width: 8
 * indent-tabs-mode: t
 * End:
 *
 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
 * :indentSize=8:tabSize=8:noTabs=false:
 */