Pull much of the processing done after a call to "fragment_add_check()"
[obnox/wireshark/wip.git] / packet-quake3.c
1 /* packet-quake3.c
2  * Routines for Quake III Arena packet dissection
3  *
4  * Uwe Girlich <uwe@planetquake.com>
5  *
6  * $Id: packet-quake3.c,v 1.14 2002/08/28 21:00:27 jmayer Exp $
7  *
8  * Ethereal - Network traffic analyzer
9  * By Gerald Combs <gerald@ethereal.com>
10  * Copyright 1998 Gerald Combs
11  *
12  * Copied from packet-quake2.c
13  *
14  * This program is free software; you can redistribute it and/or
15  * modify it under the terms of the GNU General Public License
16  * as published by the Free Software Foundation; either version 2
17  * of the License, or (at your option) any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  * GNU General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with this program; if not, write to the Free Software
26  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
27  */
28
29
30 /*
31    All informations used in this decoding were gathered from
32         * some own captures of a private server,
33         * the "Server commands howto" document written by id Software
34                 (http://www.quake3arena.com/tech/ServerCommandsHowto.html)
35         * source code of the game server browser tool qstat
36                 (http://www.qstat.org).
37 */
38
39
40 #ifdef HAVE_CONFIG_H
41 # include "config.h"
42 #endif
43
44 #include <string.h>
45 #include <glib.h>
46 #include <epan/packet.h>
47 #include "prefs.h"
48 #include <epan/resolv.h>
49
50 static int proto_quake3 = -1;
51
52 static int hf_quake3_direction = -1;
53 static int hf_quake3_connectionless = -1;
54 static int hf_quake3_game = -1;
55 static int hf_quake3_connectionless_marker = -1;
56 static int hf_quake3_connectionless_text = -1;
57 static int hf_quake3_connectionless_command = -1;
58 static int hf_quake3_server_addr = -1;
59 static int hf_quake3_server_port = -1;
60 static int hf_quake3_game_seq1 = -1;
61 static int hf_quake3_game_rel1 = -1;
62 static int hf_quake3_game_seq2 = -1;
63 static int hf_quake3_game_rel2 = -1;
64 static int hf_quake3_game_qport = -1;
65
66 static gint ett_quake3 = -1;
67 static gint ett_quake3_connectionless = -1;
68 static gint ett_quake3_connectionless_text = -1;
69 static gint ett_quake3_server = -1;
70 static gint ett_quake3_game = -1;
71 static gint ett_quake3_game_seq1 = -1;
72 static gint ett_quake3_game_seq2 = -1;
73 static gint ett_quake3_game_clc = -1;
74 static gint ett_quake3_game_svc = -1;
75
76 static dissector_handle_t data_handle;
77
78 #define QUAKE3_SERVER_PORT 27960
79 #define QUAKE3_MASTER_PORT 27950
80 static unsigned int gbl_quake3_server_port=QUAKE3_SERVER_PORT;
81 static unsigned int gbl_quake3_master_port=QUAKE3_MASTER_PORT;
82
83
84 static const value_string names_direction[] = {
85 #define DIR_UNKNOWN 0
86         { DIR_UNKNOWN, "Unknown" },
87 #define DIR_C2S 1
88         { DIR_C2S, "Client to Server" },
89 #define DIR_S2C 2
90         { DIR_S2C, "Server to Client" },
91 #define DIR_C2M 3
92         { DIR_C2M, "Client to Master" },
93 #define DIR_M2C 4
94         { DIR_M2C, "Master to Client" },
95         { 0, NULL }
96 };
97
98
99 #define string_starts_with(s1, s2) (strncmp((s1), (s2), strlen(s2)) == 0)
100
101
102 static const value_string names_command[] = {
103 #define COMMAND_UNKNOWN                 0
104         { COMMAND_UNKNOWN,              "Unknown" },
105 #define COMMAND_statusResponse          1
106         { COMMAND_statusResponse,       "Reply Status" },
107 #define COMMAND_getstatus               2
108         { COMMAND_getstatus,            "Request Status" },
109 #define COMMAND_infoResponse            3
110         { COMMAND_infoResponse,         "Reply Info" },
111 #define COMMAND_getinfo                 4
112         { COMMAND_getinfo,              "Request Info" },
113 #define COMMAND_challengeResponse       5
114         { COMMAND_challengeResponse,    "Reply Challenge" },
115 #define COMMAND_getchallenge            6
116         { COMMAND_getchallenge,         "Request Challenge" },
117 #define COMMAND_connectResponse         7
118         { COMMAND_connectResponse,      "Reply Connect" },
119 #define COMMAND_connect                 8
120         { COMMAND_connect,              "Request Connect" },
121 #define COMMAND_rconResponse            9
122         { COMMAND_rconResponse,         "Reply Remote Command" },
123 #define COMMAND_rcon                    10
124         { COMMAND_rcon,                 "Request Remote Command" },
125 #define COMMAND_getmotdResponse         11
126         { COMMAND_getmotdResponse,      "Reply Motto of the Day" },
127 #define COMMAND_getmotd                 12
128         { COMMAND_getmotd,              "Request Motto of the Day" },
129 #define COMMAND_getserversResponse      13
130         { COMMAND_getserversResponse,   "Reply Servers" },
131 #define COMMAND_getservers              14
132         { COMMAND_getservers,           "Request Servers" },
133 #define COMMAND_getKeyAuthorize         15
134         { COMMAND_getKeyAuthorize,      "Request Key Authorization" },
135 #define COMMAND_getIpAuthorize          16
136         { COMMAND_getIpAuthorize,       "Request IP Authorization" },
137 #define COMMAND_ipAuthorize             17
138         { COMMAND_ipAuthorize,          "Reply IP Authorization" },
139         { 0, NULL }
140 };
141
142
143 static void
144 dissect_quake3_ConnectionlessPacket(tvbuff_t *tvb, packet_info *pinfo _U_,
145         proto_tree *tree, int* direction)
146 {
147         proto_tree      *cl_tree = NULL;
148         proto_item      *cl_item = NULL;
149         proto_item      *text_item = NULL;
150         proto_tree      *text_tree = NULL;
151         guint8          text[2048];
152         int             maxbufsize = 0;
153         int             len;
154         int             offset;
155         guint32         marker;
156         int             command;
157         int             command_len;
158         int             command_finished = FALSE;
159
160         marker = tvb_get_ntohl(tvb, 0);
161         if (tree) {
162                 cl_item = proto_tree_add_text(tree, tvb,
163                                 0, -1, "Connectionless");
164                 if (cl_item)
165                         cl_tree = proto_item_add_subtree(
166                                 cl_item, ett_quake3_connectionless);
167         }
168
169         if (cl_tree) {
170                 proto_tree_add_uint(cl_tree, hf_quake3_connectionless_marker,
171                                 tvb, 0, 4, marker);
172         }
173
174         /* all the rest of the packet is just text */
175         offset = 4;
176
177         maxbufsize = MIN((gint)sizeof(text), tvb_length_remaining(tvb, offset));
178         len = tvb_get_nstringz0(tvb, offset, maxbufsize, text);
179         if (cl_tree) {
180                 text_item = proto_tree_add_string(cl_tree,
181                                 hf_quake3_connectionless_text,
182                                 tvb, offset, len + 1, text);
183                 if (text_item) {
184                         text_tree = proto_item_add_subtree(
185                                         text_item,
186                                         ett_quake3_connectionless_text);
187                 }
188         }
189
190         command = COMMAND_UNKNOWN;
191         command_len = 0;
192
193         if (strncmp(text, "statusResponse", 14) == 0) {
194                 command = COMMAND_statusResponse;
195                 *direction = DIR_S2C;
196                 command_len = 14;
197         }
198         else if (strncmp(text, "getstatus", 9) == 0) {
199                 command = COMMAND_getstatus;
200                 *direction = DIR_C2S;
201                 command_len = 9;
202         }
203         else if (strncmp(text, "infoResponse", 12) == 0) {
204                 command = COMMAND_infoResponse;
205                 *direction = DIR_S2C;
206                 command_len = 12;
207         }
208         else if (strncmp(text, "getinfo", 7) == 0) {
209                 command = COMMAND_getinfo;
210                 *direction = DIR_C2S;
211                 command_len = 7;
212         }
213         else if (strncmp(text, "challengeResponse", 17) == 0) {
214                 command = COMMAND_challengeResponse;
215                 *direction = DIR_S2C;
216                 command_len = 17;
217         }
218         else if (strncmp(text, "getchallenge", 12) == 0) {
219                 command = COMMAND_getchallenge;
220                 *direction = DIR_C2S;
221                 command_len = 12;
222         }
223         else if (strncmp(text, "connectResponse", 15) == 0) {
224                 command = COMMAND_connectResponse;
225                 *direction = DIR_S2C;
226                 command_len = 15;
227         }
228         else if (strncmp(text, "connect", 7) == 0) {
229                 command = COMMAND_connect;
230                 *direction = DIR_C2S;
231                 command_len = 7;
232         }
233         else if (strncmp(text, "rconResponse", 12) == 0) {
234                 command = COMMAND_rconResponse;
235                 *direction = DIR_S2C;
236                 command_len = 12;
237         }
238         else if (strncmp(text, "rcon", 4) == 0) {
239                 command = COMMAND_rcon;
240                 *direction = DIR_C2S;
241                 command_len = 4;
242         }
243         else if (strncmp(text, "getmotdResponse", 15) == 0) {
244                 command = COMMAND_getmotdResponse;
245                 *direction = DIR_M2C;
246                 command_len = 15;
247         }
248         else if (strncmp(text, "getmotd", 7) == 0) {
249                 command = COMMAND_getmotd;
250                 *direction = DIR_C2M;
251                 command_len = 7;
252         }
253         else if (strncmp(text, "getserversResponse", 18) == 0) {
254                 int base;
255                 command = COMMAND_getserversResponse;
256                 *direction = DIR_M2C;
257                 command_len = 18;
258                 /* The data can contain 0's, and the text string is binary
259                 anyway, so better replace the text string after the first
260                 \ with "<DATA>". */
261                 if (text_item) {
262                         /* first correct the length until the end of the packet */
263                         proto_item_set_len(text_item, tvb_length_remaining(tvb, offset));
264                         /* then replace the text */
265                         proto_item_set_text(text_item, "Text: getserversResponse<DATA>");
266                 }
267                 if (text_tree)
268                         proto_tree_add_string(text_tree, hf_quake3_connectionless_command,
269                                         tvb, offset, command_len,
270                                         val_to_str(command, names_command, "Unknown"));
271                 command_finished = TRUE;
272
273                 /* now we decode all the rest */
274                 base = offset + 18;
275                 /* '/', ip-address in network order, port in network order */
276                 while (tvb_reported_length_remaining(tvb, base) >= 7) {
277                         guint32         ip_addr;
278                         guint16         udp_port;
279                         proto_item      *server_item = NULL;
280                         proto_tree      *server_tree = NULL;
281
282                         tvb_memcpy(tvb, (guint8 *)&ip_addr, base + 1, 4);
283                         udp_port = tvb_get_ntohs(tvb, base + 5);
284
285                         /* It may be a good idea to create a conversation for
286                                 every server in this list, as we'll see at
287                                 least a getinfo request to each of them and they
288                                 may run on totally unusual ports.  */
289
290                         if (text_tree) {
291                                 server_item = proto_tree_add_text(text_tree,
292                                         tvb, base, 7,
293                                         "Server: %s:%u",
294                                                 get_hostname(ip_addr),
295                                                 udp_port);
296                                 if (server_item)
297                                         server_tree = proto_item_add_subtree(
298                                                 server_item,
299                                                 ett_quake3_server);
300                         }
301                         if (server_tree) {
302                                 proto_tree_add_ipv4(server_tree, hf_quake3_server_addr,
303                                         tvb, base + 1, 4, ip_addr);
304                                 proto_tree_add_uint(server_tree, hf_quake3_server_port,
305                                         tvb, base + 5, 2, udp_port);
306                         }
307
308                         base += 7;
309                 }
310         }
311         else if (strncmp(text, "getservers", 10) == 0) {
312                 command = COMMAND_getservers;
313                 *direction = DIR_C2M;
314                 command_len = 10;
315         }
316         else if (strncmp(text, "getKeyAuthorize", 15) == 0) {
317                 command = COMMAND_getKeyAuthorize;
318                 *direction = DIR_C2M;
319                 command_len = 15;
320         }
321         else if (strncmp(text, "getIpAuthorize", 14) == 0) {
322                 command = COMMAND_getIpAuthorize;
323                 *direction = DIR_C2M;
324                 command_len = 14;
325         }
326         else if (strncmp(text, "ipAuthorize", 11) == 0) {
327                 command = COMMAND_ipAuthorize;
328                 *direction = DIR_M2C;
329                 command_len = 11;
330         }
331         else {
332                 *direction = DIR_UNKNOWN;
333         }
334
335         if (text_tree && command_finished == FALSE) {
336                 proto_tree_add_string(text_tree, hf_quake3_connectionless_command,
337                                         tvb, offset, command_len,
338                                         val_to_str(command, names_command, "Unknown"));
339         }
340
341         offset += len + 1;
342
343 }
344
345
346 static void
347 dissect_quake3_client_commands(tvbuff_t *tvb, packet_info *pinfo,
348         proto_tree *tree)
349 {
350         /* this shouldn't be too difficult */
351         call_dissector(data_handle,tvb, pinfo, tree);
352 }
353
354
355 static void
356 dissect_quake3_server_commands(tvbuff_t *tvb, packet_info *pinfo,
357         proto_tree *tree)
358 {
359         /* It is totally forbidden to decode this any further,
360         I wont do it. */
361         call_dissector(data_handle,tvb, pinfo, tree);
362 }
363
364
365 static const value_string names_reliable[] = {
366         { 0, "Non Reliable" },
367         { 1, "Reliable" },
368         { 0, NULL }
369 };
370
371
372 static void
373 dissect_quake3_GamePacket(tvbuff_t *tvb, packet_info *pinfo,
374         proto_tree *tree, int *direction)
375 {
376         proto_tree      *game_tree = NULL;
377         proto_item      *game_item = NULL;
378         guint32         seq1;
379         guint32         seq2;
380         int             rel1;
381         int             rel2;
382         int             offset;
383         guint           rest_length;
384
385         *direction = (pinfo->destport == gbl_quake3_server_port) ?
386                         DIR_C2S : DIR_S2C;
387
388         if (tree) {
389                 game_item = proto_tree_add_text(tree, tvb,
390                                 0, -1, "Game");
391                 if (game_item)
392                         game_tree = proto_item_add_subtree(
393                                 game_item, ett_quake3_game);
394         }
395
396         offset = 0;
397
398         seq1 = tvb_get_letohs(tvb, offset);
399         rel1 = seq1 & 0x8000 ? 1 : 0;
400         seq1 &= ~0x8000;
401         if (game_tree) {
402                 proto_item *seq1_item = proto_tree_add_text(game_tree,
403                         tvb, offset, 2, "Current Sequence: %u (%s)",
404                         seq1, val_to_str(rel1,names_reliable,"%u"));
405                 if (seq1_item) {
406                         proto_tree *seq1_tree = proto_item_add_subtree(
407                                 seq1_item, ett_quake3_game_seq1);
408                         proto_tree_add_uint(seq1_tree, hf_quake3_game_seq1,
409                                         tvb, offset, 2, seq1);
410                         proto_tree_add_boolean(seq1_tree, hf_quake3_game_rel1,
411                                         tvb, offset+1, 1, rel1);
412                 }
413         }
414         offset += 2;
415
416         seq2 = tvb_get_letohs(tvb, offset);
417         rel2 = seq2 & 0x8000 ? 1 : 0;
418         seq2 &= ~0x8000;
419         if (game_tree) {
420                 proto_item *seq2_item = proto_tree_add_text(game_tree,
421                         tvb, offset, 2, "Acknowledge Sequence: %u (%s)",
422                         seq2, val_to_str(rel2,names_reliable,"%u"));;
423                 if (seq2_item) {
424                         proto_tree *seq2_tree = proto_item_add_subtree(
425                                 seq2_item, ett_quake3_game_seq2);
426                         proto_tree_add_uint(seq2_tree, hf_quake3_game_seq2,
427                                         tvb, offset, 2, seq2);
428                         proto_tree_add_boolean(seq2_tree, hf_quake3_game_rel2,
429                                         tvb, offset+1, 1, rel2);
430                 }
431         }
432         offset += 2;
433
434         if (*direction == DIR_C2S) {
435                 /* client to server */
436                 guint16 qport = tvb_get_letohs(tvb, offset);
437                 if (game_tree) {
438                         proto_tree_add_uint(game_tree, hf_quake3_game_qport,
439                                 tvb, offset, 2, qport);
440                 }
441                 offset +=2;
442         }
443
444         /* all the rest is pure game data */
445         rest_length = tvb_reported_length(tvb) - offset;
446         if (rest_length) {
447                 tvbuff_t *next_tvb =
448                 tvb_new_subset(tvb, offset, rest_length , rest_length);
449
450                 if (*direction == DIR_C2S) {
451                         proto_item *c_item = NULL;
452                         proto_tree *c_tree = NULL;
453                         if (tree) {
454                                 c_item = proto_tree_add_text(game_tree, next_tvb,
455                                 0, -1, "Client Commands");
456                                 if (c_item) {
457                                         c_tree = proto_item_add_subtree(
458                                                 c_item, ett_quake3_game_clc);
459                                 }
460                         }
461                         dissect_quake3_client_commands(next_tvb, pinfo, c_tree);
462                 }
463                 else {
464                         proto_item *c_item = NULL;
465                         proto_tree *c_tree = NULL;
466                         if (tree) {
467                                 c_item = proto_tree_add_text(game_tree, next_tvb,
468                                 0, -1, "Server Commands");
469                                 if (c_item) {
470                                         c_tree = proto_item_add_subtree(
471                                         c_item, ett_quake3_game_svc);
472                                 }
473                         }
474                         dissect_quake3_server_commands(next_tvb, pinfo, c_tree);
475                 }
476         }
477 }
478
479
480 static void
481 dissect_quake3(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
482 {
483         proto_tree      *quake3_tree = NULL;
484         proto_item      *quake3_item = NULL;
485         proto_item      *dir_item = NULL;
486         int             direction;
487
488         direction = DIR_UNKNOWN;
489
490         if (check_col(pinfo->cinfo, COL_PROTOCOL))
491                 col_set_str(pinfo->cinfo, COL_PROTOCOL, "QUAKE3");
492
493         if (tree) {
494                 quake3_item = proto_tree_add_item(tree, proto_quake3,
495                                 tvb, 0, -1, FALSE);
496                 if (quake3_item)
497                         quake3_tree = proto_item_add_subtree(
498                                 quake3_item, ett_quake3);
499
500                         if (quake3_tree) {
501                                 dir_item = proto_tree_add_none_format(
502                                         quake3_tree,
503                                         hf_quake3_direction, tvb, 0, 0,
504                                         "Direction: %s",
505                                         val_to_str(direction,
506                                                 names_direction, "%u"));
507                         }
508         }
509
510         if (tvb_get_ntohl(tvb, 0) == 0xffffffff) {
511                 if (check_col(pinfo->cinfo, COL_INFO)) {
512                         col_set_str(pinfo->cinfo, COL_INFO, "Connectionless ");
513                 }
514                 if (quake3_tree)
515                         proto_tree_add_uint_format(quake3_tree,
516                                 hf_quake3_connectionless,
517                                 tvb, 0, 0, 1,
518                                 "Type: Connectionless");
519                 dissect_quake3_ConnectionlessPacket(
520                         tvb, pinfo, quake3_tree, &direction);
521         }
522         else {
523                 if (check_col(pinfo->cinfo, COL_INFO)) {
524                         col_set_str(pinfo->cinfo, COL_INFO, "Game ");
525                 }
526                 if (quake3_tree)
527                         proto_tree_add_uint_format(quake3_tree,
528                                 hf_quake3_game,
529                                 tvb, 0, 0, 1,
530                                 "Type: Game");
531                 dissect_quake3_GamePacket(
532                         tvb, pinfo, quake3_tree, &direction);
533         }
534         if (direction != DIR_UNKNOWN && dir_item)
535                 proto_item_set_text(dir_item,
536                                         "Direction: %s",
537                                         val_to_str(direction,
538                                                 names_direction, "%u"));
539
540         if (check_col(pinfo->cinfo, COL_INFO))
541                 col_append_str(pinfo->cinfo, COL_INFO, val_to_str(direction,
542                         names_direction, "%u"));
543 }
544
545
546 void
547 proto_reg_handoff_quake3(void)
548 {
549         static int initialized=FALSE;
550         static dissector_handle_t quake3_handle;
551         static int server_port;
552         static int master_port;
553         int i;
554
555         if (!initialized) {
556                 quake3_handle = create_dissector_handle(dissect_quake3,
557                                 proto_quake3);
558                 initialized=TRUE;
559         } else {
560                 for (i=0;i<4;i++)
561                         dissector_delete("udp.port", server_port+i, quake3_handle);
562                 for (i=0;i<4;i++)
563                         dissector_delete("udp.port", master_port+i, quake3_handle);
564         }
565
566         /* set port for future deletes */
567         server_port = gbl_quake3_server_port;
568         master_port = gbl_quake3_master_port;
569
570         /* add dissectors */
571         for (i=0;i<4;i++)
572                 dissector_add("udp.port", gbl_quake3_server_port + i,
573                         quake3_handle);
574         for (i=0;i<4;i++)
575                 dissector_add("udp.port", gbl_quake3_master_port + i,
576                         quake3_handle);
577         data_handle = find_dissector("data");
578 }
579
580
581 void
582 proto_register_quake3(void)
583 {
584         static hf_register_info hf[] = {
585                 { &hf_quake3_direction,
586                         { "Direction", "quake3.direction",
587                         FT_NONE, BASE_DEC, NULL, 0x0,
588                         "Packet Direction", HFILL }},
589                 { &hf_quake3_connectionless,
590                         { "Connectionless", "quake3.connectionless",
591                         FT_UINT32, BASE_DEC, NULL, 0x0,
592                         "Connectionless", HFILL }},
593                 { &hf_quake3_game,
594                         { "Game", "quake3.game",
595                         FT_UINT32, BASE_DEC, NULL, 0x0,
596                         "Game", HFILL }},
597                 { &hf_quake3_connectionless_marker,
598                         { "Marker", "quake3.connectionless.marker",
599                         FT_UINT32, BASE_HEX, NULL, 0x0,
600                         "Marker", HFILL }},
601                 { &hf_quake3_connectionless_text,
602                         { "Text", "quake3.connectionless.text",
603                         FT_STRING, BASE_DEC, NULL, 0x0,
604                         "Text", HFILL }},
605                 { &hf_quake3_connectionless_command,
606                         { "Command", "quake3.connectionless.command",
607                         FT_STRING, BASE_DEC, NULL, 0x0,
608                         "Command", HFILL }},
609                 { &hf_quake3_server_addr,
610                         { "Server Address", "quake3.server.addr",
611                         FT_IPv4, BASE_DEC, NULL, 0x0,
612                         "Server IP Address", HFILL }},
613                 { &hf_quake3_server_port,
614                         { "Server Port", "quake3.server.port",
615                         FT_UINT16, BASE_DEC, NULL, 0x0,
616                         "Server UDP Port", HFILL }},
617                 { &hf_quake3_game_seq1,
618                         { "Sequence Number", "quake3.game.seq1",
619                         FT_UINT32, BASE_DEC, NULL, 0x0,
620                         "Sequence number of the current packet", HFILL }},
621                 { &hf_quake3_game_rel1,
622                         { "Reliable", "quake3.game.rel1",
623                         FT_BOOLEAN, BASE_DEC, NULL, 0x0,
624                         "Packet is reliable and may be retransmitted", HFILL }},
625                 { &hf_quake3_game_seq2,
626                         { "Sequence Number", "quake3.game.seq2",
627                         FT_UINT32, BASE_DEC, NULL, 0x0,
628                         "Sequence number of the last received packet", HFILL }},
629                 { &hf_quake3_game_rel2,
630                         { "Reliable", "quake3.game.rel2",
631                         FT_BOOLEAN, BASE_DEC, NULL, 0x0,
632                         "Packet was reliable and may be retransmitted", HFILL }},
633                 { &hf_quake3_game_qport,
634                         { "QPort", "quake3.game.qport",
635                         FT_UINT32, BASE_DEC, NULL, 0x0,
636                         "Quake III Arena Client Port", HFILL }}
637         };
638         static gint *ett[] = {
639                 &ett_quake3,
640                 &ett_quake3_connectionless,
641                 &ett_quake3_connectionless_text,
642                 &ett_quake3_server,
643                 &ett_quake3_game,
644                 &ett_quake3_game_seq1,
645                 &ett_quake3_game_seq2,
646                 &ett_quake3_game_clc,
647                 &ett_quake3_game_svc
648         };
649         module_t *quake3_module;
650
651         proto_quake3 = proto_register_protocol("Quake III Arena Network Protocol",
652                                                 "QUAKE3", "quake3");
653         proto_register_field_array(proto_quake3, hf, array_length(hf));
654         proto_register_subtree_array(ett, array_length(ett));
655
656         /* Register a configuration option for port */
657         quake3_module = prefs_register_protocol(proto_quake3,
658                 proto_reg_handoff_quake3);
659         prefs_register_uint_preference(quake3_module, "udp.arena_port",
660                                         "Quake III Arena Server UDP Base Port",
661                                         "Set the UDP base port for the Quake III Arena Server",
662                                         10, &gbl_quake3_server_port);
663         prefs_register_uint_preference(quake3_module, "udp.master_port",
664                                         "Quake III Arena Master Server UDP Base Port",
665                                         "Set the UDP base port for the Quake III Arena Master Server",
666                                         10, &gbl_quake3_master_port);
667 }