2009-05-21 00:34:03 +00:00
|
|
|
/* packet-paltalk.c
|
|
|
|
* Routines for Paltalk dissection
|
|
|
|
* Copyright 2005, Tim Hentenaar < tim at hentenaar dot com >
|
|
|
|
* Copyright 2008, Mohammad Ebrahim Mohammadi Panah < mebrahim at gmail dot com >
|
|
|
|
*
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
2012-09-20 02:03:38 +00:00
|
|
|
#include "config.h"
|
2009-05-21 00:34:03 +00:00
|
|
|
|
2009-07-11 15:36:18 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
2011-08-08 15:41:09 +00:00
|
|
|
#include <glib.h>
|
2009-05-21 00:34:03 +00:00
|
|
|
#include <epan/packet.h>
|
|
|
|
|
|
|
|
#include "packet-tcp.h"
|
|
|
|
|
2009-07-11 15:36:18 +00:00
|
|
|
#define INET_IPV4_ADDRESS_FROM_BYTES(a,b,c,d) g_htonl(((a)<<24) | ((b)<<16) | ((c)<<8) | (d)) /* *network* order */
|
|
|
|
|
|
|
|
#define PALTALK_SERVERS_ADDRESS INET_IPV4_ADDRESS_FROM_BYTES(199,106,0,0) /* 199.106.0.0 in *network* order */
|
|
|
|
#define PALTALK_SERVERS_NETMASK INET_IPV4_ADDRESS_FROM_BYTES(0xFF, 0xFE, 0x00, 0x00) /* /15 in *network* order */
|
2009-05-21 00:34:03 +00:00
|
|
|
|
|
|
|
#define PALTALK_HEADER_LENGTH 6
|
|
|
|
|
|
|
|
/* forward reference */
|
|
|
|
static guint dissect_paltalk_get_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset);
|
|
|
|
static void dissect_paltalk_desegmented(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
|
|
|
|
|
|
|
|
static int proto_paltalk = -1;
|
2009-05-21 18:36:32 +00:00
|
|
|
|
2009-05-21 00:34:03 +00:00
|
|
|
static int hf_paltalk_pdu_type = -1;
|
|
|
|
static int hf_paltalk_version = -1;
|
|
|
|
static int hf_paltalk_length = -1;
|
|
|
|
static int hf_paltalk_content = -1;
|
|
|
|
|
2009-05-21 18:36:32 +00:00
|
|
|
static gint ett_paltalk = -1;
|
2009-05-21 00:34:03 +00:00
|
|
|
|
|
|
|
static gboolean
|
2012-09-10 21:40:21 +00:00
|
|
|
dissect_paltalk(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
|
2009-05-21 00:34:03 +00:00
|
|
|
{
|
2009-07-11 15:36:18 +00:00
|
|
|
guint32 src32, dst32;
|
|
|
|
|
2009-05-21 00:34:03 +00:00
|
|
|
/* Detect if this TCP session is a Paltalk one */
|
|
|
|
/* TODO: Optimize detection logic if possible */
|
2009-07-11 15:36:18 +00:00
|
|
|
|
2011-10-21 02:10:19 +00:00
|
|
|
if ((pinfo->net_src.type != AT_IPv4)
|
2009-07-11 15:36:18 +00:00
|
|
|
|| (pinfo->net_dst.type != AT_IPv4)
|
|
|
|
|| (pinfo->net_src.len != 4)
|
|
|
|
|| (pinfo->net_dst.len != 4)
|
2011-10-21 02:10:19 +00:00
|
|
|
|| !pinfo->net_src.data
|
2009-07-11 15:36:18 +00:00
|
|
|
|| !pinfo->net_dst.data)
|
2009-05-21 00:34:03 +00:00
|
|
|
return FALSE;
|
2009-07-11 15:36:18 +00:00
|
|
|
|
|
|
|
memcpy((guint8 *)&src32, pinfo->net_src.data, 4); /* *Network* order */
|
|
|
|
memcpy((guint8 *)&dst32, pinfo->net_dst.data, 4); /* *Network* order */
|
|
|
|
|
2011-10-21 02:10:19 +00:00
|
|
|
if ( ((src32 & PALTALK_SERVERS_NETMASK) != PALTALK_SERVERS_ADDRESS)
|
2009-07-11 15:36:18 +00:00
|
|
|
&&
|
|
|
|
((dst32 & PALTALK_SERVERS_NETMASK) != PALTALK_SERVERS_ADDRESS))
|
|
|
|
return FALSE;
|
|
|
|
|
2009-05-21 00:34:03 +00:00
|
|
|
/* Dissect result of desegmented TCP data */
|
|
|
|
tcp_dissect_pdus(tvb, pinfo, tree, TRUE, PALTALK_HEADER_LENGTH
|
|
|
|
, dissect_paltalk_get_len, dissect_paltalk_desegmented);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static guint
|
|
|
|
dissect_paltalk_get_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset)
|
|
|
|
{
|
|
|
|
return tvb_get_ntohs(tvb, offset + 4) + PALTALK_HEADER_LENGTH;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
dissect_paltalk_desegmented(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|
|
|
{
|
|
|
|
proto_item *ti = NULL;
|
|
|
|
proto_tree *pt_tree = NULL;
|
|
|
|
|
2009-08-09 06:26:46 +00:00
|
|
|
col_set_str(pinfo->cinfo, COL_PROTOCOL, "Paltalk");
|
2009-08-09 07:36:13 +00:00
|
|
|
col_clear(pinfo->cinfo, COL_INFO);
|
2009-05-21 00:34:03 +00:00
|
|
|
|
|
|
|
if (tree) /* we are being asked for details */
|
|
|
|
{
|
2011-10-21 02:10:19 +00:00
|
|
|
ti = proto_tree_add_item(tree, proto_paltalk, tvb, 0, -1, ENC_NA);
|
2009-05-21 00:34:03 +00:00
|
|
|
pt_tree = proto_item_add_subtree(ti, ett_paltalk);
|
2011-10-06 03:35:44 +00:00
|
|
|
proto_tree_add_item(pt_tree, hf_paltalk_pdu_type, tvb, 0, 2, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(pt_tree, hf_paltalk_version, tvb, 2, 2, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(pt_tree, hf_paltalk_length, tvb, 4, 2, ENC_BIG_ENDIAN);
|
2011-10-04 22:44:31 +00:00
|
|
|
proto_tree_add_item(pt_tree, hf_paltalk_content, tvb, 6, tvb_get_ntohs(tvb, 4), ENC_NA);
|
2009-05-21 00:34:03 +00:00
|
|
|
}
|
|
|
|
}
|
2009-05-21 18:36:32 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
proto_register_paltalk(void)
|
|
|
|
{
|
|
|
|
static hf_register_info hf[] = {
|
2011-10-21 02:10:19 +00:00
|
|
|
{ &hf_paltalk_pdu_type, { "Packet Type", "paltalk.type",
|
2009-05-21 18:36:32 +00:00
|
|
|
FT_UINT16, BASE_HEX, NULL, 0x00, NULL, HFILL }},
|
|
|
|
{ &hf_paltalk_version, { "Protocol Version", "paltalk.version",
|
|
|
|
FT_INT16, BASE_DEC, NULL, 0x00, NULL, HFILL }},
|
|
|
|
{ &hf_paltalk_length, { "Payload Length", "paltalk.length",
|
|
|
|
FT_INT16, BASE_DEC, NULL, 0x00, NULL, HFILL }},
|
|
|
|
{ &hf_paltalk_content, { "Payload Content", "paltalk.content",
|
|
|
|
FT_BYTES, BASE_NONE, NULL, 0x00, NULL, HFILL }}
|
|
|
|
};
|
|
|
|
|
|
|
|
static gint *ett[] = { &ett_paltalk };
|
|
|
|
|
|
|
|
proto_paltalk = proto_register_protocol("Paltalk Messenger Protocol", "Paltalk", "paltalk");
|
|
|
|
proto_register_field_array(proto_paltalk, hf, array_length(hf));
|
|
|
|
proto_register_subtree_array(ett, array_length(ett));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
proto_reg_handoff_paltalk(void)
|
|
|
|
{
|
|
|
|
heur_dissector_add("tcp", dissect_paltalk, proto_paltalk);
|
|
|
|
}
|
|
|
|
|