aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/lua/packet-lua.h
diff options
context:
space:
mode:
authorLuis Ontanon <luis.ontanon@gmail.com>2006-02-03 21:25:26 +0000
committerLuis Ontanon <luis.ontanon@gmail.com>2006-02-03 21:25:26 +0000
commit1434f575d5e41345a2ed7d4105b1f7ce2664eb68 (patch)
treec4188203c2a34f4d07411b5b121d3d57d189258f /plugins/lua/packet-lua.h
parenta5c03f490e48493f84e854336cd5e89a4fe5ca2c (diff)
* packet-lua.h
* add a shiftC() function to every class for extracting values from the stack * lua_pinfo.c * fix pinfo.dst pinfo.dl_dst pinfo.dl_src pinfo.net_dst pinfo.net_src * lua_tree.c * ProtoTree_add_item_any() changed to use TvbRanges, a more handy way to give it optional arguments * lua_tvb.c * get ByteArray up and running * create TvbRange class and use it to access the tvb (this class takes care of checking bounds so that exceptions are not thrown) svn path=/trunk/; revision=17146
Diffstat (limited to 'plugins/lua/packet-lua.h')
-rw-r--r--plugins/lua/packet-lua.h27
1 files changed, 24 insertions, 3 deletions
diff --git a/plugins/lua/packet-lua.h b/plugins/lua/packet-lua.h
index d1d96ab475..4b1896b8a3 100644
--- a/plugins/lua/packet-lua.h
+++ b/plugins/lua/packet-lua.h
@@ -56,6 +56,12 @@
#define LUA_TAP_DRAW "taps_draw"
#define LUA_TAP_RESET "taps_reset"
+struct _eth_tvbrange {
+ tvbuff_t* tvb;
+ int offset;
+ int len;
+};
+
typedef struct _eth_field_t {
int hfid;
char* name;
@@ -76,7 +82,7 @@ typedef struct _eth_pref_t {
pref_type_t type;
union {
gboolean b;
- guint32 u;
+ guint u;
const gchar* s;
} value;
@@ -96,6 +102,7 @@ typedef struct _eth_proto_t {
gboolean is_postdissector;
} eth_proto_t;
+
typedef struct {const gchar* str; enum ftenum id; } eth_ft_types_t;
#define PROTO_FIELD "ProtoField"
@@ -125,6 +132,9 @@ typedef GByteArray* ByteArray;
#define TVB "Tvb"
typedef tvbuff_t* Tvb;
+#define TVB_RANGE "TvbRange"
+typedef struct _eth_tvbrange* TvbRange;
+
#define COLUMN "Column"
typedef struct _eth_col_info {
column_info* cinfo;
@@ -186,9 +196,17 @@ C* push##C(lua_State* L, C v) { \
}\
gboolean is##C(lua_State* L,int i) { \
return (gboolean)(lua_isuserdata(L,i) && luaL_checkudata(L,3,CN)); \
+} \
+extern C shift##C(lua_State* L,int i) { \
+ C* p; \
+ if ((p = (C*)luaL_checkudata(L, i, CN))) {\
+ lua_remove(L,i); \
+ return *p; \
+ } else { \
+ return NULL; \
+ } \
}
-
extern packet_info* lua_pinfo;
extern proto_tree* lua_tree;
extern tvbuff_t* lua_tvb;
@@ -202,7 +220,9 @@ extern C to##C(lua_State* L, int index); \
extern C check##C(lua_State* L, int index); \
extern C* push##C(lua_State* L, C v); \
extern int C##_register(lua_State* L); \
-extern gboolean is##C(lua_State* L,int i)
+extern gboolean is##C(lua_State* L,int i); \
+extern C shift##C(lua_State* L,int i)
+
LUA_CLASS_DECLARE(Tap,TAP);
@@ -213,6 +233,7 @@ LUA_CLASS_DECLARE(SubTree,SUBTREE);
LUA_CLASS_DECLARE(Proto,PROTO);
LUA_CLASS_DECLARE(ByteArray,BYTE_ARRAY);
LUA_CLASS_DECLARE(Tvb,TVB);
+LUA_CLASS_DECLARE(TvbRange,TVB_RANGE);
LUA_CLASS_DECLARE(Column,COLUMN);
LUA_CLASS_DECLARE(Columns,COLUMNS);
LUA_CLASS_DECLARE(Pinfo,PINFO);