Initial documentation creation!

This commit is contained in:
Noah Laptop 2019-03-31 15:52:50 -07:00
parent cf27036078
commit 8656bf9eb0
198 changed files with 14492 additions and 70 deletions

View file

@ -1,45 +0,0 @@
/*
Client.h - Base class that provides Client
Copyright (c) 2011 Adrian McEwen. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef client_h
#define client_h
#include "Print.h"
#include "Stream.h"
#include "IPAddress.h"
class Client : public Stream {
public:
virtual int connect(IPAddress ip, uint16_t port) =0;
virtual int connect(const char *host, uint16_t port) =0;
virtual size_t write(uint8_t) =0;
virtual size_t write(const uint8_t *buf, size_t size) =0;
virtual int available() = 0;
virtual int read() = 0;
virtual int read(uint8_t *buf, size_t size) = 0;
virtual int peek() = 0;
virtual void flush() = 0;
virtual void stop() = 0;
virtual uint8_t connected() = 0;
virtual operator bool() = 0;
protected:
uint8_t* rawIPAddress(IPAddress& addr) { return addr.raw_address(); };
};
#endif

View file

@ -66,7 +66,7 @@ public:
* of the SSL server certificate. Check out TrustAnchors.md for more info.
* @param trust_anchors_num The number of objects in the trust_anchors array.
* @param analog_pin An analog pin to pull random bytes from, used in seeding the RNG.
* @param debug whether to enable or disable debug logging.
* @param debug The level of debug logging (use the ::DebugLevel enum).
*/
explicit SSLClient(const C& client, const br_x509_trust_anchor *trust_anchors, const size_t trust_anchors_num, const int analog_pin, const DebugLevel debug = SSL_WARN)
: SSLClientImpl(trust_anchors, trust_anchors_num, analog_pin, debug)
@ -290,7 +290,7 @@ public:
* The implementation for this function can be found at SSLClientImpl::get_session_impl.
*
* @param host A hostname c string, or NULL if one is not available
* @param ip An IP address
* @param addr An IP address
* @returns A reference to an SSLSession object
*/
virtual SSLSession& getSession(const char* host, const IPAddress& addr) { return get_session_impl(host, addr); }
@ -301,7 +301,7 @@ public:
* The implementation for this function can be found at SSLClientImpl::remove_session_impl.
*
* @param host A hostname c string, or NULL if one is not available
* @param ip An IP address
* @param addr An IP address
*/
virtual void removeSession(const char* host, const IPAddress& addr) { return remove_session_impl(host, addr); }
@ -316,15 +316,15 @@ public:
* @returns true if connected, false if not
*/
virtual operator bool() { return connected() > 0; }
/** {@link SSLClient::bool()} */
/** @see SSLClient::operator bool */
virtual bool operator==(const bool value) { return bool() == value; }
/** {@link SSLClient::bool()} */
/** @see SSLClient::operator bool */
virtual bool operator!=(const bool value) { return bool() != value; }
/** @brief Returns whether or not two SSLClient objects have the same underlying client object */
virtual bool operator==(const C& rhs) { return m_client == rhs; }
/** @brief Returns whether or not two SSLClient objects do not have the same underlying client object */
virtual bool operator!=(const C& rhs) { return m_client != rhs; }
/** @brief Returns the local port, if the Client class has a localPort() function. Else return 0. */
/** @brief Returns the local port, C::localPort exists. Else return 0. */
virtual uint16_t localPort() {
if (std::is_member_function_pointer<decltype(&C::localPort)>::value) return m_client.localPort();
else {
@ -332,7 +332,7 @@ public:
return 0;
}
}
/** @brief Returns the remote IP, if the Client class has a remoteIP() function. Else return INADDR_NONE. */
/** @brief Returns the remote IP, if C::remoteIP exists. Else return INADDR_NONE. */
virtual IPAddress remoteIP() {
if (std::is_member_function_pointer<decltype(&C::remoteIP)>::value) return m_client.remoteIP();
else {
@ -340,7 +340,7 @@ public:
return INADDR_NONE;
}
}
/** @brief Returns the remote port, if the Client class has a remotePort() function. Else return 0. */
/** @brief Returns the remote port, if C::remotePort exists. Else return 0. */
virtual uint16_t remotePort() {
if (std::is_member_function_pointer<decltype(&C::remotePort)>::value) return m_client.remotePort();
else {

View file

@ -49,7 +49,7 @@ static int freeMemory() {
#endif // __arm__
}
/** see SSLClientImpl.h */
/* see SSLClientImpl.h */
SSLClientImpl::SSLClientImpl(const br_x509_trust_anchor *trust_anchors,
const size_t trust_anchors_num, const int analog_pin, const DebugLevel debug)
: m_trust_anchors(trust_anchors)
@ -126,7 +126,7 @@ int SSLClientImpl::connect_impl(const char *host, uint16_t port) {
return m_start_ssl(host, ses);
}
/** see SSLClientImpl.h*/
/* see SSLClientImpl.h*/
size_t SSLClientImpl::write_impl(const uint8_t *buf, size_t size) {
const char* func_name = __func__;
// check if the socket is still open and such
@ -169,7 +169,7 @@ size_t SSLClientImpl::write_impl(const uint8_t *buf, size_t size) {
return size;
}
/** see SSLClientImpl.h*/
/* see SSLClientImpl.h*/
int SSLClientImpl::available_impl() {
const char* func_name = __func__;
// connection check
@ -190,7 +190,7 @@ int SSLClientImpl::available_impl() {
return 0;
}
/** see SSLClientImpl.h */
/* see SSLClientImpl.h */
int SSLClientImpl::read_impl(uint8_t *buf, size_t size) {
// check that the engine is ready to read
if (available_impl() <= 0) return -1;
@ -205,7 +205,7 @@ int SSLClientImpl::read_impl(uint8_t *buf, size_t size) {
return read_amount;
}
/** see SSLClientImpl.h */
/* see SSLClientImpl.h */
int SSLClientImpl::peek_impl() {
// check that the engine is ready to read
if (available_impl() <= 0) return -1;
@ -217,7 +217,7 @@ int SSLClientImpl::peek_impl() {
return (int)read_num;
}
/** see SSLClientImpl.h */
/* see SSLClientImpl.h */
void SSLClientImpl::flush_impl() {
// trigger a flush, incase there's any leftover data
br_ssl_engine_flush(&m_sslctx.eng, 0);
@ -225,7 +225,7 @@ void SSLClientImpl::flush_impl() {
if(m_run_until(BR_SSL_RECVAPP) < 0) m_error("Could not flush write buffer!", __func__);
}
/** see SSLClientImpl.h */
/* see SSLClientImpl.h */
void SSLClientImpl::stop_impl() {
// tell the SSL connection to gracefully close
br_ssl_engine_close(&m_sslctx.eng);
@ -246,7 +246,7 @@ void SSLClientImpl::stop_impl() {
get_arduino_client().stop();
}
/** see SSLClientImpl.h */
/* see SSLClientImpl.h */
uint8_t SSLClientImpl::connected_impl() {
const char* func_name = __func__;
// check all of the error cases
@ -272,7 +272,7 @@ uint8_t SSLClientImpl::connected_impl() {
return c_con && br_con && wr_ok;
}
/** see SSLClientImpl.h */
/* see SSLClientImpl.h */
SSLSession& SSLClientImpl::get_session_impl(const char* host, const IPAddress& addr) {
const char* func_name = __func__;
// search for a matching session with the IP
@ -291,7 +291,7 @@ SSLSession& SSLClientImpl::get_session_impl(const char* host, const IPAddress& a
return get_session_array()[temp_index];
}
/** see SSLClientImpl.h */
/* see SSLClientImpl.h */
void SSLClientImpl::remove_session_impl(const char* host, const IPAddress& addr) {
const char* func_name = __func__;
int temp_index = m_get_session_index(host, addr);
@ -319,7 +319,7 @@ bool SSLClientImpl::m_soft_connected(const char* func_name) {
return true;
}
/** see SSLClientImpl.h */
/* see SSLClientImpl.h */
int SSLClientImpl::m_start_ssl(const char* host, SSLSession& ssl_ses) {
const char* func_name = __func__;
// clear the write error
@ -366,7 +366,7 @@ int SSLClientImpl::m_start_ssl(const char* host, SSLSession& ssl_ses) {
return 1;
}
/** see SSLClientImpl.h*/
/* see SSLClientImpl.h*/
int SSLClientImpl::m_run_until(const unsigned target) {
const char* func_name = __func__;
unsigned lastState = 0;
@ -452,7 +452,7 @@ int SSLClientImpl::m_run_until(const unsigned target) {
}
}
/** see SSLClientImpl.h*/
/* see SSLClientImpl.h*/
unsigned SSLClientImpl::m_update_engine() {
const char* func_name = __func__;
for(;;) {
@ -605,7 +605,7 @@ unsigned SSLClientImpl::m_update_engine() {
}
}
/** see SSLClientImpl.h */
/* see SSLClientImpl.h */
int SSLClientImpl::m_get_session_index(const char* host, const IPAddress& addr) const {
const char* func_name = __func__;
// search for a matching session with the IP
@ -627,7 +627,7 @@ int SSLClientImpl::m_get_session_index(const char* host, const IPAddress& addr)
return -1;
}
/** See SSLClientImpl.h */
/* See SSLClientImpl.h */
void SSLClientImpl::m_print_prefix(const char* func_name, const DebugLevel level) const
{
// print the sslclient prefix
@ -645,7 +645,7 @@ void SSLClientImpl::m_print_prefix(const char* func_name, const DebugLevel level
Serial.print("): ");
}
/** See SSLClientImpl.h */
/* See SSLClientImpl.h */
void SSLClientImpl::m_print_ssl_error(const int ssl_error, const DebugLevel level) const {
if (level > m_debug) return;
m_print_prefix(__func__, level);