More constification of arrays.
[obnox/wireshark/wip.git] / ethereal_gen.py
index 15bc8614d7e3f1e041281c5450f8438d1ff3a83d..2dacf1eaf4b844361ab6f751bb7aa65c7036552e 100644 (file)
@@ -1,6 +1,6 @@
 # -*- python -*-
 #
-# $Id: ethereal_gen.py,v 1.14 2001/10/25 19:57:06 guy Exp $
+# $Id$
 #                           
 # ethereal_gen.py (part of idl2eth)           
 #
@@ -37,7 +37,7 @@
 #   
 #   Omniidl Back-end which parses an IDL list of "Operation" nodes
 #   passed from ethereal_be2.py and generates "C" code for compiling
-#   as a dissector in Ethereal IP protocol anlayser.
+#   as a plugin for the  Ethereal IP Protocol Analyser.
 #
 #
 # Strategy (sneaky but ...)
@@ -94,8 +94,10 @@ import tempfile
 # 12. Implement IDL "union" code [done]
 # 13. Implement support for plugins [done]
 # 14. Dont generate code for empty operations (cf: exceptions without members)
-# 15. Generate code to display Enums numerically ans symbolically [done]
-# 16. Place structs in subtrees
+# 15. Generate code to display Enums numerically and symbolically [done]
+# 16. Place structs/unions in subtrees
+# 17. Recursive struct and union handling [done ]
+# 18. Improve variable naming for display (eg: structs, unions etc)
 #
 # Also test, Test, TEST
 #
@@ -169,9 +171,10 @@ class ethereal_gen_C:
     #
     #
         
-    def genCode(self,oplist, atlist, enlist):   # operation and attribute lists
+    def genCode(self,oplist, atlist, enlist, stlist, unlist):   # operation,attribute,enums,struct and union lists
 
-        self.genHelpers(oplist)         # sneaky .. call it now, to populate the fn_hash
+
+        self.genHelpers(oplist,stlist,unlist)  # sneaky .. call it now, to populate the fn_hash
                                         # so when I come to that operation later, I have the variables to
                                         # declare already.
                                         
@@ -191,7 +194,7 @@ class ethereal_gen_C:
         self.genEthCopyright()          # Ethereal Copyright comments.
         self.genGPL()                   # GPL license
         self.genIncludes()
-        self.genDeclares(oplist)
+        self.genDeclares(oplist,atlist,enlist,stlist,unlist)
         self.genProtocol()
         self.genRegisteredFields()
         self.genOpList(oplist)          # string constant declares for operation names
@@ -204,7 +207,7 @@ class ethereal_gen_C:
         self.genExceptionDelegator(oplist) # finds the helper function to decode a user exception
         self.genAttributeHelpers(atlist)   # helper function to decode "attributes"
 
-        self.genHelpers(oplist)
+        self.genHelpers(oplist,stlist,unlist)  # operation, struct and union decode helper functions
 
         self.genMainEntryStart(oplist)
         self.genOpDelegator(oplist)
@@ -273,15 +276,39 @@ class ethereal_gen_C:
             
         self.st.out(self.template_Includes)
                                 
+
     #
     # denDeclares
     #
+    # generate function prototypes if required
     #
+    # Currently this is used for struct and union helper function declarations.
+    #
+    
     
-    def genDeclares(self,oplist):
+    def genDeclares(self,oplist,atlist,enlist,stlist,unlist):
         if self.DEBUG:
             print "XXX genDeclares"
 
+        # struct prototypes
+        
+        self.st.out(self.template_prototype_struct_start)        
+        for st in stlist:
+            #print st.repoId()
+            sname = self.namespace(st, "_")   
+
+            self.st.out(self.template_prototype_struct_body, stname=st.repoId(),name=sname)        
+        self.st.out(self.template_prototype_struct_end)        
+
+        # union prototypes
+
+        self.st.out(self.template_prototype_union_start)        
+        for un in unlist:
+            sname = self.namespace(un, "_")   
+            self.st.out(self.template_prototype_union_body, unname=un.repoId(),name=sname)        
+        self.st.out(self.template_prototype_union_end)        
+                        
+
 
                                 
     #
