Timing, Attacks
[iotcloud.git] / version2 / src / server_malicious_switch_slot / iotquery.h
diff --git a/version2/src/server_malicious_switch_slot/iotquery.h b/version2/src/server_malicious_switch_slot/iotquery.h
new file mode 100644 (file)
index 0000000..6ac5113
--- /dev/null
@@ -0,0 +1,68 @@
+#ifndef IOTQUERY_H
+#define IOTQUERY_H
+#include <iostream>
+#include "fcgio.h"
+#include "fcgi_stdio.h"
+
+#define DEFAULT_SIZE 128
+#define OFFSET_MAX 0
+#define OFFSET_OLD 4
+#define OFFSET_NEW 12
+
+class IoTQuery {
+public:
+       IoTQuery(FCGX_Request * request);
+       ~IoTQuery();
+       void processQuery();
+
+private:
+       void sendResponse(char *data, int length);
+       void getQuery();
+       void getDirectory();
+       bool readData();
+       bool checkDirectory();
+       bool openStatusFile();
+       void updateStatusFile();
+       void decodeQuery();
+       void getSlot();
+       void putSlot();
+       void setSalt();
+       void getSalt();
+       void removeOldestSlot();
+       char * getSlotFileName(long long);
+       char * getSaltFileName();
+
+       FCGX_Request * request;
+       char *data;
+       /* Directory slot files are placed in. */
+       char *directory;
+       /* Full URI from Apache */
+       const char * uri;
+       /* Query portion of URI */
+       const char * query;
+       /* Type of request: GET or PUT */
+       const char * method;
+       /* Root directory for all accounts */
+       const char * iotcloudroot;
+       /* Expected length of data from client */
+       long long length;
+       /* Sequence number for oldest slot */
+       long long oldestentry;
+       /* Sequence number for newest slot */
+       long long newestentry;
+       /* Sequence number from request */
+       long long requestsequencenumber;
+       /* Size of queue */
+       int numqueueentries;
+       /* fd for queuestatus file */
+       int fd;
+       /* Is the request to get a slot? */
+       bool reqGetSlot;
+       /* Is the request to put a slot? */
+       bool reqPutSlot;
+       /* Is the request to set the salt? */
+       bool reqSetSalt;
+       /* Is the request to get the salt? */
+       bool reqGetSalt;
+};
+#endif