Reputation: 2798
I'm wrote a wireshark dissector named PLUGIN.
Now when I'm testing it, for some reason a packet of type X can be seen on the wireshark as PLUGIN (like it should), and some other packets afterwards, of the same type X cannot be seen as PLUGIN.
The other packets can be found in the .pcap as [TCP segment of a reassembled PDU]
The question is: why doesn't WireShark dissect other packets of type X like the first packet of type X and shows it to me as PLUGIN ?
Why does the dissection works only for the first time?
I use functions for assembling fragments of chopped packets:
tcp_dissect_pdus()
get_PLUGIN_message_len()
as written in "9.4.2. How to reassemble split TCP Packets"
in "http://www.wireshark.org/docs/wsdg_html_chunked/ChDissectReassemble.html#TcpDissectPdus
"
This is the function of dissection: (FRAME_HEADER_LEN = 8)
static void
dissect_PROTOC(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
//Reassembling TCP fragments
tcp_dissect_pdus(tvb, pinfo, tree, TRUE, FRAME_HEADER_LEN,
get_PROTOC_message_len, dissect_PROTOC_message);
}
static guint get_PROTOC_message_len(packet_info *pinfo, tvbuff_t *tvb, int offset)
{
/* the packet's size is "length" + 4bytes of TYPESIZE + 4bytes of LENGTHSIZE + 256bytes of CONTEXTIDSIZE */
return (guint)(tvb_get_ntohl(tvb, offset + 4) + CONTEXT_ID_SIZE + TYPE_SIZE + LENGTH_SIZE); /* e.g. length is at offset 4 */
}
static void dissect_PROTOC_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
/* my dissecting code */
guint32 packet_type = tvb_get_ntohl(tvb, 0);
col_set_str(pinfo->cinfo, COL_PROTOCOL, "PROTOC");
/* Clear out stuff in the info column */
col_clear(pinfo->cinfo,COL_INFO);
col_add_fstr(pinfo->cinfo, COL_INFO, "%d > %d [%s]",pinfo->srcport, pinfo->destport,
val_to_str(packet_type, packettypenames, "Unknown (0x%02x)"));
if (tree) { /* we are being asked for details */
proto_item *ti = NULL;
proto_tree *PROTOC_tree = NULL;
proto_item *PROTOC_data = NULL;
proto_tree *PROTOC_data_tree = NULL;
guint32 type = 0;
guint32 length = 0;
gint offset = 0;
ti = proto_tree_add_item(tree, proto_PROTOC, tvb, 0, -1, ENC_NA);
proto_item_append_text(ti, ", Type: %s",
val_to_str(packet_type, packettypenames, "Unknown (0x%02x)"));
PROTOC_tree = proto_item_add_subtree(ti, ett_PROTOC);
//getting type
type = tvb_get_ntohl(tvb, offset);
proto_tree_add_item(PROTOC_tree, hf_PROTOC_pdu_type, tvb, 0, TYPE_SIZE, ENC_BIG_ENDIAN);
offset += TYPE_SIZE;
//getting length for the data length
length = tvb_get_ntohl(tvb, offset);
proto_tree_add_item(PROTOC_tree, hf_PROTOC_len, tvb, offset, LENGTH_SIZE, ENC_BIG_ENDIAN);
offset += LENGTH_SIZE;
proto_tree_add_item(PROTOC_tree, hf_PROTOC_contextid, tvb, offset, CONTEXT_ID_SIZE, ENC_BIG_ENDIAN);
offset += CONTEXT_ID_SIZE;
PROTOC_data = proto_tree_add_item(PROTOC_tree, hf_PROTOC_data, tvb, offset, length, FALSE);
PROTOC_data_tree = proto_item_add_subtree(PROTOC_data, ett_PROTOC_data);
offset += length;
}
}
more information:
I opened the file.pcap on some hex editor and I can see my packets that the wireshark doesn't dissect...
Inside wireshark I can find a packet that wireshark doesn't dissect, with the info of: "[TCP segment of a reassembled PDU]", but it doesn't say to which reassemble packet it belong, and I can't find it anywhere...
Upvotes: 0
Views: 1512
Reputation: 1213
I would speculate that your calculated length does not match the reality. If wireshark does not think it has all the frames it needs to complete the PDU, then I guess it might not call dissect_PROTOC_message()
You could try to print your calculated lengths and then verify that the pcap file contains that many frames:
static guint get_PROTOC_message_len(packet_info *pinfo, tvbuff_t *tvb, int offset)
{
/* the packet's size is "length" + 4bytes of TYPESIZE + 4bytes of LENGTHSIZE + 256bytes of CONTEXTIDSIZE */
guint len = (guint)(tvb_get_ntohl(tvb, offset + 4) + CONTEXT_ID_SIZE + TYPE_SIZE + LENGTH_SIZE); /* e.g. length is at offset 4 */
g_warning("frame=%d PDU len=%d", pinfo->fd->num, len);
return len;
}
Upvotes: 1