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 #ifndef GetProperty_H 27 #define GetProperty_H 28 29 #include "Message.h" 30 31 // 32 // Set the verbosity level. 33 // 34 35 #define PANIC 36 #define WARNING 37 #undef TEST 38 #undef DEBUG 39 #undef DUMP 40 41 // 42 // Set default values. 43 // 44 45 #define GETPROPERTY_ENABLE_CACHE 1 46 #define GETPROPERTY_ENABLE_DATA 0 47 #define GETPROPERTY_ENABLE_SPLIT 0 48 #define GETPROPERTY_ENABLE_COMPRESS 0 49 50 #define GETPROPERTY_DATA_LIMIT 0 51 #define GETPROPERTY_DATA_OFFSET 24 52 53 #define GETPROPERTY_CACHE_SLOTS 2000 54 #define GETPROPERTY_CACHE_THRESHOLD 2 55 #define GETPROPERTY_CACHE_LOWER_THRESHOLD 1 56 57 // 58 // The message class. 59 // 60 61 class GetPropertyMessage : public Message 62 { 63 friend class GetPropertyStore; 64 65 public: 66 GetPropertyMessage()67 GetPropertyMessage() 68 { 69 } 70 ~GetPropertyMessage()71 ~GetPropertyMessage() 72 { 73 } 74 75 // 76 // Put here the fields which constitute 77 // the 'identity' part of the message. 78 // 79 80 private: 81 82 unsigned char property_delete; 83 unsigned long window; 84 unsigned long property; 85 unsigned long type; 86 unsigned long long_offset; 87 unsigned long long_length; 88 }; 89 90 class GetPropertyStore : public MessageStore 91 { 92 93 // 94 // Constructors and destructors. 95 // 96 97 public: 98 GetPropertyStore()99 GetPropertyStore() : MessageStore() 100 { 101 enableCache = GETPROPERTY_ENABLE_CACHE; 102 enableData = GETPROPERTY_ENABLE_DATA; 103 enableSplit = GETPROPERTY_ENABLE_SPLIT; 104 enableCompress = GETPROPERTY_ENABLE_COMPRESS; 105 106 dataLimit = GETPROPERTY_DATA_LIMIT; 107 dataOffset = GETPROPERTY_DATA_OFFSET; 108 109 cacheSlots = GETPROPERTY_CACHE_SLOTS; 110 cacheThreshold = GETPROPERTY_CACHE_THRESHOLD; 111 cacheLowerThreshold = GETPROPERTY_CACHE_LOWER_THRESHOLD; 112 113 messages_ -> resize(cacheSlots); 114 115 for (T_messages::iterator i = messages_ -> begin(); 116 i < messages_ -> end(); i++) 117 { 118 *i = NULL; 119 } 120 121 temporary_ = NULL; 122 } 123 ~GetPropertyStore()124 virtual ~GetPropertyStore() 125 { 126 for (T_messages::iterator i = messages_ -> begin(); 127 i < messages_ -> end(); i++) 128 { 129 destroy(*i); 130 } 131 132 destroy(temporary_); 133 } 134 name()135 virtual const char *name() const 136 { 137 return "GetProperty"; 138 } 139 opcode()140 virtual unsigned char opcode() const 141 { 142 return X_GetProperty; 143 } 144 storage()145 virtual unsigned int storage() const 146 { 147 return sizeof(GetPropertyMessage); 148 } 149 150 // 151 // Message handling methods. 152 // 153 154 protected: 155 create()156 virtual Message *create() const 157 { 158 return new GetPropertyMessage(); 159 } 160 create(const Message & message)161 virtual Message *create(const Message &message) const 162 { 163 return new GetPropertyMessage((const GetPropertyMessage &) message); 164 } 165 destroy(Message * message)166 virtual void destroy(Message *message) const 167 { 168 delete (GetPropertyMessage *) message; 169 } 170 171 virtual int parseIdentity(Message *message, const unsigned char *buffer, 172 unsigned int size, int bigEndian) const; 173 174 virtual int unparseIdentity(const Message *message, unsigned char *buffer, 175 unsigned int size, int bigEndian) const; 176 177 virtual void identityChecksum(const Message *message, const unsigned char *buffer, 178 unsigned int size, int bigEndian) const; 179 180 virtual void dumpIdentity(const Message *message) const; 181 }; 182 183 #endif /* GetProperty_H */ 184