From yami <yamisoe@gmail.com>:
authorrbalint <rbalint@f5534014-38df-0310-8fa8-9805f1628bb7>
Tue, 30 Dec 2008 12:49:42 +0000 (12:49 +0000)
committerrbalint <rbalint@f5534014-38df-0310-8fa8-9805f1628bb7>
Tue, 30 Dec 2008 12:49:42 +0000 (12:49 +0000)
Expose pinfo->private_data to lua interface.
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=3129

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@27132 f5534014-38df-0310-8fa8-9805f1628bb7

epan/wslua/wslua_pinfo.c

index cd58c5948602c780ba9c50505345eb4aa5721261..ff0eaf0d9f410b4529cf80fddaf315e666638f23 100644 (file)
@@ -634,6 +634,17 @@ static int Pinfo_tostring(lua_State *L) { lua_pushstring(L,"a Pinfo"); return 1;
     return 1; \
 }
 
+#define PINFO_GET_LIGHTUSERDATA(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_pushlightuserdata(L, (void *) (val)); \
+    return 1; \
+}
+
 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)
@@ -658,6 +669,8 @@ PINFO_GET_ADDRESS(Pinfo_dl_dst,dl_dst)
 PINFO_GET_ADDRESS(Pinfo_src,src)
 PINFO_GET_ADDRESS(Pinfo_dst,dst)
 
+PINFO_GET_LIGHTUSERDATA(Pinfo_private_data, pinfo->ws_pinfo->private_data)
+
 static int Pinfo_visited(lua_State *L) {
     Pinfo pinfo = checkPinfo(L,1);
     if (!pinfo) return 0;
@@ -939,6 +952,9 @@ static const pinfo_method_t Pinfo_methods[] = {
        /* WSLUA_ATTRIBUTE Pinfo_desegment_offset RW Offset in the tvbuff at which the dissector will continue processing when next called*/
     {"desegment_offset", Pinfo_desegment_offset, Pinfo_set_int,  PARAM_DESEGMENT_OFFSET },
        
+       /* WSLUA_ATTRIBUTE Pinfo_private_data RO Access to private data */
+    {"private_data", Pinfo_private_data, pushnil_param, PARAM_NONE},
+       
        {NULL,NULL,NULL,PARAM_NONE}
 };