2000-07-27 10:57:12 +00:00
|
|
|
/* packet-quake.c
|
2001-06-21 15:13:42 +00:00
|
|
|
* Routines for Quake packet dissection
|
2000-07-27 10:57:12 +00:00
|
|
|
*
|
|
|
|
* Uwe Girlich <uwe@planetquake.com>
|
|
|
|
* http://www.idsoftware.com/q1source/q1source.zip
|
|
|
|
*
|
2004-07-18 00:24:25 +00:00
|
|
|
* $Id$
|
2000-07-27 10:57:12 +00:00
|
|
|
*
|
2006-05-21 04:49:01 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
2000-07-27 10:57:12 +00:00
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
|
|
|
* Copied from packet-tftp.c
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
2000-07-27 10:57:12 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
2000-07-27 10:57:12 +00:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
2000-07-27 10:57:12 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <glib.h>
|
2002-01-21 07:37:49 +00:00
|
|
|
#include <epan/packet.h>
|
|
|
|
#include <epan/conversation.h>
|
2004-09-27 22:55:15 +00:00
|
|
|
#include <epan/prefs.h>
|
2000-07-27 10:57:12 +00:00
|
|
|
|
|
|
|
static int proto_quake = -1;
|
2002-08-28 21:04:11 +00:00
|
|
|
static int hf_quake_header_flags = -1;
|
|
|
|
static int hf_quake_header_length = -1;
|
|
|
|
static int hf_quake_header_sequence = -1;
|
2000-07-27 10:57:12 +00:00
|
|
|
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;
|
2000-07-31 12:59:51 +00:00
|
|
|
static gint ett_quake_flags = -1;
|
2000-07-27 10:57:12 +00:00
|
|
|
|
2001-11-27 07:13:32 +00:00
|
|
|
static dissector_handle_t quake_handle;
|
2001-11-25 22:19:25 +00:00
|
|
|
static dissector_handle_t data_handle;
|
2000-07-27 10:57:12 +00:00
|
|
|
|
|
|
|
/* I took these names directly out of the Q1 source. */
|
|
|
|
#define NETFLAG_LENGTH_MASK 0x0000ffff
|
|
|
|
#define NET_HEADERSIZE 8
|
|
|
|
#define DEFAULTnet_hostport 26000
|
2008-09-23 01:10:45 +00:00
|
|
|
static guint gbl_quakeServerPort=DEFAULTnet_hostport;
|
2000-07-27 10:57:12 +00:00
|
|
|
|
|
|
|
#define NETFLAG_LENGTH_MASK 0x0000ffff
|
|
|
|
#define NETFLAG_DATA 0x00010000
|
|
|
|
#define NETFLAG_ACK 0x00020000
|
|
|
|
#define NETFLAG_NAK 0x00040000
|
|
|
|
#define NETFLAG_EOM 0x00080000
|
|
|
|
#define NETFLAG_UNRELIABLE 0x00100000
|
2002-08-28 21:04:11 +00:00
|
|
|
#define NETFLAG_CTL 0x80000000
|
2000-07-27 10:57:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
#define CCREQ_CONNECT 0x01
|
|
|
|
#define CCREQ_SERVER_INFO 0x02
|
|
|
|
#define CCREQ_PLAYER_INFO 0x03
|
|
|
|
#define CCREQ_RULE_INFO 0x04
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2000-07-27 10:57:12 +00:00
|
|
|
#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, "Blue" },
|
|
|
|
{ 15, "Blue" },
|
|
|
|
{ 0, NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2000-07-31 12:59:51 +00:00
|
|
|
static void dissect_quake(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
|
|
|
|
|
|
|
|
|
2000-07-27 10:57:12 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
dissect_quake_CCREQ_CONNECT
|
2002-04-02 06:28:16 +00:00
|
|
|
(tvbuff_t *tvb, proto_tree *tree)
|
2000-07-27 10:57:12 +00:00
|
|
|
{
|
Add new routines:
tvb_get_string() - takes a tvbuff, an offset, and a length as
arguments, allocates a buffer big enough to hold a string with
the specified number of bytes plus an added null terminator
(i.e., length+1), copies the specified number of bytes from the
tvbuff, at the specified offset, to that buffer and puts in a
null terminator, and returns a pointer to that buffer (or throws
an exception before allocating the buffer if that many bytes
aren't available in the tvbuff);
tvb_get_stringz() - takes a tvbuff, an offset, and a pointer to
a "gint" as arguments, gets the size of the null-terminated
string starting at the specified offset in the tvbuff (throwing
an exception if the null terminator isn't found), allocates a
buffer big enough to hold that string, copies the string to that
buffer, and returns a pointer to that buffer and stores the
length of the string (including the terminating null) in the
variable pointed to by the "gint" pointer.
Replace many pieces of code allocating a buffer and copying a string
with calls to "tvb_get_string()" (for one thing, "tvb_get_string()"
doesn't require you to remember that the argument to
"tvb_get_nstringz0()" is the size of the buffer into which you're
copying the string, which might be the length of the string to be copied
*plus 1*).
Don't use fixed-length buffers for null-terminated strings (even if the
code that generates those packets has a #define to limit the length of
the string). Use "tvb_get_stringz()", instead.
In some cases where a value is fetched but is only used to pass an
argument to a "proto_tree_add_XXX" routine, use "proto_tree_add_item()"
instead.
svn path=/trunk/; revision=7859
2003-06-12 08:33:32 +00:00
|
|
|
gint offset;
|
|
|
|
proto_item *ti;
|
2000-07-27 10:57:12 +00:00
|
|
|
|
Add new routines:
tvb_get_string() - takes a tvbuff, an offset, and a length as
arguments, allocates a buffer big enough to hold a string with
the specified number of bytes plus an added null terminator
(i.e., length+1), copies the specified number of bytes from the
tvbuff, at the specified offset, to that buffer and puts in a
null terminator, and returns a pointer to that buffer (or throws
an exception before allocating the buffer if that many bytes
aren't available in the tvbuff);
tvb_get_stringz() - takes a tvbuff, an offset, and a pointer to
a "gint" as arguments, gets the size of the null-terminated
string starting at the specified offset in the tvbuff (throwing
an exception if the null terminator isn't found), allocates a
buffer big enough to hold that string, copies the string to that
buffer, and returns a pointer to that buffer and stores the
length of the string (including the terminating null) in the
variable pointed to by the "gint" pointer.
Replace many pieces of code allocating a buffer and copying a string
with calls to "tvb_get_string()" (for one thing, "tvb_get_string()"
doesn't require you to remember that the argument to
"tvb_get_nstringz0()" is the size of the buffer into which you're
copying the string, which might be the length of the string to be copied
*plus 1*).
Don't use fixed-length buffers for null-terminated strings (even if the
code that generates those packets has a #define to limit the length of
the string). Use "tvb_get_stringz()", instead.
In some cases where a value is fetched but is only used to pass an
argument to a "proto_tree_add_XXX" routine, use "proto_tree_add_item()"
instead.
svn path=/trunk/; revision=7859
2003-06-12 08:33:32 +00:00
|
|
|
offset = 0;
|
2000-07-27 10:57:12 +00:00
|
|
|
|
|
|
|
if (tree) {
|
Add new routines:
tvb_get_string() - takes a tvbuff, an offset, and a length as
arguments, allocates a buffer big enough to hold a string with
the specified number of bytes plus an added null terminator
(i.e., length+1), copies the specified number of bytes from the
tvbuff, at the specified offset, to that buffer and puts in a
null terminator, and returns a pointer to that buffer (or throws
an exception before allocating the buffer if that many bytes
aren't available in the tvbuff);
tvb_get_stringz() - takes a tvbuff, an offset, and a pointer to
a "gint" as arguments, gets the size of the null-terminated
string starting at the specified offset in the tvbuff (throwing
an exception if the null terminator isn't found), allocates a
buffer big enough to hold that string, copies the string to that
buffer, and returns a pointer to that buffer and stores the
length of the string (including the terminating null) in the
variable pointed to by the "gint" pointer.
Replace many pieces of code allocating a buffer and copying a string
with calls to "tvb_get_string()" (for one thing, "tvb_get_string()"
doesn't require you to remember that the argument to
"tvb_get_nstringz0()" is the size of the buffer into which you're
copying the string, which might be the length of the string to be copied
*plus 1*).
Don't use fixed-length buffers for null-terminated strings (even if the
code that generates those packets has a #define to limit the length of
the string). Use "tvb_get_stringz()", instead.
In some cases where a value is fetched but is only used to pass an
argument to a "proto_tree_add_XXX" routine, use "proto_tree_add_item()"
instead.
svn path=/trunk/; revision=7859
2003-06-12 08:33:32 +00:00
|
|
|
ti = proto_tree_add_item(tree, hf_quake_CCREQ_CONNECT_game,
|
|
|
|
tvb, offset, -1, TRUE);
|
|
|
|
offset += proto_item_get_len(ti);
|
|
|
|
|
|
|
|
proto_tree_add_item(tree, hf_quake_CCREQ_CONNECT_version,
|
|
|
|
tvb, offset, 1, TRUE);
|
2000-07-27 10:57:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
dissect_quake_CCREQ_SERVER_INFO
|
2002-04-02 06:28:16 +00:00
|
|
|
(tvbuff_t *tvb, proto_tree *tree)
|
2000-07-27 10:57:12 +00:00
|
|
|
{
|
Add new routines:
tvb_get_string() - takes a tvbuff, an offset, and a length as
arguments, allocates a buffer big enough to hold a string with
the specified number of bytes plus an added null terminator
(i.e., length+1), copies the specified number of bytes from the
tvbuff, at the specified offset, to that buffer and puts in a
null terminator, and returns a pointer to that buffer (or throws
an exception before allocating the buffer if that many bytes
aren't available in the tvbuff);
tvb_get_stringz() - takes a tvbuff, an offset, and a pointer to
a "gint" as arguments, gets the size of the null-terminated
string starting at the specified offset in the tvbuff (throwing
an exception if the null terminator isn't found), allocates a
buffer big enough to hold that string, copies the string to that
buffer, and returns a pointer to that buffer and stores the
length of the string (including the terminating null) in the
variable pointed to by the "gint" pointer.
Replace many pieces of code allocating a buffer and copying a string
with calls to "tvb_get_string()" (for one thing, "tvb_get_string()"
doesn't require you to remember that the argument to
"tvb_get_nstringz0()" is the size of the buffer into which you're
copying the string, which might be the length of the string to be copied
*plus 1*).
Don't use fixed-length buffers for null-terminated strings (even if the
code that generates those packets has a #define to limit the length of
the string). Use "tvb_get_stringz()", instead.
In some cases where a value is fetched but is only used to pass an
argument to a "proto_tree_add_XXX" routine, use "proto_tree_add_item()"
instead.
svn path=/trunk/; revision=7859
2003-06-12 08:33:32 +00:00
|
|
|
gint offset;
|
|
|
|
proto_item *ti;
|
2000-07-27 10:57:12 +00:00
|
|
|
|
Add new routines:
tvb_get_string() - takes a tvbuff, an offset, and a length as
arguments, allocates a buffer big enough to hold a string with
the specified number of bytes plus an added null terminator
(i.e., length+1), copies the specified number of bytes from the
tvbuff, at the specified offset, to that buffer and puts in a
null terminator, and returns a pointer to that buffer (or throws
an exception before allocating the buffer if that many bytes
aren't available in the tvbuff);
tvb_get_stringz() - takes a tvbuff, an offset, and a pointer to
a "gint" as arguments, gets the size of the null-terminated
string starting at the specified offset in the tvbuff (throwing
an exception if the null terminator isn't found), allocates a
buffer big enough to hold that string, copies the string to that
buffer, and returns a pointer to that buffer and stores the
length of the string (including the terminating null) in the
variable pointed to by the "gint" pointer.
Replace many pieces of code allocating a buffer and copying a string
with calls to "tvb_get_string()" (for one thing, "tvb_get_string()"
doesn't require you to remember that the argument to
"tvb_get_nstringz0()" is the size of the buffer into which you're
copying the string, which might be the length of the string to be copied
*plus 1*).
Don't use fixed-length buffers for null-terminated strings (even if the
code that generates those packets has a #define to limit the length of
the string). Use "tvb_get_stringz()", instead.
In some cases where a value is fetched but is only used to pass an
argument to a "proto_tree_add_XXX" routine, use "proto_tree_add_item()"
instead.
svn path=/trunk/; revision=7859
2003-06-12 08:33:32 +00:00
|
|
|
offset = 0;
|
2000-07-27 10:57:12 +00:00
|
|
|
|
|
|
|
if (tree) {
|
Add new routines:
tvb_get_string() - takes a tvbuff, an offset, and a length as
arguments, allocates a buffer big enough to hold a string with
the specified number of bytes plus an added null terminator
(i.e., length+1), copies the specified number of bytes from the
tvbuff, at the specified offset, to that buffer and puts in a
null terminator, and returns a pointer to that buffer (or throws
an exception before allocating the buffer if that many bytes
aren't available in the tvbuff);
tvb_get_stringz() - takes a tvbuff, an offset, and a pointer to
a "gint" as arguments, gets the size of the null-terminated
string starting at the specified offset in the tvbuff (throwing
an exception if the null terminator isn't found), allocates a
buffer big enough to hold that string, copies the string to that
buffer, and returns a pointer to that buffer and stores the
length of the string (including the terminating null) in the
variable pointed to by the "gint" pointer.
Replace many pieces of code allocating a buffer and copying a string
with calls to "tvb_get_string()" (for one thing, "tvb_get_string()"
doesn't require you to remember that the argument to
"tvb_get_nstringz0()" is the size of the buffer into which you're
copying the string, which might be the length of the string to be copied
*plus 1*).
Don't use fixed-length buffers for null-terminated strings (even if the
code that generates those packets has a #define to limit the length of
the string). Use "tvb_get_stringz()", instead.
In some cases where a value is fetched but is only used to pass an
argument to a "proto_tree_add_XXX" routine, use "proto_tree_add_item()"
instead.
svn path=/trunk/; revision=7859
2003-06-12 08:33:32 +00:00
|
|
|
ti = proto_tree_add_item(tree, hf_quake_CCREQ_SERVER_INFO_game,
|
|
|
|
tvb, offset, -1, TRUE);
|
|
|
|
offset += proto_item_get_len(ti);
|
|
|
|
proto_tree_add_item(tree, hf_quake_CCREQ_SERVER_INFO_version,
|
|
|
|
tvb, offset, 1, TRUE);
|
2000-07-27 10:57:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
dissect_quake_CCREQ_PLAYER_INFO
|
2002-04-02 06:28:16 +00:00
|
|
|
(tvbuff_t *tvb, proto_tree *tree)
|
2000-07-27 10:57:12 +00:00
|
|
|
{
|
|
|
|
if (tree) {
|
Add new routines:
tvb_get_string() - takes a tvbuff, an offset, and a length as
arguments, allocates a buffer big enough to hold a string with
the specified number of bytes plus an added null terminator
(i.e., length+1), copies the specified number of bytes from the
tvbuff, at the specified offset, to that buffer and puts in a
null terminator, and returns a pointer to that buffer (or throws
an exception before allocating the buffer if that many bytes
aren't available in the tvbuff);
tvb_get_stringz() - takes a tvbuff, an offset, and a pointer to
a "gint" as arguments, gets the size of the null-terminated
string starting at the specified offset in the tvbuff (throwing
an exception if the null terminator isn't found), allocates a
buffer big enough to hold that string, copies the string to that
buffer, and returns a pointer to that buffer and stores the
length of the string (including the terminating null) in the
variable pointed to by the "gint" pointer.
Replace many pieces of code allocating a buffer and copying a string
with calls to "tvb_get_string()" (for one thing, "tvb_get_string()"
doesn't require you to remember that the argument to
"tvb_get_nstringz0()" is the size of the buffer into which you're
copying the string, which might be the length of the string to be copied
*plus 1*).
Don't use fixed-length buffers for null-terminated strings (even if the
code that generates those packets has a #define to limit the length of
the string). Use "tvb_get_stringz()", instead.
In some cases where a value is fetched but is only used to pass an
argument to a "proto_tree_add_XXX" routine, use "proto_tree_add_item()"
instead.
svn path=/trunk/; revision=7859
2003-06-12 08:33:32 +00:00
|
|
|
proto_tree_add_item(tree, hf_quake_CCREQ_PLAYER_INFO_player,
|
|
|
|
tvb, 0, 1, TRUE);
|
2000-07-27 10:57:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
dissect_quake_CCREQ_RULE_INFO
|
2002-04-02 06:28:16 +00:00
|
|
|
(tvbuff_t *tvb, proto_tree *tree)
|
2000-07-27 10:57:12 +00:00
|
|
|
{
|
|
|
|
if (tree) {
|
Add new routines:
tvb_get_string() - takes a tvbuff, an offset, and a length as
arguments, allocates a buffer big enough to hold a string with
the specified number of bytes plus an added null terminator
(i.e., length+1), copies the specified number of bytes from the
tvbuff, at the specified offset, to that buffer and puts in a
null terminator, and returns a pointer to that buffer (or throws
an exception before allocating the buffer if that many bytes
aren't available in the tvbuff);
tvb_get_stringz() - takes a tvbuff, an offset, and a pointer to
a "gint" as arguments, gets the size of the null-terminated
string starting at the specified offset in the tvbuff (throwing
an exception if the null terminator isn't found), allocates a
buffer big enough to hold that string, copies the string to that
buffer, and returns a pointer to that buffer and stores the
length of the string (including the terminating null) in the
variable pointed to by the "gint" pointer.
Replace many pieces of code allocating a buffer and copying a string
with calls to "tvb_get_string()" (for one thing, "tvb_get_string()"
doesn't require you to remember that the argument to
"tvb_get_nstringz0()" is the size of the buffer into which you're
copying the string, which might be the length of the string to be copied
*plus 1*).
Don't use fixed-length buffers for null-terminated strings (even if the
code that generates those packets has a #define to limit the length of
the string). Use "tvb_get_stringz()", instead.
In some cases where a value is fetched but is only used to pass an
argument to a "proto_tree_add_XXX" routine, use "proto_tree_add_item()"
instead.
svn path=/trunk/; revision=7859
2003-06-12 08:33:32 +00:00
|
|
|
proto_tree_add_item(tree, hf_quake_CCREQ_RULE_INFO_lastrule,
|
|
|
|
tvb, 0, -1, TRUE);
|
2000-07-27 10:57:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
dissect_quake_CCREP_ACCEPT
|
|
|
|
(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|
|
|
{
|
|
|
|
guint32 port;
|
2000-07-31 12:59:51 +00:00
|
|
|
conversation_t *c;
|
2000-07-27 10:57:12 +00:00
|
|
|
|
|
|
|
port = tvb_get_letohl(tvb, 0);
|
2005-02-02 20:07:03 +00:00
|
|
|
c = conversation_new( pinfo->fd->num, &pinfo->src, &pinfo->dst, PT_UDP, port,
|
2001-09-03 10:33:12 +00:00
|
|
|
pinfo->destport, 0);
|
2000-07-31 12:59:51 +00:00
|
|
|
if (c) {
|
2001-11-27 07:13:32 +00:00
|
|
|
conversation_set_dissector(c, quake_handle);
|
2000-07-31 12:59:51 +00:00
|
|
|
}
|
2000-07-27 10:57:12 +00:00
|
|
|
if (tree) {
|
|
|
|
proto_tree_add_uint(tree, hf_quake_CCREP_ACCEPT_port,
|
|
|
|
tvb, 0, 4, port);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
dissect_quake_CCREP_REJECT
|
2002-04-02 06:28:16 +00:00
|
|
|
(tvbuff_t *tvb, proto_tree *tree)
|
2000-07-27 10:57:12 +00:00
|
|
|
{
|
|
|
|
if (tree) {
|
Add new routines:
tvb_get_string() - takes a tvbuff, an offset, and a length as
arguments, allocates a buffer big enough to hold a string with
the specified number of bytes plus an added null terminator
(i.e., length+1), copies the specified number of bytes from the
tvbuff, at the specified offset, to that buffer and puts in a
null terminator, and returns a pointer to that buffer (or throws
an exception before allocating the buffer if that many bytes
aren't available in the tvbuff);
tvb_get_stringz() - takes a tvbuff, an offset, and a pointer to
a "gint" as arguments, gets the size of the null-terminated
string starting at the specified offset in the tvbuff (throwing
an exception if the null terminator isn't found), allocates a
buffer big enough to hold that string, copies the string to that
buffer, and returns a pointer to that buffer and stores the
length of the string (including the terminating null) in the
variable pointed to by the "gint" pointer.
Replace many pieces of code allocating a buffer and copying a string
with calls to "tvb_get_string()" (for one thing, "tvb_get_string()"
doesn't require you to remember that the argument to
"tvb_get_nstringz0()" is the size of the buffer into which you're
copying the string, which might be the length of the string to be copied
*plus 1*).
Don't use fixed-length buffers for null-terminated strings (even if the
code that generates those packets has a #define to limit the length of
the string). Use "tvb_get_stringz()", instead.
In some cases where a value is fetched but is only used to pass an
argument to a "proto_tree_add_XXX" routine, use "proto_tree_add_item()"
instead.
svn path=/trunk/; revision=7859
2003-06-12 08:33:32 +00:00
|
|
|
proto_tree_add_item(tree, hf_quake_CCREP_REJECT_reason,
|
|
|
|
tvb, 0, -1, TRUE);
|
2000-07-27 10:57:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
dissect_quake_CCREP_SERVER_INFO
|
2002-04-02 06:28:16 +00:00
|
|
|
(tvbuff_t *tvb, proto_tree *tree)
|
2000-07-27 10:57:12 +00:00
|
|
|
{
|
|
|
|
gint offset;
|
Add new routines:
tvb_get_string() - takes a tvbuff, an offset, and a length as
arguments, allocates a buffer big enough to hold a string with
the specified number of bytes plus an added null terminator
(i.e., length+1), copies the specified number of bytes from the
tvbuff, at the specified offset, to that buffer and puts in a
null terminator, and returns a pointer to that buffer (or throws
an exception before allocating the buffer if that many bytes
aren't available in the tvbuff);
tvb_get_stringz() - takes a tvbuff, an offset, and a pointer to
a "gint" as arguments, gets the size of the null-terminated
string starting at the specified offset in the tvbuff (throwing
an exception if the null terminator isn't found), allocates a
buffer big enough to hold that string, copies the string to that
buffer, and returns a pointer to that buffer and stores the
length of the string (including the terminating null) in the
variable pointed to by the "gint" pointer.
Replace many pieces of code allocating a buffer and copying a string
with calls to "tvb_get_string()" (for one thing, "tvb_get_string()"
doesn't require you to remember that the argument to
"tvb_get_nstringz0()" is the size of the buffer into which you're
copying the string, which might be the length of the string to be copied
*plus 1*).
Don't use fixed-length buffers for null-terminated strings (even if the
code that generates those packets has a #define to limit the length of
the string). Use "tvb_get_stringz()", instead.
In some cases where a value is fetched but is only used to pass an
argument to a "proto_tree_add_XXX" routine, use "proto_tree_add_item()"
instead.
svn path=/trunk/; revision=7859
2003-06-12 08:33:32 +00:00
|
|
|
proto_item *ti;
|
2000-07-27 10:57:12 +00:00
|
|
|
|
|
|
|
offset = 0;
|
|
|
|
|
|
|
|
if (tree) {
|
Add new routines:
tvb_get_string() - takes a tvbuff, an offset, and a length as
arguments, allocates a buffer big enough to hold a string with
the specified number of bytes plus an added null terminator
(i.e., length+1), copies the specified number of bytes from the
tvbuff, at the specified offset, to that buffer and puts in a
null terminator, and returns a pointer to that buffer (or throws
an exception before allocating the buffer if that many bytes
aren't available in the tvbuff);
tvb_get_stringz() - takes a tvbuff, an offset, and a pointer to
a "gint" as arguments, gets the size of the null-terminated
string starting at the specified offset in the tvbuff (throwing
an exception if the null terminator isn't found), allocates a
buffer big enough to hold that string, copies the string to that
buffer, and returns a pointer to that buffer and stores the
length of the string (including the terminating null) in the
variable pointed to by the "gint" pointer.
Replace many pieces of code allocating a buffer and copying a string
with calls to "tvb_get_string()" (for one thing, "tvb_get_string()"
doesn't require you to remember that the argument to
"tvb_get_nstringz0()" is the size of the buffer into which you're
copying the string, which might be the length of the string to be copied
*plus 1*).
Don't use fixed-length buffers for null-terminated strings (even if the
code that generates those packets has a #define to limit the length of
the string). Use "tvb_get_stringz()", instead.
In some cases where a value is fetched but is only used to pass an
argument to a "proto_tree_add_XXX" routine, use "proto_tree_add_item()"
instead.
svn path=/trunk/; revision=7859
2003-06-12 08:33:32 +00:00
|
|
|
ti = proto_tree_add_item(tree,
|
|
|
|
hf_quake_CCREP_SERVER_INFO_address, tvb, offset, -1,
|
|
|
|
TRUE);
|
|
|
|
offset += proto_item_get_len(ti);
|
|
|
|
|
|
|
|
ti = proto_tree_add_item(tree,
|
|
|
|
hf_quake_CCREP_SERVER_INFO_server, tvb, offset, -1,
|
|
|
|
TRUE);
|
|
|
|
offset += proto_item_get_len(ti);
|
|
|
|
|
|
|
|
ti = proto_tree_add_item(tree, hf_quake_CCREP_SERVER_INFO_map,
|
|
|
|
tvb, offset, -1, TRUE);
|
|
|
|
offset += proto_item_get_len(ti);
|
|
|
|
|
|
|
|
proto_tree_add_item(tree, hf_quake_CCREP_SERVER_INFO_num_player,
|
|
|
|
tvb, offset, 1, TRUE);
|
|
|
|
offset += 1;
|
|
|
|
proto_tree_add_item(tree, hf_quake_CCREP_SERVER_INFO_max_player,
|
|
|
|
tvb, offset, 1, TRUE);
|
|
|
|
offset += 1;
|
|
|
|
proto_tree_add_item(tree, hf_quake_CCREQ_SERVER_INFO_version,
|
|
|
|
tvb, offset, 1, TRUE);
|
2000-07-27 10:57:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
dissect_quake_CCREP_PLAYER_INFO
|
2002-04-02 06:28:16 +00:00
|
|
|
(tvbuff_t *tvb, proto_tree *tree)
|
2000-07-27 10:57:12 +00:00
|
|
|
{
|
|
|
|
gint offset;
|
Add new routines:
tvb_get_string() - takes a tvbuff, an offset, and a length as
arguments, allocates a buffer big enough to hold a string with
the specified number of bytes plus an added null terminator
(i.e., length+1), copies the specified number of bytes from the
tvbuff, at the specified offset, to that buffer and puts in a
null terminator, and returns a pointer to that buffer (or throws
an exception before allocating the buffer if that many bytes
aren't available in the tvbuff);
tvb_get_stringz() - takes a tvbuff, an offset, and a pointer to
a "gint" as arguments, gets the size of the null-terminated
string starting at the specified offset in the tvbuff (throwing
an exception if the null terminator isn't found), allocates a
buffer big enough to hold that string, copies the string to that
buffer, and returns a pointer to that buffer and stores the
length of the string (including the terminating null) in the
variable pointed to by the "gint" pointer.
Replace many pieces of code allocating a buffer and copying a string
with calls to "tvb_get_string()" (for one thing, "tvb_get_string()"
doesn't require you to remember that the argument to
"tvb_get_nstringz0()" is the size of the buffer into which you're
copying the string, which might be the length of the string to be copied
*plus 1*).
Don't use fixed-length buffers for null-terminated strings (even if the
code that generates those packets has a #define to limit the length of
the string). Use "tvb_get_stringz()", instead.
In some cases where a value is fetched but is only used to pass an
argument to a "proto_tree_add_XXX" routine, use "proto_tree_add_item()"
instead.
svn path=/trunk/; revision=7859
2003-06-12 08:33:32 +00:00
|
|
|
proto_item *ti;
|
2000-07-27 10:57:12 +00:00
|
|
|
guint32 colors;
|
|
|
|
guint32 color_shirt;
|
|
|
|
guint32 color_pants;
|
Add new routines:
tvb_get_string() - takes a tvbuff, an offset, and a length as
arguments, allocates a buffer big enough to hold a string with
the specified number of bytes plus an added null terminator
(i.e., length+1), copies the specified number of bytes from the
tvbuff, at the specified offset, to that buffer and puts in a
null terminator, and returns a pointer to that buffer (or throws
an exception before allocating the buffer if that many bytes
aren't available in the tvbuff);
tvb_get_stringz() - takes a tvbuff, an offset, and a pointer to
a "gint" as arguments, gets the size of the null-terminated
string starting at the specified offset in the tvbuff (throwing
an exception if the null terminator isn't found), allocates a
buffer big enough to hold that string, copies the string to that
buffer, and returns a pointer to that buffer and stores the
length of the string (including the terminating null) in the
variable pointed to by the "gint" pointer.
Replace many pieces of code allocating a buffer and copying a string
with calls to "tvb_get_string()" (for one thing, "tvb_get_string()"
doesn't require you to remember that the argument to
"tvb_get_nstringz0()" is the size of the buffer into which you're
copying the string, which might be the length of the string to be copied
*plus 1*).
Don't use fixed-length buffers for null-terminated strings (even if the
code that generates those packets has a #define to limit the length of
the string). Use "tvb_get_stringz()", instead.
In some cases where a value is fetched but is only used to pass an
argument to a "proto_tree_add_XXX" routine, use "proto_tree_add_item()"
instead.
svn path=/trunk/; revision=7859
2003-06-12 08:33:32 +00:00
|
|
|
proto_item *colors_item;
|
|
|
|
proto_tree *colors_tree;
|
2000-07-27 10:57:12 +00:00
|
|
|
|
|
|
|
offset = 0;
|
|
|
|
|
|
|
|
if (tree) {
|
Add new routines:
tvb_get_string() - takes a tvbuff, an offset, and a length as
arguments, allocates a buffer big enough to hold a string with
the specified number of bytes plus an added null terminator
(i.e., length+1), copies the specified number of bytes from the
tvbuff, at the specified offset, to that buffer and puts in a
null terminator, and returns a pointer to that buffer (or throws
an exception before allocating the buffer if that many bytes
aren't available in the tvbuff);
tvb_get_stringz() - takes a tvbuff, an offset, and a pointer to
a "gint" as arguments, gets the size of the null-terminated
string starting at the specified offset in the tvbuff (throwing
an exception if the null terminator isn't found), allocates a
buffer big enough to hold that string, copies the string to that
buffer, and returns a pointer to that buffer and stores the
length of the string (including the terminating null) in the
variable pointed to by the "gint" pointer.
Replace many pieces of code allocating a buffer and copying a string
with calls to "tvb_get_string()" (for one thing, "tvb_get_string()"
doesn't require you to remember that the argument to
"tvb_get_nstringz0()" is the size of the buffer into which you're
copying the string, which might be the length of the string to be copied
*plus 1*).
Don't use fixed-length buffers for null-terminated strings (even if the
code that generates those packets has a #define to limit the length of
the string). Use "tvb_get_stringz()", instead.
In some cases where a value is fetched but is only used to pass an
argument to a "proto_tree_add_XXX" routine, use "proto_tree_add_item()"
instead.
svn path=/trunk/; revision=7859
2003-06-12 08:33:32 +00:00
|
|
|
proto_tree_add_item(tree, hf_quake_CCREQ_PLAYER_INFO_player,
|
|
|
|
tvb, offset, 1, TRUE);
|
|
|
|
offset += 1;
|
2002-08-28 21:04:11 +00:00
|
|
|
|
Add new routines:
tvb_get_string() - takes a tvbuff, an offset, and a length as
arguments, allocates a buffer big enough to hold a string with
the specified number of bytes plus an added null terminator
(i.e., length+1), copies the specified number of bytes from the
tvbuff, at the specified offset, to that buffer and puts in a
null terminator, and returns a pointer to that buffer (or throws
an exception before allocating the buffer if that many bytes
aren't available in the tvbuff);
tvb_get_stringz() - takes a tvbuff, an offset, and a pointer to
a "gint" as arguments, gets the size of the null-terminated
string starting at the specified offset in the tvbuff (throwing
an exception if the null terminator isn't found), allocates a
buffer big enough to hold that string, copies the string to that
buffer, and returns a pointer to that buffer and stores the
length of the string (including the terminating null) in the
variable pointed to by the "gint" pointer.
Replace many pieces of code allocating a buffer and copying a string
with calls to "tvb_get_string()" (for one thing, "tvb_get_string()"
doesn't require you to remember that the argument to
"tvb_get_nstringz0()" is the size of the buffer into which you're
copying the string, which might be the length of the string to be copied
*plus 1*).
Don't use fixed-length buffers for null-terminated strings (even if the
code that generates those packets has a #define to limit the length of
the string). Use "tvb_get_stringz()", instead.
In some cases where a value is fetched but is only used to pass an
argument to a "proto_tree_add_XXX" routine, use "proto_tree_add_item()"
instead.
svn path=/trunk/; revision=7859
2003-06-12 08:33:32 +00:00
|
|
|
ti = proto_tree_add_item(tree, hf_quake_CCREP_PLAYER_INFO_name,
|
|
|
|
tvb, offset, -1, TRUE);
|
|
|
|
offset += proto_item_get_len(ti);
|
2000-07-27 10:57:12 +00:00
|
|
|
|
Add new routines:
tvb_get_string() - takes a tvbuff, an offset, and a length as
arguments, allocates a buffer big enough to hold a string with
the specified number of bytes plus an added null terminator
(i.e., length+1), copies the specified number of bytes from the
tvbuff, at the specified offset, to that buffer and puts in a
null terminator, and returns a pointer to that buffer (or throws
an exception before allocating the buffer if that many bytes
aren't available in the tvbuff);
tvb_get_stringz() - takes a tvbuff, an offset, and a pointer to
a "gint" as arguments, gets the size of the null-terminated
string starting at the specified offset in the tvbuff (throwing
an exception if the null terminator isn't found), allocates a
buffer big enough to hold that string, copies the string to that
buffer, and returns a pointer to that buffer and stores the
length of the string (including the terminating null) in the
variable pointed to by the "gint" pointer.
Replace many pieces of code allocating a buffer and copying a string
with calls to "tvb_get_string()" (for one thing, "tvb_get_string()"
doesn't require you to remember that the argument to
"tvb_get_nstringz0()" is the size of the buffer into which you're
copying the string, which might be the length of the string to be copied
*plus 1*).
Don't use fixed-length buffers for null-terminated strings (even if the
code that generates those packets has a #define to limit the length of
the string). Use "tvb_get_stringz()", instead.
In some cases where a value is fetched but is only used to pass an
argument to a "proto_tree_add_XXX" routine, use "proto_tree_add_item()"
instead.
svn path=/trunk/; revision=7859
2003-06-12 08:33:32 +00:00
|
|
|
colors = tvb_get_letohl(tvb, offset + 0);
|
|
|
|
color_shirt = (colors >> 4) & 0x0f;
|
|
|
|
color_pants = (colors ) & 0x0f;
|
2000-07-27 10:57:12 +00:00
|
|
|
|
|
|
|
colors_item = proto_tree_add_uint(tree,
|
|
|
|
hf_quake_CCREP_PLAYER_INFO_colors,
|
Add new routines:
tvb_get_string() - takes a tvbuff, an offset, and a length as
arguments, allocates a buffer big enough to hold a string with
the specified number of bytes plus an added null terminator
(i.e., length+1), copies the specified number of bytes from the
tvbuff, at the specified offset, to that buffer and puts in a
null terminator, and returns a pointer to that buffer (or throws
an exception before allocating the buffer if that many bytes
aren't available in the tvbuff);
tvb_get_stringz() - takes a tvbuff, an offset, and a pointer to
a "gint" as arguments, gets the size of the null-terminated
string starting at the specified offset in the tvbuff (throwing
an exception if the null terminator isn't found), allocates a
buffer big enough to hold that string, copies the string to that
buffer, and returns a pointer to that buffer and stores the
length of the string (including the terminating null) in the
variable pointed to by the "gint" pointer.
Replace many pieces of code allocating a buffer and copying a string
with calls to "tvb_get_string()" (for one thing, "tvb_get_string()"
doesn't require you to remember that the argument to
"tvb_get_nstringz0()" is the size of the buffer into which you're
copying the string, which might be the length of the string to be copied
*plus 1*).
Don't use fixed-length buffers for null-terminated strings (even if the
code that generates those packets has a #define to limit the length of
the string). Use "tvb_get_stringz()", instead.
In some cases where a value is fetched but is only used to pass an
argument to a "proto_tree_add_XXX" routine, use "proto_tree_add_item()"
instead.
svn path=/trunk/; revision=7859
2003-06-12 08:33:32 +00:00
|
|
|
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, TRUE);
|
|
|
|
offset += 4;
|
|
|
|
proto_tree_add_item(tree, hf_quake_CCREP_PLAYER_INFO_connect_time,
|
|
|
|
tvb, offset, 4, TRUE);
|
|
|
|
offset += 4;
|
|
|
|
|
|
|
|
proto_tree_add_item(tree, hf_quake_CCREP_PLAYER_INFO_address,
|
|
|
|
tvb, offset, -1, TRUE);
|
2000-07-27 10:57:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
dissect_quake_CCREP_RULE_INFO
|
2002-04-02 06:28:16 +00:00
|
|
|
(tvbuff_t *tvb, proto_tree *tree)
|
2000-07-27 10:57:12 +00:00
|
|
|
{
|
|
|
|
gint offset;
|
Add new routines:
tvb_get_string() - takes a tvbuff, an offset, and a length as
arguments, allocates a buffer big enough to hold a string with
the specified number of bytes plus an added null terminator
(i.e., length+1), copies the specified number of bytes from the
tvbuff, at the specified offset, to that buffer and puts in a
null terminator, and returns a pointer to that buffer (or throws
an exception before allocating the buffer if that many bytes
aren't available in the tvbuff);
tvb_get_stringz() - takes a tvbuff, an offset, and a pointer to
a "gint" as arguments, gets the size of the null-terminated
string starting at the specified offset in the tvbuff (throwing
an exception if the null terminator isn't found), allocates a
buffer big enough to hold that string, copies the string to that
buffer, and returns a pointer to that buffer and stores the
length of the string (including the terminating null) in the
variable pointed to by the "gint" pointer.
Replace many pieces of code allocating a buffer and copying a string
with calls to "tvb_get_string()" (for one thing, "tvb_get_string()"
doesn't require you to remember that the argument to
"tvb_get_nstringz0()" is the size of the buffer into which you're
copying the string, which might be the length of the string to be copied
*plus 1*).
Don't use fixed-length buffers for null-terminated strings (even if the
code that generates those packets has a #define to limit the length of
the string). Use "tvb_get_stringz()", instead.
In some cases where a value is fetched but is only used to pass an
argument to a "proto_tree_add_XXX" routine, use "proto_tree_add_item()"
instead.
svn path=/trunk/; revision=7859
2003-06-12 08:33:32 +00:00
|
|
|
proto_item *ti;
|
2000-07-27 10:57:12 +00:00
|
|
|
|
Add new routines:
tvb_get_string() - takes a tvbuff, an offset, and a length as
arguments, allocates a buffer big enough to hold a string with
the specified number of bytes plus an added null terminator
(i.e., length+1), copies the specified number of bytes from the
tvbuff, at the specified offset, to that buffer and puts in a
null terminator, and returns a pointer to that buffer (or throws
an exception before allocating the buffer if that many bytes
aren't available in the tvbuff);
tvb_get_stringz() - takes a tvbuff, an offset, and a pointer to
a "gint" as arguments, gets the size of the null-terminated
string starting at the specified offset in the tvbuff (throwing
an exception if the null terminator isn't found), allocates a
buffer big enough to hold that string, copies the string to that
buffer, and returns a pointer to that buffer and stores the
length of the string (including the terminating null) in the
variable pointed to by the "gint" pointer.
Replace many pieces of code allocating a buffer and copying a string
with calls to "tvb_get_string()" (for one thing, "tvb_get_string()"
doesn't require you to remember that the argument to
"tvb_get_nstringz0()" is the size of the buffer into which you're
copying the string, which might be the length of the string to be copied
*plus 1*).
Don't use fixed-length buffers for null-terminated strings (even if the
code that generates those packets has a #define to limit the length of
the string). Use "tvb_get_stringz()", instead.
In some cases where a value is fetched but is only used to pass an
argument to a "proto_tree_add_XXX" routine, use "proto_tree_add_item()"
instead.
svn path=/trunk/; revision=7859
2003-06-12 08:33:32 +00:00
|
|
|
if (tvb_reported_length(tvb) == 0) return;
|
2000-07-27 10:57:12 +00:00
|
|
|
|
|
|
|
offset = 0;
|
|
|
|
|
|
|
|
if (tree) {
|
Add new routines:
tvb_get_string() - takes a tvbuff, an offset, and a length as
arguments, allocates a buffer big enough to hold a string with
the specified number of bytes plus an added null terminator
(i.e., length+1), copies the specified number of bytes from the
tvbuff, at the specified offset, to that buffer and puts in a
null terminator, and returns a pointer to that buffer (or throws
an exception before allocating the buffer if that many bytes
aren't available in the tvbuff);
tvb_get_stringz() - takes a tvbuff, an offset, and a pointer to
a "gint" as arguments, gets the size of the null-terminated
string starting at the specified offset in the tvbuff (throwing
an exception if the null terminator isn't found), allocates a
buffer big enough to hold that string, copies the string to that
buffer, and returns a pointer to that buffer and stores the
length of the string (including the terminating null) in the
variable pointed to by the "gint" pointer.
Replace many pieces of code allocating a buffer and copying a string
with calls to "tvb_get_string()" (for one thing, "tvb_get_string()"
doesn't require you to remember that the argument to
"tvb_get_nstringz0()" is the size of the buffer into which you're
copying the string, which might be the length of the string to be copied
*plus 1*).
Don't use fixed-length buffers for null-terminated strings (even if the
code that generates those packets has a #define to limit the length of
the string). Use "tvb_get_stringz()", instead.
In some cases where a value is fetched but is only used to pass an
argument to a "proto_tree_add_XXX" routine, use "proto_tree_add_item()"
instead.
svn path=/trunk/; revision=7859
2003-06-12 08:33:32 +00:00
|
|
|
ti = proto_tree_add_item(tree, hf_quake_CCREP_RULE_INFO_rule,
|
|
|
|
tvb, offset, -1, TRUE);
|
|
|
|
offset += proto_item_get_len(ti);
|
2000-07-27 10:57:12 +00:00
|
|
|
|
Add new routines:
tvb_get_string() - takes a tvbuff, an offset, and a length as
arguments, allocates a buffer big enough to hold a string with
the specified number of bytes plus an added null terminator
(i.e., length+1), copies the specified number of bytes from the
tvbuff, at the specified offset, to that buffer and puts in a
null terminator, and returns a pointer to that buffer (or throws
an exception before allocating the buffer if that many bytes
aren't available in the tvbuff);
tvb_get_stringz() - takes a tvbuff, an offset, and a pointer to
a "gint" as arguments, gets the size of the null-terminated
string starting at the specified offset in the tvbuff (throwing
an exception if the null terminator isn't found), allocates a
buffer big enough to hold that string, copies the string to that
buffer, and returns a pointer to that buffer and stores the
length of the string (including the terminating null) in the
variable pointed to by the "gint" pointer.
Replace many pieces of code allocating a buffer and copying a string
with calls to "tvb_get_string()" (for one thing, "tvb_get_string()"
doesn't require you to remember that the argument to
"tvb_get_nstringz0()" is the size of the buffer into which you're
copying the string, which might be the length of the string to be copied
*plus 1*).
Don't use fixed-length buffers for null-terminated strings (even if the
code that generates those packets has a #define to limit the length of
the string). Use "tvb_get_stringz()", instead.
In some cases where a value is fetched but is only used to pass an
argument to a "proto_tree_add_XXX" routine, use "proto_tree_add_item()"
instead.
svn path=/trunk/; revision=7859
2003-06-12 08:33:32 +00:00
|
|
|
proto_tree_add_item(tree, hf_quake_CCREP_RULE_INFO_value,
|
|
|
|
tvb, offset, -1, TRUE);
|
2000-07-27 10:57:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
dissect_quake_control(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|
|
|
{
|
|
|
|
guint8 command;
|
|
|
|
int direction;
|
|
|
|
proto_item *control_item = NULL;
|
|
|
|
proto_tree *control_tree = NULL;
|
|
|
|
guint rest_length;
|
|
|
|
tvbuff_t *next_tvb;
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2000-07-27 10:57:12 +00:00
|
|
|
command = tvb_get_guint8(tvb, 0);
|
|
|
|
direction = (command & 0x80) ? CCREP : CCREQ;
|
|
|
|
|
2001-12-10 00:26:21 +00:00
|
|
|
if (check_col(pinfo->cinfo, COL_INFO)) {
|
|
|
|
col_add_fstr(pinfo->cinfo, COL_INFO, "%s %s",
|
2000-07-27 10:57:12 +00:00
|
|
|
val_to_str(command,names_control_command, "%u"),
|
|
|
|
val_to_str(direction,names_control_direction,"%u"));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tree) {
|
|
|
|
control_item = proto_tree_add_text(tree, tvb,
|
2002-01-24 09:20:54 +00:00
|
|
|
0, -1, "Control %s: %s",
|
2000-07-27 10:57:12 +00:00
|
|
|
val_to_str(direction, names_control_direction, "%u"),
|
|
|
|
val_to_str(command, names_control_command, "%u"));
|
|
|
|
if (control_item)
|
|
|
|
control_tree = proto_item_add_subtree(control_item,
|
|
|
|
ett_quake_control);
|
|
|
|
proto_tree_add_uint(control_tree, hf_quake_control_command,
|
|
|
|
tvb, 0, 1, command);
|
2000-07-31 12:59:51 +00:00
|
|
|
}
|
2000-07-27 10:57:12 +00:00
|
|
|
|
2000-07-31 12:59:51 +00:00
|
|
|
rest_length = tvb_reported_length(tvb) - 1;
|
|
|
|
next_tvb = tvb_new_subset(tvb, 1, rest_length , rest_length);
|
|
|
|
switch (command) {
|
|
|
|
case CCREQ_CONNECT:
|
|
|
|
dissect_quake_CCREQ_CONNECT
|
2002-04-02 06:28:16 +00:00
|
|
|
(next_tvb, control_tree);
|
2000-07-31 12:59:51 +00:00
|
|
|
break;
|
|
|
|
case CCREQ_SERVER_INFO:
|
|
|
|
dissect_quake_CCREQ_SERVER_INFO
|
2002-04-02 06:28:16 +00:00
|
|
|
(next_tvb, control_tree);
|
2000-07-31 12:59:51 +00:00
|
|
|
break;
|
|
|
|
case CCREQ_PLAYER_INFO:
|
|
|
|
dissect_quake_CCREQ_PLAYER_INFO
|
2002-04-02 06:28:16 +00:00
|
|
|
(next_tvb, control_tree);
|
2000-07-31 12:59:51 +00:00
|
|
|
break;
|
|
|
|
case CCREQ_RULE_INFO:
|
|
|
|
dissect_quake_CCREQ_RULE_INFO
|
2002-04-02 06:28:16 +00:00
|
|
|
(next_tvb, control_tree);
|
2000-07-31 12:59:51 +00:00
|
|
|
break;
|
|
|
|
case CCREP_ACCEPT:
|
|
|
|
dissect_quake_CCREP_ACCEPT
|
|
|
|
(next_tvb, pinfo, control_tree);
|
|
|
|
break;
|
|
|
|
case CCREP_REJECT:
|
|
|
|
dissect_quake_CCREP_REJECT
|
2002-04-02 06:28:16 +00:00
|
|
|
(next_tvb, control_tree);
|
2000-07-31 12:59:51 +00:00
|
|
|
break;
|
|
|
|
case CCREP_SERVER_INFO:
|
|
|
|
dissect_quake_CCREP_SERVER_INFO
|
2002-04-02 06:28:16 +00:00
|
|
|
(next_tvb, control_tree);
|
2000-07-31 12:59:51 +00:00
|
|
|
break;
|
|
|
|
case CCREP_PLAYER_INFO:
|
|
|
|
dissect_quake_CCREP_PLAYER_INFO
|
2002-04-02 06:28:16 +00:00
|
|
|
(next_tvb, control_tree);
|
2000-07-31 12:59:51 +00:00
|
|
|
break;
|
|
|
|
case CCREP_RULE_INFO:
|
|
|
|
dissect_quake_CCREP_RULE_INFO
|
2002-04-02 06:28:16 +00:00
|
|
|
(next_tvb, control_tree);
|
2000-07-31 12:59:51 +00:00
|
|
|
break;
|
|
|
|
default:
|
2001-11-25 22:19:25 +00:00
|
|
|
call_dissector(data_handle,next_tvb, pinfo, control_tree);
|
2000-07-31 12:59:51 +00:00
|
|
|
break;
|
2000-07-27 10:57:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
dissect_quake(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|
|
|
{
|
|
|
|
proto_tree *quake_tree = NULL;
|
|
|
|
proto_item *quake_item = NULL;
|
|
|
|
guint32 length;
|
|
|
|
guint32 flags;
|
|
|
|
guint32 sequence = 0;
|
|
|
|
guint rest_length;
|
|
|
|
tvbuff_t *next_tvb;
|
|
|
|
|
2001-12-10 00:26:21 +00:00
|
|
|
if (check_col(pinfo->cinfo, COL_PROTOCOL))
|
|
|
|
col_set_str(pinfo->cinfo, COL_PROTOCOL, "QUAKE");
|
|
|
|
if (check_col(pinfo->cinfo, COL_INFO))
|
|
|
|
col_clear(pinfo->cinfo, COL_INFO);
|
2000-07-27 10:57:12 +00:00
|
|
|
|
|
|
|
length = tvb_get_ntohl(tvb, 0);
|
|
|
|
flags = length & (~NETFLAG_LENGTH_MASK);
|
|
|
|
length &= NETFLAG_LENGTH_MASK;
|
|
|
|
|
|
|
|
if (tree) {
|
|
|
|
quake_item = proto_tree_add_item(tree, proto_quake,
|
2002-01-24 09:20:54 +00:00
|
|
|
tvb, 0, -1, FALSE);
|
2000-07-27 10:57:12 +00:00
|
|
|
if (quake_item)
|
|
|
|
quake_tree = proto_item_add_subtree(quake_item, ett_quake);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (quake_tree) {
|
2000-07-31 12:59:51 +00:00
|
|
|
proto_item* flags_item = NULL;
|
|
|
|
proto_tree* flags_tree = NULL;
|
|
|
|
|
|
|
|
flags_item = proto_tree_add_uint(quake_tree, hf_quake_header_flags,
|
2000-07-27 10:57:12 +00:00
|
|
|
tvb, 0, 2, flags);
|
2000-07-31 12:59:51 +00:00
|
|
|
if (flags_item) {
|
|
|
|
flags_tree = proto_item_add_subtree(flags_item, ett_quake_flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flags_tree) {
|
|
|
|
proto_tree_add_text(flags_tree, tvb, 0, 2,
|
|
|
|
decode_boolean_bitfield(flags, NETFLAG_DATA, 32,
|
|
|
|
"Data","-"));
|
|
|
|
proto_tree_add_text(flags_tree, tvb, 0, 2,
|
|
|
|
decode_boolean_bitfield(flags, NETFLAG_ACK, 32,
|
|
|
|
"Acknowledgment","-"));
|
|
|
|
proto_tree_add_text(flags_tree, tvb, 0, 2,
|
|
|
|
decode_boolean_bitfield(flags, NETFLAG_NAK, 32,
|
|
|
|
"No Acknowledgment","-"));
|
|
|
|
proto_tree_add_text(flags_tree, tvb, 0, 2,
|
|
|
|
decode_boolean_bitfield(flags, NETFLAG_EOM, 32,
|
|
|
|
"End Of Message","-"));
|
|
|
|
proto_tree_add_text(flags_tree, tvb, 0, 2,
|
|
|
|
decode_boolean_bitfield(flags, NETFLAG_UNRELIABLE, 32,
|
|
|
|
"Unreliable","-"));
|
|
|
|
proto_tree_add_text(flags_tree, tvb, 0, 2,
|
|
|
|
decode_boolean_bitfield(flags, NETFLAG_CTL, 32,
|
|
|
|
"Control","-"));
|
|
|
|
}
|
2000-07-27 10:57:12 +00:00
|
|
|
proto_tree_add_uint(quake_tree, hf_quake_header_length,
|
|
|
|
tvb, 2, 2, length);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flags == NETFLAG_CTL) {
|
|
|
|
rest_length = tvb_reported_length(tvb) - 4;
|
|
|
|
next_tvb = tvb_new_subset(tvb, 4, rest_length , rest_length);
|
|
|
|
dissect_quake_control(next_tvb, pinfo, quake_tree);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
sequence = tvb_get_ntohl(tvb, 4);
|
2001-12-10 00:26:21 +00:00
|
|
|
if (check_col(pinfo->cinfo, COL_INFO)) {
|
|
|
|
col_add_fstr(pinfo->cinfo, COL_INFO, "seq 0x%x", sequence);
|
2000-07-27 10:57:12 +00:00
|
|
|
}
|
|
|
|
if (quake_tree) {
|
|
|
|
proto_tree_add_uint(quake_tree, hf_quake_header_sequence,
|
|
|
|
tvb, 4, 4, sequence);
|
|
|
|
}
|
|
|
|
|
|
|
|
rest_length = tvb_reported_length(tvb) - 8;
|
|
|
|
next_tvb = tvb_new_subset(tvb, 8, rest_length , rest_length);
|
2001-11-25 22:19:25 +00:00
|
|
|
call_dissector(data_handle,next_tvb, pinfo, quake_tree);
|
2000-07-27 10:57:12 +00:00
|
|
|
}
|
|
|
|
|
2001-06-21 15:13:42 +00:00
|
|
|
|
2000-07-27 10:57:12 +00:00
|
|
|
void
|
2001-06-21 15:13:42 +00:00
|
|
|
proto_reg_handoff_quake(void)
|
2000-07-27 10:57:12 +00:00
|
|
|
{
|
2008-09-03 16:42:35 +00:00
|
|
|
static gboolean Initialized=FALSE;
|
2008-09-23 01:10:45 +00:00
|
|
|
static guint ServerPort;
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2008-09-03 16:42:35 +00:00
|
|
|
if (!Initialized) {
|
|
|
|
quake_handle = create_dissector_handle(dissect_quake, proto_quake);
|
|
|
|
data_handle = find_dissector("data");
|
2001-06-21 15:13:42 +00:00
|
|
|
Initialized=TRUE;
|
2008-09-03 16:42:35 +00:00
|
|
|
} else {
|
|
|
|
dissector_delete("udp.port", ServerPort, quake_handle);
|
2001-06-21 15:13:42 +00:00
|
|
|
}
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-21 15:13:42 +00:00
|
|
|
/* set port for future deletes */
|
|
|
|
ServerPort=gbl_quakeServerPort;
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-12-03 04:00:26 +00:00
|
|
|
dissector_add("udp.port", gbl_quakeServerPort, quake_handle);
|
2001-06-21 15:13:42 +00:00
|
|
|
}
|
|
|
|
|
2000-07-27 10:57:12 +00:00
|
|
|
|
2001-06-21 15:13:42 +00:00
|
|
|
void
|
|
|
|
proto_register_quake(void)
|
|
|
|
{
|
2000-07-27 10:57:12 +00:00
|
|
|
static hf_register_info hf[] = {
|
|
|
|
{ &hf_quake_header_flags,
|
|
|
|
{ "Flags", "quake.header.flags",
|
|
|
|
FT_UINT16, BASE_HEX, NULL, 0x0,
|
2001-06-18 02:18:27 +00:00
|
|
|
"Flags", HFILL }},
|
2000-07-27 10:57:12 +00:00
|
|
|
{ &hf_quake_header_length,
|
|
|
|
{ "Length", "quake.header.length",
|
|
|
|
FT_UINT16, BASE_DEC, NULL, 0x0,
|
2001-06-18 02:18:27 +00:00
|
|
|
"full data length", HFILL }},
|
2000-07-27 10:57:12 +00:00
|
|
|
{ &hf_quake_header_sequence,
|
|
|
|
{ "Sequence", "quake.header.sequence",
|
|
|
|
FT_UINT32, BASE_HEX, NULL, 0x0,
|
2001-06-18 02:18:27 +00:00
|
|
|
"Sequence Number", HFILL }},
|
2000-07-27 10:57:12 +00:00
|
|
|
{ &hf_quake_control_command,
|
|
|
|
{ "Command", "quake.control.command",
|
|
|
|
FT_UINT8, BASE_HEX, VALS(names_control_command), 0x0,
|
2001-06-18 02:18:27 +00:00
|
|
|
"Control Command", HFILL }},
|
2000-07-27 10:57:12 +00:00
|
|
|
{ &hf_quake_CCREQ_CONNECT_game,
|
|
|
|
{ "Game", "quake.control.connect.game",
|
Add new routines:
tvb_get_string() - takes a tvbuff, an offset, and a length as
arguments, allocates a buffer big enough to hold a string with
the specified number of bytes plus an added null terminator
(i.e., length+1), copies the specified number of bytes from the
tvbuff, at the specified offset, to that buffer and puts in a
null terminator, and returns a pointer to that buffer (or throws
an exception before allocating the buffer if that many bytes
aren't available in the tvbuff);
tvb_get_stringz() - takes a tvbuff, an offset, and a pointer to
a "gint" as arguments, gets the size of the null-terminated
string starting at the specified offset in the tvbuff (throwing
an exception if the null terminator isn't found), allocates a
buffer big enough to hold that string, copies the string to that
buffer, and returns a pointer to that buffer and stores the
length of the string (including the terminating null) in the
variable pointed to by the "gint" pointer.
Replace many pieces of code allocating a buffer and copying a string
with calls to "tvb_get_string()" (for one thing, "tvb_get_string()"
doesn't require you to remember that the argument to
"tvb_get_nstringz0()" is the size of the buffer into which you're
copying the string, which might be the length of the string to be copied
*plus 1*).
Don't use fixed-length buffers for null-terminated strings (even if the
code that generates those packets has a #define to limit the length of
the string). Use "tvb_get_stringz()", instead.
In some cases where a value is fetched but is only used to pass an
argument to a "proto_tree_add_XXX" routine, use "proto_tree_add_item()"
instead.
svn path=/trunk/; revision=7859
2003-06-12 08:33:32 +00:00
|
|
|
FT_STRINGZ, BASE_NONE, NULL, 0x0,
|
2001-06-18 02:18:27 +00:00
|
|
|
"Game Name", HFILL }},
|
2000-07-27 10:57:12 +00:00
|
|
|
{ &hf_quake_CCREQ_CONNECT_version,
|
|
|
|
{ "Version", "quake.control.connect.version",
|
|
|
|
FT_UINT8, BASE_DEC, NULL, 0x0,
|
2001-06-18 02:18:27 +00:00
|
|
|
"Game Protocol Version Number", HFILL }},
|
2000-07-27 10:57:12 +00:00
|
|
|
{ &hf_quake_CCREQ_SERVER_INFO_game,
|
|
|
|
{ "Game", "quake.control.server_info.game",
|
Add new routines:
tvb_get_string() - takes a tvbuff, an offset, and a length as
arguments, allocates a buffer big enough to hold a string with
the specified number of bytes plus an added null terminator
(i.e., length+1), copies the specified number of bytes from the
tvbuff, at the specified offset, to that buffer and puts in a
null terminator, and returns a pointer to that buffer (or throws
an exception before allocating the buffer if that many bytes
aren't available in the tvbuff);
tvb_get_stringz() - takes a tvbuff, an offset, and a pointer to
a "gint" as arguments, gets the size of the null-terminated
string starting at the specified offset in the tvbuff (throwing
an exception if the null terminator isn't found), allocates a
buffer big enough to hold that string, copies the string to that
buffer, and returns a pointer to that buffer and stores the
length of the string (including the terminating null) in the
variable pointed to by the "gint" pointer.
Replace many pieces of code allocating a buffer and copying a string
with calls to "tvb_get_string()" (for one thing, "tvb_get_string()"
doesn't require you to remember that the argument to
"tvb_get_nstringz0()" is the size of the buffer into which you're
copying the string, which might be the length of the string to be copied
*plus 1*).
Don't use fixed-length buffers for null-terminated strings (even if the
code that generates those packets has a #define to limit the length of
the string). Use "tvb_get_stringz()", instead.
In some cases where a value is fetched but is only used to pass an
argument to a "proto_tree_add_XXX" routine, use "proto_tree_add_item()"
instead.
svn path=/trunk/; revision=7859
2003-06-12 08:33:32 +00:00
|
|
|
FT_STRINGZ, BASE_NONE, NULL, 0x0,
|
2001-06-18 02:18:27 +00:00
|
|
|
"Game Name", HFILL }},
|
2000-07-27 10:57:12 +00:00
|
|
|
{ &hf_quake_CCREQ_SERVER_INFO_version,
|
|
|
|
{ "Version", "quake.control.server_info.version",
|
|
|
|
FT_UINT8, BASE_DEC, NULL, 0x0,
|
2001-06-18 02:18:27 +00:00
|
|
|
"Game Protocol Version Number", HFILL }},
|
2000-07-27 10:57:12 +00:00
|
|
|
{ &hf_quake_CCREQ_PLAYER_INFO_player,
|
|
|
|
{ "Player", "quake.control.player_info.player",
|
|
|
|
FT_UINT8, BASE_DEC, NULL, 0x0,
|
2001-06-18 02:18:27 +00:00
|
|
|
"Player", HFILL }},
|
2000-07-27 10:57:12 +00:00
|
|
|
{ &hf_quake_CCREQ_RULE_INFO_lastrule,
|
|
|
|
{ "Last Rule", "quake.control.rule_info.lastrule",
|
Add new routines:
tvb_get_string() - takes a tvbuff, an offset, and a length as
arguments, allocates a buffer big enough to hold a string with
the specified number of bytes plus an added null terminator
(i.e., length+1), copies the specified number of bytes from the
tvbuff, at the specified offset, to that buffer and puts in a
null terminator, and returns a pointer to that buffer (or throws
an exception before allocating the buffer if that many bytes
aren't available in the tvbuff);
tvb_get_stringz() - takes a tvbuff, an offset, and a pointer to
a "gint" as arguments, gets the size of the null-terminated
string starting at the specified offset in the tvbuff (throwing
an exception if the null terminator isn't found), allocates a
buffer big enough to hold that string, copies the string to that
buffer, and returns a pointer to that buffer and stores the
length of the string (including the terminating null) in the
variable pointed to by the "gint" pointer.
Replace many pieces of code allocating a buffer and copying a string
with calls to "tvb_get_string()" (for one thing, "tvb_get_string()"
doesn't require you to remember that the argument to
"tvb_get_nstringz0()" is the size of the buffer into which you're
copying the string, which might be the length of the string to be copied
*plus 1*).
Don't use fixed-length buffers for null-terminated strings (even if the
code that generates those packets has a #define to limit the length of
the string). Use "tvb_get_stringz()", instead.
In some cases where a value is fetched but is only used to pass an
argument to a "proto_tree_add_XXX" routine, use "proto_tree_add_item()"
instead.
svn path=/trunk/; revision=7859
2003-06-12 08:33:32 +00:00
|
|
|
FT_STRINGZ, BASE_NONE, NULL, 0x0,
|
2001-06-18 02:18:27 +00:00
|
|
|
"Last Rule Name", HFILL }},
|
2000-07-27 10:57:12 +00:00
|
|
|
{ &hf_quake_CCREP_ACCEPT_port,
|
|
|
|
{ "Port", "quake.control.accept.port",
|
|
|
|
FT_UINT32, BASE_DEC, NULL, 0x0,
|
2001-06-18 02:18:27 +00:00
|
|
|
"Game Data Port", HFILL }},
|
2000-07-27 10:57:12 +00:00
|
|
|
{ &hf_quake_CCREP_REJECT_reason,
|
|
|
|
{ "Reason", "quake.control.reject.reason",
|
Add new routines:
tvb_get_string() - takes a tvbuff, an offset, and a length as
arguments, allocates a buffer big enough to hold a string with
the specified number of bytes plus an added null terminator
(i.e., length+1), copies the specified number of bytes from the
tvbuff, at the specified offset, to that buffer and puts in a
null terminator, and returns a pointer to that buffer (or throws
an exception before allocating the buffer if that many bytes
aren't available in the tvbuff);
tvb_get_stringz() - takes a tvbuff, an offset, and a pointer to
a "gint" as arguments, gets the size of the null-terminated
string starting at the specified offset in the tvbuff (throwing
an exception if the null terminator isn't found), allocates a
buffer big enough to hold that string, copies the string to that
buffer, and returns a pointer to that buffer and stores the
length of the string (including the terminating null) in the
variable pointed to by the "gint" pointer.
Replace many pieces of code allocating a buffer and copying a string
with calls to "tvb_get_string()" (for one thing, "tvb_get_string()"
doesn't require you to remember that the argument to
"tvb_get_nstringz0()" is the size of the buffer into which you're
copying the string, which might be the length of the string to be copied
*plus 1*).
Don't use fixed-length buffers for null-terminated strings (even if the
code that generates those packets has a #define to limit the length of
the string). Use "tvb_get_stringz()", instead.
In some cases where a value is fetched but is only used to pass an
argument to a "proto_tree_add_XXX" routine, use "proto_tree_add_item()"
instead.
svn path=/trunk/; revision=7859
2003-06-12 08:33:32 +00:00
|
|
|
FT_STRINGZ, BASE_NONE, NULL, 0x0,
|
2001-06-18 02:18:27 +00:00
|
|
|
"Reject Reason", HFILL }},
|
2000-07-27 10:57:12 +00:00
|
|
|
{ &hf_quake_CCREP_SERVER_INFO_address,
|
|
|
|
{ "Address", "quake.control.server_info.address",
|
Add new routines:
tvb_get_string() - takes a tvbuff, an offset, and a length as
arguments, allocates a buffer big enough to hold a string with
the specified number of bytes plus an added null terminator
(i.e., length+1), copies the specified number of bytes from the
tvbuff, at the specified offset, to that buffer and puts in a
null terminator, and returns a pointer to that buffer (or throws
an exception before allocating the buffer if that many bytes
aren't available in the tvbuff);
tvb_get_stringz() - takes a tvbuff, an offset, and a pointer to
a "gint" as arguments, gets the size of the null-terminated
string starting at the specified offset in the tvbuff (throwing
an exception if the null terminator isn't found), allocates a
buffer big enough to hold that string, copies the string to that
buffer, and returns a pointer to that buffer and stores the
length of the string (including the terminating null) in the
variable pointed to by the "gint" pointer.
Replace many pieces of code allocating a buffer and copying a string
with calls to "tvb_get_string()" (for one thing, "tvb_get_string()"
doesn't require you to remember that the argument to
"tvb_get_nstringz0()" is the size of the buffer into which you're
copying the string, which might be the length of the string to be copied
*plus 1*).
Don't use fixed-length buffers for null-terminated strings (even if the
code that generates those packets has a #define to limit the length of
the string). Use "tvb_get_stringz()", instead.
In some cases where a value is fetched but is only used to pass an
argument to a "proto_tree_add_XXX" routine, use "proto_tree_add_item()"
instead.
svn path=/trunk/; revision=7859
2003-06-12 08:33:32 +00:00
|
|
|
FT_STRINGZ, BASE_NONE, NULL, 0x0,
|
2001-06-18 02:18:27 +00:00
|
|
|
"Server Address", HFILL }},
|
2000-07-27 10:57:12 +00:00
|
|
|
{ &hf_quake_CCREP_SERVER_INFO_server,
|
|
|
|
{ "Server", "quake.control.server_info.server",
|
Add new routines:
tvb_get_string() - takes a tvbuff, an offset, and a length as
arguments, allocates a buffer big enough to hold a string with
the specified number of bytes plus an added null terminator
(i.e., length+1), copies the specified number of bytes from the
tvbuff, at the specified offset, to that buffer and puts in a
null terminator, and returns a pointer to that buffer (or throws
an exception before allocating the buffer if that many bytes
aren't available in the tvbuff);
tvb_get_stringz() - takes a tvbuff, an offset, and a pointer to
a "gint" as arguments, gets the size of the null-terminated
string starting at the specified offset in the tvbuff (throwing
an exception if the null terminator isn't found), allocates a
buffer big enough to hold that string, copies the string to that
buffer, and returns a pointer to that buffer and stores the
length of the string (including the terminating null) in the
variable pointed to by the "gint" pointer.
Replace many pieces of code allocating a buffer and copying a string
with calls to "tvb_get_string()" (for one thing, "tvb_get_string()"
doesn't require you to remember that the argument to
"tvb_get_nstringz0()" is the size of the buffer into which you're
copying the string, which might be the length of the string to be copied
*plus 1*).
Don't use fixed-length buffers for null-terminated strings (even if the
code that generates those packets has a #define to limit the length of
the string). Use "tvb_get_stringz()", instead.
In some cases where a value is fetched but is only used to pass an
argument to a "proto_tree_add_XXX" routine, use "proto_tree_add_item()"
instead.
svn path=/trunk/; revision=7859
2003-06-12 08:33:32 +00:00
|
|
|
FT_STRINGZ, BASE_NONE, NULL, 0x0,
|
2001-06-18 02:18:27 +00:00
|
|
|
"Server Name", HFILL }},
|
2000-07-27 10:57:12 +00:00
|
|
|
{ &hf_quake_CCREP_SERVER_INFO_map,
|
|
|
|
{ "Map", "quake.control.server_info.map",
|
Add new routines:
tvb_get_string() - takes a tvbuff, an offset, and a length as
arguments, allocates a buffer big enough to hold a string with
the specified number of bytes plus an added null terminator
(i.e., length+1), copies the specified number of bytes from the
tvbuff, at the specified offset, to that buffer and puts in a
null terminator, and returns a pointer to that buffer (or throws
an exception before allocating the buffer if that many bytes
aren't available in the tvbuff);
tvb_get_stringz() - takes a tvbuff, an offset, and a pointer to
a "gint" as arguments, gets the size of the null-terminated
string starting at the specified offset in the tvbuff (throwing
an exception if the null terminator isn't found), allocates a
buffer big enough to hold that string, copies the string to that
buffer, and returns a pointer to that buffer and stores the
length of the string (including the terminating null) in the
variable pointed to by the "gint" pointer.
Replace many pieces of code allocating a buffer and copying a string
with calls to "tvb_get_string()" (for one thing, "tvb_get_string()"
doesn't require you to remember that the argument to
"tvb_get_nstringz0()" is the size of the buffer into which you're
copying the string, which might be the length of the string to be copied
*plus 1*).
Don't use fixed-length buffers for null-terminated strings (even if the
code that generates those packets has a #define to limit the length of
the string). Use "tvb_get_stringz()", instead.
In some cases where a value is fetched but is only used to pass an
argument to a "proto_tree_add_XXX" routine, use "proto_tree_add_item()"
instead.
svn path=/trunk/; revision=7859
2003-06-12 08:33:32 +00:00
|
|
|
FT_STRINGZ, BASE_NONE, NULL, 0x0,
|
2001-06-18 02:18:27 +00:00
|
|
|
"Map Name", HFILL }},
|
2000-07-27 10:57:12 +00:00
|
|
|
{ &hf_quake_CCREP_SERVER_INFO_num_player,
|
|
|
|
{ "Number of Players", "quake.control.server_info.num_player",
|
|
|
|
FT_UINT8, BASE_DEC, NULL, 0x0,
|
2001-06-18 02:18:27 +00:00
|
|
|
"Current Number of Players", HFILL }},
|
2000-07-27 10:57:12 +00:00
|
|
|
{ &hf_quake_CCREP_SERVER_INFO_max_player,
|
|
|
|
{ "Maximal Number of Players", "quake.control.server_info.max_player",
|
|
|
|
FT_UINT8, BASE_DEC, NULL, 0x0,
|
2001-06-18 02:18:27 +00:00
|
|
|
"Maximal Number of Players", HFILL }},
|
2000-07-27 10:57:12 +00:00
|
|
|
{ &hf_quake_CCREP_PLAYER_INFO_name,
|
|
|
|
{ "Name", "quake.control.player_info.name",
|
Add new routines:
tvb_get_string() - takes a tvbuff, an offset, and a length as
arguments, allocates a buffer big enough to hold a string with
the specified number of bytes plus an added null terminator
(i.e., length+1), copies the specified number of bytes from the
tvbuff, at the specified offset, to that buffer and puts in a
null terminator, and returns a pointer to that buffer (or throws
an exception before allocating the buffer if that many bytes
aren't available in the tvbuff);
tvb_get_stringz() - takes a tvbuff, an offset, and a pointer to
a "gint" as arguments, gets the size of the null-terminated
string starting at the specified offset in the tvbuff (throwing
an exception if the null terminator isn't found), allocates a
buffer big enough to hold that string, copies the string to that
buffer, and returns a pointer to that buffer and stores the
length of the string (including the terminating null) in the
variable pointed to by the "gint" pointer.
Replace many pieces of code allocating a buffer and copying a string
with calls to "tvb_get_string()" (for one thing, "tvb_get_string()"
doesn't require you to remember that the argument to
"tvb_get_nstringz0()" is the size of the buffer into which you're
copying the string, which might be the length of the string to be copied
*plus 1*).
Don't use fixed-length buffers for null-terminated strings (even if the
code that generates those packets has a #define to limit the length of
the string). Use "tvb_get_stringz()", instead.
In some cases where a value is fetched but is only used to pass an
argument to a "proto_tree_add_XXX" routine, use "proto_tree_add_item()"
instead.
svn path=/trunk/; revision=7859
2003-06-12 08:33:32 +00:00
|
|
|
FT_STRINGZ, BASE_NONE, NULL, 0x0,
|
2001-06-18 02:18:27 +00:00
|
|
|
"Player Name", HFILL }},
|
2000-07-27 10:57:12 +00:00
|
|
|
{ &hf_quake_CCREP_PLAYER_INFO_colors,
|
|
|
|
{ "Colors", "quake.control.player_info.colors",
|
|
|
|
FT_UINT32, BASE_HEX, NULL, 0x0,
|
2001-06-18 02:18:27 +00:00
|
|
|
"Player Colors", HFILL }},
|
2000-07-27 10:57:12 +00:00
|
|
|
{ &hf_quake_CCREP_PLAYER_INFO_colors_shirt,
|
|
|
|
{ "Shirt", "quake.control.player_info.colors.shirt",
|
|
|
|
FT_UINT8, BASE_DEC, VALS(names_colors), 0x0,
|
2001-06-18 02:18:27 +00:00
|
|
|
"Shirt Color", HFILL }},
|
2000-07-27 10:57:12 +00:00
|
|
|
{ &hf_quake_CCREP_PLAYER_INFO_colors_pants,
|
|
|
|
{ "Pants", "quake.control.player_info.colors.pants",
|
|
|
|
FT_UINT8, BASE_DEC, VALS(names_colors), 0x0,
|
2001-06-18 02:18:27 +00:00
|
|
|
"Pants Color", HFILL }},
|
2000-07-27 10:57:12 +00:00
|
|
|
{ &hf_quake_CCREP_PLAYER_INFO_frags,
|
|
|
|
{ "Frags", "quake.control.player_info.frags",
|
|
|
|
FT_UINT32, BASE_DEC, NULL, 0x0,
|
2001-06-18 02:18:27 +00:00
|
|
|
"Player Frags", HFILL }},
|
2000-07-27 10:57:12 +00:00
|
|
|
{ &hf_quake_CCREP_PLAYER_INFO_connect_time,
|
|
|
|
{ "Connect Time", "quake.control.player_info.connect_time",
|
|
|
|
FT_UINT32, BASE_DEC, NULL, 0x0,
|
2001-06-18 02:18:27 +00:00
|
|
|
"Player Connect Time", HFILL }},
|
2000-07-27 10:57:12 +00:00
|
|
|
{ &hf_quake_CCREP_PLAYER_INFO_address,
|
|
|
|
{ "Address", "quake.control.player_info.address",
|
Add new routines:
tvb_get_string() - takes a tvbuff, an offset, and a length as
arguments, allocates a buffer big enough to hold a string with
the specified number of bytes plus an added null terminator
(i.e., length+1), copies the specified number of bytes from the
tvbuff, at the specified offset, to that buffer and puts in a
null terminator, and returns a pointer to that buffer (or throws
an exception before allocating the buffer if that many bytes
aren't available in the tvbuff);
tvb_get_stringz() - takes a tvbuff, an offset, and a pointer to
a "gint" as arguments, gets the size of the null-terminated
string starting at the specified offset in the tvbuff (throwing
an exception if the null terminator isn't found), allocates a
buffer big enough to hold that string, copies the string to that
buffer, and returns a pointer to that buffer and stores the
length of the string (including the terminating null) in the
variable pointed to by the "gint" pointer.
Replace many pieces of code allocating a buffer and copying a string
with calls to "tvb_get_string()" (for one thing, "tvb_get_string()"
doesn't require you to remember that the argument to
"tvb_get_nstringz0()" is the size of the buffer into which you're
copying the string, which might be the length of the string to be copied
*plus 1*).
Don't use fixed-length buffers for null-terminated strings (even if the
code that generates those packets has a #define to limit the length of
the string). Use "tvb_get_stringz()", instead.
In some cases where a value is fetched but is only used to pass an
argument to a "proto_tree_add_XXX" routine, use "proto_tree_add_item()"
instead.
svn path=/trunk/; revision=7859
2003-06-12 08:33:32 +00:00
|
|
|
FT_STRINGZ, BASE_NONE, NULL, 0x0,
|
2001-06-18 02:18:27 +00:00
|
|
|
"Player Address", HFILL }},
|
2000-07-27 10:57:12 +00:00
|
|
|
{ &hf_quake_CCREP_RULE_INFO_rule,
|
|
|
|
{ "Rule", "quake.control.rule_info.rule",
|
Add new routines:
tvb_get_string() - takes a tvbuff, an offset, and a length as
arguments, allocates a buffer big enough to hold a string with
the specified number of bytes plus an added null terminator
(i.e., length+1), copies the specified number of bytes from the
tvbuff, at the specified offset, to that buffer and puts in a
null terminator, and returns a pointer to that buffer (or throws
an exception before allocating the buffer if that many bytes
aren't available in the tvbuff);
tvb_get_stringz() - takes a tvbuff, an offset, and a pointer to
a "gint" as arguments, gets the size of the null-terminated
string starting at the specified offset in the tvbuff (throwing
an exception if the null terminator isn't found), allocates a
buffer big enough to hold that string, copies the string to that
buffer, and returns a pointer to that buffer and stores the
length of the string (including the terminating null) in the
variable pointed to by the "gint" pointer.
Replace many pieces of code allocating a buffer and copying a string
with calls to "tvb_get_string()" (for one thing, "tvb_get_string()"
doesn't require you to remember that the argument to
"tvb_get_nstringz0()" is the size of the buffer into which you're
copying the string, which might be the length of the string to be copied
*plus 1*).
Don't use fixed-length buffers for null-terminated strings (even if the
code that generates those packets has a #define to limit the length of
the string). Use "tvb_get_stringz()", instead.
In some cases where a value is fetched but is only used to pass an
argument to a "proto_tree_add_XXX" routine, use "proto_tree_add_item()"
instead.
svn path=/trunk/; revision=7859
2003-06-12 08:33:32 +00:00
|
|
|
FT_STRINGZ, BASE_NONE, NULL, 0x0,
|
2001-06-18 02:18:27 +00:00
|
|
|
"Rule Name", HFILL }},
|
2000-07-27 10:57:12 +00:00
|
|
|
{ &hf_quake_CCREP_RULE_INFO_value,
|
|
|
|
{ "Value", "quake.control.rule_info.value",
|
Add new routines:
tvb_get_string() - takes a tvbuff, an offset, and a length as
arguments, allocates a buffer big enough to hold a string with
the specified number of bytes plus an added null terminator
(i.e., length+1), copies the specified number of bytes from the
tvbuff, at the specified offset, to that buffer and puts in a
null terminator, and returns a pointer to that buffer (or throws
an exception before allocating the buffer if that many bytes
aren't available in the tvbuff);
tvb_get_stringz() - takes a tvbuff, an offset, and a pointer to
a "gint" as arguments, gets the size of the null-terminated
string starting at the specified offset in the tvbuff (throwing
an exception if the null terminator isn't found), allocates a
buffer big enough to hold that string, copies the string to that
buffer, and returns a pointer to that buffer and stores the
length of the string (including the terminating null) in the
variable pointed to by the "gint" pointer.
Replace many pieces of code allocating a buffer and copying a string
with calls to "tvb_get_string()" (for one thing, "tvb_get_string()"
doesn't require you to remember that the argument to
"tvb_get_nstringz0()" is the size of the buffer into which you're
copying the string, which might be the length of the string to be copied
*plus 1*).
Don't use fixed-length buffers for null-terminated strings (even if the
code that generates those packets has a #define to limit the length of
the string). Use "tvb_get_stringz()", instead.
In some cases where a value is fetched but is only used to pass an
argument to a "proto_tree_add_XXX" routine, use "proto_tree_add_item()"
instead.
svn path=/trunk/; revision=7859
2003-06-12 08:33:32 +00:00
|
|
|
FT_STRINGZ, BASE_NONE, NULL, 0x0,
|
2001-06-18 02:18:27 +00:00
|
|
|
"Rule Value", HFILL }},
|
2000-07-27 10:57:12 +00:00
|
|
|
};
|
2001-06-21 15:13:42 +00:00
|
|
|
static gint *ett[] = {
|
|
|
|
&ett_quake,
|
|
|
|
&ett_quake_control,
|
|
|
|
&ett_quake_control_colors,
|
|
|
|
&ett_quake_flags,
|
|
|
|
};
|
|
|
|
module_t *quake_module;
|
|
|
|
|
|
|
|
proto_quake = proto_register_protocol("Quake Network Protocol",
|
2001-01-03 06:56:03 +00:00
|
|
|
"QUAKE", "quake");
|
2001-06-21 15:13:42 +00:00
|
|
|
proto_register_field_array(proto_quake, hf, array_length(hf));
|
|
|
|
proto_register_subtree_array(ett, array_length(ett));
|
|
|
|
|
|
|
|
/* Register a configuration option for port */
|
|
|
|
quake_module = prefs_register_protocol(proto_quake,
|
|
|
|
proto_reg_handoff_quake);
|
|
|
|
prefs_register_uint_preference(quake_module, "udp.port",
|
|
|
|
"Quake Server UDP Port",
|
|
|
|
"Set the UDP port for the Quake Server",
|
|
|
|
10, &gbl_quakeServerPort);
|
2000-07-27 10:57:12 +00:00
|
|
|
}
|