ANNOUNCEMENT: Live Wireshark University & Allegro Packets online APAC Wireshark Training Session
July 17th, 2024 | 10:00am-11:55am SGT (UTC+8) | Online

Ethereal-dev: [Ethereal-dev] Lua autofoo stuff - please test

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Joerg Mayer <jmayer@xxxxxxxxx>
Date: Mon, 30 Jan 2006 00:57:25 +0100
On Tue, Jan 24, 2006 at 03:41:43PM +0100, LEGO wrote:
> > As mentioned above: I'm willing to do the autofoo stuff, which can cover
> > this case as well. Just let me know if you want me to do it - that way
> > you can continue working on the code ;)
> 
> I'd love that, Thanks!!!

Attached a patch that should do it. Please test it and if it works, commit
it.

 ciao
  Joerg
-- 
Joerg Mayer                                           <jmayer@xxxxxxxxx>
We are stuck with technology when what we really want is just stuff that
works. Some say that should read Microsoft instead of technology.
Index: configure.in
===================================================================
--- configure.in	(revision 17118)
+++ configure.in	(working copy)
@@ -749,6 +749,41 @@
 fi
 
 
+dnl lua check
+AC_MSG_CHECKING(whether to use liblua for the lua scripting plugin)
+
+AC_ARG_WITH(lua,
+[  --with-lua[[=DIR]]       use liblua (located in directory DIR, if supplied) for the lua scripting plugin.  [[default=no]]],
+[
+	if test $withval = no
+	then
+		want_lua=no
+	elif test $withval = yes
+	then
+		want_lua=yes
+	else
+		want_lua=yes
+		lua=dir=$withval
+	fi
+],[
+	#
+	# Use liblua if it's present, otherwise don't.
+	#
+	want_lua=ifavailable
+	lua_dir=
+])
+if test "x$want_lua" = "xno" ; then
+        AC_MSG_RESULT(no)
+else
+        AC_MSG_RESULT(yes)
+        AC_ETHEREAL_LIBLUA_CHECK
+	if test "x$want_lua" = "xno" ; then
+		AC_MSG_RESULT(liblua not found - disabling support for the lua scripting plugin)
+	fi
+fi
+AM_CONDITIONAL(HAVE_LIBLUA, test x$want_lua = xyes)
+
+
 dnl ipv6 check
 AC_ARG_ENABLE(ipv6,
 [  --enable-ipv6           use ipv6 name resolution, if available.  [default=yes]],enable_ipv6=$enableval,enable_ipv6=yes)
@@ -1256,6 +1291,7 @@
   plugins/gryphon/Makefile
   plugins/h223/Makefile
   plugins/irda/Makefile
+  plugins/lua/Makefile
   plugins/lwres/Makefile
   plugins/mate/Makefile
   plugins/megaco/Makefile
@@ -1294,6 +1330,12 @@
 	pcre_message="yes"
 fi
 
+if test "x$want_lua" = "xno" -a "x$have_plugins" = "yes" ; then
+	lua_message="no"
+else
+	lua_message="yes"
+fi
+
 if test "x$want_ssl" = "xno" ; then
 	ssl_message="no"
 else
@@ -1335,6 +1377,7 @@
 echo ""
 echo "                    Install setuid : $setuid_message"
 echo "                       Use plugins : $have_plugins"
+echo "                  Build lua plugin : $lua_message"
 echo "               Use GTK+ v2 library : $enable_gtk2"
 if test "x$enable_gtk2" = "xyes" ; then
 echo "                       Use threads : $enable_threads"
Index: acinclude.m4
===================================================================
--- acinclude.m4	(revision 17118)
+++ acinclude.m4	(working copy)
@@ -736,6 +736,112 @@
 ])
 
 #
