nexmon – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 /******************************************************************************
2 ** Copyright (C) 2006-2007 ascolab GmbH. All Rights Reserved.
3 ** Web: http://www.ascolab.com
4 **
5 ** This program is free software; you can redistribute it and/or
6 ** modify it under the terms of the GNU General Public License
7 ** as published by the Free Software Foundation; either version 2
8 ** of the License, or (at your option) any later version.
9 **
10 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
11 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
12 **
13 ** Project: OpcUa Wireshark Plugin
14 **
15 ** Description: OpcUa Application Layer Decoder.
16 **
17 ** Author: Gerhard Gappmeier <gerhard.gappmeier@ascolab.com>
18 ******************************************************************************/
19  
20 #include "config.h"
21  
22 #include <epan/packet.h>
23 #include "opcua_application_layer.h"
24  
25 /** NodeId encoding mask table */
26 static const value_string g_nodeidmasks[] = {
27 { 0x00, "Two byte encoded Numeric" },
28 { 0x01, "Four byte encoded Numeric" },
29 { 0x02, "Numeric of arbitrary length" },
30 { 0x03, "String" },
31 { 0x04, "GUID" },
32 { 0x05, "Opaque" },
33 { 0, NULL }
34 };
35  
36 /** Service type table */
37 extern const value_string g_requesttypes[];
38  
39 static int hf_opcua_nodeid_encodingmask = -1;
40 static int hf_opcua_app_nsid = -1;
41 static int hf_opcua_app_numeric = -1;
42  
43 /** Register application layer types. */
44 void registerApplicationLayerTypes(int proto)
45 {
46 /** header field definitions */
47 static hf_register_info hf[] =
48 {
49 /* id full name abbreviation type display strings bitmask blurb HFILL */
50 {&hf_opcua_nodeid_encodingmask, {"NodeId EncodingMask", "opcua.servicenodeid.encodingmask", FT_UINT8, BASE_HEX, VALS(g_nodeidmasks), 0x0, NULL, HFILL}},
51 {&hf_opcua_app_nsid, {"NodeId Namespace Index", "opcua.servicenodeid.nsid", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}},
52 {&hf_opcua_app_numeric, {"NodeId Identifier Numeric", "opcua.servicenodeid.numeric", FT_UINT32, BASE_DEC, VALS(g_requesttypes), 0x0, NULL, HFILL}}
53 };
54  
55 proto_register_field_array(proto, hf, array_length(hf));
56 }
57  
58 /** Parses an OpcUa Service NodeId and returns the service type.
59 * In this cases the NodeId is always from type numeric and NSId = 0.
60 */
61 int parseServiceNodeId(proto_tree *tree, tvbuff_t *tvb, gint *pOffset)
62 {
63 gint iOffset = *pOffset;
64 guint8 EncodingMask;
65 guint32 Numeric = 0;
66  
67 EncodingMask = tvb_get_guint8(tvb, iOffset);
68 proto_tree_add_item(tree, hf_opcua_nodeid_encodingmask, tvb, iOffset, 1, ENC_LITTLE_ENDIAN);
69 iOffset++;
70  
71 switch(EncodingMask)
72 {
73 case 0x00: /* two byte node id */
74 Numeric = tvb_get_guint8(tvb, iOffset);
75 proto_tree_add_item(tree, hf_opcua_app_numeric, tvb, iOffset, 1, ENC_LITTLE_ENDIAN);
76 iOffset+=1;
77 break;
78 case 0x01: /* four byte node id */
79 proto_tree_add_item(tree, hf_opcua_app_nsid, tvb, iOffset, 1, ENC_LITTLE_ENDIAN);
80 iOffset+=1;
81 Numeric = tvb_get_letohs(tvb, iOffset);
82 proto_tree_add_item(tree, hf_opcua_app_numeric, tvb, iOffset, 2, ENC_LITTLE_ENDIAN);
83 iOffset+=2;
84 break;
85 case 0x02: /* numeric, that does not fit into four bytes */
86 proto_tree_add_item(tree, hf_opcua_app_nsid, tvb, iOffset, 2, ENC_LITTLE_ENDIAN);
87 iOffset+=2;
88 Numeric = tvb_get_letohl(tvb, iOffset);
89 proto_tree_add_item(tree, hf_opcua_app_numeric, tvb, iOffset, 4, ENC_LITTLE_ENDIAN);
90 iOffset+=4;
91 break;
92 case 0x03: /* string */
93 case 0x04: /* guid */
94 case 0x05: /* opaque*/
95 /* NOT USED */
96 break;
97 };
98  
99 *pOffset = iOffset;
100  
101 return Numeric;
102 }
103  
104 /*
105 * Editor modelines - http://www.wireshark.org/tools/modelines.html
106 *
107 * Local variables:
108 * c-basic-offset: 4
109 * tab-width: 8
110 * indent-tabs-mode: nil
111 * End:
112 *
113 * vi: set shiftwidth=4 tabstop=8 expandtab:
114 * :indentSize=4:tabSize=8:noTabs=true:
115 */