aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuis Ontanon <luis.ontanon@gmail.com>2006-02-07 03:06:02 +0000
committerLuis Ontanon <luis.ontanon@gmail.com>2006-02-07 03:06:02 +0000
commit5a2013cdfccccd6c613008ac679fbe0ffacf4a5a (patch)
tree483e392e97f6f5a31fb3778974bbbed922cd30ab
parent1352ce5fe61e2cbf66bf82f5f92351920ab356af (diff)
I Noticed a crash when registering a tap with filter during handoff (that's when I had lua starting) trying to see if I could move dfilter_init() before protocol registration I discovered register_final_registration_routine() neat!
Lua protocols won't need a handoff routine anymore!! svn path=/trunk/; revision=17191
-rw-r--r--plugins/lua/lua_proto.c21
-rw-r--r--plugins/lua/packet-lua.c34
2 files changed, 9 insertions, 46 deletions
diff --git a/plugins/lua/lua_proto.c b/plugins/lua/lua_proto.c
index e946b62900..b7f1165c3c 100644
--- a/plugins/lua/lua_proto.c
+++ b/plugins/lua/lua_proto.c
@@ -888,26 +888,6 @@ static int Proto_set_init(lua_State* L) {
}
-static int Proto_set_handoff(lua_State* L) {
- Proto proto = toProto(L,1);
-
- if (lua_isfunction(L,3)) {
- /* insert the dissector into the dissectors table */
- lua_pushstring(L, LUA_HANDOFF_ROUTINES);
- lua_gettable(L, LUA_REGISTRYINDEX);
- lua_replace(L, 1);
- lua_pushstring(L,proto->name);
- lua_replace(L, 2);
- lua_settable(L,1);
-
- return 0;
- } else {
- luaL_argerror(L,3,"The handoff of a protocol must be a function");
- return 0;
- }
-
-}
-
static int Proto_get_name(lua_State* L) {
Proto proto = toProto(L,1);
@@ -926,7 +906,6 @@ static const proto_actions_t proto_actions[] = {
{"fields",NULL,Proto_register_field_array},
{"prefs",Proto_get_prefs,NULL},
{"init",NULL,Proto_set_init},
- {"handoff",NULL,Proto_set_handoff},
{"name",Proto_get_name,NULL},
{NULL,NULL,NULL}
};
diff --git a/plugins/lua/packet-lua.c b/plugins/lua/packet-lua.c
index 6c651510d6..ad036fc848 100644
--- a/plugins/lua/packet-lua.c
+++ b/plugins/lua/packet-lua.c
@@ -145,12 +145,12 @@ void dissect_lua(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree) {
}
-static void iter_table_and_call(lua_State* LS, const gchar* table_name, lua_CFunction error_handler) {
+static void iter_table_and_call(lua_State* LS, int env, const gchar* table_name, lua_CFunction error_handler) {
lua_settop(LS,0);
lua_pushcfunction(LS,error_handler);
lua_pushstring(LS, table_name);
- lua_gettable(LS, LUA_REGISTRYINDEX);
+ lua_gettable(LS, env);
if (!lua_istable(LS, 2)) {
report_failure("Lua: either `%s' does not exist or it is not a table!\n",table_name);
@@ -200,22 +200,7 @@ static void init_lua(void) {
}
if (L) {
- iter_table_and_call(L, LUA_INIT_ROUTINES,init_error_handler);
- }
-
-}
-
-static int handoff_error_handler(lua_State* L) {
- const gchar* error = lua_tostring(L,1);
- report_failure("Lua: Error During execution of Handoff:\n %s",error);
- return 0;
-}
-
-void proto_reg_handoff_lua(void) {
- lua_data_handle = find_dissector("data");
-
- if (L) {
- iter_table_and_call(L, LUA_HANDOFF_ROUTINES,handoff_error_handler);
+ iter_table_and_call(L, LUA_GLOBALSINDEX, LUA_INIT_ROUTINES,init_error_handler);
}
}
@@ -235,8 +220,7 @@ static int lua_main_error_handler(lua_State* LS) {
return 0;
}
-void proto_register_lua(void)
-{
+void register_lua(void) {
FILE* file;
gchar* filename = getenv("ETHEREAL_LUA_INIT");
@@ -307,13 +291,9 @@ void proto_register_lua(void)
lua_pushcfunction(L, lua_new_dialog);
lua_settable(L, LUA_GLOBALSINDEX);
- lua_pushstring(L, LUA_HANDOFF_ROUTINES);
- lua_newtable (L);
- lua_settable(L, LUA_REGISTRYINDEX);
-
lua_pushstring(L, LUA_INIT_ROUTINES);
lua_newtable (L);
- lua_settable(L, LUA_REGISTRYINDEX);
+ lua_settable(L, LUA_GLOBALSINDEX);
lua_pushstring(L, LUA_DISSECTORS_TABLE);
lua_newtable (L);
@@ -353,3 +333,7 @@ void proto_register_lua(void)
return;
}
+void proto_register_lua(void)
+{
+ register_final_registration_routine(register_lua);
+}