We always HAVE_CONFIG_H so don't bother checking whether we have it or not.
[metze/wireshark/wip.git] / plugins / opcua / opcua_security_layer.c
1 /******************************************************************************
2 ** $Id$
3 **
4 ** Copyright (C) 2006-2007 ascolab GmbH. All Rights Reserved.
5 ** Web: http://www.ascolab.com
6 ** 
7 ** This program is free software; you can redistribute it and/or
8 ** modify it under the terms of the GNU General Public License
9 ** as published by the Free Software Foundation; either version 2
10 ** of the License, or (at your option) any later version.
11 ** 
12 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
13 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
14 ** 
15 ** Project: OpcUa Wireshark Plugin
16 **
17 ** Description: OpcUa Security Layer Decoder.
18 **
19 ** Author: Gerhard Gappmeier <gerhard.gappmeier@ascolab.com>
20 ** Last change by: $Author: gergap $
21 **
22 ******************************************************************************/
23
24 #include "config.h"
25
26 #include <glib.h>
27 #include <epan/packet.h>
28 #include "opcua_application_layer.h"
29 #include "opcua_simpletypes.h"
30
31 /** NodeClass enum table */
32 static const value_string g_SecSigTable[] = {
33   { 0, "GetSecurityPolcies" },
34   { 1, "OpenSecureChannel" },
35   { 2, "CloseSecureChannel" },
36   { 3, "Message" },
37   { 0, NULL }
38 };
39
40 static int hf_opcua_security_tokenid = -1;
41 static int hf_opcua_security_seq = -1;
42 static int hf_opcua_security_rqid = -1;
43
44 /** Register security layer types. */
45 void registerSecurityLayerTypes(int proto)
46 {
47     static hf_register_info hf[] =
48     {
49         { &hf_opcua_security_tokenid,
50         {  "Security Token Id",        "security.tokenid",   FT_UINT32, BASE_DEC,  NULL, 0x0,    NULL,    HFILL }
51         },
52         { &hf_opcua_security_seq,
53         {  "Security Sequence Number", "security.seq",       FT_UINT32, BASE_DEC,  NULL, 0x0,    NULL,    HFILL }
54         },
55         { &hf_opcua_security_rqid,
56         {  "Security RequestId",       "security.rqid",      FT_UINT32, BASE_DEC,  NULL, 0x0,    NULL,    HFILL }
57         }
58     };
59     proto_register_field_array(proto, hf, array_length(hf));
60 }
61
62 /* Security Layer: message parsers
63  * Only works for Security Policy "NoSecurity" at the moment.
64  */
65 void parseSecurityLayer(proto_tree *tree, tvbuff_t *tvb, gint *pOffset)
66 {
67     proto_tree_add_item(tree, hf_opcua_security_tokenid, tvb, *pOffset, 4, ENC_LITTLE_ENDIAN); *pOffset+=4;
68     proto_tree_add_item(tree, hf_opcua_security_seq, tvb, *pOffset, 4, ENC_LITTLE_ENDIAN); *pOffset+=4;
69     proto_tree_add_item(tree, hf_opcua_security_rqid, tvb, *pOffset, 4, ENC_LITTLE_ENDIAN); *pOffset+=4;
70 }
71
72