Huge thanks to our Platinum Members Endace and LiveAction,
and our Silver Member Veeam, for supporting the Wireshark Foundation and project.

Wireshark-dev: Re: [Wireshark-dev] OpCua faulty checkin and breaks the build

From: Gerhard Gappmeier <gerhard.gappmeier@xxxxxxxxxxx>
Date: Tue, 15 May 2007 14:54:54 +0200
Hi

I updated the files for the build process to fit the current wireshark
version.
I don't know much about it so a just copied the missing parts from
another module.
I'm not sure of it's right, so please have a look at it.

Modifications:
* added plugin.rc.in
* added moduleinfo.nmake
* updated Makefile.am/nmake/common
* removed unused variable from opcua_application_layer.c
* fixed unused parameter warning in opcua.c

I tested it on Windows with VC6 and on Gentoo linux with gcc 3.4.6.

regards,
Gerhard.

Index: Makefile.am
===================================================================
--- Makefile.am	(revision 21784)
+++ Makefile.am	(working copy)
@@ -27,6 +27,10 @@
 
 include Makefile.common
 
+if HAVE_WARNINGS_AS_ERRORS
+AM_CFLAGS = -Werror
+endif
+
 plugindir = @plugindir@
 
 plugin_LTLIBRARIES = opcua.la
@@ -116,4 +120,7 @@
 
 EXTRA_DIST = \
 	Makefile.common		\
-	Makefile.nmake
+	Makefile.nmake		\
+	moduleinfo.nmake	\
+	plugin.rc.in		\
+	README
Index: Makefile.common
===================================================================
--- Makefile.common	(revision 21784)
+++ Makefile.common	(working copy)
@@ -29,16 +29,7 @@
 
 # the dissector sources (without any helpers)
 DISSECTOR_SRC = \
-	opcua.c \
-	opcua_transport_layer.c \
-	opcua_security_layer.c \
-	opcua_application_layer.c \
-	opcua_serviceparser.c \
-	opcua_complextypeparser.c \
-	opcua_enumparser.c \
-	opcua_simpletypes.c \
-	opcua_servicetable.c \
-	opcua_hfindeces.c
+	opcua.c 
 
 # corresponding headers
 DISSECTOR_INCLUDES =	\
@@ -51,3 +42,15 @@
 	opcua_application_layer.h \
 	opcua_security_layer.h \
 	opcua_transport_layer.h
+
+# other sources
+DISSECTOR_SUPPORT_SRC = \
+	opcua_transport_layer.c \
+	opcua_security_layer.c \
+	opcua_application_layer.c \
+	opcua_serviceparser.c \
+	opcua_complextypeparser.c \
+	opcua_enumparser.c \
+	opcua_simpletypes.c \
+	opcua_servicetable.c \
+	opcua_hfindeces.c
Index: Makefile.nmake
===================================================================
--- Makefile.nmake	(revision 21784)
+++ Makefile.nmake	(working copy)
@@ -5,12 +5,11 @@
 #
 
 include ..\..\config.nmake
+include moduleinfo.nmake
 
-############### no need to modify below this line #########
-
 include Makefile.common
 
-CFLAGS=/DHAVE_CONFIG_H /I../.. /I../../wiretap $(GLIB_CFLAGS) \
+CFLAGS=/WX /DHAVE_CONFIG_H /I../.. /I../../wiretap $(GLIB_CFLAGS) \
 	/I$(PCAP_DIR)\include -D_U_="" $(LOCAL_CFLAGS)
 
 LDFLAGS = /NOLOGO /INCREMENTAL:no /MACHINE:I386 $(LOCAL_LDFLAGS)
@@ -21,12 +20,27 @@
 
 DISSECTOR_OBJECTS = $(DISSECTOR_SRC:.c=.obj)
 
-OBJECTS=$(DISSECTOR_OBJECTS) plugin.obj
+DISSECTOR_SUPPORT_OBJECTS = $(DISSECTOR_SUPPORT_SRC:.c=.obj)
 
