1 /**************************************************************************/
2 /* */
3 /* Copyright (c) 2001, 2010 NoMachine, http://www.nomachine.com/. */
4 /* */
5 /* NXCOMP, NX protocol compression and NX extensions to this software */
6 /* are copyright of NoMachine. Redistribution and use of the present */
7 /* software is allowed according to terms specified in the file LICENSE */
8 /* which comes in the source distribution. */
9 /* */
10 /* Check http://www.nomachine.com/licensing.html for applicability. */
11 /* */
12 /* NX and NoMachine are trademarks of Medialogic S.p.A. */
13 /* */
14 /* All rights reserved. */
15 /* */
16 /**************************************************************************/
17
18 #include "GetProperty.h"
19
20 #include "ClientCache.h"
21
22 #include "EncodeBuffer.h"
23 #include "DecodeBuffer.h"
24
25 //
26 // Set the verbosity level.
27 //
28
29 #define PANIC
30 #define WARNING
31 #undef TEST
32 #undef DEBUG
33 #undef DUMP
34
35 //
36 // Here are the methods to handle messages' content.
37 //
38
parseIdentity(Message * message,const unsigned char * buffer,unsigned int size,int bigEndian) const39 int GetPropertyStore::parseIdentity(Message *message, const unsigned char *buffer,
40 unsigned int size, int bigEndian) const
41 {
42 GetPropertyMessage *getProperty = (GetPropertyMessage *) message;
43
44 //
45 // Here is the fingerprint.
46 //
47
48 getProperty -> property_delete = *(buffer + 1);
49
50 getProperty -> window = GetULONG(buffer + 4, bigEndian);
51 getProperty -> property = GetULONG(buffer + 8, bigEndian);
52 getProperty -> type = GetULONG(buffer + 12, bigEndian);
53 getProperty -> long_offset = GetULONG(buffer + 16, bigEndian);
54 getProperty -> long_length = GetULONG(buffer + 20, bigEndian);
55
56 #ifdef DEBUG
57 *logofs << name() << ": Parsed identity for message at " << message << ".\n" << logofs_flush;
58 #endif
59
60 return 1;
61 }
62
unparseIdentity(const Message * message,unsigned char * buffer,unsigned int size,int bigEndian) const63 int GetPropertyStore::unparseIdentity(const Message *message, unsigned char *buffer,
64 unsigned int size, int bigEndian) const
65 {
66
67 GetPropertyMessage *getProperty = (GetPropertyMessage *) message;
68
69 //
70 // Fill all the message's fields.
71 //
72
73 *(buffer + 1) = getProperty -> property_delete;
74
75 PutULONG(getProperty -> window, buffer + 4, bigEndian);
76 PutULONG(getProperty -> property, buffer + 8, bigEndian);
77 PutULONG(getProperty -> type, buffer + 12, bigEndian);
78 PutULONG(getProperty -> long_offset, buffer + 16, bigEndian);
79 PutULONG(getProperty -> long_length, buffer + 20, bigEndian);
80
81 #ifdef DEBUG
82 *logofs << name() << ": Unparsed identity for message at " << message << ".\n" << logofs_flush;
83 #endif
84
85 return 1;
86 }
87
dumpIdentity(const Message * message) const88 void GetPropertyStore::dumpIdentity(const Message *message) const
89 {
90 #ifdef DUMP
91
92 GetPropertyMessage *getProperty = (GetPropertyMessage *) message;
93
94 *logofs << name() << ": Identity property_delete " << (unsigned int) getProperty -> property_delete
95 << ", window " << getProperty -> window << ", property " << getProperty -> property
96 << ", type " << getProperty -> type << ", long-offset " << getProperty -> long_offset
97 << ", long-length " << getProperty -> long_length << ".\n" << logofs_flush;
98
99 #endif
100 }
101
identityChecksum(const Message * message,const unsigned char * buffer,unsigned int size,int bigEndian) const102 void GetPropertyStore::identityChecksum(const Message *message, const unsigned char *buffer,
103 unsigned int size, int bigEndian) const
104 {
105 md5_append(md5_state_, buffer + 1, 1);
106 md5_append(md5_state_, buffer + 4, 20);
107 }
108