wslua: pinfo: make p2p_dir accessible to lua dissectors

Some dissectors populate pinfo->p2p_dir with a packet's direction
(incoming / outgoing). Make this info available to lua dissectors.

Add a simple test for Pinfo's new p2p_dir attribute to the wslua
test suite. It checks that p2p_dir is unknown for dhcp packets.
(The dhcp dissector does not set p2p_dir).

Change-Id: I8cc39a11cff840d10ef7fa94d30cbac8bf9b533f
Reviewed-on: https://code.wireshark.org/review/33935
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Martin Kaiser <wireshark@kaiser.cx>
This commit is contained in:
Martin Kaiser 2019-07-06 15:27:20 +02:00
parent cc15201436
commit 429082dd71
3 changed files with 11 additions and 0 deletions

View File

@ -106,6 +106,12 @@ end
%MENU_GROUPS%
-- the possible values for Pinfo's p2p_dir attribute
P2P_DIR_UNKNOWN = -1
P2P_DIR_SENT = 0
P2P_DIR_RECV = 1
-- other useful constants
-- DATA_DIR and USER_DIR have a trailing directory separator.
GUI_ENABLED = gui_enabled()

View File

@ -292,6 +292,8 @@ PINFO_ADDRESS_SETTER(src);
PINFO_ADDRESS_GETTER(dst);
PINFO_ADDRESS_SETTER(dst);
/* WSLUA_ATTRIBUTE Pinfo_p2p_dir RO direction of this Packet. (incoming / outgoing) */
PINFO_NUMBER_GETTER(p2p_dir);
/* WSLUA_ATTRIBUTE Pinfo_match RO Port/Data we are matching. */
static int Pinfo_get_match(lua_State *L) {
@ -457,6 +459,7 @@ WSLUA_ATTRIBUTES Pinfo_attributes[] = {
WSLUA_ATTRIBUTE_ROREG(Pinfo,match_uint),
WSLUA_ATTRIBUTE_ROREG(Pinfo,match_string),
WSLUA_ATTRIBUTE_WOREG(Pinfo,conversation),
WSLUA_ATTRIBUTE_ROREG(Pinfo,p2p_dir),
{ NULL, NULL, NULL }
};

View File

@ -210,6 +210,8 @@ again, these *should* pass, but Pinfo silently allows it!
test("Pinfo.desegment_len-get-1",pinfo.desegment_len == 0)
test("Pinfo.desegment_offset-get-1",pinfo.desegment_offset == 0)
test("pinfo.p2p_dir", pinfo.p2p_dir == P2P_DIR_UNKNOWN)
if pinfo.number == 1 then
test("Pinfo.rel_ts-get-1",pinfo.rel_ts == 0)
test("Pinfo.delta_ts-get-1",pinfo.delta_ts == 0)