diff --git a/src/HAP.cpp b/src/HAP.cpp index 76b3155..47ca60c 100644 --- a/src/HAP.cpp +++ b/src/HAP.cpp @@ -3,6 +3,7 @@ #include #include "HAP.h" +#include "HomeSpan.h" ////////////////////////////////////// @@ -192,7 +193,7 @@ void HAPClient::processRequest(){ if(!strncmp(body,"POST /pair-setup ",17) && // POST PAIR-SETUP strstr(body,"Content-Type: application/pairing+tlv8") && // check that content is TLV8 tlv8.unpack(content,cLen)){ // read TLV content - tlv8.print(); // print TLV records in form "TAG(INT) LENGTH(INT) VALUES(HEX)" + if(homeSpan.logLevel>1) tlv8.print(); // print TLV records in form "TAG(INT) LENGTH(INT) VALUES(HEX)" LOG2("------------ END TLVS! ------------\n"); postPairSetupURL(); // process URL @@ -202,7 +203,7 @@ void HAPClient::processRequest(){ if(!strncmp(body,"POST /pair-verify ",18) && // POST PAIR-VERIFY strstr(body,"Content-Type: application/pairing+tlv8") && // check that content is TLV8 tlv8.unpack(content,cLen)){ // read TLV content - tlv8.print(); // print TLV records in form "TAG(INT) LENGTH(INT) VALUES(HEX)" + if(homeSpan.logLevel>1) tlv8.print(); // print TLV records in form "TAG(INT) LENGTH(INT) VALUES(HEX)" LOG2("------------ END TLVS! ------------\n"); postPairVerifyURL(); // process URL @@ -212,7 +213,7 @@ void HAPClient::processRequest(){ if(!strncmp(body,"POST /pairings ",15) && // POST PAIRINGS strstr(body,"Content-Type: application/pairing+tlv8") && // check that content is TLV8 tlv8.unpack(content,cLen)){ // read TLV content - tlv8.print(); // print TLV records in form "TAG(INT) LENGTH(INT) VALUES(HEX)" + if(homeSpan.logLevel>1) tlv8.print(); // print TLV records in form "TAG(INT) LENGTH(INT) VALUES(HEX)" LOG2("------------ END TLVS! ------------\n"); postPairingsURL(); // process URL @@ -222,7 +223,7 @@ void HAPClient::processRequest(){ if(!strncmp(body,"POST /pairings ",15) && // POST PAIRINGS strstr(body,"Content-Type: application/pairing+tlv8") && // check that content is TLV8 tlv8.unpack(content,cLen)){ // read TLV content - tlv8.print(); // print TLV records in form "TAG(INT) LENGTH(INT) VALUES(HEX)" + if(homeSpan.logLevel>1) tlv8.print(); // print TLV records in form "TAG(INT) LENGTH(INT) VALUES(HEX)" LOG2("------------ END TLVS! ------------\n"); postPairingsURL(); // process URL @@ -496,7 +497,7 @@ int HAPClient::postPairSetupURL(){ return(0); } - tlv8.print(); // print decrypted TLV data + if(homeSpan.logLevel>1) tlv8.print(); // print decrypted TLV data LOG2("------- END DECRYPTED TLVS! -------\n"); if(!tlv8.buf(kTLVType_Identifier) || !tlv8.buf(kTLVType_PublicKey) || !tlv8.buf(kTLVType_Signature)){ @@ -576,7 +577,7 @@ int HAPClient::postPairSetupURL(){ LOG2("------- ENCRYPTING SUB-TLVS -------\n"); - tlv8.print(); + if(homeSpan.logLevel>1) tlv8.print(); size_t subTLVLen=tlv8.pack(NULL); // get size of buffer needed to store sub-TLV uint8_t subTLV[subTLVLen]; @@ -682,7 +683,7 @@ int HAPClient::postPairVerifyURL(){ LOG2("------- ENCRYPTING SUB-TLVS -------\n"); - tlv8.print(); + if(homeSpan.logLevel>1) tlv8.print(); size_t subTLVLen=tlv8.pack(NULL); // get size of buffer needed to store sub-TLV uint8_t subTLV[subTLVLen]; @@ -746,7 +747,7 @@ int HAPClient::postPairVerifyURL(){ return(0); } - tlv8.print(); // print decrypted TLV data + if(homeSpan.logLevel>1) tlv8.print(); // print decrypted TLV data LOG2("------- END DECRYPTED TLVS! -------\n"); if(!tlv8.buf(kTLVType_Identifier) || !tlv8.buf(kTLVType_Signature)){ @@ -1278,7 +1279,7 @@ void HAPClient::tlvRespond(){ LOG2(client.remoteIP()); LOG2(" >>>>>>>>>>\n"); LOG2(body); - tlv8.print(); + if(homeSpan.logLevel>1) tlv8.print(); if(!cPair){ // unverified, unencrypted session client.print(body); diff --git a/src/HAP.h b/src/HAP.h index c49b6d5..9689943 100644 --- a/src/HAP.h +++ b/src/HAP.h @@ -4,11 +4,11 @@ #include #include +#include "HomeSpan.h" #include "TLV.h" #include "HAPConstants.h" #include "HKDF.h" #include "SRP.h" -#include "HomeSpan.h" ///////////////////////////////////////////////// // NONCE Structure (HAP used last 64 of 96 bits) diff --git a/src/HomeSpan.cpp b/src/HomeSpan.cpp index 416b1db..6d23ab8 100644 --- a/src/HomeSpan.cpp +++ b/src/HomeSpan.cpp @@ -2,7 +2,9 @@ #include #include #include +#include +#include "HomeSpan.h" #include "HAP.h" using namespace Utils; diff --git a/src/Network.cpp b/src/Network.cpp index ae3f98a..b6bd566 100644 --- a/src/Network.cpp +++ b/src/Network.cpp @@ -1,7 +1,9 @@ #include +#include "Network.h" #include "HomeSpan.h" +#include "Utils.h" using namespace Utils; diff --git a/src/SRP.cpp b/src/SRP.cpp index f2f3394..be22d76 100644 --- a/src/SRP.cpp +++ b/src/SRP.cpp @@ -1,6 +1,8 @@ #include +#include +#include "SRP.h" #include "HAP.h" ///////////////////////////////////////////////////////////////////////////////// diff --git a/src/SRP.h b/src/SRP.h index dd78a62..91d0da1 100644 --- a/src/SRP.h +++ b/src/SRP.h @@ -4,6 +4,8 @@ #include #include +#include "HAPConstants.h" + ///////////////////////////////////////////////// // SRP-6A Structure from RFC 5054 (Nov 2007) // ** HAP uses N=3072-bit Group specified in RFC 5054 diff --git a/src/TLV.h b/src/TLV.h index f210e45..415d15a 100644 --- a/src/TLV.h +++ b/src/TLV.h @@ -1,8 +1,6 @@ #pragma once -#include "HomeSpan.h" - template class TLV { @@ -168,9 +166,6 @@ uint8_t *TLV::buf(tagType tag, int len){ template void TLV::print(){ - if(homeSpan.logLevel<2) - return; - char buf[3]; for(int i=0;i