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