X-Git-Url: http://plrg.eecs.uci.edu/git/?p=iotcloud.git;a=blobdiff_plain;f=version2%2Fsrc%2FC%2FCloudComm.h;h=2f825083214a26608087b08b656d575c59004119;hp=cdec4950174c55e4fd22566bda37a22ae3337d1e;hb=ea13af1b791836a1b5e5c1d382dd2d02e180430d;hpb=f4653df8179e5eedd5c3919b380916d49ccb6225 diff --git a/version2/src/C/CloudComm.h b/version2/src/C/CloudComm.h index cdec495..2f82508 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,27 @@ #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; - Thread *localServerThread; + pthread_t localServerThread; bool doEnd; TimingSingleton *timer; /** * Generates Key from password. */ - SecretKeySpec *initKey(); + AESKey *initKey(); /** * Inits the HMAC generator. @@ -44,14 +46,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: /** @@ -90,5 +92,6 @@ public: Array *sendLocalData(Array *sendData, int64_t localSequenceNumber, IoTString *host, int port); void close(); + void localServerWorkerFunction(); }; #endif