Move the STRING dissector to packet-dcerpc-nt.c and add one more parameter
[obnox/wireshark/wip.git] / ethereal_gen.py
index 104b54f4e683902f24214b630c2fbb108c9250cd..3c7e193e7ee7d118f5bdd6e1e81eb865b9a2e3a5 100644 (file)
@@ -1,6 +1,6 @@
 # -*- python -*-
 #
-# $Id: ethereal_gen.py,v 1.11 2001/08/11 04:37:31 guy Exp $
+# $Id: ethereal_gen.py,v 1.22 2002/01/23 23:15:32 guy Exp $
 #                           
 # 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,6 +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 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
 #
@@ -102,12 +106,12 @@ import tempfile
 
 #
 #   Strategy:
-#
-#    For return val and all parameters do
+#    For every operation and attribute do
+#       For return val and all parameters do
 #       find basic IDL type for each parameter
 #       output get_CDR_xxx
-#    output exception handling code
-#    output attribute handling code
+#       output exception handling code
+#       output attribute handling code
 #
 #
 
@@ -167,9 +171,10 @@ class ethereal_gen_C:
     #
     #
         
-    def genCode(self,oplist, atlist):   # 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.
                                         
@@ -189,19 +194,20 @@ 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
         self.genExList(oplist)          # string constant declares for user exceptions
         self.genAtList(atlist)          # string constant declares for Attributes
+        self.genEnList(enlist)          # string constant declares for Enums
         
         
         self.genExceptionHelpers(oplist)   # helper function to decode user exceptions that have members
         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)
@@ -270,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)        
+                        
+
 
                                 
     #
@@ -323,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)        
         
 
@@ -429,6 +458,43 @@ class ethereal_gen_C:
         self.st.out(self.template_comment_attributes_end)
 
 
+    #
+    # genEnList
+    #
+    # in: enlist
+    #
+    # out: C code for IDL Enum decalarations using "static const value_string" template
+    #
+
+    
+
+    def genEnList(self,enlist):
+        
+        self.st.out(self.template_comment_enums_start)        
+
+        for enum in enlist:
+            sname = self.namespace(enum, "_")
+            
+            self.st.out(self.template_comment_enum_comment, ename=enum.repoId())
+            self.st.out(self.template_value_string_start, valstringname=sname)
+            for enumerator in enum.enumerators():
+                self.st.out(self.template_value_string_entry, intval=str(self.valFromEnum(enum,enumerator)), description=enumerator.identifier())
+                
+                
+            #atname = n.identifier()
+            self.st.out(self.template_value_string_end, valstringname=sname)
+    
+        self.st.out(self.template_comment_enums_end)
+
+
+
+
+
+
+
+
+
+
     #
     # genExceptionDelegator
     #
@@ -627,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()
@@ -715,7 +787,6 @@ class ethereal_gen_C:
     #
     # Decode function parameters for a GIOP request message
     #
-    # TODO check for enum
     #
     
     def genOperationRequest(self,opnode):
@@ -732,7 +803,6 @@ class ethereal_gen_C:
     #
     # Decode function parameters for a GIOP reply message
     #
-    # TODO check for enum
 
     
     def genOperationReply(self,opnode):
@@ -920,7 +990,9 @@ class ethereal_gen_C:
             self.get_CDR_wchar(pn)            
         elif pt ==  idltype.tk_enum:
             #print type.decl()
-            self.get_CDR_enum(pn)
+            self.get_CDR_enum(pn,type)
+            #self.get_CDR_enum(pn)
+            
         elif pt ==  idltype.tk_struct:
             self.get_CDR_struct(type,pn)
         elif pt ==  idltype.tk_TypeCode: # will I ever get here ?
@@ -1003,8 +1075,12 @@ class ethereal_gen_C:
     def get_CDR_any(self,pn):
         self.st.out(self.template_get_CDR_any, varname=pn)
 
-    def get_CDR_enum(self,pn):
-        self.st.out(self.template_get_CDR_enum, varname=pn)
+    def get_CDR_enum(self,pn,type):
+        #self.st.out(self.template_get_CDR_enum, varname=pn)
+        sname = self.namespace(type, "_")
+        self.st.out(self.template_get_CDR_enum_symbolic, valstringarray=sname)
+
+
         self.addvar(self.c_u_octet4)
 
     def get_CDR_string(self,pn):
@@ -1033,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
@@ -1049,25 +1127,53 @@ class ethereal_gen_C:
         if self.DEBUG:    
             print "XXX Union ntype =" , ntype
 
