1 /******************************************************************************
\r
2 ** $Id: ua_security_layer.c,v 1.2 2007/02/08 12:16:59 gergap Exp $
\r
4 ** Copyright (C) 2006-2007 ascolab GmbH. All Rights Reserved.
\r
5 ** Web: http://www.ascolab.com
\r
7 ** This program is free software; you can redistribute it and/or
\r
8 ** modify it under the terms of the GNU General Public License
\r
9 ** as published by the Free Software Foundation; either version 2
\r
10 ** of the License, or (at your option) any later version.
\r
12 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
\r
13 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
\r
15 ** Project: OpcUa Wireshark Plugin
\r
17 ** Description: OpcUa Security Layer Decoder.
\r
19 ** Author: Gerhard Gappmeier <gerhard.gappmeier@ascolab.com>
\r
20 ** Last change by: $Author: gergap $
\r
22 ******************************************************************************/
\r
24 #ifdef HAVE_CONFIG_H
\r
25 # include "config.h"
\r
28 #include <gmodule.h>
\r
29 #include <epan/packet.h>
\r
30 #include "ua_application_layer.h"
\r
31 #include "opcua_simpletypes.h"
\r
33 /** NodeClass enum table */
\r
34 static const value_string g_SecSigTable[] = {
35 { 0, "GetSecurityPolcies" },
36 { 1, "OpenSecureChannel" },
37 { 2, "CloseSecureChannel" },
41 static int hf_opcua_SecuritySigEnum = -1;
\r
43 static int hf_opcua_security_sig = -1;
\r
44 static int hf_opcua_security_policy = -1;
\r
45 static int hf_opcua_security_channel = -1;
\r
46 static int hf_opcua_security_token = -1;
\r
48 static hf_register_info hf[] =
\r
50 { &hf_opcua_security_sig,
\r
51 { "Security Signature", "security.sig", FT_UINT16, BASE_HEX, VALS(g_SecSigTable), 0x0, "", HFILL }
\r
53 { &hf_opcua_security_policy,
\r
54 { "Security Policy", "security.policy", FT_STRING, BASE_NONE, NULL, 0x0, "", HFILL }
\r
56 { &hf_opcua_security_channel,
\r
57 { "Secure Channel Id", "security.channel", FT_GUID, BASE_NONE, NULL, 0x0, "", HFILL }
\r
59 { &hf_opcua_security_token,
\r
60 { "Security Token Id", "security.token", FT_STRING, BASE_NONE, NULL, 0x0, "", HFILL }
\r
64 /** Register security layer types. */
\r
65 void registerSecurityLayerTypes(int proto)
\r
67 proto_register_field_array(proto, hf, array_length(hf));
\r
71 /* Security Layer: message parsers
\r
72 * Only works for Security Policy "NoSecurity" at the moment.
\r
74 void parseSecurityLayer(proto_tree *tree, tvbuff_t *tvb, gint *pOffset)
\r
78 Sig = tvb_get_letohs(tvb, pOffset[0]);
\r
79 proto_tree_add_item(tree, hf_opcua_security_sig, tvb, *pOffset, 2, TRUE); *pOffset+=2;
\r
83 case 0: /* GetSecurityPolicies */
\r
85 case 1: /* OpenSecureChannel */
\r
86 parseGuid(tree, tvb, pOffset, hf_opcua_security_channel);
\r
87 parseString(tree, tvb, pOffset, hf_opcua_security_policy);
\r
89 case 2: /* CloseSecureChannel */
\r
90 parseGuid(tree, tvb, pOffset, hf_opcua_security_channel);
\r
91 parseString(tree, tvb, pOffset, hf_opcua_security_token);
\r
93 case 3: /* Other Services Messages */
\r
94 parseGuid(tree, tvb, pOffset, hf_opcua_security_channel);
\r
95 parseString(tree, tvb, pOffset, hf_opcua_security_token);
\r