X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=version2%2Fsrc%2FC%2FCloudComm.h;h=728025c50cc98985b7eb3894bc0b90c8860680fd;hb=04bc90cf1dfcac3b6443d9a5b1866c6dabea77d3;hp=bb319c2d4cb8731be28590d7c955b69dff8f2816;hpb=2345e7ea95433815c8cae09c3b719820e0ba44cd;p=iotcloud.git diff --git a/version2/src/C/CloudComm.h b/version2/src/C/CloudComm.h index bb319c2..728025c 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,29 @@ #define CloudComm_IV_SIZE 16 /** Sets the size for the HMAC. */ #define CloudComm_HMAC_SIZE 32 +#define HttpURLConnection_HTTP_OK 200 + class CloudComm { private: IoTString *baseurl; - SecretKeySpec *key; + AESKey *key; Mac *mac; IoTString *password; SecureRandom *random; Array *salt; Table *table; - int32_t listeningPort = -1; - Thread *localServerThread = NULL; - bool doEnd = false; - TimingSingleton *timer = NULL; + int32_t listeningPort; + 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 +48,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(int fd); + public: /** @@ -89,6 +93,7 @@ public: */ Array *sendLocalData(Array *sendData, int64_t localSequenceNumber, IoTString *host, int port); - public void close(); + void closeCloud(); + void localServerWorkerFunction(); }; #endif