Skip to content

Commit

Permalink
fix set/getSocketOption inheritance (#7480)
Browse files Browse the repository at this point in the history
  • Loading branch information
bertmelis committed Dec 8, 2022
1 parent 05e55d8 commit 394f721
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 13 deletions.
2 changes: 1 addition & 1 deletion libraries/WiFi/src/WiFiClient.h
Expand Up @@ -84,7 +84,7 @@ class WiFiClient : public ESPLwIPClient
return !this->operator==(rhs);
};

int fd() const;
virtual int fd() const;

int setSocketOption(int option, char* value, size_t len);
int setSocketOption(int level, int option, const void* value, size_t len);
Expand Down
13 changes: 3 additions & 10 deletions libraries/WiFiClientSecure/src/WiFiClientSecure.cpp
Expand Up @@ -376,16 +376,9 @@ int WiFiClientSecure::setTimeout(uint32_t seconds)
return 0;
}
}
int WiFiClientSecure::setSocketOption(int option, char* value, size_t len)
{
return setSocketOption(SOL_SOCKET, option, (const void*)value, len);
}

int WiFiClientSecure::setSocketOption(int level, int option, const void* value, size_t len)
int WiFiClientSecure::fd() const
{
int res = setsockopt(sslclient->socket, level, option, value, len);
if(res < 0) {
log_e("fail on %d, errno: %d, \"%s\"", sslclient->socket, errno, strerror(errno));
}
return res;
return sslclient->socket;
}

3 changes: 1 addition & 2 deletions libraries/WiFiClientSecure/src/WiFiClientSecure.h
Expand Up @@ -80,8 +80,7 @@ class WiFiClientSecure : public WiFiClient
const mbedtls_x509_crt* getPeerCertificate() { return mbedtls_ssl_get_peer_cert(&sslclient->ssl_ctx); };
bool getFingerprintSHA256(uint8_t sha256_result[32]) { return get_peer_fingerprint(sslclient, sha256_result); };
int setTimeout(uint32_t seconds);
int setSocketOption(int option, char* value, size_t len);
int setSocketOption(int level, int option, const void* value, size_t len);
int fd() const;

operator bool()
{
Expand Down

0 comments on commit 394f721

Please sign in to comment.