@@ -326,7 +353,6 @@ class ethereal_gen_C:
         self.st.dec_indent()
         self.st.out(self.template_main_dissector_switch_msgtype_all_other_msgtype)             
         self.st.dec_indent()
-        #self.st.out(self.template_main_dissector_switch_msgtype_end)              
         self.st.out(self.template_main_dissector_end)        
         
 
@@ -667,15 +693,21 @@ class ethereal_gen_C:
     # genHelpers()
     #
     # Generate private helper functions for each IDL operation.
+    # Generate private helper functions for each IDL struct.
+    # Generate private helper functions for each IDL union.
     #
-    # in: oplist
+    #
+    # in: oplist, stlist, unlist
     #
     
         
-    def genHelpers(self,oplist):
+    def genHelpers(self,oplist,stlist,unlist):
         for op in oplist:
             self.genOperation(op)
-
+        for st in stlist:
+            self.genStructHelper(st)
+        for un in unlist:
+            self.genUnionHelper(un)
 
     #
     # genOperation()
@@ -755,7 +787,6 @@ class ethereal_gen_C:
     #
     # Decode function parameters for a GIOP request message
     #
-    # TODO check for enum
     #
     
     def genOperationRequest(self,opnode):
@@ -772,7 +803,6 @@ class ethereal_gen_C:
     #
     # Decode function parameters for a GIOP reply message
     #
-    # TODO check for enum
 
     
     def genOperationReply(self,opnode):
@@ -966,7 +996,7 @@ class ethereal_gen_C:
         elif pt ==  idltype.tk_struct:
             self.get_CDR_struct(type,pn)
         elif pt ==  idltype.tk_TypeCode: # will I ever get here ?
-            self.get_CDR_TypeCode(type,pn)
+            self.get_CDR_TypeCode(pn)
         elif pt == idltype.tk_sequence:
             self.get_CDR_sequence(type,pn)
         elif pt == idltype.tk_objref:
@@ -1047,7 +1077,7 @@ class ethereal_gen_C:
 
     def get_CDR_enum(self,pn,type):
         #self.st.out(self.template_get_CDR_enum, varname=pn)
-        sname = self.namespace(type, "_")
+        sname = self.namespace(type.unalias(), "_")
         self.st.out(self.template_get_CDR_enum_symbolic, valstringarray=sname)
 
 
@@ -1079,6 +1109,8 @@ class ethereal_gen_C:
         self.st.out(self.template_get_CDR_sequence_length, seqname=pn)
         self.addvar(self.c_u_octet4)
 
+
+            
     def get_CDR_union(self,type,pn):
         if self.DEBUG:
             print "XXX Union type =" , type, " pn = ",pn
@@ -1095,27 +1127,53 @@ class ethereal_gen_C:
         if self.DEBUG:    
             print "XXX Union ntype =" , ntype
 
-        if ntype.recursive():
-            sys.stderr.write( "Error: idl2eth does not handle recursive unions yet \n")
-            sys.exit(1)
+        sname = self.namespace(ntype, "_")
+        self.st.out(self.template_union_start, name=sname )
+
+        # Output a call to the union helper function so I can handle recursive union also.
+        
+        self.st.out(self.template_decode_union,name=sname)    
+
+        self.st.out(self.template_union_end, name=sname )
             
-        st = ntype.switchType().unalias() # may be typedef switch type, so find real type
 
-        #std = st.decl()
+    #
+    # Code to generate Union Helper functions
+    #
+    # in: un - a union node
+    #
+    #
 
-        if self.DEBUG:    
-            print "XXX Union ntype =" , ntype
-            print "XXX Union ntype.switchType =" , st
-            #print "XXX Union ntype.switchType().decl() = " , std
-            #print "XXX Union  std.repoId() = ", std.repoId()
 
+    def genUnionHelper(self,un):
+        if self.DEBUG:
+            print "XXX Union type =" , un
+            print "XXX Union type.decl()" , un.decl()
+            print "XXX Union Scoped Name" , un.scopedName()
 
-        self.st.out(self.template_comment_union_code_start, uname=ntype.repoId() )
+        sname = self.namespace(un, "_")
+        self.curr_sname = sname         # update current opnode/exnode/stnode/unnode scoped name
+        if not self.fn_hash_built:
+            self.fn_hash[sname] = []        # init empty list as val for this sname key
+                                            # but only if the fn_hash is not already built
+
+        self.st.out(self.template_union_helper_function_start, sname=sname, unname=un.repoId())
+        self.st.inc_indent()
 