+# AC_ETHEREAL_LIBLUA_CHECK
+#
+AC_DEFUN([AC_ETHEREAL_LIBLUA_CHECK],
+[
+	if test "x$lua_dir" != "x"
+	then
+	  #
+	  # The user specified a directory in which liblua resides,
+	  # so add the "include" subdirectory of that directory to
+	  # the include file search path and the "lib" subdirectory
+	  # of that directory to the library search path.
+	  #
+	  # XXX - if there's also a liblua in a directory that's
+	  # already in CFLAGS, CPPFLAGS, or LDFLAGS, this won't
+	  # make us find the version in the specified directory,
+	  # as the compiler and/or linker will search that other
+	  # directory before it searches the specified directory.
+	  #
+	  ethereal_save_CFLAGS="$CFLAGS"
+	  CFLAGS="$CFLAGS -I$lua_dir/include"
+	  ethereal_save_CPPFLAGS="$CPPFLAGS"
+	  CPPFLAGS="$CPPFLAGS -I$lua_dir/include"
+	  ethereal_save_LIBS="$LIBS"
+	  LIBS="$LIBS -llua"
+	  ethereal_save_LDFLAGS="$LDFLAGS"
+	  LDFLAGS="$LDFLAGS -L$lua_dir/lib"
+	fi
+
+	#
+	# Make sure we have "lua.h".  If we don't, it means we probably
+	# don't have liblua, so don't use it.
+	#
+	AC_CHECK_HEADER(lua.h,,
+	  [
+	    if test "x$lua_dir" != "x"
+	    then
+	      #
+	      # The user used "--with-lua=" to specify a directory
+	      # containing liblua, but we didn't find the header file
+	      # there; that either means they didn't specify the
+	      # right directory or are confused about whether liblua
+	      # is, in fact, installed.  Report the error and give up.
+	      #
+	      AC_MSG_ERROR([liblua header not found in directory specified in --with-lua])
+	    else
+	      if test "x$want_lua" = "xyes"
+	      then
+		#
+		# The user tried to force us to use the library, but we
+		# couldn't find the header file; report an error.
+		#
+		AC_MSG_ERROR(Header file lua.h not found.)
+	      else
+		#
+		# We couldn't find the header file; don't use the
+		# library, as it's probably not present.
+		#
+		want_lua=no
+	      fi
+	    fi
+	  ])
+
+	if test "x$want_lua" != "xno"
+	then
+		#
+		# Well, we at least have the lua header file.
+		#
+		# We're only using standard functions from liblua,
+		# so we don't need to perform extra checks.
+		#
+		AC_CHECK_LIB(lua, lua_version,
+		[
+			if test "x$lua_dir" != "x"
+			then
+				#
+				# Put the "-I" and "-L" flags for lua at
+				# the beginning of CFLAGS, CPPFLAGS,
+				# LDFLAGS, and LIBS.
+				#
+				LUA_LIBS="-L$lua_dir/lib -llua $ethereal_save_LIBS"
+			else
+				LUA_LIBS="-llua"
+			fi
+			AC_DEFINE(HAVE_LIBLUA, 1, [Define to use liblua library])
+		],[
+			if test "x$lua_dir" != "x"
+			then
+				#
+				# Restore the versions of CFLAGS, CPPFLAGS,
+				# LDFLAGS, and LIBS before we added the
+				# "--with-lua=" directory, as we didn't
+				# actually find lua there.
+				#
+				CFLAGS="$ethereal_save_CFLAGS"
+				CPPFLAGS="$ethereal_save_CPPFLAGS"
+				LDFLAGS="$ethereal_save_LDFLAGS"
+				LIBS="$ethereal_save_LIBS"
+				LUA_LIBS=""
+			fi
+			want_lua=no
+		])
+		AC_SUBST(LUA_LIBS)
+	fi
+])
+
+#
 # AC_ETHEREAL_NETSNMP_CHECK
 #
 AC_DEFUN([AC_ETHEREAL_NETSNMP_CHECK],
Index: Makefile.am
===================================================================
--- Makefile.am	(revision 17118)
+++ Makefile.am	(working copy)
@@ -178,6 +178,14 @@
 include Makefile.common
 
 if HAVE_PLUGINS
+
+if HAVE_LIBLUA
+lua_lib = \
+	plugins/lua/lua.la
+else		# HAVE_LIBLUA
+lua_lib =
+endif		# HAVE_LIBLUA
+
 plugin_libs = \
 	plugins/acn/acn.la \
 	plugins/agentx/agentx.la \
@@ -190,7 +198,9 @@
 	plugins/giop/coseventcomm.la \
 	plugins/gryphon/gryphon.la \
 	plugins/irda/irda.la \
+	$(lua_lib) \
 	plugins/lwres/lwres.la \
+	plugins/mate/mate.la \
 	plugins/megaco/megaco.la \
 	plugins/mgcp/mgcp.la \
 	plugins/opsi/opsi.la \
@@ -200,12 +210,21 @@
 	plugins/rlm/rlm.la \
 	plugins/rtnet/rtnet.la \
 	plugins/rudp/rudp.la \
+	plugins/stats_tree/stats_tree.la \
 	plugins/v5ua/v5ua.la
 
 if ENABLE_STATIC
 plugin_ldadd = $(plugin_libs)
 
 else		# ENABLE_STATIC
+
+if HAVE_LIBLUA
+lua_ldadd = \
+	"-dlopen" plugins/lua/lua.la
+else		# HAVE_LIBLUA
+lua_ldadd =
+endif		# HAVE_LIBLUA
+
 plugin_ldadd = \
 	"-dlopen" self	\
 	"-dlopen" plugins/acn/acn.la \
@@ -218,8 +237,12 @@
 	"-dlopen" plugins/giop/cosnaming.la \
 	"-dlopen" plugins/giop/coseventcomm.la \
 	"-dlopen" plugins/gryphon/gryphon.la \
+	"-dlopen" plugins/h223/h223.la \
 	"-dlopen" plugins/irda/irda.la \
+	$(lua_ldadd) \
+	"-dlopen" plugins/lua/lua.la \
 	"-dlopen" plugins/lwres/lwres.la \
+	"-dlopen" plugins/mate/mate.la \
 	"-dlopen" plugins/megaco/megaco.la \
 	"-dlopen" plugins/mgcp/mgcp.la \
 	"-dlopen" plugins/opsi/opsi.la \
@@ -229,6 +252,7 @@
 	"-dlopen" plugins/rlm/rlm.la \
 	"-dlopen" plugins/rtnet/rtnet.la \
 	"-dlopen" plugins/rudp/rudp.la \
+	"-dlopen" plugins/stats_tree/stats_tree.la \
 	"-dlopen" plugins/v5ua/v5ua.la
 
 endif		# ENABLE_STATIC
Index: plugins/Makefile.am
===================================================================
--- plugins/Makefile.am	(revision 17118)
+++ plugins/Makefile.am	(working copy)
@@ -21,6 +21,13 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
+if HAVE_LIBLUA
+lua_dir = \
+	lua
+else		# HAVE_LIBLUA
+lua_dir =
+endif		# HAVE_LIBLUA
+
 SUBDIRS = \
 	acn \
 	agentx \
@@ -33,6 +40,7 @@
 	gryphon \
 	h223 \
 	irda \
+	$(lua_dir) \
 	lwres \
 	mate \
 	megaco \
Index: plugins/lua/Makefile.am
===================================================================
--- plugins/lua/Makefile.am	(revision 17118)
+++ plugins/lua/Makefile.am	(working copy)
@@ -28,23 +28,23 @@
 plugin_LTLIBRARIES = lua.la
 
 lua_la_SOURCES = \
-    lua_tvb.c \
-    lua_proto.c \
-    lua_tree.c \
-    lua_pinfo.c \
-    lua_tap.c \
-    packet-lua.c \
-    packet-lua.h \
+	lua_tvb.c \
+	lua_proto.c \
+	lua_tree.c \
+	lua_pinfo.c \
+	lua_tap.c \
+	packet-lua.c \
+	packet-lua.h \
 	plugin.c
 
 lua_la_LDFLAGS = -module -avoid-version
-lua_la_LIBADD = @PLUGIN_LIBS@
+lua_la_LIBADD = @PLUGIN_LIBS@ @LUA_LIBS@
 
 
 # Libs must be cleared, or else libtool won't create a shared module.
 # If your module needs to be linked against any particular libraries,
 # add them here.
-LIBS = -L./lua-5.0.2/lib -llua -llualib
+LIBS =
 
 
 CLEANFILES = \