1 /**************************************************************************/
2 /* */
3 /* Copyright (c) 2001, 2011 NoMachine (http://www.nomachine.com) */
4 /* Copyright (c) 2008-2014 Oleksandr Shneyder <o.shneyder@phoca-gmbh.de> */
5 /* Copyright (c) 2014-2016 Ulrich Sibiller <uli42@gmx.de> */
6 /* Copyright (c) 2014-2016 Mihai Moldovan <ionic@ionic.de> */
7 /* Copyright (c) 2011-2016 Mike Gabriel <mike.gabriel@das-netzwerkteam.de>*/
8 /* Copyright (c) 2015-2016 Qindel Group (http://www.qindel.com) */
9 /* */
10 /* NXCOMP, NX protocol compression and NX extensions to this software */
11 /* are copyright of the aforementioned persons and companies. */
12 /* */
13 /* Redistribution and use of the present software is allowed according */
14 /* to terms specified in the file LICENSE.nxcomp which comes in the */
15 /* source distribution. */
16 /* */
17 /* All rights reserved. */
18 /* */
19 /* NOTE: This software has received contributions from various other */
20 /* contributors, only the core maintainers and supporters are listed as */
21 /* copyright holders. Please contact us, if you feel you should be listed */
22 /* as copyright holder, as well. */
23 /* */
24 /**************************************************************************/
25
26 #ifdef HAVE_CONFIG_H
27 #include "config.h"
28 #endif
29
30 #include "GetProperty.h"
31
32 #include "ClientCache.h"
33
34 #include "EncodeBuffer.h"
35 #include "DecodeBuffer.h"
36
37 //
38 // Set the verbosity level.
39 //
40
41 #define PANIC
42 #define WARNING
43 #undef TEST
44 #undef DEBUG
45 #undef DUMP
46
47 //
48 // Here are the methods to handle messages' content.
49 //
50
parseIdentity(Message * message,const unsigned char * buffer,unsigned int size,int bigEndian) const51 int GetPropertyStore::parseIdentity(Message *message, const unsigned char *buffer,
52 unsigned int size, int bigEndian) const
53 {
54 GetPropertyMessage *getProperty = (GetPropertyMessage *) message;
55
56 //
57 // Here is the fingerprint.
58 //
59
60 getProperty -> property_delete = *(buffer + 1);
61
62 getProperty -> window = GetULONG(buffer + 4, bigEndian);
63 getProperty -> property = GetULONG(buffer + 8, bigEndian);
64 getProperty -> type = GetULONG(buffer + 12, bigEndian);
65 getProperty -> long_offset = GetULONG(buffer + 16, bigEndian);
66 getProperty -> long_length = GetULONG(buffer + 20, bigEndian);
67
68 #ifdef DEBUG
69 *logofs << name() << ": Parsed identity for message at " << message << ".\n" << logofs_flush;
70 #endif
71
72 return 1;
73 }
74
unparseIdentity(const Message * message,unsigned char * buffer,unsigned int size,int bigEndian) const75 int GetPropertyStore::unparseIdentity(const Message *message, unsigned char *buffer,
76 unsigned int size, int bigEndian) const
77 {
78
79 GetPropertyMessage *getProperty = (GetPropertyMessage *) message;
80
81 //
82 // Fill all the message's fields.
83 //
84
85 *(buffer + 1) = getProperty -> property_delete;
86
87 PutULONG(getProperty -> window, buffer + 4, bigEndian);
88 PutULONG(getProperty -> property, buffer + 8, bigEndian);
89 PutULONG(getProperty -> type, buffer + 12, bigEndian);
90 PutULONG(getProperty -> long_offset, buffer + 16, bigEndian);
91 PutULONG(getProperty -> long_length, buffer + 20, bigEndian);
92
93 #ifdef DEBUG
94 *logofs << name() << ": Unparsed identity for message at " << message << ".\n" << logofs_flush;
95 #endif
96
97 return 1;
98 }
99
dumpIdentity(const Message * message) const100 void GetPropertyStore::dumpIdentity(const Message *message) const
101 {
102 #ifdef DUMP
103
104 GetPropertyMessage *getProperty = (GetPropertyMessage *) message;
105
106 *logofs << name() << ": Identity property_delete " << (unsigned int) getProperty -> property_delete
107 << ", window " << getProperty -> window << ", property " << getProperty -> property
108 << ", type " << getProperty -> type << ", long-offset " << getProperty -> long_offset
109 << ", long-length " << getProperty -> long_length << ".\n" << logofs_flush;
110
111 #endif
112 }
113
identityChecksum(const Message * message,const unsigned char * buffer,unsigned int size,int bigEndian) const114 void GetPropertyStore::identityChecksum(const Message *message, const unsigned char *buffer,
115 unsigned int size, int bigEndian) const
116 {
117 md5_append(md5_state_, buffer + 1, 1);
118 md5_append(md5_state_, buffer + 4, 20);
119 }
120