2011-11-26 16:23:37 +00:00
|
|
|
/* packet-knet.c
|
2011-11-27 15:34:07 +00:00
|
|
|
* Routines for the KristalliNet (kNet) protocol.
|
2011-11-26 16:23:37 +00:00
|
|
|
* Kari Vatjus-Anttila <kari.vatjus-anttila@cie.fi>
|
|
|
|
* Ville Saarinen <ville.saarinen@cie.fi>
|
|
|
|
*
|
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
2018-02-12 11:23:27 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
2011-11-26 16:23:37 +00:00
|
|
|
*/
|
|
|
|
|
2012-09-20 02:03:38 +00:00
|
|
|
#include "config.h"
|
2011-11-26 16:23:37 +00:00
|
|
|
|
|
|
|
#include <epan/packet.h>
|
|
|
|
#include <epan/prefs.h>
|
2014-12-20 21:23:59 +00:00
|
|
|
#include "packet-tcp.h"
|
2011-11-26 16:23:37 +00:00
|
|
|
|
2013-12-15 23:44:12 +00:00
|
|
|
void proto_register_knet(void);
|
|
|
|
void proto_reg_handoff_knet(void);
|
|
|
|
|
2011-11-26 16:23:37 +00:00
|
|
|
#define PROTO_TAG_KNET "KNET" /*!< Definition of kNet Protocol */
|
2016-10-07 20:25:01 +00:00
|
|
|
#define PORT 2345 /* Not IANA registered */
|
2011-11-26 16:23:37 +00:00
|
|
|
|
|
|
|
#define KNET_SCTP_PACKET 1000
|
|
|
|
#define KNET_TCP_PACKET 1001
|
|
|
|
#define KNET_UDP_PACKET 1002
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @addtogroup messageids kNet Message ID:s
|
|
|
|
* Message ID:s of the kNet protocol
|
|
|
|
*/
|
|
|
|
/**@{*/
|
2011-11-27 15:34:07 +00:00
|
|
|
#define PINGREQUEST 1 /*!< Message ID definition: Ping Request */
|
|
|
|
#define PINGREPLY 2 /*!< Message ID definition: Ping Reply */
|
|
|
|
#define FLOWCONTROLREQUEST 3 /*!< Message ID definition: Flow Control Request */
|
|
|
|
#define PACKETACK 4 /*!< Message ID definition: Packet Acknowledge */
|
2011-11-26 16:23:37 +00:00
|
|
|
#define DISCONNECT 255 /*!< Message ID definition: Disconnect */
|
|
|
|
#define DISCONNECTACK 254 /*!< Message ID definition: Disconnect Ack */
|
|
|
|
#define CONNECTSYN 253 /*!< Message ID definition: Connect Syn */
|
|
|
|
#define CONNECTSYNACK 252 /*!< Message ID definition: Connect Syn Acknowledge */
|
|
|
|
#define CONNECTACK 251 /*!< Message ID definition: Connect Acknowledge */
|
|
|
|
/**@}*/
|
|
|
|
|
2013-11-01 18:29:29 +00:00
|
|
|
#define UDP_DATAGRAM_RELIABLE_FLAG 0x40
|
|
|
|
#define UDP_MSG_BLOCK_RELIABLE_FLAG 0x10
|
2011-11-26 16:23:37 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @addtogroup protocols Protocol Variables
|
|
|
|
* Protocol variables.
|
|
|
|
*/
|
|
|
|
/**@{*/
|
|
|
|
static int proto_knet = -1;
|
|
|
|
/**@}*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @addtogroup headerfields Dissector Header Fields
|
|
|
|
* Header fields of the kNet datagram
|
|
|
|
*/
|
|
|
|
/* *@{*/
|
2011-11-27 15:34:07 +00:00
|
|
|
|
2011-11-26 16:23:37 +00:00
|
|
|
/* Fields used by the TCP/SCTP dissector */
|
|
|
|
static int hf_knet_message_tree = -1; /*!< Message tree */
|
2013-11-01 18:29:29 +00:00
|
|
|
static int hf_knet_content_length_vle = -1; /*!< Content Length */
|
2011-11-26 16:23:37 +00:00
|
|
|
|
|
|
|
/* Fields used by the UDP dissector */
|
2013-11-01 18:29:29 +00:00
|
|
|
static int hf_knet_content_length = -1; /*!< Content Length */
|
2011-11-27 15:34:07 +00:00
|
|
|
static int hf_knet_datagram_tree = -1; /*!< Datagram subtree */
|
|
|
|
static int hf_knet_flags = -1; /*!< UDP Flags subtree */
|
|
|
|
static int hf_knet_inorder = -1; /*!< Inorder Flag */
|
|
|
|
static int hf_knet_reliable = -1; /*!< Reliable Flag */
|
|
|
|
static int hf_knet_packetid = -1; /*!< PacketID */
|
|
|
|
static int hf_knet_rmib = -1; /*!< Reliable Message Index Base */
|
2011-11-26 16:23:37 +00:00
|
|
|
static int hf_knet_msg_flags = -1; /*!< Message Block Flags subtree */
|
|
|
|
static int hf_knet_msg_fs = -1; /*!< Fragment Start */
|
|
|
|
static int hf_knet_msg_ff = -1; /*!< Fragment Flag */
|
|
|
|
static int hf_knet_msg_inorder = -1; /*!< Inorder Flag */
|
|
|
|
static int hf_knet_msg_reliable = -1; /*!< Reliable Flag */
|
|
|
|
static int hf_knet_msg_reliable_message_number = -1; /*!< Reliable Message Number */
|
|
|
|
|
|
|
|
static int hf_knet_payload_tree = -1; /*!< Payload subtree */
|
2011-11-27 15:34:07 +00:00
|
|
|
static int hf_knet_payload = -1; /*!< Payload subtree */
|
2011-11-26 16:23:37 +00:00
|
|
|
static int hf_knet_messageid = -1; /*!< MessageID of the packet */
|
2011-11-27 15:34:07 +00:00
|
|
|
static int hf_knet_pingid = -1;
|
2011-11-26 16:23:37 +00:00
|
|
|
static int hf_knet_flowctrlreq = -1;
|
|
|
|
static int hf_knet_packetack = -1;
|
|
|
|
static int hf_knet_seqnumber = -1;
|
|
|
|
/**@}*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @addtogroup trees Subtrees used by the dissectors
|
|
|
|
*/
|
|
|
|
/* *@{*/
|
|
|
|
|
|
|
|
/*Knet Subtrees */
|
2011-11-27 15:34:07 +00:00
|
|
|
static gint ett_knet_main = -1; /*!< Main kNet tree */
|
|
|
|
static gint ett_knet_message = -1; /*!< Message tree */
|
|
|
|
static gint ett_knet_payload = -1; /*!< Payload tree */
|
|
|
|
static gint ett_knet_message_flags = -1; /*!< Message flags tree */
|
2011-11-26 16:23:37 +00:00
|
|
|
static gint ett_knet_datagram = -1;
|
2011-11-27 15:34:07 +00:00
|
|
|
static gint ett_knet_flags = -1;
|
2011-11-26 16:23:37 +00:00
|
|
|
/**@}*/
|
|
|
|
|
2013-08-05 18:09:43 +00:00
|
|
|
static dissector_handle_t knet_handle_sctp;
|
|
|
|
static dissector_handle_t knet_handle_tcp;
|
|
|
|
static dissector_handle_t knet_handle_udp;
|
|
|
|
|
2011-11-26 16:23:37 +00:00
|
|
|
/* Ports used by the dissectors */
|
|
|
|
static guint32 knet_sctp_port = PORT; /*!< Port used by kNet SCTP */
|
|
|
|
|
|
|
|
static const value_string packettypenames[] = { /*!< Messageid List */
|
|
|
|
{ PINGREQUEST, "Ping Request" },
|
|
|
|
{ PINGREPLY, "Ping Reply" },
|
|
|
|
{ FLOWCONTROLREQUEST, "Flowcontrol Request" },
|
|
|
|
{ PACKETACK, "Packet Ack" },
|
|
|
|
{ DISCONNECT, "Disconnect" },
|
|
|
|
{ DISCONNECTACK, "Disconnect Ack" },
|
|
|
|
{ CONNECTSYN, "Connect Syn" },
|
|
|
|
{ CONNECTSYNACK, "Connect Syn Ack" },
|
|
|
|
{ CONNECTACK, "Connect Ack" },
|
|
|
|
{ 0, NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* counts length of the variable length encoded field
|
|
|
|
*
|
|
|
|
* @param tvb the buffer to the data
|
|
|
|
* @param offset the offset of data in the buffer
|
|
|
|
* @return int returns number of bytes used
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
count_vle_bytes(tvbuff_t *tvb, int offset)
|
|
|
|
{
|
2013-11-01 18:29:29 +00:00
|
|
|
int byte_count = 1;
|
2011-11-26 16:23:37 +00:00
|
|
|
|
2013-11-01 18:29:29 +00:00
|
|
|
if(tvb_get_guint8(tvb, offset) & 0x80) /* If the first bit of the first byte is 1 */
|
2011-11-26 16:23:37 +00:00
|
|
|
byte_count = 2; /* There's at least 2 bytes of content length */
|
2013-11-01 18:29:29 +00:00
|
|
|
if(tvb_get_guint8(tvb, offset+1) & 0x80) /* If the next one is also 1 */
|
2011-11-26 16:23:37 +00:00
|
|
|
byte_count = 4;
|
|
|
|
|
|
|
|
return byte_count;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* dissect_packetid is a utility function which calculates
|
|
|
|
* the packets Packet ID from the data. Packet ID is a field
|
|
|
|
* located in the datagram header.
|
2011-11-27 15:34:07 +00:00
|
|
|
*
|
2011-11-26 16:23:37 +00:00
|
|
|
* @see dissect_reliable_message_index_base()
|
|
|
|
* @see dissect_reliable_message_number()
|
|
|
|
* @see dissect_content_length()
|
|
|
|
* @see dissect_messageid()
|
|
|
|
* @see dissect_payload()
|
|
|
|
* @param buffer the buffer to the data
|
|
|
|
* @param offset the offset where to start reading the data
|
|
|
|
* @param tree the parent tree where the dissected data is going to be inserted
|
|
|
|
* @return int returns the new offset
|
|
|
|
*
|
|
|
|
*/
|
2013-11-01 18:29:29 +00:00
|
|
|
static guint32
|
2011-11-26 16:23:37 +00:00
|
|
|
dissect_packetid(tvbuff_t *buffer, int offset, proto_tree *tree)
|
|
|
|
{
|
|
|
|
guint32 packetid;
|
|
|
|
|
2013-11-01 18:29:29 +00:00
|
|
|
packetid = tvb_get_guint8(buffer, offset+2) << 14;
|
|
|
|
packetid += tvb_get_guint8(buffer, offset+1) << 6;
|
|
|
|
packetid += tvb_get_guint8(buffer, offset) & 63;
|
2011-11-26 16:23:37 +00:00
|
|
|
|
2013-11-01 18:29:29 +00:00
|
|
|
proto_tree_add_uint(tree, hf_knet_packetid, buffer, 0, 3, packetid);
|
2011-11-26 16:23:37 +00:00
|
|
|
return packetid;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-11-27 15:34:07 +00:00
|
|
|
* dissect_reliable_message_index_base is a utility function
|
2011-11-26 16:23:37 +00:00
|
|
|
* which calculates the packets RMIB if and only if the reliable
|
|
|
|
* flag is set to 1.
|
2011-11-27 15:34:07 +00:00
|
|
|
*
|
2011-11-26 16:23:37 +00:00
|
|
|
* @see dissect_packetid()
|
|
|
|
* @see dissect_content_length()
|
|
|
|
* @see dissect_reliable_message_number()
|
|
|
|
* @see dissect_messageid()
|
|
|
|
* @see dissect_payload()
|
|
|
|
* @param buffer the buffer to the data
|
|
|
|
* @param offset the offset where to start reading the data
|
|
|
|
* @param tree the parent tree where the dissected data is going to be inserted
|
|
|
|
* @return int returns the new offset
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
dissect_reliable_message_index_base(tvbuff_t *buffer, int offset, proto_tree *tree)
|
|
|
|
{
|
2013-11-01 18:29:29 +00:00
|
|
|
int byte_count = 2;
|
2011-11-26 16:23:37 +00:00
|
|
|
|
2013-11-01 18:29:29 +00:00
|
|
|
if(tvb_get_guint8(buffer, offset+1) & 0x80)
|
2011-11-26 16:23:37 +00:00
|
|
|
byte_count = 4;
|
|
|
|
|
2013-11-01 18:29:29 +00:00
|
|
|
proto_tree_add_item(tree, hf_knet_rmib, buffer, offset, byte_count, ENC_LITTLE_ENDIAN);
|
2011-11-26 16:23:37 +00:00
|
|
|
|
|
|
|
return byte_count;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* dissect_content_length_vle is a utility function which
|
|
|
|
* calculates how long is the payload section of the message
|
|
|
|
* in bytes which is VLE encoded.
|
|
|
|
*
|
|
|
|
* @see dissect_packetid()
|
|
|
|
* @see dissect_reliable_message_index_base()
|
|
|
|
* @see dissect_reliable_message_number()
|
|
|
|
* @see dissect_messageid()
|
|
|
|
* @see dissect_payload()
|
|
|
|
* @param buffer the buffer to the data
|
|
|
|
* @param offset the offset where to start reading the data
|
|
|
|
* @param tree the parent tree where the dissected data is going to be inserted
|
|
|
|
* @return int returns the content length of the packet
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
dissect_content_length_vle(tvbuff_t *buffer, int *offset, proto_tree *tree)
|
|
|
|
{
|
2012-01-14 16:18:16 +00:00
|
|
|
int byte_count;
|
2011-11-26 16:23:37 +00:00
|
|
|
guint32 length;
|
|
|
|
|
2012-01-14 16:18:16 +00:00
|
|
|
length = 0;
|
2011-11-26 16:23:37 +00:00
|
|
|
byte_count = count_vle_bytes(buffer, *offset);
|
|
|
|
|
|
|
|
switch(byte_count) /*We must calculate length by hand because we use the length later */
|
|
|
|
{
|
|
|
|
case 4:
|
2013-11-01 18:29:29 +00:00
|
|
|
length = tvb_get_guint8(buffer, (*offset) + 3) << 23;
|
|
|
|
length += (tvb_get_guint8(buffer, (*offset) + 2) << 15);
|
2011-11-27 16:29:42 +00:00
|
|
|
/* FALLTHRU */
|
2011-11-26 16:23:37 +00:00
|
|
|
case 2:
|
2013-11-01 18:29:29 +00:00
|
|
|
length += (tvb_get_guint8(buffer, (*offset) + 1) << 7);
|
2011-11-27 16:29:42 +00:00
|
|
|
/* FALLTHRU */
|
2011-11-26 16:23:37 +00:00
|
|
|
case 1:
|
2013-11-01 18:29:29 +00:00
|
|
|
length += (tvb_get_guint8(buffer, (*offset)) & 0x7F);
|
2011-11-26 16:23:37 +00:00
|
|
|
break;
|
|
|
|
default:
|
2012-01-14 16:18:16 +00:00
|
|
|
REPORT_DISSECTOR_BUG("Error in Content Length calculation");
|
2011-11-26 16:23:37 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-11-01 18:29:29 +00:00
|
|
|
proto_tree_add_uint(tree, hf_knet_content_length_vle, buffer, (*offset), byte_count, length);
|
|
|
|
(*offset) += byte_count;
|
2011-11-26 16:23:37 +00:00
|
|
|
|
|
|
|
return length;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* dissect_content_length is a utility function which
|
|
|
|
* calculates how long is the payload section of the message
|
|
|
|
* in bytes. Used only by the UDP dissector.
|
2011-11-27 15:34:07 +00:00
|
|
|
*
|
2011-11-26 16:23:37 +00:00
|
|
|
* @see dissect_packetid()
|
|
|
|
* @see dissect_reliable_message_index_base()
|
|
|
|
* @see dissect_reliable_message_number()
|
|
|
|
* @see dissect_messageid()
|
|
|
|
* @see dissect_payload()
|
|
|
|
* @param buffer the buffer to the data
|
|
|
|
* @param offset the offset where to start reading the data
|
|
|
|
* @param tree the parent tree where the dissected data is going to be inserted
|
|
|
|
* @return int returns the content length of the packet
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
dissect_content_length(tvbuff_t *buffer, int offset, proto_tree *tree)
|
|
|
|
{
|
|
|
|
proto_item *msgflags_ti;
|
|
|
|
proto_tree *msgflags_tree;
|
2012-01-14 16:18:16 +00:00
|
|
|
guint32 length;
|
2011-11-26 16:23:37 +00:00
|
|
|
|
2012-01-14 16:18:16 +00:00
|
|
|
length = tvb_get_bits8(buffer, offset * 8 + 12, 4) << 8;
|
2011-11-26 16:23:37 +00:00
|
|
|
length += tvb_get_bits8(buffer, offset * 8, 8);
|
|
|
|
|
|
|
|
if(tree != NULL)
|
|
|
|
{
|
2012-01-14 16:18:16 +00:00
|
|
|
msgflags_ti = proto_tree_add_item(tree, hf_knet_msg_flags, buffer, offset + 1, 1, ENC_NA);
|
2011-11-26 16:23:37 +00:00
|
|
|
msgflags_tree = proto_item_add_subtree(msgflags_ti, ett_knet_message_flags);
|
|
|
|
|
2013-11-01 18:29:29 +00:00
|
|
|
proto_tree_add_item(msgflags_tree, hf_knet_msg_fs, buffer, offset+1, 1, ENC_NA); /* Fragment start flag */
|
|
|
|
proto_tree_add_item(msgflags_tree, hf_knet_msg_ff, buffer, offset+1, 1, ENC_NA); /* Fragment flag */
|
|
|
|
proto_tree_add_item(msgflags_tree, hf_knet_msg_inorder, buffer, offset+1, 1, ENC_NA); /* Inorder flag */
|
|
|
|
proto_tree_add_item(msgflags_tree, hf_knet_msg_reliable, buffer, offset+1, 1, ENC_NA); /* Reliable flag */
|
2011-11-26 16:23:37 +00:00
|
|
|
|
2013-07-16 15:10:38 +00:00
|
|
|
proto_tree_add_uint(tree, hf_knet_content_length, buffer, offset, 2, length);
|
|
|
|
}
|
2011-11-26 16:23:37 +00:00
|
|
|
|
|
|
|
return length;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* dissect_reliable_message_number is a utility function which
|
|
|
|
* calculates the RMN if and only if the reliable flag in the
|
|
|
|
* message block is set to 1.
|
2011-11-27 15:34:07 +00:00
|
|
|
*
|
2011-11-26 16:23:37 +00:00
|
|
|
* @see dissect_packetid()
|
|
|
|
* @see dissect_reliable_message_index_base()
|
|
|
|
* @see dissect_content_length()
|
|
|
|
* @see dissect_messageid()
|
|
|
|
* @see dissect_payload()
|
|
|
|
* @param buffer the buffer to the data
|
|
|
|
* @param offset the offset where to start reading the data
|
|
|
|
* @param tree the parent tree where the dissected data is going to be inserted
|
|
|
|
* @return int returns the new offset
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
dissect_reliable_message_number(tvbuff_t *buffer, int offset, proto_tree *tree)
|
|
|
|
{
|
2013-11-01 18:29:29 +00:00
|
|
|
int byte_count = 1;
|
2011-11-26 16:23:37 +00:00
|
|
|
|
2013-11-01 18:29:29 +00:00
|
|
|
if(tvb_get_guint8(buffer, offset) & 0x80)
|
2011-11-26 16:23:37 +00:00
|
|
|
byte_count = 2;
|
|
|
|
|
2013-11-01 18:29:29 +00:00
|
|
|
proto_tree_add_item(tree, hf_knet_msg_reliable_message_number, buffer, offset, byte_count, ENC_LITTLE_ENDIAN);
|
2011-11-26 16:23:37 +00:00
|
|
|
|
|
|
|
return byte_count;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* dissect_messageid is a utility function which
|
|
|
|
* calculates the ID of the message.
|
2011-11-27 15:34:07 +00:00
|
|
|
*
|
2011-11-26 16:23:37 +00:00
|
|
|
* @see dissect_packetid()
|
|
|
|
* @see dissect_reliable_message_index_base()
|
|
|
|
* @see dissect_content_length()
|
|
|
|
* @see dissect_reliable_message_number()
|
|
|
|
* @see dissect_payload()
|
|
|
|
* @param buffer the buffer to the data
|
|
|
|
* @param offset the offset where to start reading the data
|
|
|
|
* @param tree the parent tree where the dissected data is going to be inserted
|
|
|
|
* @return int returns the messageid
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static int
|
2013-11-01 18:29:29 +00:00
|
|
|
dissect_messageid(tvbuff_t *buffer, int *offset, proto_tree *tree, packet_info *pinfo, gboolean separator)
|
2011-11-26 16:23:37 +00:00
|
|
|
{
|
2012-01-14 16:18:16 +00:00
|
|
|
gint messageid_length;
|
2011-11-26 16:23:37 +00:00
|
|
|
guint8 messageid;
|
|
|
|
|
2013-11-01 18:29:29 +00:00
|
|
|
messageid = tvb_get_guint8(buffer, (*offset));
|
2011-11-26 16:23:37 +00:00
|
|
|
|
|
|
|
switch(messageid)
|
|
|
|
{
|
|
|
|
case DISCONNECT:
|
|
|
|
case DISCONNECTACK:
|
|
|
|
case CONNECTSYN:
|
|
|
|
case CONNECTSYNACK:
|
|
|
|
case CONNECTACK:
|
|
|
|
messageid_length = 4;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
messageid_length = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-11-01 18:29:29 +00:00
|
|
|
proto_tree_add_uint_format_value(tree, hf_knet_messageid, buffer, *offset, messageid_length, messageid,
|
|
|
|
"%s (%d)", val_to_str_const(messageid, packettypenames, "AppData or Malformed Message ID"), messageid);
|
2011-11-26 16:23:37 +00:00
|
|
|
|
2013-11-01 18:29:29 +00:00
|
|
|
if (separator)
|
|
|
|
{
|
|
|
|
col_append_sep_fstr(pinfo->cinfo, COL_INFO, ", ", "%s (%d)", val_to_str_const(messageid, packettypenames, "AppData"), messageid);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
col_append_fstr(pinfo->cinfo, COL_INFO, "%s (%d)", val_to_str_const(messageid, packettypenames, "AppData"), messageid);
|
|
|
|
}
|
2011-11-26 16:23:37 +00:00
|
|
|
|
|
|
|
*offset += messageid_length;
|
|
|
|
|
|
|
|
return messageid;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* dissect_payload is a utility function which
|
|
|
|
* calculates the actual payload of the message.
|
2011-11-27 15:34:07 +00:00
|
|
|
*
|
2011-11-26 16:23:37 +00:00
|
|
|
* @see dissect_packetid()
|
|
|
|
* @see dissect_reliable_message_index_base()
|
|
|
|
* @see dissect_content_length()
|
|
|
|
* @see dissect_reliable_message_number()
|
|
|
|
* @see dissect_messageid()
|
|
|
|
* @param buffer the buffer to the data
|
|
|
|
* @param offset the offset where to start reading the data
|
|
|
|
* @param messageid the messageid of the received message
|
|
|
|
* @param tree the parent tree where the dissected data is going to be inserted
|
|
|
|
* @param content_length the content length of the payload
|
|
|
|
* @return int returns 0 at the moment
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
dissect_payload(tvbuff_t *buffer, int offset, int messageid, proto_tree *tree, int content_length)
|
|
|
|
{
|
|
|
|
proto_item *payload_ti;
|
|
|
|
proto_tree *payload_tree;
|
|
|
|
|
2012-01-14 16:18:16 +00:00
|
|
|
payload_ti = proto_tree_add_item(tree, hf_knet_payload_tree, buffer, offset, content_length - 1, ENC_NA);
|
2011-11-26 16:23:37 +00:00
|
|
|
payload_tree = proto_item_add_subtree(payload_ti, ett_knet_payload);
|
|
|
|
|
|
|
|
switch(messageid)
|
|
|
|
{
|
|
|
|
case PINGREQUEST:
|
|
|
|
case PINGREPLY:
|
|
|
|
proto_tree_add_item(payload_tree, hf_knet_pingid, buffer, offset, 1, ENC_LITTLE_ENDIAN);
|
|
|
|
break;
|
|
|
|
case FLOWCONTROLREQUEST:
|
|
|
|
proto_tree_add_item(payload_tree, hf_knet_flowctrlreq, buffer, offset, 3, ENC_LITTLE_ENDIAN);
|
|
|
|
break;
|
|
|
|
case PACKETACK:
|
|
|
|
proto_tree_add_item(payload_tree, hf_knet_packetack, buffer, offset, 3, ENC_LITTLE_ENDIAN);
|
|
|
|
offset += 3;
|
|
|
|
proto_tree_add_item(payload_tree, hf_knet_seqnumber, buffer, offset, 4, ENC_LITTLE_ENDIAN);
|
|
|
|
break;
|
|
|
|
case DISCONNECT: /*No payload*/
|
|
|
|
case DISCONNECTACK: /*No payload*/
|
2014-08-13 12:56:22 +00:00
|
|
|
proto_tree_add_bytes_format(payload_tree, hf_knet_payload, buffer, offset, 0, NULL, "No Payload");
|
2011-11-26 16:23:37 +00:00
|
|
|
break;
|
|
|
|
case CONNECTSYN: /*TODO: Not yet implemented, implement when available*/
|
|
|
|
case CONNECTSYNACK: /*TODO: Not yet implemented, implement when available*/
|
|
|
|
case CONNECTACK: /*TODO: Not yet implemented, implement when available*/
|
2013-11-01 18:29:29 +00:00
|
|
|
proto_tree_add_item(payload_tree, hf_knet_payload, buffer, offset, content_length-1, ENC_NA);
|
2011-11-26 16:23:37 +00:00
|
|
|
break;
|
|
|
|
default: /* Application Specific Message */
|
2013-11-01 18:29:29 +00:00
|
|
|
proto_tree_add_item(payload_tree, hf_knet_payload, buffer, offset, content_length-1, ENC_NA);
|
2011-11-26 16:23:37 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* dissect_knet_message is the subdissector which is called
|
|
|
|
* by dissect_knet when the dissector has dissected the
|
|
|
|
* datagram header. This subdissector dissects all of the
|
|
|
|
* messages which are encapsulated in the kNet datagram.
|
2011-11-27 15:34:07 +00:00
|
|
|
*
|
2011-11-26 16:23:37 +00:00
|
|
|
* @see dissect_knet()
|
|
|
|
* @param tvb the buffer to the data
|
|
|
|
* @param pinfo the packet info structure
|
|
|
|
* @param tree the parent tree where the dissected data is going to be inserted
|
|
|
|
*
|
|
|
|
*/
|
2013-11-01 18:29:29 +00:00
|
|
|
static int
|
|
|
|
dissect_knet_message(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, int messageindex)
|
2011-11-26 16:23:37 +00:00
|
|
|
{
|
2013-11-01 18:29:29 +00:00
|
|
|
int content_length, total_length, messageid;
|
|
|
|
int start_offset = offset;
|
2011-11-26 16:23:37 +00:00
|
|
|
|
|
|
|
proto_item *msgblock_ti;
|
|
|
|
proto_tree *msgblock_tree;
|
|
|
|
|
2013-11-01 18:29:29 +00:00
|
|
|
msgblock_ti = proto_tree_add_item(tree, hf_knet_message_tree, tvb, offset, -1, ENC_NA);
|
2011-11-26 16:23:37 +00:00
|
|
|
msgblock_tree = proto_item_add_subtree(msgblock_ti, ett_knet_message);
|
|
|
|
|
|
|
|
content_length = dissect_content_length(tvb, offset, msgblock_tree); /* Calculates the Content Length of this packet. */
|
|
|
|
|
2013-11-01 18:29:29 +00:00
|
|
|
if(tvb_get_guint8(tvb, offset+1) & UDP_MSG_BLOCK_RELIABLE_FLAG) /* If the reliable flag is 1 then calculate RMN */
|
|
|
|
offset += dissect_reliable_message_number(tvb, offset+2, msgblock_tree);
|
2011-11-26 16:23:37 +00:00
|
|
|
|
|
|
|
offset += 2; /* Move the offset the amount of contentlength and flags fields */
|
|
|
|
|
2013-11-01 18:29:29 +00:00
|
|
|
total_length = (offset-start_offset)+content_length;
|
|
|
|
proto_item_set_len(msgblock_ti, total_length);
|
2011-11-26 16:23:37 +00:00
|
|
|
|
2013-11-01 18:29:29 +00:00
|
|
|
messageid = dissect_messageid(tvb, &offset, msgblock_tree, pinfo, messageindex != 0);
|
2011-11-26 16:23:37 +00:00
|
|
|
|
|
|
|
dissect_payload(tvb, offset, messageid, msgblock_tree, content_length);
|
|
|
|
|
2013-11-01 18:29:29 +00:00
|
|
|
return total_length;
|
2011-11-26 16:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* dissect_knet is the dissector which is called
|
|
|
|
* by Wireshark when kNet packets are captured. Here
|
2011-11-27 15:34:07 +00:00
|
|
|
* is dissected the SCTP and TCP packets in its own
|
2011-11-26 16:23:37 +00:00
|
|
|
* section and UDP packets in its own, because UDP
|
|
|
|
* packets differ quite a lot from SCTP and TCP.
|
|
|
|
* SCTP and TCP in the other hand has quite the same
|
|
|
|
* structure.
|
|
|
|
*
|
|
|
|
* @param tvb the buffer to the data
|
|
|
|
* @param pinfo the packet info structure
|
|
|
|
* @param tree the parent tree where the dissected data is going to be inserted
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static void
|
2013-11-01 18:29:29 +00:00
|
|
|
dissect_knet(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int current_protocol)
|
2011-11-26 16:23:37 +00:00
|
|
|
{
|
2013-11-01 18:29:29 +00:00
|
|
|
proto_item *knet_ti, *message_ti;
|
|
|
|
proto_tree *knet_tree, *message_tree;
|
2011-11-26 16:23:37 +00:00
|
|
|
|
2013-11-01 18:29:29 +00:00
|
|
|
int offset = 0, content_length, messageid;
|
2011-11-26 16:23:37 +00:00
|
|
|
|
2013-11-01 18:29:29 +00:00
|
|
|
/* Attach kNet main tree to Wireshark tree */
|
|
|
|
knet_ti = proto_tree_add_item(tree, proto_knet, tvb, 0, -1, ENC_NA);
|
|
|
|
knet_tree = proto_item_add_subtree(knet_ti, ett_knet_main);
|
2011-11-26 16:23:37 +00:00
|
|
|
|
2013-11-01 18:29:29 +00:00
|
|
|
/* Attach message tree to kNet tree */
|
|
|
|
message_ti = proto_tree_add_item(knet_tree, hf_knet_message_tree, tvb, offset, -1, ENC_NA);
|
|
|
|
message_tree = proto_item_add_subtree(message_ti, ett_knet_message);
|
2011-11-26 16:23:37 +00:00
|
|
|
|
2013-11-01 18:29:29 +00:00
|
|
|
content_length = dissect_content_length_vle(tvb, &offset, message_tree); /* Calculate length and add it to the tree-view */
|
|
|
|
proto_item_set_len(message_ti, (current_protocol == KNET_SCTP_PACKET ? content_length + 1 : content_length + 2));
|
2011-11-26 16:23:37 +00:00
|
|
|
|
2013-11-01 18:29:29 +00:00
|
|
|
messageid = dissect_messageid(tvb, &offset, message_tree, pinfo, TRUE); /* Calculate messageid and add it to the tree-view */
|
2011-11-26 16:23:37 +00:00
|
|
|
|
2013-11-01 18:29:29 +00:00
|
|
|
dissect_payload(tvb, offset, messageid, message_tree, content_length); /* Calculate payload and add it to the tree-view */
|
2011-11-26 16:23:37 +00:00
|
|
|
|
2013-11-01 18:29:29 +00:00
|
|
|
col_set_fence(pinfo->cinfo, COL_INFO);
|
2011-11-26 16:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Callback function that returns the pdu length.
|
|
|
|
* Used by TCP dissector.
|
|
|
|
*
|
|
|
|
* @param pinfo the info about the packet
|
|
|
|
* @param tvb the data buffer
|
|
|
|
* @param offset the offset to the tvb buffer
|
|
|
|
* @return guint returns pdu length
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static guint
|
2015-01-25 19:30:13 +00:00
|
|
|
get_knet_pdu_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset, void *data _U_)
|
2011-11-26 16:23:37 +00:00
|
|
|
{
|
2013-11-01 18:29:29 +00:00
|
|
|
return count_vle_bytes(tvb, offset) + dissect_content_length_vle(tvb, &offset, NULL);
|
2011-11-26 16:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* dissect_knet_tcp is the dissector which is called
|
|
|
|
* by Wireshark when kNet TCP packets are captured.
|
2011-11-27 15:34:07 +00:00
|
|
|
*
|
2011-11-26 16:23:37 +00:00
|
|
|
* @param tvb the buffer to the data
|
|
|
|
* @param pinfo the packet info structure
|
|
|
|
* @param tree the parent tree where the dissected data is going to be inserted
|
|
|
|
*
|
|
|
|
*/
|
2013-11-09 17:46:28 +00:00
|
|
|
static int
|
|
|
|
dissect_knet_tcp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
|
2013-11-01 18:29:29 +00:00
|
|
|
{
|
|
|
|
dissect_knet(tvb, pinfo, tree, KNET_TCP_PACKET);
|
2015-06-23 18:24:48 +00:00
|
|
|
return tvb_captured_length(tvb);
|
2013-11-01 18:29:29 +00:00
|
|
|
}
|
|
|
|
|
2013-11-09 17:46:28 +00:00
|
|
|
static int
|
|
|
|
dissect_knet_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
|
2011-11-26 16:23:37 +00:00
|
|
|
{
|
2018-12-30 16:37:13 +00:00
|
|
|
//Sanity check the length field
|
|
|
|
if (tvb_reported_length(tvb) < 2)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
int offset = 0;
|
|
|
|
if (dissect_content_length_vle(tvb, &offset, NULL) == 0)
|
|
|
|
return 0;
|
|
|
|
|
2013-11-01 18:29:29 +00:00
|
|
|
col_clear(pinfo->cinfo, COL_INFO);
|
|
|
|
col_set_str(pinfo->cinfo, COL_PROTOCOL, "KNET");
|
2011-11-26 16:23:37 +00:00
|
|
|
|
2013-11-09 17:46:28 +00:00
|
|
|
tcp_dissect_pdus(tvb, pinfo, tree, TRUE, 2, get_knet_pdu_len, dissect_knet_tcp_pdu, data);
|
2015-06-23 18:24:48 +00:00
|
|
|
return tvb_captured_length(tvb);
|
2011-11-26 16:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* dissect_knet_sctp is the dissector which is called
|
|
|
|
* by Wireshark when kNet STCP packets are captured.
|
2011-11-27 15:34:07 +00:00
|
|
|
*
|
2011-11-26 16:23:37 +00:00
|
|
|
* @param tvb the buffer to the data
|
|
|
|
* @param pinfo the packet info structure
|
|
|
|
* @param tree the parent tree where the dissected data is going to be inserted
|
|
|
|
*
|
|
|
|
*/
|
2015-11-09 00:30:18 +00:00
|
|
|
static int
|
|
|
|
dissect_knet_sctp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
|
2011-11-26 16:23:37 +00:00
|
|
|
{
|
2013-11-01 18:29:29 +00:00
|
|
|
col_clear(pinfo->cinfo, COL_INFO);
|
|
|
|
col_set_str(pinfo->cinfo, COL_PROTOCOL, "KNET");
|
2011-11-26 16:23:37 +00:00
|
|
|
|
2013-11-01 18:29:29 +00:00
|
|
|
dissect_knet(tvb, pinfo, tree, KNET_SCTP_PACKET);
|
2015-11-09 00:30:18 +00:00
|
|
|
return tvb_captured_length(tvb);
|
2011-11-26 16:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* dissect_knet_udp is the dissector which is called
|
|
|
|
* by Wireshark when kNet UDP packets are captured.
|
2011-11-27 15:34:07 +00:00
|
|
|
*
|
2011-11-26 16:23:37 +00:00
|
|
|
* @param tvb the buffer to the data
|
|
|
|
* @param pinfo the packet info structure
|
|
|
|
* @param tree the parent tree where the dissected data is going to be inserted
|
|
|
|
*
|
|
|
|
*/
|
2015-11-09 00:30:18 +00:00
|
|
|
static int
|
|
|
|
dissect_knet_udp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
|
2011-11-26 16:23:37 +00:00
|
|
|
{
|
2013-11-01 18:29:29 +00:00
|
|
|
/* Common subtrees */
|
|
|
|
proto_item *knet_ti;
|
|
|
|
proto_tree *knet_tree;
|
2011-11-26 16:23:37 +00:00
|
|
|
|
2013-11-01 18:29:29 +00:00
|
|
|
/* Subtrees used in kNet UDP dissector */
|
|
|
|
proto_item *datagram_ti, *udpflags_ti;
|
|
|
|
proto_tree *datagram_tree, /* Tree containing all header related info */
|
|
|
|
*udpflags_tree; /* Tree containing UDP Datagram Flags */
|
|
|
|
|
|
|
|
int offset = 0;
|
|
|
|
guint32 packetid; /* Contains info about PacketID */
|
|
|
|
int messageindex = 0; /*!< Index of the kNet message inside a datagram */
|
|
|
|
|
|
|
|
col_clear(pinfo->cinfo, COL_INFO);
|
|
|
|
col_set_str(pinfo->cinfo, COL_PROTOCOL, "KNET");
|
|
|
|
|
|
|
|
/*kNet UDP Tree*/
|
|
|
|
knet_ti = proto_tree_add_item(tree, proto_knet, tvb, 0, -1, ENC_NA); /* Attach kNet tree to wireshark main tree */
|
|
|
|
knet_tree = proto_item_add_subtree(knet_ti, ett_knet_main);
|
|
|
|
|
|
|
|
/*Datagram Header Tree*/
|
|
|
|
datagram_ti = proto_tree_add_item(knet_ti, hf_knet_datagram_tree, tvb, 0, 3, ENC_NA); /* Attach Header tree to wireshark main tree */
|
|
|
|
datagram_tree = proto_item_add_subtree(datagram_ti, ett_knet_datagram);
|
|
|
|
|
|
|
|
packetid = dissect_packetid(tvb, 0, datagram_tree); /* Lets calculate our packetid! */
|
|
|
|
col_add_fstr(pinfo->cinfo, COL_INFO, "Packet ID %d: ", packetid);
|
|
|
|
|
|
|
|
/*UDPFlags Tree*/
|
|
|
|
udpflags_ti = proto_tree_add_item(datagram_ti, hf_knet_flags, tvb, 0, 1, ENC_NA); /* Attach UDP Flags tree to kNet tree */
|
|
|
|
udpflags_tree = proto_item_add_subtree(udpflags_ti, ett_knet_flags);
|
|
|
|
|
|
|
|
proto_tree_add_item(udpflags_tree, hf_knet_inorder, tvb, 0, 1, ENC_NA); /* Add inorder flag to UDP Flags tree */
|
|
|
|
proto_tree_add_item(udpflags_tree, hf_knet_reliable, tvb, 0, 1, ENC_NA); /* Add reliable flag to UDP Flags tree */
|
|
|
|
|
|
|
|
offset += 3;
|
|
|
|
|
|
|
|
if(tvb_get_guint8(tvb, 0) & UDP_DATAGRAM_RELIABLE_FLAG)
|
|
|
|
offset += dissect_reliable_message_index_base(tvb, 3, datagram_tree); /* Calculate RMIB */
|
|
|
|
|
2015-06-24 00:22:18 +00:00
|
|
|
while ((tvb_reported_length_remaining(tvb, offset) > 2) && /* If there's at least 2 bytes available in the buffer */
|
2013-11-01 18:29:29 +00:00
|
|
|
(dissect_content_length(tvb, offset, NULL) > 0)) /* Empty data Abort */
|
|
|
|
{
|
|
|
|
offset += dissect_knet_message(tvb, pinfo, knet_tree, offset, messageindex); /* Call the message subdissector */
|
|
|
|
messageindex++;
|
|
|
|
}
|
2015-11-09 00:30:18 +00:00
|
|
|
|
|
|
|
return tvb_captured_length(tvb);
|
2011-11-26 16:23:37 +00:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* proto_register_knet registers our kNet protocol,
|
|
|
|
* headerfield- and subtree-array to Wireshark.
|
2011-11-27 15:34:07 +00:00
|
|
|
*
|
2011-11-26 16:23:37 +00:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
proto_register_knet(void)
|
|
|
|
{
|
|
|
|
module_t *knet_module;
|
|
|
|
|
|
|
|
static hf_register_info hf_knet[] =
|
|
|
|
{
|
2011-11-27 15:34:07 +00:00
|
|
|
/* TCP & SCTP Header */
|
2013-11-01 18:29:29 +00:00
|
|
|
{&hf_knet_content_length_vle,
|
2011-11-27 15:34:07 +00:00
|
|
|
{"Content Length", "knet.length",
|
|
|
|
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL}},
|
|
|
|
{&hf_knet_message_tree,
|
|
|
|
{"Message Block", "knet.msg",
|
|
|
|
FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL}},
|
|
|
|
|
2011-11-26 16:23:37 +00:00
|
|
|
/* UDP Header */
|
2011-11-27 15:34:07 +00:00
|
|
|
{&hf_knet_datagram_tree,
|
|
|
|
{"Datagram Header", "knet.datagram",
|
|
|
|
FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL}},
|
|
|
|
{&hf_knet_flags,
|
|
|
|
{"Flags", "knet.datagram.flags",
|
|
|
|
FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL}},
|
|
|
|
{&hf_knet_inorder,
|
|
|
|
{"Inorder Flag", "knet.datagram.inorder",
|
2013-11-01 18:29:29 +00:00
|
|
|
FT_BOOLEAN, 8, NULL, 0x80, NULL, HFILL}},
|
2011-11-27 15:34:07 +00:00
|
|
|
{&hf_knet_reliable,
|
|
|
|
{"Reliable Flag", "knet.datagram.reliable",
|
2013-11-01 18:29:29 +00:00
|
|
|
FT_BOOLEAN, 8, NULL, UDP_DATAGRAM_RELIABLE_FLAG, NULL, HFILL}},
|
2011-11-27 15:34:07 +00:00
|
|
|
{&hf_knet_packetid,
|
|
|
|
{"Packet ID", "knet.datagram.packetid",
|
|
|
|
FT_UINT24, BASE_DEC, NULL, 0x0, NULL, HFILL}},
|
|
|
|
{&hf_knet_rmib,
|
|
|
|
{"Reliable Message Index Base", "knet.datagram.rmib",
|
|
|
|
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL}},
|
|
|
|
{&hf_knet_msg_flags,
|
|
|
|
{"Flags", "knet.msg.flags",
|
|
|
|
FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL}},
|
|
|
|
{&hf_knet_msg_fs,
|
|
|
|
{"Fragment Start", "knet.msg.flags.fs",
|
2013-11-01 18:29:29 +00:00
|
|
|
FT_BOOLEAN, 8, NULL, 0x80, NULL, HFILL}},
|
2011-11-27 15:34:07 +00:00
|
|
|
{&hf_knet_msg_ff,
|
|
|
|
{"Fragment Flag", "knet.msg.flags.ff",
|
2013-11-01 18:29:29 +00:00
|
|
|
FT_BOOLEAN, 8, NULL, 0x40, NULL, HFILL}},
|
2011-11-27 15:34:07 +00:00
|
|
|
{&hf_knet_msg_inorder,
|
|
|
|
{"Inorder Flag", "knet.msg.flags.inorder",
|
2013-11-01 18:29:29 +00:00
|
|
|
FT_BOOLEAN, 8, NULL, 0x20, NULL, HFILL}},
|
2011-11-27 15:34:07 +00:00
|
|
|
{&hf_knet_msg_reliable,
|
|
|
|
{"Reliable Flag", "knet.msg.flags.reliable",
|
2013-11-01 18:29:29 +00:00
|
|
|
FT_BOOLEAN, 8, NULL, UDP_MSG_BLOCK_RELIABLE_FLAG, NULL, HFILL}},
|
|
|
|
{&hf_knet_content_length,
|
|
|
|
{"Content Length", "knet.length",
|
|
|
|
FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}},
|
2011-11-27 15:34:07 +00:00
|
|
|
{&hf_knet_msg_reliable_message_number,
|
|
|
|
{"Reliable Message Number", "knet.msg.reliable_number",
|
|
|
|
FT_UINT24, BASE_DEC, NULL, 0x0, NULL, HFILL}},
|
2011-11-26 16:23:37 +00:00
|
|
|
|
|
|
|
/* Payload */
|
2011-11-27 15:34:07 +00:00
|
|
|
{&hf_knet_payload_tree,
|
|
|
|
{"Payload", "knet.payload.tree",
|
|
|
|
FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL}},
|
|
|
|
{&hf_knet_payload,
|
|
|
|
{"Payload", "knet.payload.data",
|
|
|
|
FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}},
|
|
|
|
{&hf_knet_messageid,
|
|
|
|
{"Message ID", "knet.payload.messageid",
|
2013-11-01 18:29:29 +00:00
|
|
|
FT_UINT32, BASE_DEC, VALS(packettypenames), 0x0, NULL, HFILL}},
|
2011-11-27 15:34:07 +00:00
|
|
|
{&hf_knet_pingid,
|
|
|
|
{"Ping ID", "knet.payload.pingid",
|
|
|
|
FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}},
|
|
|
|
{&hf_knet_flowctrlreq,
|
|
|
|
{"Flowcontrol Request", "knet.payload.flowctrlreq",
|
|
|
|
FT_UINT24, BASE_DEC, NULL, 0x0, NULL, HFILL}},
|
|
|
|
{&hf_knet_packetack,
|
|
|
|
{"Packet Ack", "knet.payload.packetack",
|
|
|
|
FT_UINT24, BASE_DEC, NULL, 0x0, NULL, HFILL}},
|
|
|
|
{&hf_knet_seqnumber,
|
|
|
|
{"Sequence Number", "knet.payload.seqnumber",
|
|
|
|
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL}}
|
2011-11-26 16:23:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static gint *ett_knet[] =
|
|
|
|
{
|
|
|
|
&ett_knet_main,
|
|
|
|
&ett_knet_datagram,
|
|
|
|
&ett_knet_flags,
|
|
|
|
&ett_knet_message,
|
|
|
|
&ett_knet_message_flags,
|
|
|
|
&ett_knet_payload
|
|
|
|
};
|
|
|
|
|
2016-09-22 13:25:07 +00:00
|
|
|
/* Register protocols */
|
|
|
|
proto_knet = proto_register_protocol ("kNet Protocol", "KNET", "knet");
|
|
|
|
|
2011-11-26 16:23:37 +00:00
|
|
|
/* Register header field & subtree arrays */
|
|
|
|
proto_register_field_array(proto_knet, hf_knet, array_length(hf_knet));
|
|
|
|
proto_register_subtree_array(ett_knet, array_length(ett_knet));
|
|
|
|
|
2015-12-09 04:04:01 +00:00
|
|
|
knet_handle_sctp = register_dissector("knetsctp", dissect_knet_sctp, proto_knet);
|
|
|
|
knet_handle_tcp = register_dissector("knettcp", dissect_knet_tcp, proto_knet);
|
|
|
|
knet_handle_udp = register_dissector("knetudp", dissect_knet_udp, proto_knet);
|
2011-11-26 16:23:37 +00:00
|
|
|
|
|
|
|
knet_module = prefs_register_protocol(proto_knet, proto_reg_handoff_knet);
|
|
|
|
|
|
|
|
prefs_register_uint_preference(knet_module, "sctp.port", "kNet SCTP Port",
|
|
|
|
"Set the SCTP port for kNet messages",
|
|
|
|
10, &knet_sctp_port);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-08-10 21:30:08 +00:00
|
|
|
* proto_reg_handoff_knet registers our kNet dissectors to Wireshark
|
2011-11-26 16:23:37 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
proto_reg_handoff_knet(void)
|
|
|
|
{
|
|
|
|
static gboolean initialized = FALSE;
|
|
|
|
|
|
|
|
static guint current_sctp_port;
|
|
|
|
|
|
|
|
if(!initialized)
|
|
|
|
{
|
2016-10-07 20:25:01 +00:00
|
|
|
dissector_add_uint_with_preference("tcp.port", PORT, knet_handle_tcp);
|
2016-10-05 20:33:54 +00:00
|
|
|
dissector_add_uint_with_preference("udp.port", PORT, knet_handle_udp);
|
2011-11-26 16:23:37 +00:00
|
|
|
initialized = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dissector_delete_uint("sctp.port", current_sctp_port, knet_handle_sctp);
|
|
|
|
}
|
|
|
|
|
|
|
|
current_sctp_port = knet_sctp_port;
|
|
|
|
dissector_add_uint("sctp.port", current_sctp_port, knet_handle_sctp);
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
|
|
|
*
|
|
|
|
* Local variables:
|
|
|
|
* c-basic-offset: 4
|
|
|
|
* tab-width: 8
|
|
|
|
* indent-tabs-mode: nil
|
|
|
|
* End:
|
|
|
|
*
|
|
|
|
* ex: set shiftwidth=4 tabstop=8 expandtab:
|
|
|
|
* :indentSize=4:tabSize=8:noTabs=true:
|
|
|
|
*/
|