-        self.getCDR3(st,pn);
+        self.st.out(self.template_helper_function_vars_start)
+        self.dumpCvars(sname)
+        self.st.out(self.template_helper_function_vars_end )
+        
+        self.st.out(self.template_union_helper_function_get_endianess)
+
+        st = un.switchType().unalias() # may be typedef switch type, so find real type
+
+        self.st.out(self.template_comment_union_code_start, uname=un.repoId() )
+
+        self.getCDR3(st,un.identifier());
 
         # Depending on what kind of discriminant I come accross (enum,integer,char,
-        # boolean), make sure I cast the return value of the get_XXX accessor
+        # short, boolean), make sure I cast the return value of the get_XXX accessor
         # to an appropriate value. Omniidl idlast.CaseLabel.value() accessor will
         # return an integer, or an Enumerator object that is then converted to its
         # integer equivalent.
@@ -1127,24 +1185,32 @@ class ethereal_gen_C:
         if (st.kind() == idltype.tk_enum):
             std = st.decl()            
             self.st.out(self.template_comment_union_code_discriminant, uname=std.repoId() )
-            self.st.out(self.template_union_code_save_discriminant_enum, discname=pn )
-            self.addvar(self.c_s_disc + pn + ";")            
+            self.st.out(self.template_union_code_save_discriminant_enum, discname=un.identifier() )
+            self.addvar(self.c_s_disc + un.identifier() + ";")            
 
         elif (st.kind() == idltype.tk_long):
-            self.st.out(self.template_union_code_save_discriminant_long, discname=pn )
-            self.addvar(self.c_s_disc + pn + ";")            
+            self.st.out(self.template_union_code_save_discriminant_long, discname=un.identifier() )
+            self.addvar(self.c_s_disc + un.identifier() + ";")            
+
+        elif (st.kind() == idltype.tk_ulong):
+            self.st.out(self.template_union_code_save_discriminant_ulong, discname=un.identifier() )
+            self.addvar(self.c_s_disc + un.identifier() + ";")            
 
         elif (st.kind() == idltype.tk_short):
-            self.st.out(self.template_union_code_save_discriminant_short, discname=pn )
-            self.addvar(self.c_s_disc + pn + ";")            
+            self.st.out(self.template_union_code_save_discriminant_short, discname=un.identifier() )
+            self.addvar(self.c_s_disc + un.identifier() + ";")            
+
+        elif (st.kind() == idltype.tk_ushort):
+            self.st.out(self.template_union_code_save_discriminant_ushort, discname=un.identifier() )
+            self.addvar(self.c_s_disc + un.identifier() + ";")            
 
         elif (st.kind() == idltype.tk_boolean):
-            self.st.out(self.template_union_code_save_discriminant_boolean, discname=pn )
-            self.addvar(self.c_s_disc + pn + ";")            
+            self.st.out(self.template_union_code_save_discriminant_boolean, discname=un.identifier()  )
+            self.addvar(self.c_s_disc + un.identifier() + ";")            
             
         elif (st.kind() == idltype.tk_char):
-            self.st.out(self.template_union_code_save_discriminant_char, discname=pn )
-            self.addvar(self.c_s_disc + pn + ";")            
+            self.st.out(self.template_union_code_save_discriminant_char, discname=un.identifier() )
+            self.addvar(self.c_s_disc + un.identifier() + ";")            
 
         else:
             print "XXX Unknown st.kind() = ", st.kind()
@@ -1153,8 +1219,8 @@ class ethereal_gen_C:
         # Loop over all cases in this union
         #
         
-        for uc in ntype.cases():        # for all UnionCase objects in this union
-            for cl in uc.labels():       # for all Caselabel objects in this UnionCase
+        for uc in un.cases():           # for all UnionCase objects in this union
+            for cl in uc.labels():      # for all Caselabel objects in this UnionCase
 
                 # get integer value, even if discriminant is
                 # an Enumerator node
@@ -1198,7 +1264,7 @@ class ethereal_gen_C:
                 #
                 
                 if not cl.default():
