mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-11 16:44:35 +02:00
tcp_transport: Update tcp_transport to support linux build
This commit is contained in:
@@ -8,7 +8,12 @@ list(APPEND srcs
|
|||||||
"transport_ws.c")
|
"transport_ws.c")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
set(req esp-tls)
|
||||||
|
if(NOT ${IDF_TARGET} STREQUAL "linux")
|
||||||
|
list(APPEND req lwip)
|
||||||
|
endif()
|
||||||
|
|
||||||
idf_component_register(SRCS "${srcs}"
|
idf_component_register(SRCS "${srcs}"
|
||||||
INCLUDE_DIRS "include"
|
INCLUDE_DIRS "include"
|
||||||
PRIV_INCLUDE_DIRS "private_include"
|
PRIV_INCLUDE_DIRS "private_include"
|
||||||
REQUIRES esp-tls lwip)
|
REQUIRES ${req})
|
||||||
|
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "esp_tls.h"
|
#include "esp_tls.h"
|
||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
@@ -13,6 +14,7 @@
|
|||||||
#include "esp_transport.h"
|
#include "esp_transport.h"
|
||||||
#include "esp_transport_ssl.h"
|
#include "esp_transport_ssl.h"
|
||||||
#include "esp_transport_internal.h"
|
#include "esp_transport_internal.h"
|
||||||
|
#include "errno.h"
|
||||||
|
|
||||||
#define INVALID_SOCKET (-1)
|
#define INVALID_SOCKET (-1)
|
||||||
|
|
||||||
|
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <sys/random.h>
|
#include <sys/random.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
@@ -16,6 +17,7 @@
|
|||||||
#include "esp_transport_internal.h"
|
#include "esp_transport_internal.h"
|
||||||
#include "errno.h"
|
#include "errno.h"
|
||||||
#include "esp_tls_crypto.h"
|
#include "esp_tls_crypto.h"
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
|
||||||
static const char *TAG = "transport_ws";
|
static const char *TAG = "transport_ws";
|
||||||
|
|
||||||
@@ -145,7 +147,11 @@ static int ws_connect(esp_transport_handle_t t, const char *host, int port, int
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsigned char random_key[16];
|
unsigned char random_key[16];
|
||||||
getrandom(random_key, sizeof(random_key), 0);
|
ssize_t rc;
|
||||||
|
if ((rc = getrandom(random_key, sizeof(random_key), 0)) < 0) {
|
||||||
|
ESP_LOGD(TAG, "getrandom() returned %zd", rc);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
// Size of base64 coded string is equal '((input_size * 4) / 3) + (input_size / 96) + 6' including Z-term
|
// Size of base64 coded string is equal '((input_size * 4) / 3) + (input_size / 96) + 6' including Z-term
|
||||||
unsigned char client_key[28] = {0};
|
unsigned char client_key[28] = {0};
|
||||||
@@ -289,7 +295,11 @@ static int _ws_write(esp_transport_handle_t t, int opcode, int mask_flag, const
|
|||||||
|
|
||||||
if (mask_flag) {
|
if (mask_flag) {
|
||||||
mask = &ws_header[header_len];
|
mask = &ws_header[header_len];
|
||||||
getrandom(ws_header + header_len, 4, 0);
|
ssize_t rc;
|
||||||
|
if ((rc = getrandom(ws_header + header_len, 4, 0)) < 0) {
|
||||||
|
ESP_LOGD(TAG, "getrandom() returned %zd", rc);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
header_len += 4;
|
header_len += 4;
|
||||||
|
|
||||||
for (i = 0; i < len; ++i) {
|
for (i = 0; i < len; ++i) {
|
||||||
|
Reference in New Issue
Block a user