-        st = ntype.switchType()
+        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 )
             
 
-        #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()
+
+        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.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=ntype.repoId() )
+        self.st.out(self.template_comment_union_code_start, uname=un.repoId() )
 
-        self.getCDR3(st,pn);
+        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.
@@ -1079,20 +1185,24 @@ 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_integer, 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_short):
+            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_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()
@@ -1101,8 +1211,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
@@ -1126,9 +1236,18 @@ class ethereal_gen_C:
                 #    
                 # if char, dont convert to int, but put inside single quotes so that it is understood by C.
                 # eg: if (disc == 'b')..
+                #
+                # TODO : handle \xxx chars generically from a function or table lookup rather than
+                #        a whole bunch of "if" statements. -- FS
+                
                                           
-                if (st.kind() == idltype.tk_char):      
-                    string_clv = "'" + clv + "'"
+                if (st.kind() == idltype.tk_char):
+                    if (clv == '\n'):          # newline
+                        string_clv = "'\\n'" 
+                    elif (clv == '\t'):        # tab
+                        string_clv = "'\\t'"
+                    else:
+                        string_clv = "'" + clv + "'"
                 else:                    
                     string_clv = '%i ' % clv
 
@@ -1137,7 +1256,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  )
@@ -1150,7 +1269,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 
@@ -1190,8 +1313,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
         
@@ -1199,8 +1325,44 @@ class ethereal_gen_C:
             ntype = type.decl().alias().aliasType().decl()           
         else:
             ntype = type.decl()         # I am a struct node
-                        
-        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())
@@ -1210,21 +1372,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 )
@@ -1821,18 +1987,18 @@ g_free(seq);          /*  free buffer  */
 seq = NULL;
 
 """
-    
-    
-    template_get_CDR_enum = """\
 
-/* TODO - translate Enum val into symbolic value */
+            
+    template_get_CDR_enum_symbolic = """\
     
 u_octet4 = get_CDR_enum(tvb,offset,stream_is_big_endian, boundary);
 if (tree) {
-   proto_tree_add_text(tree,tvb,*offset-4,4,"Enum value = %u ",u_octet4);
+   proto_tree_add_text(tree,tvb,*offset-4,4,"Enum value = %u (%s)",u_octet4,val_to_str(u_octet4,@valstringarray@,"Unknown Enum Value"));
 }
 """
 
+
+
     template_get_CDR_string = """\
 u_octet4 = get_CDR_string(tvb, &seq, offset, stream_is_big_endian, boundary);
 if (tree) {
@@ -1932,6 +2098,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@\"  */
+"""
+
 
 
 
@@ -2019,10 +2194,12 @@ for (i_@aname@=0; i_@aname@ < @aval@; i_@aname@++) {
 
 #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
@@ -2043,10 +2220,16 @@ static gboolean dissect_@dissname@(tvbuff_t *tvb, packet_info *pinfo, proto_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);
@@ -2262,6 +2445,118 @@ 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                         #
+#-------------------------------------------------------------#
+
+    template_value_string_start = """\
+static const value_string @valstringname@[] = {
+"""
+
+    template_value_string_entry = """\
+   { @intval@, \"@description@\" }, """    
+    
+    template_value_string_end = """\
+   { 0,       NULL },
+};
+    
+"""
+
+    
+
+#-------------------------------------------------------------#
+#             Enum   handling templates                       #
+#-------------------------------------------------------------#
+
+    template_comment_enums_start = """\
+/*
+ * IDL Enums Start
+ */
+ """
+    
+    template_comment_enums_end = """\
+/*
+ * IDL Enums End
+ */
+ """
+    
+    template_comment_enum_comment = """\
+/*
+ * Enum = @ename@
+ */
+ """
 
 
 
@@ -2426,9 +2721,13 @@ stream_is_big_endian = is_big_endian(header);  /* get stream endianess */
 disc_s_@discname@ = (gint32) u_octet4;     /* save Enum Value  discriminant and cast to gint32 */
 """
     
-    template_union_code_save_discriminant_integer = """\
+    template_union_code_save_discriminant_long = """\
 disc_s_@discname@ = (gint32) s_octet4;     /* save gint32 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_char = """\
 disc_s_@discname@ = (gint32) u_octet1;     /* save guint1 discriminant and cast to gint32 */
@@ -2444,7 +2743,7 @@ if (disc_s_@discname@ == @labelval@) {
 
  """
     template_comment_union_code_label_compare_end = """\
-    break;
+    return;     /* End Compare for this discriminant type */
 }
 
  """
@@ -2459,3 +2758,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);
+
+"""
+    
+