Is it possible to get DissectorTable according to "tcp.srcport" or "tcp.dstport" in Lua? Now,I have two package, one's tcp source port is 7709, another's tcp destination port is 7709. That is ,a request and a response. The fields of request package and response package are different. So I need to register two different dissector to process the two different packaget. At the time, I do it like this: local tcp_req_table = DissectorTable.get("tcp.port") tcp_req_table:add(7709,p_req) local tcp_res_table = DissectorTable.get("tcp.port") tcp_res_table:add(7709,p_res) But,finally, only the p_res works. So, How should I register the two different dissector? When I try "DissectorTable.get("tcp.srcport")", wireshark said that didn't exist. Thank you! asked 01 Nov '11, 07:14 happyboy8909 edited 01 Nov '11, 12:56 Guy Harris ♦♦ |
3 Answers:
There do not exist "tcp.srcport" or "tcp.dstport" dissector tables, so you can't get them in any programming language, whether it's C or Lua or.... You do not need to register two different dissectors for this case. You merely need to have the one-and-only dissector for port 7709 determine whether the packet is a request or a response and dissect it appropriately? Does this protocol truly have no field in the packet to indicate whether it's a request or a response? If it truly has no such field, then the best you can do is something such as checking whether the matching port value is the same as the source port or the destination port. In a C-language dissector, this would be done by comparing answered 01 Nov '11, 12:55 Guy Harris ♦♦ |
To add a few notes for the Guy's answer, if you want to register multiple dissectors per port you have an option of saving previous dissector registered for that port and calling it in your dissector, thus creating dissector chain. The sample code can be found within wiki and looks smth like this:
answered 08 Nov ‘11, 16:37 ShomeaX edited 08 Nov ‘11, 16:38 |
Yes, ShowmeaX is right. I test it as following: 1) data.dissector 2) report.dissector 3)
4) add wrapper to dissectorTable answered 24 Jul '14, 19:16 wireshark_xg edited 24 Jul '14, 19:18 Guy Harris ♦♦ |
Lua has
pinfo
.src_port
andpinfo.dst_port