X-Git-Url: http://plrg.eecs.uci.edu/git/?p=iotcloud.git;a=blobdiff_plain;f=version2%2Fsrc%2FC%2FCloudComm.h;h=ce7cfa07023a3832252f2633cd1973b4b35e1541;hp=3e0a56e85a9b65ae026b7047c432d29332f0c69a;hb=b2bc9b5c707bd7d932d60cd4e8c1cb580b36b5b4;hpb=1ae973a3cc837cb62ef220dedbb731ab3f833719 diff --git a/version2/src/C/CloudComm.h b/version2/src/C/CloudComm.h index 3e0a56e..ce7cfa0 100644 --- a/version2/src/C/CloudComm.h +++ b/version2/src/C/CloudComm.h @@ -2,7 +2,7 @@ #define CLOUDCOMM_H #include "common.h" - +#include /** * This class provides a communication API to the webserver. It also * validates the HMACs on the slots and handles encryption. @@ -16,25 +16,34 @@ #define CloudComm_IV_SIZE 16 /** Sets the size for the HMAC. */ #define CloudComm_HMAC_SIZE 32 +#define HttpURLConnection_HTTP_OK 200 + +typedef struct { + int fd; + int numBytes; +} WebConnection; + class CloudComm { private: IoTString *baseurl; - SecretKeySpec *key; + AESKey *key; Mac *mac; IoTString *password; SecureRandom *random; Array *salt; Table *table; int32_t listeningPort; - Thread *localServerThread; + pthread_t localServerThread; bool doEnd; TimingSingleton *timer; + Array *getslot; + Array *putslot; /** * Generates Key from password. */ - SecretKeySpec *initKey(); + AESKey *initKey(); /** * Inits the HMAC generator. @@ -44,14 +53,14 @@ private: /* * Builds the URL for the given request. */ - URL buildRequest(bool isput, int64_t sequencenumber, int64_t maxentries); + IoTString *buildRequest(bool isput, int64_t sequencenumber, int64_t maxentries); void setSalt(); bool getSalt(); Array *createIV(int64_t machineId, int64_t localSequenceNumber); Array *encryptSlotAndPrependIV(Array *rawData, Array *ivBytes); Array *stripIVAndDecryptSlot(Array *rawData); - Array *processSlots(DataInputStream dis); - void localServerWorkerFunction(); + Array *processSlots(WebConnection *wc); + public: /** @@ -63,6 +72,7 @@ public: * Constructor for actual use. Takes in the url and password. */ CloudComm(Table *_table, IoTString *_baseurl, IoTString *_password, int _listeningPort); + ~CloudComm(); /** * Inits all the security stuff @@ -89,6 +99,7 @@ public: */ Array *sendLocalData(Array *sendData, int64_t localSequenceNumber, IoTString *host, int port); - void close(); + void closeCloud(); + void localServerWorkerFunction(); }; #endif