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 GetPropertyReply_H
27 #define GetPropertyReply_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 GETPROPERTYREPLY_ENABLE_CACHE                       1
46 #define GETPROPERTYREPLY_ENABLE_DATA                        1
47 #define GETPROPERTYREPLY_ENABLE_SPLIT                       0
48 
49 #define GETPROPERTYREPLY_DATA_LIMIT                         1048576 - 32
50 #define GETPROPERTYREPLY_DATA_OFFSET                        32
51 
52 #define GETPROPERTYREPLY_CACHE_SLOTS                        400
53 #define GETPROPERTYREPLY_CACHE_THRESHOLD                    5
54 #define GETPROPERTYREPLY_CACHE_LOWER_THRESHOLD              1
55 
56 #define GETPROPERTYREPLY_ENABLE_COMPRESS_IF_PROTO_STEP_7    0
57 
58 //
59 // The message class.
60 //
61 
62 class GetPropertyReplyMessage : public Message
63 {
64   friend class GetPropertyReplyStore;
65 
66   public:
67 
GetPropertyReplyMessage()68   GetPropertyReplyMessage()
69   {
70   }
71 
~GetPropertyReplyMessage()72   ~GetPropertyReplyMessage()
73   {
74   }
75 
76   //
77   // Put here the fields which constitute
78   // the 'identity' part of the message.
79   //
80 
81   private:
82 
83   unsigned char format;
84   unsigned int  type;
85   unsigned int  after;
86   unsigned int  items;
87 };
88 
89 class GetPropertyReplyStore : public MessageStore
90 {
91   public:
92 
93   GetPropertyReplyStore(StaticCompressor *compressor);
94 
95   virtual ~GetPropertyReplyStore();
96 
name()97   virtual const char *name() const
98   {
99     return "GetPropertyReply";
100   }
101 
opcode()102   virtual unsigned char opcode() const
103   {
104     return X_GetProperty;
105   }
106 
storage()107   virtual unsigned int storage() const
108   {
109     return sizeof(GetPropertyReplyMessage);
110   }
111 
112   //
113   // Message handling methods.
114   //
115 
116   protected:
117 
create()118   virtual Message *create() const
119   {
120     return new GetPropertyReplyMessage();
121   }
122 
create(const Message & message)123   virtual Message *create(const Message &message) const
124   {
125     return new GetPropertyReplyMessage((const GetPropertyReplyMessage &) message);
126   }
127 
destroy(Message * message)128   virtual void destroy(Message *message) const
129   {
130     delete (GetPropertyReplyMessage *) message;
131   }
132 
133   virtual int encodeIdentity(EncodeBuffer &encodeBuffer, const unsigned char *buffer,
134                                  const unsigned int size, int bigEndian,
135                                      ChannelCache *channelCache) const;
136 
137   virtual int decodeIdentity(DecodeBuffer &decodeBuffer, unsigned char *&buffer,
138                                  unsigned int &size, int bigEndian, WriteBuffer *writeBuffer,
139                                      ChannelCache *channelCache) const;
140 
141   virtual int parseIdentity(Message *message, const unsigned char *buffer,
142                                 unsigned int size, int bigEndian) const;
143 
144   virtual int unparseIdentity(const Message *message, unsigned char *buffer,
145                                   unsigned int size, int bigEndian) const;
146 
147   virtual void updateIdentity(EncodeBuffer &encodeBuffer, const Message *message,
148                                   const Message *cachedMessage,
149                                       ChannelCache *channelCache) const;
150 
151   virtual void updateIdentity(DecodeBuffer &decodeBuffer, const Message *message,
152                                   ChannelCache *channelCache) const;
153 
154   virtual void identityChecksum(const Message *message, const unsigned char *buffer,
155                                     unsigned int size, int bigEndian) const;
156 
157   virtual void dumpIdentity(const Message *message) const;
158 };
159 
160 #endif /* GetPropertyReply_H */
161