-opcua.dll opcua.exp opcua.lib : $(OBJECTS) $(LINK_PLUGIN_WITH) 
-	link -dll /out:opcua.dll $(LDFLAGS) $(OBJECTS) $(LINK_PLUGIN_WITH)  \
-	$(GLIB_LIBS)
+OBJECTS = $(DISSECTOR_OBJECTS) $(DISSECTOR_SUPPORT_OBJECTS) plugin.obj
 
+RESOURCE=$(PLUGIN_NAME).res
+
+all: $(PLUGIN_NAME).dll
+
+$(PLUGIN_NAME).rc : moduleinfo.nmake
+	sed -e s/@PLUGIN_NAME@/$(PLUGIN_NAME)/ \
+	-e s/@RC_MODULE_VERSION@/$(RC_MODULE_VERSION)/ \
+	-e s/@RC_VERSION@/$(RC_VERSION)/ \
+	-e s/@MODULE_VERSION@/$(MODULE_VERSION)/ \
+	-e s/@PACKAGE@/$(PACKAGE)/ \
+	-e s/@VERSION@/$(VERSION)/ \
+	-e s/@MSVC_VARIANT@/$(MSVC_VARIANT)/ \
+	< plugin.rc.in > $@
+
+$(PLUGIN_NAME).dll $(PLUGIN_NAME).exp $(PLUGIN_NAME).lib : $(OBJECTS) $(LINK_PLUGIN_WITH) $(RESOURCE)
+	link -dll /out:$(PLUGIN_NAME).dll $(LDFLAGS) $(OBJECTS) $(LINK_PLUGIN_WITH) \
+	$(GLIB_LIBS) $(RESOURCE)
 #
 # Build plugin.c, which contains the plugin version[] string, a
 # function plugin_register() that calls the register routines for all
@@ -60,7 +74,7 @@
 # a plugin.c file for a plugin.
 # All subsequent arguments are the files to scan.
 #
-plugin.c: $(DISSECTOR_SRC)
+plugin.c: $(DISSECTOR_SRC) ../../tools/make-dissector-reg.py ../../tools/make-dissector-reg
 !IFDEF PYTHON
 	@echo Making plugin.c (using python)
 	@$(PYTHON) "../../tools/make-dissector-reg.py" . plugin $(DISSECTOR_SRC)
@@ -72,7 +86,9 @@
 !ENDIF
 
 clean:
-	rm -f $(OBJECTS) opcua.dll opcua.exp opcua.lib *.pdb
+	rm -f $(OBJECTS) $(RESOURCE) plugin.c *.pdb \
+		$(PLUGIN_NAME).dll $(PLUGIN_NAME).dll.manifest $(PLUGIN_NAME).lib \
+        $(PLUGIN_NAME).exp $(PLUGIN_NAME).rc 
 
 distclean: clean
 