-                    self.st.out(self.template_comment_union_code_label_compare_start, discname=pn,labelval=string_clv )
+                    self.st.out(self.template_comment_union_code_label_compare_start, discname=un.identifier(),labelval=string_clv )
                     self.st.inc_indent()       
                 else:
                     self.st.out(self.template_comment_union_code_label_default_start  )
@@ -1211,7 +1277,11 @@ class ethereal_gen_C:
                     self.st.out(self.template_comment_union_code_label_compare_end )
                 else:
                     self.st.out(self.template_comment_union_code_label_default_end  )
-            
+
+        self.st.dec_indent()
+        self.st.out(self.template_union_helper_function_end)
+
+
 
     #
     # Currently, get_CDR_alias is geared to finding typdef 
@@ -1251,8 +1321,11 @@ class ethereal_gen_C:
         
         
 
+    #
+    # Handle structs, including recursive
+    #
+    
     def get_CDR_struct(self,type,pn):       
-        self.st.out(self.template_structure_start, name=type.name() )
 
         #  If I am a typedef struct {..}; node then find the struct node
         
@@ -1261,11 +1334,43 @@ class ethereal_gen_C:
         else:
             ntype = type.decl()         # I am a struct node
 
-        if ntype.recursive():
-            sys.stderr.write("Error: idl2eth does not handle recursive structs yet \n")
-            sys.exit(1)
-                                    
-        for m in ntype.members():
+        sname = self.namespace(ntype, "_")
+        self.st.out(self.template_structure_start, name=sname )
+
+        # Output a call to the struct helper function so I can handle recursive structs also.
+        
+        self.st.out(self.template_decode_struct,name=sname)    
+
+        self.st.out(self.template_structure_end, name=sname )
+
+    #
+    # genStructhelper() 
+    #
+    # Generate private helper functions to decode a struct
+    #
+    # in: stnode ( a struct node)
+    #
+    
+    def genStructHelper(self,st):
+        if self.DEBUG:
+            print "XXX genStructHelper"
+            
+        sname = self.namespace(st, "_")
+        self.curr_sname = sname         # update current opnode/exnode/stnode scoped name
+        if not self.fn_hash_built:
+            self.fn_hash[sname] = []        # init empty list as val for this sname key
+                                            # but only if the fn_hash is not already built
+
+        self.st.out(self.template_struct_helper_function_start, sname=sname, stname=st.repoId())
+        self.st.inc_indent()
+
+        self.st.out(self.template_helper_function_vars_start)
+        self.dumpCvars(sname)
+        self.st.out(self.template_helper_function_vars_end )
+        
+        self.st.out(self.template_struct_helper_function_get_endianess)
+
+        for m in st.members():
             for decl in m.declarators():
                 if decl.sizes():        # an array
                     indices = self.get_indices_from_sizes(decl.sizes())
@@ -1275,21 +1380,25 @@ class ethereal_gen_C:
                     self.addvar(self.c_i + decl.identifier() + ";")
                     
                     self.st.inc_indent()       
-                    self.getCDR3(m.memberType(), type.name() + "_" + decl.identifier() )                    
+                    self.getCDR3(m.memberType(), st.identifier() + "_" + decl.identifier() )                    
                     self.st.dec_indent()
                     self.st.out(self.template_get_CDR_array_end)
                     
                     
-                else:    
-                    self.getCDR3(m.memberType(), type.name() + "_" + decl.identifier() )
+                else:                            
+                    self.getCDR3(m.memberType(), st.identifier() + "_" + decl.identifier() )
+                            
+        self.st.dec_indent()
+        self.st.out(self.template_struct_helper_function_end)
+
 
-        self.st.out(self.template_structure_end, name=type.name())
 
 
 
     #
     # Generate code to access a sequence of a type
     #
+
     
     def get_CDR_sequence(self,type, pn):
         self.st.out(self.template_get_CDR_sequence_length, seqname=pn )
@@ -1508,7 +1617,7 @@ class ethereal_gen_C:
 
 
     template_helper_function_start = """\
-static void decode_@sname@(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int *offset, MessageHeader *header, gchar *operation) {
+static void decode_@sname@(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, int *offset _U_, MessageHeader *header, gchar *operation _U_) {
 
     gboolean stream_is_big_endian;          /* big endianess */
 """
