2 * Routines for Quake II packet dissection
4 * Uwe Girlich <uwe@planetquake.com>
5 * http://www.idsoftware.com/q1source/q1source.zip
6 * http://www.planetquake.com/demospecs/dm2
7 * http://www.dgs.monash.edu.au/~timf/bottim/
8 * http://www.opt-sci.Arizona.EDU/Pandora/default.asp
12 * Wireshark - Network traffic analyzer
13 * By Gerald Combs <gerald@wireshark.org>
14 * Copyright 1998 Gerald Combs
16 * Copied from packet-quakeworld.c
18 * This program is free software; you can redistribute it and/or
19 * modify it under the terms of the GNU General Public License
20 * as published by the Free Software Foundation; either version 2
21 * of the License, or (at your option) any later version.
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
28 * You should have received a copy of the GNU General Public License
29 * along with this program; if not, write to the Free Software
30 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
38 #include <epan/packet.h>
39 #include <epan/prefs.h>
41 static int proto_quake2 = -1;
43 static int hf_quake2_s2c = -1;
44 static int hf_quake2_c2s = -1;
45 static int hf_quake2_connectionless = -1;
46 static int hf_quake2_game = -1;
47 static int hf_quake2_connectionless_marker = -1;
48 static int hf_quake2_connectionless_text = -1;
49 static int hf_quake2_game_seq1 = -1;
50 static int hf_quake2_game_rel1 = -1;
51 static int hf_quake2_game_seq2 = -1;
52 static int hf_quake2_game_rel2 = -1;
53 static int hf_quake2_game_qport = -1;
54 static int hf_quake2_game_client_command = -1;
55 static int hf_quake2_game_server_command = -1;
56 static int hf_quake2_game_client_command_move = -1;
57 static int hf_quake2_game_client_command_move_chksum = -1;
58 static int hf_quake2_game_client_command_move_lframe = -1;
59 static int hf_quake2_game_client_command_move_bitfield_angles1 = -1;
60 static int hf_quake2_game_client_command_move_bitfield_angles2 = -1;
61 static int hf_quake2_game_client_command_move_bitfield_angles3 = -1;
62 static int hf_quake2_game_client_command_move_bitfield_movement_fwd = -1;
63 static int hf_quake2_game_client_command_move_bitfield_movement_side = -1;
64 static int hf_quake2_game_client_command_move_bitfield_movement_up = -1;
65 static int hf_quake2_game_client_command_move_bitfield_buttons = -1;
66 static int hf_quake2_game_client_command_move_bitfield_impulse = -1;
67 static int hf_quake2_game_client_command_move_msec = -1;
68 static int hf_quake2_game_client_command_move_lightlevel = -1;
70 static gint ett_quake2 = -1;
71 static gint ett_quake2_connectionless = -1;
72 static gint ett_quake2_game = -1;
73 static gint ett_quake2_game_seq1 = -1;
74 static gint ett_quake2_game_seq2 = -1;
75 static gint ett_quake2_game_clc = -1;
76 static gint ett_quake2_game_svc = -1;
77 static gint ett_quake2_game_clc_cmd = -1;
78 static gint ett_quake2_game_svc_cmd = -1;
79 static gint ett_quake2_game_clc_cmd_move_bitfield = -1;
80 static gint ett_quake2_game_clc_cmd_move_moves = -1;
83 static dissector_handle_t data_handle;
85 #define PORT_MASTER 27910
86 static guint gbl_quake2ServerPort=PORT_MASTER;
90 dissect_quake2_ConnectionlessPacket(tvbuff_t *tvb, packet_info *pinfo _U_,
91 proto_tree *tree, int direction _U_)
93 proto_tree *cl_tree = NULL;
100 marker = tvb_get_ntohl(tvb, 0);
102 proto_item *cl_item = NULL;
103 cl_item = proto_tree_add_text(tree, tvb,
104 0, -1, "Connectionless");
105 cl_tree = proto_item_add_subtree(cl_item, ett_quake2_connectionless);
106 proto_tree_add_uint(cl_tree, hf_quake2_connectionless_marker,
110 /* all the rest of the packet is just text */
113 len = tvb_length_remaining(tvb, offset);
115 text = tvb_get_ephemeral_string(tvb, offset, len);
116 proto_tree_add_string(cl_tree, hf_quake2_connectionless_text,
117 tvb, offset, len, text);
121 /* we should analyse the result 'text' a bit further */
122 /* for this we need the direction parameter */
125 static const value_string hf_quake2_game_client_command_move_vals[] = {
132 dissect_quake2_client_commands_move(tvbuff_t *tvb, packet_info *pinfo _U_,
135 #define MOVES 3 /* 3 updates per command */
137 /* taken from qcommon.h */
138 #define CM_ANGLE1 (1<<0)
139 #define CM_ANGLE2 (1<<1)
140 #define CM_ANGLE3 (1<<2)
141 #define CM_FORWARD (1<<3)
142 #define CM_SIDE (1<<4)
144 #define CM_BUTTONS (1<<6)
145 #define CM_IMPULSE (1<<7)
147 #define BUTTON_ATTACK 1
149 #define BUTTON_ANY 128
154 enum { Q_OFFSET, Q_VALUE, Q_SIZE };
157 guint16 angles[3][Q_SIZE];
158 gint16 movement[3][Q_SIZE];
159 guint8 buttons[Q_SIZE];
160 guint8 lightlevel[Q_SIZE];
162 guint8 impulse[Q_SIZE];
165 chksum = tvb_get_guint8(tvb, offset);
167 lastframe = tvb_get_letohl(tvb, offset);
170 for (i=0; i < MOVES; i++) {
171 move[i].bits[Q_VALUE] = tvb_get_guint8(tvb, offset);
172 move[i].bits[Q_OFFSET] = offset;
174 if (move[i].bits[Q_VALUE] & CM_ANGLE1) {
175 move[i].angles[0][Q_VALUE] = tvb_get_letohs(tvb, offset);
176 move[i].angles[0][Q_OFFSET] = offset;
179 if (move[i].bits[Q_VALUE] & CM_ANGLE2) {
180 move[i].angles[1][Q_VALUE] = tvb_get_letohs(tvb, offset);
181 move[i].angles[1][Q_OFFSET] = offset;
184 if (move[i].bits[Q_VALUE] & CM_ANGLE3) {
185 move[i].angles[2][Q_VALUE] = tvb_get_letohs(tvb, offset);
186 move[i].angles[2][Q_OFFSET] = offset;
189 if (move[i].bits[Q_VALUE] & CM_FORWARD) {
190 move[i].movement[0][Q_VALUE] = tvb_get_letohs(tvb, offset);
191 move[i].movement[0][Q_OFFSET] = offset;
194 if (move[i].bits[Q_VALUE] & CM_SIDE) {
195 move[i].movement[1][Q_VALUE] = tvb_get_letohs(tvb, offset);
196 move[i].movement[1][Q_OFFSET] = offset;
199 if (move[i].bits[Q_VALUE] & CM_UP) {
200 move[i].movement[2][Q_VALUE] = tvb_get_letohs(tvb, offset);
201 move[i].movement[2][Q_OFFSET] = offset;
204 if (move[i].bits[Q_VALUE] & CM_BUTTONS) {
205 move[i].buttons[Q_VALUE] = tvb_get_guint8(tvb, offset);
206 move[i].buttons[Q_OFFSET] = offset;
209 if (move[i].bits[Q_VALUE] & CM_IMPULSE) {
210 move[i].impulse[Q_VALUE] = tvb_get_guint8(tvb, offset);
211 move[i].impulse[Q_OFFSET] = offset;
215 move[i].msec[Q_VALUE] = tvb_get_guint8(tvb, offset);
216 move[i].msec[Q_OFFSET] = offset;
218 move[i].lightlevel[Q_VALUE] = tvb_get_guint8(tvb, offset);
219 move[i].lightlevel[Q_OFFSET] = offset;
226 proto_tree_add_uint(tree, hf_quake2_game_client_command_move_chksum, tvb,
228 proto_tree_add_uint(tree, hf_quake2_game_client_command_move_lframe, tvb,
231 move[MOVES].bits[Q_OFFSET] = offset;
232 for (i=0; i < MOVES; i++) {
233 proto_item *move_item, *movebits_item, *bit_item;
234 proto_item *sub_tree, *field_tree;
235 #define SHORT2ANGLE(x) ((float)x/65536.0*360.0)
237 move_item = proto_tree_add_text(tree,
239 move[i].bits[Q_OFFSET],
240 move[i+1].bits[Q_OFFSET]-move[i].bits[Q_OFFSET],
242 sub_tree = proto_item_add_subtree(move_item,
243 ett_quake2_game_clc_cmd_move_moves);
246 proto_tree_add_uint(sub_tree, hf_quake2_game_client_command_move,
248 move[i].bits[Q_OFFSET],
250 move[i].bits[Q_VALUE]);
252 proto_tree_add_uint(sub_tree,
253 hf_quake2_game_client_command_move_msec,
254 tvb, move[i].msec[Q_OFFSET], 1, move[i].msec[Q_VALUE]);
255 proto_tree_add_uint(sub_tree,
256 hf_quake2_game_client_command_move_lightlevel,
257 tvb, move[i].lightlevel[Q_OFFSET], 1, move[i].lightlevel[Q_VALUE]);
259 if (move[i].bits[Q_VALUE] == 0) {
260 proto_item_append_text(movebits_item, " (no moves)");
264 field_tree = proto_item_add_subtree(movebits_item,
265 ett_quake2_game_clc_cmd_move_bitfield);
267 if (move[i].bits[Q_VALUE] & CM_ANGLE1) {
268 bit_item = proto_tree_add_uint(field_tree,
269 hf_quake2_game_client_command_move_bitfield_angles1, tvb,
270 move[i].angles[0][Q_OFFSET], 2, move[i].bits[Q_VALUE]);
271 proto_item_append_text(bit_item, " (%d", move[i].angles[0][Q_VALUE]);
272 proto_item_append_text(bit_item, " = %.2f deg)",
273 SHORT2ANGLE(move[i].angles[0][Q_VALUE]));
276 if (move[i].bits[Q_VALUE] & CM_ANGLE2) {
277 bit_item = proto_tree_add_uint(field_tree,
278 hf_quake2_game_client_command_move_bitfield_angles2, tvb,
279 move[i].angles[1][Q_OFFSET], 2, move[i].bits[Q_VALUE]);
280 proto_item_append_text(bit_item, " (%d", move[i].angles[1][Q_VALUE]);
281 proto_item_append_text(bit_item, " = %.2f deg)",
282 SHORT2ANGLE(move[i].angles[1][Q_VALUE]));
284 if (move[i].bits[Q_VALUE] & CM_ANGLE3) {
285 bit_item = proto_tree_add_uint(field_tree,
286 hf_quake2_game_client_command_move_bitfield_angles3, tvb,
287 move[i].angles[2][Q_OFFSET], 2, move[i].bits[Q_VALUE]);
288 proto_item_append_text(bit_item, " (%d", move[i].angles[2][Q_VALUE]);
289 proto_item_append_text(bit_item, " = %.2f deg)",
290 SHORT2ANGLE(move[i].angles[2][Q_VALUE]));
292 if (move[i].bits[Q_VALUE] & CM_FORWARD) {
293 bit_item = proto_tree_add_uint(field_tree,
294 hf_quake2_game_client_command_move_bitfield_movement_fwd, tvb,
295 move[i].movement[0][Q_OFFSET], 2, move[i].bits[Q_VALUE]);
296 proto_item_append_text(bit_item, " (%hd)",
297 move[i].movement[0][Q_VALUE]);
299 if (move[i].bits[Q_VALUE] & CM_SIDE) {
300 bit_item = proto_tree_add_uint(field_tree,
301 hf_quake2_game_client_command_move_bitfield_movement_side, tvb,
302 move[i].movement[1][Q_OFFSET], 2, move[i].bits[Q_VALUE]);
303 proto_item_append_text(bit_item, " (%hd)",
304 move[i].movement[1][Q_VALUE]);
306 if (move[i].bits[Q_VALUE] & CM_UP) {
307 bit_item = proto_tree_add_uint(field_tree,
308 hf_quake2_game_client_command_move_bitfield_movement_up, tvb,
309 move[i].movement[2][Q_OFFSET], 2, move[i].bits[Q_VALUE]);
310 proto_item_append_text(bit_item, " (%hd)",
311 move[i].movement[2][Q_VALUE]);
313 if (move[i].bits[Q_VALUE] & CM_BUTTONS) {
314 bit_item = proto_tree_add_uint(field_tree,
315 hf_quake2_game_client_command_move_bitfield_buttons, tvb,
316 move[i].buttons[Q_OFFSET], 1, move[i].bits[Q_VALUE]);
317 proto_item_append_text(bit_item, " (%d)",
318 move[i].buttons[Q_VALUE]);
319 if (move[i].buttons[Q_VALUE] & BUTTON_ATTACK)
320 proto_item_append_text(bit_item, " (Attack)");
321 if (move[i].buttons[Q_VALUE] & BUTTON_USE)
322 proto_item_append_text(bit_item, " (Use)");
323 if (move[i].buttons[Q_VALUE] & BUTTON_ANY)
324 proto_item_append_text(bit_item, " (Any)");
326 if (move[i].bits[Q_VALUE] & CM_IMPULSE) {
327 bit_item = proto_tree_add_uint(field_tree,
328 hf_quake2_game_client_command_move_bitfield_impulse, tvb,
329 move[i].impulse[Q_OFFSET], 1, move[i].bits[Q_VALUE]);
330 proto_item_append_text(bit_item, " (%d)",
331 move[i].impulse[Q_VALUE]);
340 dissect_quake2_client_commands_uinfo(tvbuff_t *tvb, packet_info *pinfo _U_,
344 proto_item *userinfo_item;
346 len = tvb_strsize(tvb, 0);
349 userinfo_item = proto_tree_add_text(tree, tvb, 0, len, "Userinfo: %s",
350 tvb_get_ptr(tvb, 0, len));
357 dissect_quake2_client_commands_stringcmd(tvbuff_t *tvb, packet_info *pinfo _U_,
361 proto_item *stringcmd_item;
363 len = tvb_strsize(tvb, 0);
366 stringcmd_item = proto_tree_add_text(tree, tvb, 0, len, "Command: %s",
367 tvb_get_ptr(tvb, 0, len));
373 static const value_string names_client_cmd[] = {
376 { CLC_BAD, "clc_bad" },
378 { CLC_NOP, "clc_nop" },
380 { CLC_MOVE, "clc_move" },
381 #define CLC_USERINFO 3
382 { CLC_USERINFO, "clc_userinfo" },
383 #define CLC_STRINGCMD 4
384 { CLC_STRINGCMD, "clc_stringcmd" },
389 dissect_quake2_client_commands(tvbuff_t *tvb, packet_info *pinfo,
392 proto_tree *clc_tree = NULL;
393 tvbuff_t *next_tvb = NULL;
394 guint8 client_cmd_type;
395 guint rest_length = 0;
399 client_cmd_type = tvb_get_guint8(tvb, offset);
402 proto_item *cmd_type_item = proto_tree_add_uint(tree,
403 hf_quake2_game_client_command, tvb, offset, 1,
406 proto_item_append_text(cmd_type_item, " (%s)",
407 val_to_str(client_cmd_type, names_client_cmd, "%u"));
408 clc_tree = proto_item_add_subtree(cmd_type_item, ett_quake2_game_clc_cmd);
412 rest_length = tvb_reported_length(tvb) - offset;
414 next_tvb = tvb_new_subset(tvb, offset,
415 rest_length, rest_length);
420 switch (client_cmd_type) {
427 dissect_quake2_client_commands_move(next_tvb,
432 dissect_quake2_client_commands_uinfo(next_tvb,
437 dissect_quake2_client_commands_stringcmd(next_tvb,
443 offset += rest_length;
444 } while (tvb_reported_length(tvb) - offset > 0);
447 static const value_string names_server_cmd[] = {
450 { SVC_BAD, "svc_bad" },
451 #define SVC_MUZZLEFLASH 1
452 { SVC_MUZZLEFLASH, "svc_muzzleflash" },
453 #define SVC_MUZZLEFLASH2 2
454 { SVC_MUZZLEFLASH2, "svc_muzzleflash2" },
455 #define SVC_TEMP_ENTITY 3
456 { SVC_TEMP_ENTITY, "svc_temp_entity" },
458 { SVC_LAYOUT, "svc_layout" },
459 #define SVC_INVENTORY 5
460 { SVC_INVENTORY, "svc_inventory" },
462 { SVC_NOP, "svc_nop" },
463 #define SVC_DISCONNECT 7
464 { SVC_DISCONNECT, "svc_disconnect" },
465 #define SVC_RECONNECT 8
466 { SVC_RECONNECT, "svc_reconnect" },
468 { SVC_SOUND, "svc_sound" },
470 { SVC_PRINT, "svc_print" },
471 #define SVC_STUFFTEXT 11
472 { SVC_STUFFTEXT, "svc_stufftext" },
473 #define SVC_SERVERDATA 12
474 { SVC_SERVERDATA, "svc_serverdata" },
475 #define SVC_CONFIGSTRING 13
476 { SVC_CONFIGSTRING, "svc_configstring" },
477 #define SVC_SPAWNBASELINE 14
478 { SVC_SPAWNBASELINE, "svc_spawnbaseline" },
479 #define SVC_CENTERPRINT 15
480 { SVC_CENTERPRINT, "svc_centerprint" },
481 #define SVC_DOWNLOAD 16
482 { SVC_DOWNLOAD, "svc_download" },
483 #define SVC_PLAYERINFO 17
484 { SVC_PLAYERINFO, "svc_playerinfo" },
485 #define SVC_PACKETENTITIES 18
486 { SVC_PACKETENTITIES, "svc_packetentities" },
487 #define SVC_DELTAPACKETENTITIES 19
488 { SVC_DELTAPACKETENTITIES, "svc_deltapacketentities" },
490 { SVC_FRAME, "svc_frame" },
495 dissect_quake2_server_commands(tvbuff_t *tvb, packet_info *pinfo,
498 tvbuff_t *next_tvb = NULL;
499 guint8 server_cmd_type;
500 guint rest_length = 0;
503 server_cmd_type = tvb_get_guint8(tvb, offset);
506 proto_item *cmd_type_item;
507 cmd_type_item = proto_tree_add_uint(tree,
508 hf_quake2_game_server_command, tvb, offset, 1, server_cmd_type);
510 proto_item_append_text(cmd_type_item, " (%s)",
511 val_to_str(server_cmd_type, names_server_cmd, "%u"));
515 rest_length = tvb_reported_length(tvb) - offset;
517 next_tvb = tvb_new_subset(tvb, offset, rest_length, rest_length);
522 switch (server_cmd_type) {
525 case SVC_MUZZLEFLASH:
527 case SVC_MUZZLEFLASH2:
529 case SVC_TEMP_ENTITY:
547 case SVC_CONFIGSTRING:
549 case SVC_SPAWNBASELINE:
551 case SVC_CENTERPRINT:
557 case SVC_PACKETENTITIES:
559 case SVC_DELTAPACKETENTITIES:
567 call_dissector(data_handle, next_tvb, pinfo, tree);
571 static const value_string names_reliable[] = {
572 { 0, "Non Reliable" },
577 static const value_string names_direction[] = {
579 { DIR_C2S, "Client to Server" },
581 { DIR_S2C, "Server to Client" },
587 dissect_quake2_GamePacket(tvbuff_t *tvb, packet_info *pinfo,
588 proto_tree *tree, int direction)
590 proto_tree *game_tree = NULL;
598 direction = (pinfo->destport == gbl_quake2ServerPort) ?
602 proto_item *game_item;
603 game_item = proto_tree_add_text(tree, tvb,
605 game_tree = proto_item_add_subtree(game_item, ett_quake2_game);
610 seq1 = tvb_get_letohl(tvb, offset);
611 rel1 = seq1 & 0x80000000 ? 1 : 0;
614 proto_item *seq1_item = proto_tree_add_text(game_tree,
615 tvb, offset, 4, "Current Sequence: %u (%s)",
616 seq1, val_to_str(rel1,names_reliable,"%u"));
617 proto_tree *seq1_tree = proto_item_add_subtree(
618 seq1_item, ett_quake2_game_seq1);
619 proto_tree_add_uint(seq1_tree, hf_quake2_game_seq1,
620 tvb, offset, 4, seq1);
621 proto_tree_add_boolean(seq1_tree, hf_quake2_game_rel1,
622 tvb, offset+3, 1, rel1);
626 seq2 = tvb_get_letohl(tvb, offset);
627 rel2 = seq2 & 0x80000000 ? 1 : 0;
630 proto_item *seq2_item = proto_tree_add_text(game_tree,
631 tvb, offset, 4, "Acknowledge Sequence: %u (%s)",
632 seq2, val_to_str(rel2,names_reliable,"%u"));
633 proto_tree *seq2_tree = proto_item_add_subtree(
634 seq2_item, ett_quake2_game_seq2);
635 proto_tree_add_uint(seq2_tree, hf_quake2_game_seq2,
636 tvb, offset, 4, seq2);
637 proto_tree_add_boolean(seq2_tree, hf_quake2_game_rel2,
638 tvb, offset+3, 1, rel2);
642 if (direction == DIR_C2S) {
643 /* client to server */
644 guint16 qport = tvb_get_letohs(tvb, offset);
646 proto_tree_add_uint(game_tree, hf_quake2_game_qport,
647 tvb, offset, 2, qport);
652 /* all the rest is pure game data */
653 rest_length = tvb_reported_length(tvb) - offset;
656 tvb_new_subset(tvb, offset, rest_length , rest_length);
658 if (direction == DIR_C2S) {
659 proto_tree *c_tree = NULL;
662 c_item = proto_tree_add_text(game_tree, next_tvb,
663 0, -1, "Client Commands");
664 c_tree = proto_item_add_subtree(c_item, ett_quake2_game_clc);
666 dissect_quake2_client_commands(next_tvb, pinfo, c_tree);
669 proto_tree *c_tree = NULL;
672 c_item = proto_tree_add_text(game_tree, next_tvb,
673 0, -1, "Server Commands");
674 c_tree = proto_item_add_subtree(c_item, ett_quake2_game_svc);
676 dissect_quake2_server_commands(next_tvb, pinfo, c_tree);
683 dissect_quake2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
685 proto_tree *quake2_tree = NULL;
688 direction = (pinfo->destport == gbl_quake2ServerPort) ?
691 col_set_str(pinfo->cinfo, COL_PROTOCOL, "QUAKE2");
692 if (check_col(pinfo->cinfo, COL_INFO))
693 col_add_str(pinfo->cinfo, COL_INFO, val_to_str(direction,
694 names_direction, "%u"));
697 proto_item *quake2_item;
698 quake2_item = proto_tree_add_item(tree, proto_quake2,
700 quake2_tree = proto_item_add_subtree(quake2_item, ett_quake2);
701 proto_tree_add_uint_format(quake2_tree,
702 direction == DIR_S2C ?
706 "Direction: %s", val_to_str(direction, names_direction, "%u"));
709 if (tvb_get_ntohl(tvb, 0) == 0xffffffff) {
710 col_append_str(pinfo->cinfo, COL_INFO, " Connectionless");
712 proto_tree_add_uint_format(quake2_tree,
713 hf_quake2_connectionless,
715 "Type: Connectionless");
716 dissect_quake2_ConnectionlessPacket(
717 tvb, pinfo, quake2_tree, direction);
720 col_append_str(pinfo->cinfo, COL_INFO, " Game");
722 proto_tree_add_uint_format(quake2_tree,
726 dissect_quake2_GamePacket(
727 tvb, pinfo, quake2_tree, direction);
732 void proto_reg_handoff_quake2(void);
735 proto_register_quake2(void)
737 static hf_register_info hf[] = {
739 { "Client to Server", "quake2.c2s",
740 FT_UINT32, BASE_DEC, NULL, 0x0,
743 { "Server to Client", "quake2.s2c",
744 FT_UINT32, BASE_DEC, NULL, 0x0,
746 { &hf_quake2_connectionless,
747 { "Connectionless", "quake2.connectionless",
748 FT_UINT32, BASE_DEC, NULL, 0x0,
751 { "Game", "quake2.game",
752 FT_UINT32, BASE_DEC, NULL, 0x0,
754 { &hf_quake2_connectionless_marker,
755 { "Marker", "quake2.connectionless.marker",
756 FT_UINT32, BASE_HEX, NULL, 0x0,
758 { &hf_quake2_connectionless_text,
759 { "Text", "quake2.connectionless.text",
760 FT_STRING, BASE_NONE, NULL, 0x0,
762 { &hf_quake2_game_seq1,
763 { "Sequence Number", "quake2.game.seq1",
764 FT_UINT32, BASE_DEC, NULL, 0x0,
765 "Sequence number of the current packet", HFILL }},
766 { &hf_quake2_game_rel1,
767 { "Reliable", "quake2.game.rel1",
768 FT_BOOLEAN, BASE_NONE, NULL, 0x0,
769 "Packet is reliable and may be retransmitted", HFILL }},
770 { &hf_quake2_game_seq2,
771 { "Sequence Number", "quake2.game.seq2",
772 FT_UINT32, BASE_DEC, NULL, 0x0,
773 "Sequence number of the last received packet", HFILL }},
774 { &hf_quake2_game_rel2,
775 { "Reliable", "quake2.game.rel2",
776 FT_BOOLEAN, BASE_NONE, NULL, 0x0,
777 "Packet was reliable and may be retransmitted", HFILL }},
778 { &hf_quake2_game_qport,
779 { "QPort", "quake2.game.qport",
780 FT_UINT32, BASE_DEC, NULL, 0x0,
781 "Quake II Client Port", HFILL }},
782 { &hf_quake2_game_client_command,
783 { "Client Command Type", "quake2.game.client.command",
784 FT_UINT8, BASE_DEC, NULL, 0x0,
785 "Quake II Client Command", HFILL }},
786 { &hf_quake2_game_server_command,
787 { "Server Command", "quake2.game.server.command",
788 FT_UINT8, BASE_DEC, NULL, 0x0,
789 "Quake II Server Command", HFILL }},
790 { &hf_quake2_game_client_command_move_chksum,
791 { "Checksum", "quake2.game.client.command.move.chksum",
792 FT_UINT8, BASE_HEX, NULL, 0x0,
793 "Quake II Client Command Move", HFILL }},
794 { &hf_quake2_game_client_command_move_lframe,
795 { "Last Frame", "quake2.game.client.command.move.lframe",
796 FT_UINT32, BASE_DEC, NULL, 0x0,
797 "Quake II Client Command Move", HFILL }},
798 { &hf_quake2_game_client_command_move,
799 { "Bitfield", "quake2.game.client.command.move",
800 FT_UINT8, BASE_HEX, NULL, 0x0,
801 "Quake II Client Command Move", HFILL }},
802 { &hf_quake2_game_client_command_move_bitfield_angles1,
803 { "Angles (pitch)", "quake2.game.client.command.move.angles",
805 VALS(hf_quake2_game_client_command_move_vals),
806 CM_ANGLE1, NULL, HFILL }},
807 { &hf_quake2_game_client_command_move_bitfield_angles2,
808 { "Angles (yaw)", "quake2.game.client.command.move.angles",
810 VALS(hf_quake2_game_client_command_move_vals),
811 CM_ANGLE2, NULL, HFILL }},
812 { &hf_quake2_game_client_command_move_bitfield_angles3,
813 { "Angles (roll)", "quake2.game.client.command.move.angles",
815 VALS(hf_quake2_game_client_command_move_vals),
816 CM_ANGLE3, NULL, HFILL }},
817 { &hf_quake2_game_client_command_move_bitfield_movement_fwd,
818 { "Movement (fwd)", "quake2.game.client.command.move.movement",
820 VALS(hf_quake2_game_client_command_move_vals),
821 CM_FORWARD, NULL, HFILL }},
822 { &hf_quake2_game_client_command_move_bitfield_movement_side,
823 { "Movement (side)", "quake2.game.client.command.move.movement",
825 VALS(hf_quake2_game_client_command_move_vals),
826 CM_SIDE, NULL, HFILL }},
827 { &hf_quake2_game_client_command_move_bitfield_movement_up,
828 { "Movement (up)", "quake2.game.client.command.move.movement",
830 VALS(hf_quake2_game_client_command_move_vals),
831 CM_UP, NULL, HFILL }},
832 { &hf_quake2_game_client_command_move_bitfield_buttons,
833 { "Buttons", "quake2.game.client.command.move.buttons",
835 VALS(hf_quake2_game_client_command_move_vals),
836 CM_BUTTONS, NULL, HFILL }},
837 { &hf_quake2_game_client_command_move_bitfield_impulse,
838 { "Impulse", "quake2.game.client.command.move.impulse",
840 VALS(hf_quake2_game_client_command_move_vals),
841 CM_IMPULSE, NULL, HFILL }},
842 { &hf_quake2_game_client_command_move_msec,
843 { "Msec", "quake2.game.client.command.move.msec",
844 FT_UINT8, BASE_DEC, NULL, 0x0,
845 "Quake II Client Command Move", HFILL }},
846 { &hf_quake2_game_client_command_move_lightlevel,
847 { "Lightlevel", "quake2.game.client.command.move.lightlevel",
848 FT_UINT8, BASE_DEC, NULL, 0x0,
849 "Quake II Client Command Move", HFILL }}
851 static gint *ett[] = {
853 &ett_quake2_connectionless,
855 &ett_quake2_game_seq1,
856 &ett_quake2_game_seq2,
857 &ett_quake2_game_clc,
858 &ett_quake2_game_svc,
859 &ett_quake2_game_clc_cmd,
860 &ett_quake2_game_svc_cmd,
861 &ett_quake2_game_clc_cmd_move_moves,
862 &ett_quake2_game_clc_cmd_move_bitfield
864 module_t *quake2_module;
866 proto_quake2 = proto_register_protocol("Quake II Network Protocol",
868 proto_register_field_array(proto_quake2, hf, array_length(hf));
869 proto_register_subtree_array(ett, array_length(ett));
871 /* Register a configuration option for port */
872 quake2_module = prefs_register_protocol(proto_quake2,
873 proto_reg_handoff_quake2);
874 prefs_register_uint_preference(quake2_module, "udp.port",
875 "Quake II Server UDP Port",
876 "Set the UDP port for the Quake II Server",
877 10, &gbl_quake2ServerPort);
882 proto_reg_handoff_quake2(void)
884 static gboolean Initialized=FALSE;
885 static dissector_handle_t quake2_handle;
886 static guint ServerPort;
889 quake2_handle = create_dissector_handle(dissect_quake2,
891 data_handle = find_dissector("data");
894 dissector_delete("udp.port", ServerPort, quake2_handle);
897 /* set port for future deletes */
898 ServerPort=gbl_quake2ServerPort;
900 dissector_add("udp.port", gbl_quake2ServerPort, quake2_handle);