diff options
author | Hadriel Kaplan <hadrielk@yahoo.com> | 2014-03-10 01:54:51 -0400 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2014-03-14 07:29:15 +0000 |
commit | 04c39bb0972bac1f95eb9394b5ca1086f19c0d93 (patch) | |
tree | 62171e4584b86bb746d6a73181eb7627a15b9e44 /epan/wslua/wslua_pinfo.c | |
parent | a59ac1bd10d29d05ca5cd657b7c64ab13a08670d (diff) |
Add Lua heuristic dissector support
This adds the ability for Lua scripts to register heuristic dissectors
for any protocol that has registered a heuristic dissector list, such
as UDP, TCP, and ~50 others. The Lua function can also establish a
conversation tied to its Proto dissector, to avoid having to check the
heuristics for the same flow. The example dissector in the testsuite
has also been enhanced to include a heuristic dissector, to verify
the functionality and provide an example implementation.
Change-Id: Ie232602779f43d3418fe8db09c61d5fc0b59597a
Reviewed-on: https://code.wireshark.org/review/576
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/wslua/wslua_pinfo.c')
-rw-r--r-- | epan/wslua/wslua_pinfo.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/epan/wslua/wslua_pinfo.c b/epan/wslua/wslua_pinfo.c index 13a2a33a7a..c5cbaa3802 100644 --- a/epan/wslua/wslua_pinfo.c +++ b/epan/wslua/wslua_pinfo.c @@ -36,6 +36,7 @@ #include "wslua.h" #include <epan/addr_resolv.h> +#include <epan/conversation.h> #include <string.h> @@ -1128,6 +1129,23 @@ static int Pinfo_get_lo(lua_State *L) { return 1; } +/* WSLUA_ATTRIBUTE Pinfo_conversation WO sets the packet conversation to the given Proto object */ +static int Pinfo_set_conversation(lua_State *L) { + Pinfo pinfo = checkPinfo(L,1); + Proto proto = checkProto(L,2); + conversation_t *conversation; + + if (!proto->handle) { + luaL_error(L,"Proto %s has no registered dissector", proto->name? proto->name:"<UKNOWN>"); + return 0; + } + + conversation = find_or_create_conversation(pinfo->ws_pinfo); + conversation_set_dissector(conversation,proto->handle); + + return 0; +} + /* Gets registered as metamethod automatically by WSLUA_REGISTER_CLASS/META */ static int Pinfo__gc(lua_State* L) { Pinfo pinfo = toPinfo(L,1); @@ -1183,6 +1201,7 @@ WSLUA_ATTRIBUTES Pinfo_attributes[] = { WSLUA_ATTRIBUTE_ROREG(Pinfo,fragmented), WSLUA_ATTRIBUTE_ROREG(Pinfo,match_uint), WSLUA_ATTRIBUTE_ROREG(Pinfo,match_string), + WSLUA_ATTRIBUTE_WOREG(Pinfo,conversation), { NULL, NULL, NULL } }; |