Hi, I must admit I am very new to wireshark, but I have read a lot of material of the last few days and this problem has me stumped. I have written a custom dissector plugin to handle an XCP protocol. This consists of PDUs on TCP and I am using the tcp_dissect_pdus function to handle the reassembly of TCP packets to allow successful dissecting of my PDUs. I want to add to the info (COL_INFO) column in the GUI the packets contained in the TCP packet (e.g. Packets: 0x1234 - 0x1240). This works as expected except when the TCP packet is reassembled and then I just get the first PDU packet number. What is really strange is that the other PDUs are correctly dissected and added to the tree view at the bottom. I've tried all manner of things to work out what is going on, but figure I need some expert help! ;-)
} Any suggestions greatly appreciated! I also want to add a PDU sequence check (i.e. packet numbers increase monotonically). This is what lead me to this problem in the first place, since I was getting failed sequence check on the reassembled TCP packets. Thanks asked 01 Aug ‘11, 14:34 Tupperware edited 01 Aug ‘11, 16:05 helloworld |
4 Answers:
TBH your code in As to your problem, I can't see a declaration of offset. That should be declared and initialised in answered 01 Aug '11, 14:55 grahamb ♦ |
With reassembly, your dissector isn't going to be called until TCP has enough data to hand off to your dissector as informed by You may want to re-read answered 01 Aug '11, 19:40 cmaynard ♦♦ |
Thanks for your responses, much appreciated. I should have mentioned that the code has been hacked about a good few times to test out various theories which is why is looked a mess. I have re-read the manula items you suggested, but I think maybe I need to clarify the issue a bit further. The reassembly of the packets is working as expected, but it is the calling of the dissect function that I don't quite follow. Here is my code simplified a bit.
}
} So this bit of code shows the packet numbers in the info column e.g. [0x1234] [0x1235] [0x1236] [0x1237] and in the detailed information I get a breakdown of each XCP packet (4 of them) arranged as XCP Protocol->Header->(Packet Length and Package Counter). This is exactly as I expected for some of the TCP packets. However, on a packet which indicated [2 Reassembled TCP Segments xxxx] I only get the first packet number e.g. [0x1234]. In the detailed view at the bottom I get the 4 packets I expected. I could probably live without the packet display in the info column, but when I tried to implement a packet counter check I saw the same issue when checking packet counters across TCP segments in that the packet counter I was checking against was the first one in the reassembled TCP segment rather than the last one. Thanks EDIT: I thought a picture might be useful to see the problem. http://postimage.org/image/uih7wfc4/ answered 02 Aug '11, 02:37 Tupperware edited 02 Aug '11, 04:56 First off, as grahamb already pointed out, stop using tvb_memcpy(). Use proto_tree_add_item() instead or where you really need to grab data, use the tvb endian-friendly accessors. Is XCP Big-Endian (BE) or Little-Endian (LE)? I assume BE. Try coding get_xcp_message_len() like this instead: static guint get_xcp_message_len(packet_info pinfo, tvbuff_t tvb, int offset){return 4 + tvb_get_ntohs(tvb, offset);} And if XCP is BE, xcpcount is being assigned wrong. Try this instead: xcpcount = tvb_get_ntohs(tvb, 2); If it's LE, then use tvb_get_letohs() consistently throughout instead. (02 Aug '11, 08:08) cmaynard ♦♦ Also, get rid of C++ comments and get rid of check_col(). (02 Aug '11, 08:08) cmaynard ♦♦ |
Hi cmaynard, Thanks for your support. I've tidied up the code (hopefully) to your liking and removed any unecessary variables. The output is the same as described above and shown in the screenshot.
answered 02 Aug ‘11, 08:54 Tupperware OK, so it’s LE then. When you add items to the tree, be sure to use ENC_LITTLE_ENDIAN for the proto_tree_add_xyz() endian argument instead of FALSE as FALSE is actually synonymous with ENC_BIG_ENDIAN. For items where endian-ness is irrelevant, some folks prefer to use ENC_NA. What is the value of FRAME_HEADER_LEN? Are you calling col_clear() anywhere? (02 Aug ‘11, 09:02) cmaynard ♦♦ FRAME_HEADER_LEN is 2 I removed col_clear in this example to ensure I never lost any data from the info column. Question is, how do the proto_tree_* calls get executed whilst col_append_fstr does not for the reassembled TCP packets? TCP packets which were not reassembled work as expected. (02 Aug ‘11, 09:51) Tupperware At this point, it would probably be better to move this over to the -dev mailing list. There, if you could supply your code and a sample capture file, I think it would be a lot easier to help you. More critiques … these are wrong: proto_tree_add_uint(xcp_header_tree, hf_xcp_length, tvb, 0, 0, tvb_get_letohs(tvb, 0)); proto_tree_add_uint(xcp_header_tree, hf_xcp_counter, tvb, 0, 0, xcpcount); The length field should be 2, not 0 and the offset for xcpcount should be 2, not 0. But don’t use proto_tree_add_uint() -> use proto_tree_add_item() instead. (02 Aug ‘11, 10:10) cmaynard ♦♦ Added it to the list :-) (03 Aug ‘11, 03:48) Tupperware And for anyone following this question, the thread is here. (03 Aug ‘11, 08:56) cmaynard ♦♦ |
And you don't need check_col() anymore.