@@ -1609,7 +1718,11 @@ plugin_reg_handoff(void){
 }
 
 G_MODULE_EXPORT void
-plugin_init(plugin_address_table_t *pat){
+plugin_init(plugin_address_table_t *pat
+#ifndef PLUGINS_NEED_ADDRESS_TABLE
+_U_
+#endif
+){
    /* initialise the table of pointers needed in Win32 DLLs */
    plugin_address_table_init(pat);
    if (proto_@dissector_name@ == -1) {
@@ -1997,6 +2110,15 @@ for (i_@aname@=0; i_@aname@ < @aval@; i_@aname@++) {
 /*  End struct \"@name@\"  */
 """
 
+    template_union_start = """\
+/*  Begin union \"@name@\"  */
+"""
+
+
+    template_union_end = """\
+/*  End union \"@name@\"  */
+"""
+
 
 
 
@@ -2065,29 +2187,18 @@ for (i_@aname@=0; i_@aname@ < @aval@; i_@aname@++) {
 #include <stdlib.h>
 #include <gmodule.h>
 
-#ifdef HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-
-#ifdef HAVE_NETINET_IN_H
-# include <netinet/in.h>
-#endif
-
 #ifdef NEED_SNPRINTF_H
-# ifdef HAVE_STDARG_H
-#  include <stdarg.h>
-# else
-#  include <varargs.h>
-# endif
 # include "snprintf.h"
 #endif
 
 #include <string.h>
 #include <glib.h>
-#include "packet.h"
-#include "proto.h"
+#include <epan/packet.h>
+#include <epan/proto.h>
 #include "packet-giop.h"
 
+#include "plugins/plugin_api_defs.h"
+
 #ifndef __ETHEREAL_STATIC__
 G_MODULE_EXPORT const gchar version[] = "0.0.1";
 #endif
@@ -2100,18 +2211,23 @@ G_MODULE_EXPORT const gchar version[] = "0.0.1";
 #
 
     template_main_dissector_start = """\
-static gboolean dissect_@dissname@(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ptree, int *offset, MessageHeader *header, gchar *operation, gchar *idlname) {
+static gboolean dissect_@dissname@(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ptree, int *offset, MessageHeader *header, gchar *operation, gchar *idlname _U_) {
 
     proto_item *ti = NULL;
     proto_tree *tree = NULL;            /* init later, inside if(tree) */
     
     gboolean be;                        /* big endianess */
-    guint32  offset_saved = (*offset);  /* save in case we must back out */
 
-    pinfo->current_proto = \"@disprot@\";
+    if (check_col(pinfo->cinfo, COL_PROTOCOL))
+       col_set_str(pinfo->cinfo, COL_PROTOCOL, \"@disprot@\");
 
-    if (check_col(pinfo->fd, COL_PROTOCOL))
-       col_add_str(pinfo->fd, COL_PROTOCOL, \"@disprot@\");
+/* 
+ * Do not clear COL_INFO, as nothing is being written there by 
+ * this dissector yet. So leave it as is from the GIOP dissector.
+ * TODO: add something useful to COL_INFO 
+ *  if (check_col(pinfo->cinfo, COL_INFO))
+ *     col_clear(pinfo->cinfo, COL_INFO);
+ */
 
     if (ptree) {
        ti = proto_tree_add_item(ptree, proto_@dissname@, tvb, *offset, tvb_length(tvb) - *offset, FALSE);
@@ -2151,23 +2267,6 @@ break;
 """
 
 
-    template_main_dissector_switch_msgtype_end = """\
-
-
-/*
- * We failed to match ANY operations, so perhaps this is not for us !
- */
-
-(*offset) = offset_saved;       /* be nice */
-
-return FALSE;
-
-
-"""
-
-
-
-    
     template_main_dissector_switch_msgtype_all_other_msgtype = """\
 case CancelRequest:
 case LocateRequest:
@@ -2185,14 +2284,6 @@ default:
 """
 
 
-    template_main_dissector_switch_msgtype_end = """\
-
-   return TRUE;
-
-} /* switch */
-
-"""
-
     template_main_dissector_end = """\
 
     return FALSE;
@@ -2262,9 +2353,9 @@ default:
  *
  */
  
-static gboolean decode_user_exception(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int *offset, MessageHeader *header, gchar *operation ) {
+static gboolean decode_user_exception(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, int *offset _U_, MessageHeader *header _U_, gchar *operation _U_ ) {
     
-    gboolean be;                        /* big endianess */
+    gboolean be _U_;                        /* big endianess */
 
     
 """
@@ -2327,6 +2418,75 @@ stream_is_big_endian = is_big_endian(header);  /* get stream endianess */
 }
 """
 
+    
+#
+# template for struct helper code
+#
+
+
+    template_struct_helper_function_start = """\
+
+/* Struct = @stname@ */
+
+static void decode_@sname@_st(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int *offset, MessageHeader *header, gchar *operation) {
+
+    gboolean stream_is_big_endian;          /* big endianess */
+"""
+
+
+
+
+    #
+    # Template for the helper function
+    # to get stream endianess from header
+    #
+
+    template_struct_helper_function_get_endianess = """\
+
+stream_is_big_endian = is_big_endian(header);  /* get stream endianess */
+
+"""
+
+    
+    template_struct_helper_function_end = """\
+}
+"""
+
+#
+# template for union helper code
+#
+
+
+    template_union_helper_function_start = """\
+
+/* Union = @unname@ */
+
+static void decode_@sname@_un(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int *offset, MessageHeader *header, gchar *operation) {
+
+    gboolean stream_is_big_endian;          /* big endianess */
+"""
+
+
+
+
+    #
+    # Template for the helper function
+    # to get stream endianess from header
+    #
+
+    template_union_helper_function_get_endianess = """\
+
+stream_is_big_endian = is_big_endian(header);  /* get stream endianess */
+
+"""
+
+    
+    template_union_helper_function_end = """\
+}
+"""
+
+
+
 #-------------------------------------------------------------#
 #             Value string  templates                         #
 #-------------------------------------------------------------#
@@ -2538,8 +2698,16 @@ disc_s_@discname@ = (gint32) u_octet4;     /* save Enum Value  discriminant and
 disc_s_@discname@ = (gint32) s_octet4;     /* save gint32 discriminant and cast to gint32 */
 """
 
+    template_union_code_save_discriminant_ulong = """\
+disc_s_@discname@ = (gint32) u_octet4;     /* save guint32 discriminant and cast to gint32 */
+"""    
+
     template_union_code_save_discriminant_short = """\
 disc_s_@discname@ = (gint32) s_octet2;     /* save gint16 discriminant and cast to gint32 */
+"""    
+
+    template_union_code_save_discriminant_ushort = """\
+disc_s_@discname@ = (gint32) u_octet2;     /* save guint16 discriminant and cast to gint32 */
 """    
     
     template_union_code_save_discriminant_char = """\
@@ -2556,7 +2724,7 @@ if (disc_s_@discname@ == @labelval@) {
 
  """
     template_comment_union_code_label_compare_end = """\
-    break;
+    return;     /* End Compare for this discriminant type */
 }
 
  """
@@ -2571,3 +2739,62 @@ if (disc_s_@discname@ == @labelval@) {
 /* Default Union Case End */
  
  """
+
+    #
+    # Templates for function prototypes.
+    # This is used in genDeclares() for declaring function prototypes
+    # for structs and union helper functions.
+    #
+
+    template_prototype_struct_start = """
+/* Struct prototype declaration Start */
+"""
+    
+    template_prototype_struct_end = """
+/* Struct prototype declaration End */
+"""
+    
+    template_prototype_struct_body = """
+        
+/* Struct = @stname@ */
+
+static void decode_@name@_st(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int *offset, MessageHeader *header, gchar *operation);
+
+"""
+
+    template_decode_struct = """
+        
+decode_@name@_st(tvb, pinfo, tree, offset, header, operation);
+
+"""
+
+
+    
+    
+    template_prototype_union_start = """
+/* Union prototype declaration Start */
+"""
+    
+    template_prototype_union_end = """
+/* Union prototype declaration End */
+"""
+    
+    template_prototype_union_body = """
+        
+/* Union = @unname@ */
+
+static void decode_@name@_un(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int *offset, MessageHeader *header, gchar *operation);
+
+"""
+
+    template_decode_union = """
+        
+decode_@name@_un(tvb, pinfo, tree, offset, header, operation);
+
+"""
+    
+