1 /****************************************************************************** 2 ** Copyright (C) 2006-2007 ascolab GmbH. All Rights Reserved. 3 ** Web: http://www.ascolab.com 4 ** 5 ** SPDX-License-Identifier: GPL-2.0-or-later 6 ** 7 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 8 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 9 ** 10 ** Project: OpcUa Wireshark Plugin 11 ** 12 ** Description: Implementation of OpcUa built-in type parsers. 13 ** This contains all the simple types and some complex types. 14 ** 15 ** Author: Gerhard Gappmeier <gerhard.gappmeier@ascolab.com> 16 ******************************************************************************/ 17 #include "opcua_identifiers.h" 18 19 /* simple header fields */ 20 extern int hf_opcua_returnDiag; 21 extern int hf_opcua_returnDiag_mask_sl_symbolicId; 22 extern int hf_opcua_returnDiag_mask_sl_localizedText; 23 extern int hf_opcua_returnDiag_mask_sl_additionalinfo; 24 extern int hf_opcua_returnDiag_mask_sl_innerstatuscode; 25 extern int hf_opcua_returnDiag_mask_sl_innerdiagnostics; 26 extern int hf_opcua_returnDiag_mask_ol_symbolicId; 27 extern int hf_opcua_returnDiag_mask_ol_localizedText; 28 extern int hf_opcua_returnDiag_mask_ol_additionalinfo; 29 extern int hf_opcua_returnDiag_mask_ol_innerstatuscode; 30 extern int hf_opcua_returnDiag_mask_ol_innerdiagnostics; 31 extern int hf_opcua_nodeClassMask; 32 extern int hf_opcua_nodeClassMask_object; 33 extern int hf_opcua_nodeClassMask_variable; 34 extern int hf_opcua_nodeClassMask_method; 35 extern int hf_opcua_nodeClassMask_objecttype; 36 extern int hf_opcua_nodeClassMask_variabletype; 37 extern int hf_opcua_nodeClassMask_referencetype; 38 extern int hf_opcua_nodeClassMask_datatype; 39 extern int hf_opcua_nodeClassMask_view; 40 41 /* simple types trees */ 42 extern gint ett_opcua_array_Boolean; 43 extern gint ett_opcua_array_SByte; 44 extern gint ett_opcua_array_Byte; 45 extern gint ett_opcua_array_Int16; 46 extern gint ett_opcua_array_UInt16; 47 extern gint ett_opcua_array_Int32; 48 extern gint ett_opcua_array_UInt32; 49 extern gint ett_opcua_array_Int64; 50 extern gint ett_opcua_array_UInt64; 51 extern gint ett_opcua_array_Float; 52 extern gint ett_opcua_array_Double; 53 extern gint ett_opcua_array_String; 54 extern gint ett_opcua_array_DateTime; 55 extern gint ett_opcua_array_Guid; 56 extern gint ett_opcua_array_ByteString; 57 extern gint ett_opcua_array_XmlElement; 58 extern gint ett_opcua_array_NodeId; 59 extern gint ett_opcua_array_ExpandedNodeId; 60 extern gint ett_opcua_array_StatusCode; 61 extern gint ett_opcua_array_DiagnosticInfo; 62 extern gint ett_opcua_array_QualifiedName; 63 extern gint ett_opcua_array_LocalizedText; 64 extern gint ett_opcua_array_ExtensionObject; 65 extern gint ett_opcua_array_DataValue; 66 extern gint ett_opcua_array_Variant; 67 extern gint ett_opcua_returnDiagnostics; 68 69 /* simple types */ 70 proto_item* parseBoolean(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint *pOffset, int hfIndex); 71 proto_item* parseByte(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint *pOffset, int hfIndex); 72 proto_item* parseSByte(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint *pOffset, int hfIndex); 73 proto_item* parseUInt16(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint *pOffset, int hfIndex); 74 proto_item* parseInt16(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint *pOffset, int hfIndex); 75 proto_item* parseUInt32(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint *pOffset, int hfIndex); 76 proto_item* parseInt32(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint *pOffset, int hfIndex); 77 proto_item* parseUInt64(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint *pOffset, int hfIndex); 78 proto_item* parseInt64(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint *pOffset, int hfIndex); 79 proto_item* parseString(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint *pOffset, int hfIndex); 80 proto_item* parseGuid(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint *pOffset, int hfIndex); 81 proto_item* parseByteString(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint *pOffset, int hfIndex); 82 proto_item* parseXmlElement(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint *pOffset, int hfIndex); 83 proto_item* parseFloat(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint *pOffset, int hfIndex); 84 proto_item* parseDouble(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint *pOffset, int hfIndex); 85 proto_item* parseDateTime(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint *pOffset, int hfIndex); 86 proto_item* parseStatusCode(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint *pOffset, int hfIndex); 87 /* complex types */ 88 void parseLocalizedText(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint *pOffset, const char *szFieldName); 89 void parseNodeId(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint *pOffset, const char *szFieldName); 90 void parseDiagnosticInfo(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint *pOffset, const char *szFieldName); 91 void parseExtensionObject(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint *pOffset, const char *szFieldName); 92 void parseQualifiedName(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint *pOffset, const char *szFieldName); 93 void parseDataValue(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint *pOffset, const char *szFieldName); 94 void parseVariant(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint *pOffset, const char *szFieldName); 95 void parseExpandedNodeId(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint *pOffset, const char *szFieldName); 96 void parseArraySimple(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint *pOffset, const char *szFieldName, const char *szTypeName, int hfIndex, fctSimpleTypeParser pParserFunction, const gint idx); 97 void parseArrayEnum(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint *pOffset, const char *szFieldName, const char *szTypeName, fctEnumParser pParserFunction, const gint idx); 98 void parseArrayComplex(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint *pOffset, const char *szFieldName, const char *szTypeName, fctComplexTypeParser pParserFunction, const gint idx); 99 void registerSimpleTypes(int proto); 100 guint32 getExtensionObjectType(tvbuff_t *tvb, gint *pOffset); 101 void parseNodeClassMask(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint *pOffset); 102 void parseResultMask(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint *pOffset); 103 104 void dispatchExtensionObjectType(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint *pOffset, int TypeId); 105 106