Index: moduleinfo.nmake
===================================================================
--- moduleinfo.nmake	(revision 0)
+++ moduleinfo.nmake	(revision 0)
@@ -0,0 +1,28 @@
+#
+# $Id$
+#
+
+# The name
+PACKAGE=opcua
+
+# The version
+MODULE_VERSION_MAJOR=0
+MODULE_VERSION_MINOR=0
+MODULE_VERSION_MICRO=1
+MODULE_VERSION_EXTRA=0
+
+#
+# The RC_VERSION should be comma-separated, not dot-separated, 
+# as per Graham Bloice's message in
+#
+#	http://www.ethereal.com/lists/ethereal-dev/200303/msg00283.html
+#
+# "The RC_VERSION variable in config.nmake should be comma separated. 
+# This allows the resources to be built correctly and the version
+# number to be correctly displayed in the explorer properties dialog
+# for the executables, and XP's tooltip, rather than 0.0.0.0."
+#
+
+MODULE_VERSION=$(MODULE_VERSION_MAJOR).$(MODULE_VERSION_MINOR).$(MODULE_VERSION_MICRO).$(MODULE_VERSION_EXTRA)
+RC_MODULE_VERSION=$(MODULE_VERSION_MAJOR),$(MODULE_VERSION_MINOR),$(MODULE_VERSION_MICRO),$(MODULE_VERSION_EXTRA)
+
Index: opcua.c
===================================================================
--- opcua.c	(revision 21784)
+++ opcua.c	(working copy)
@@ -151,6 +151,9 @@
 static guint get_opcua_message_len(packet_info *pinfo, tvbuff_t *tvb, int offset)
 {
     gint32 plen;
+	
+	/* use parameter to avoid warning */
+    pinfo = 0;
 
     /* the message length starts at offset 4 */
     plen = tvb_get_letohl(tvb, offset + 4);
Index: opcua_application_layer.c
===================================================================
--- opcua_application_layer.c	(revision 21784)
+++ opcua_application_layer.c	(working copy)
@@ -75,7 +75,7 @@
 int parseServiceNodeId(proto_tree *tree, tvbuff_t *tvb, gint *pOffset, char *szFieldName)
 {
     gint    iOffset = *pOffset;
-    guint8  EncodingMask, NSId = 0;
+    guint8  EncodingMask;
     guint32 Numeric = 0;
 
 	szFieldName = 0; /* avoid warning */
@@ -92,7 +92,6 @@
         iOffset+=1;
         break;
     case 0x01: /* four byte node id */
-        NSId = tvb_get_guint8(tvb, iOffset);
         proto_tree_add_item(tree, hf_opcua_app_nsid, tvb, iOffset, 1, TRUE);
         iOffset+=1;
         Numeric = tvb_get_letohs(tvb, iOffset);
@@ -100,7 +99,6 @@
         iOffset+=2;
         break;
     case 0x02: /* numeric, that does not fit into four bytes */
-        NSId = tvb_get_letohl(tvb, iOffset);
         proto_tree_add_item(tree, hf_opcua_app_nsid, tvb, iOffset, 4, TRUE);
         iOffset+=4;
         Numeric = tvb_get_letohl(tvb, iOffset);
Index: plugin.rc.in
===================================================================
--- plugin.rc.in	(revision 0)
+++ plugin.rc.in	(revision 0)
@@ -0,0 +1,34 @@
+#include "winver.h"
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION @RC_MODULE_VERSION@
+ PRODUCTVERSION @RC_VERSION@,0
+ FILEFLAGSMASK 0x0L
+#ifdef _DEBUG
+ FILEFLAGS VS_FF_PRERELEASE+VS_FF_DEBUG
+#else
+ FILEFLAGS VS_FF_PRERELEASE
+#endif
+ FILEOS VOS_NT_WINDOWS32
+ FILETYPE VFT_DLL
+BEGIN
+    BLOCK "StringFileInfo"
+    BEGIN
+        BLOCK "040904b0"
+        BEGIN
+            VALUE "CompanyName", "The Wireshark developer community, http://www.wireshark.org/\0";
+            VALUE "FileDescription", "OPC Unified Architecture Dissector\0"
+            VALUE "FileVersion", "@MODULE_VERSION@\0"
+            VALUE "InternalName", "@PACKAGE@ @MODULE_VERSION@\0"
+            VALUE "LegalCopyright", "Copyright © 1998 Gerald Combs <gerald@xxxxxxxxxxxxx>, Gilbert Ramirez <gram@xxxxxxxxxxxxxxx> and others\0"
+            VALUE "OriginalFilename", "@[email protected]\0"
+            VALUE "ProductName", "Wireshark\0"
+            VALUE "ProductVersion", "@VERSION@\0"
+            VALUE "Comments", "Build with @MSVC_VARIANT@\0"
+        END
+    END
+    BLOCK "VarFileInfo"
+    BEGIN
+        VALUE "Translation", 0x409, 1200
+    END
+END