diff options
author | Stig Bjørlykke <stig@bjorlykke.org> | 2011-10-13 19:39:35 +0000 |
---|---|---|
committer | Stig Bjørlykke <stig@bjorlykke.org> | 2011-10-13 19:39:35 +0000 |
commit | 022929724b747a70f8978df4dddbbd1da8efb705 (patch) | |
tree | 2f1d36ea9c4c81dd091eb2010c974feeb2bfd873 | |
parent | 2579d4f5d0d5db17821f2015ca5e87df540f9bfc (diff) | |
download | wireshark-022929724b747a70f8978df4dddbbd1da8efb705.tar.gz wireshark-022929724b747a70f8978df4dddbbd1da8efb705.tar.bz2 wireshark-022929724b747a70f8978df4dddbbd1da8efb705.zip |
Added some Lua pinfo fields:
ethertype, fragmented, in_error_pkt, match_uint and match_string.
svn path=/trunk/; revision=39407
-rw-r--r-- | epan/wslua/wslua_pinfo.c | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/epan/wslua/wslua_pinfo.c b/epan/wslua/wslua_pinfo.c index a55c64497c..f77fd94563 100644 --- a/epan/wslua/wslua_pinfo.c +++ b/epan/wslua/wslua_pinfo.c @@ -825,6 +825,17 @@ WSLUA_CLASS_DEFINE(Pinfo,FAIL_ON_NULL("expired pinfo"),NOP); static int Pinfo_tostring(lua_State *L) { lua_pushstring(L,"a Pinfo"); return 1; } +#define PINFO_GET_BOOLEAN(name,val) static int name(lua_State *L) { \ + Pinfo pinfo = checkPinfo(L,1); \ + if (!pinfo) return 0;\ + if (pinfo->expired) { \ + luaL_error(L,"expired_pinfo"); \ + return 0; \ + } \ + lua_pushboolean(L,val);\ + return 1;\ +} + #define PINFO_GET_NUMBER(name,val) static int name(lua_State *L) { \ Pinfo pinfo = checkPinfo(L,1); \ if (!pinfo) return 0;\ @@ -873,6 +884,9 @@ static int Pinfo_tostring(lua_State *L) { lua_pushstring(L,"a Pinfo"); return 1; return 1; \ } +PINFO_GET_BOOLEAN(Pinfo_fragmented,pinfo->ws_pinfo->fragmented) +PINFO_GET_BOOLEAN(Pinfo_in_error_pkt,pinfo->ws_pinfo->in_error_pkt) + PINFO_GET_NUMBER(Pinfo_number,pinfo->ws_pinfo->fd->num) PINFO_GET_NUMBER(Pinfo_len,pinfo->ws_pinfo->fd->pkt_len) PINFO_GET_NUMBER(Pinfo_caplen,pinfo->ws_pinfo->fd->cap_len) @@ -887,8 +901,11 @@ PINFO_GET_NUMBER(Pinfo_desegment_offset,pinfo->ws_pinfo->desegment_offset) PINFO_GET_NUMBER(Pinfo_ptype,pinfo->ws_pinfo->ptype) PINFO_GET_NUMBER(Pinfo_src_port,pinfo->ws_pinfo->srcport) PINFO_GET_NUMBER(Pinfo_dst_port,pinfo->ws_pinfo->destport) +PINFO_GET_NUMBER(Pinfo_ethertype,pinfo->ws_pinfo->ethertype) +PINFO_GET_NUMBER(Pinfo_match_uint,pinfo->ws_pinfo->match_uint) PINFO_GET_STRING(Pinfo_curr_proto,pinfo->ws_pinfo->current_proto) +PINFO_GET_STRING(Pinfo_match_string,pinfo->ws_pinfo->match_string) PINFO_GET_ADDRESS(Pinfo_net_src,net_src) PINFO_GET_ADDRESS(Pinfo_net_dst,net_dst) @@ -968,7 +985,8 @@ typedef enum { PARAM_CIRCUIT_ID, PARAM_DESEGMENT_LEN, PARAM_DESEGMENT_OFFSET, - PARAM_PORT_TYPE + PARAM_PORT_TYPE, + PARAM_ETHERTYPE } pinfo_param_type_t; static int pushnil_param(lua_State* L, packet_info* pinfo _U_, pinfo_param_type_t pt _U_ ) { @@ -1042,6 +1060,9 @@ static int Pinfo_set_int(lua_State* L, packet_info* pinfo, pinfo_param_type_t pt case PARAM_DESEGMENT_OFFSET: pinfo->desegment_offset = (int)v; return 0; + case PARAM_ETHERTYPE: + pinfo->ethertype = (guint32)v; + return 0; default: g_assert(!"BUG: A bad parameter"); } @@ -1183,6 +1204,21 @@ static const pinfo_method_t Pinfo_methods[] = { /* WSLUA_ATTRIBUTE Pinfo_private_data RO Access to private data */ {"private_data", Pinfo_private_data, pushnil_param, PARAM_NONE}, + /* WSLUA_ATTRIBUTE Pinfo_ethertype RW Ethernet Type Code, if this is an Ethernet packet */ + {"ethertype", Pinfo_ethertype, Pinfo_set_int, PARAM_ETHERTYPE}, + + /* WSLUA_ATTRIBUTE Pinfo_fragmented RO If the protocol is only a fragment */ + {"fragmented", Pinfo_fragmented, pushnil_param, PARAM_NONE}, + + /* WSLUA_ATTRIBUTE Pinfo_in_error_pkt RO If we're inside an error packet */ + {"in_error_pkt", Pinfo_in_error_pkt, pushnil_param, PARAM_NONE}, + + /* WSLUA_ATTRIBUTE Pinfo_match_uint RO Matched uint for calling subdissector from table */ + {"match_uint", Pinfo_match_uint, pushnil_param, PARAM_NONE }, + + /* WSLUA_ATTRIBUTE Pinfo_match_string RO Matched string for calling subdissector from table */ + {"match_string", Pinfo_match_string, pushnil_param, PARAM_NONE }, + {NULL,NULL,NULL,PARAM_NONE} }; |