Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Networking rampage and accumulated fixes #3060

Merged
merged 17 commits into from
Apr 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions app/http/httpclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -563,21 +563,20 @@ void ICACHE_FLASH_ATTR http_raw_request( const char * hostname, int port, bool s
req->redirect_follow_count = redirect_follow_count;

ip_addr_t addr;
err_t error = espconn_gethostbyname( (struct espconn *) req, /* It seems we don't need a real espconn pointer here. */
hostname, &addr, http_dns_callback );
err_t error = dns_gethostbyname( hostname, &addr, http_dns_callback, req );

if ( error == ESPCONN_INPROGRESS )
if ( error == ERR_INPROGRESS )
{
HTTPCLIENT_DEBUG( "DNS pending" );
}
else if ( error == ESPCONN_OK )
else if ( error == ERR_OK )
{
/* Already in the local names table (or hostname was an IP address), execute the callback ourselves. */
http_dns_callback( hostname, &addr, req );
}
else
{
if ( error == ESPCONN_ARG )
if ( error == ERR_ARG )
{
HTTPCLIENT_ERR( "DNS arg error %s", hostname );
}else {
Expand Down
306 changes: 0 additions & 306 deletions app/include/lwip/app/espconn.h

Large diffs are not rendered by default.

53 changes: 5 additions & 48 deletions app/include/sys/espconn_mbedtls.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ typedef struct{
int record_len;
pmbedtls_session psession;
mbedtls_net_context fd;
mbedtls_net_context listen_fd;
mbedtls_ctr_drbg_context ctr_drbg;
mbedtls_ssl_context ssl;
mbedtls_ssl_config conf;
Expand All @@ -65,14 +64,11 @@ typedef enum {
ESPCONN_CERT_OWN,
ESPCONN_CERT_AUTH,
ESPCONN_PK,
ESPCONN_PASSWORD
}mbedtls_auth_type;

typedef enum {
ESPCONN_IDLE = 0,
ESPCONN_CLIENT,
ESPCONN_SERVER,
ESPCONN_BOTH,
ESPCONN_MAX
}espconn_level;

Expand All @@ -91,23 +87,14 @@ typedef struct _ssl_sector{
bool flag;
}ssl_sector;

struct ssl_packet{
uint8* pbuffer;
struct ssl_options {
uint16 buffer_size;
ssl_sector cert_ca_sector;
ssl_sector cert_req_sector;
};

typedef struct _ssl_opt {
struct ssl_packet server;
struct ssl_packet client;
uint8 type;
}ssl_opt;

typedef struct{
mbedtls_auth_type auth_type;
espconn_level auth_level;
}mbedtls_auth_info;
int cert_verify_callback;
int cert_auth_callback;
};

#define SSL_KEEP_INTVL 1
#define SSL_KEEP_CNT 5
Expand All @@ -122,13 +109,12 @@ enum {

#define ESPCONN_SECURE_MAX_SIZE 8192
#define ESPCONN_SECURE_DEFAULT_HEAP 0x3800
#define ESPCONN_SECURE_DEFAULT_SIZE SSL_BUFFER_SIZE
#define ESPCONN_HANDSHAKE_TIMEOUT 0x3C
#define ESPCONN_INVALID_TYPE 0xFFFFFFFF
#define MBEDTLS_SSL_PLAIN_ADD TCP_MSS
#define FLASH_SECTOR_SIZE 4096

extern ssl_opt ssl_option;
extern struct ssl_options ssl_client_options;

typedef struct{
uint32 parame_sec;
Expand Down Expand Up @@ -199,25 +185,6 @@ typedef enum{
} \
} while (0)

/******************************************************************************
* FunctionName : mbedtls_load_default_obj
* Description : Initialize the server: set up a listen PCB and bind it to
* the defined port
* Parameters : espconn -- the espconn used to build client
* Returns : none
*******************************************************************************/
bool mbedtls_load_default_obj(uint32 flash_sector, int obj_type, const unsigned char *load_buf, uint16 length);

/******************************************************************************
* FunctionName : sslserver_start
* Description : Initialize the server: set up a listen PCB and bind it to
* the defined port
* Parameters : espconn -- the espconn used to build client
* Returns : none
*******************************************************************************/

extern sint8 espconn_ssl_server(struct espconn *espconn);

/******************************************************************************
* FunctionName : espconn_ssl_client
* Description : Initialize the client: set up a connect PCB and bind it to
Expand Down Expand Up @@ -248,16 +215,6 @@ extern void espconn_ssl_sent(void *arg, uint8 *psent, uint16 length);

extern void espconn_ssl_disconnect(espconn_msg *pdis);

/******************************************************************************
* FunctionName : espconn_secure_get_size
* Description : get buffer size for client or server
* Parameters : level -- set for client or server
* 1: client,2:server,3:client and server
* Returns : buffer size for client or server
*******************************************************************************/

extern sint16 espconn_secure_get_size(uint8 level);

#endif


Expand Down
6 changes: 0 additions & 6 deletions app/include/user_mbedtls.h
Original file line number Diff line number Diff line change
Expand Up @@ -303,17 +303,11 @@ extern void mbedtls_free_wrap(void *p);
//#define MBEDTLS_SSL_CACHE_DEFAULT_TIMEOUT 86400 /**< 1 day */
//#define MBEDTLS_SSL_CACHE_DEFAULT_MAX_ENTRIES 50 /**< Maximum entries in cache */

#if 0
// dynamic buffer sizing with espconn_secure_set_size()
extern unsigned int max_content_len;
#define MBEDTLS_SSL_MAX_CONTENT_LEN max_content_len;
#else
// the current mbedtls integration doesn't allow to set the buffer size dynamically:
// MBEDTLS_SSL_MAX_FRAGMENT_LENGTH feature and dynamic sizing are mutually exclusive
// due to non-constant initializer element in app/mbedtls/library/ssl_tls.c:150
// the buffer size is hardcoded here and value is taken from SSL_BUFFER_SIZE (user_config.h)
#define MBEDTLS_SSL_MAX_CONTENT_LEN SSL_BUFFER_SIZE /**< Maxium fragment length in bytes, determines the size of each of the two internal I/O buffers */
#endif

//#define MBEDTLS_SSL_DEFAULT_TICKET_LIFETIME 86400 /**< Lifetime of session tickets (if enabled) */
//#define MBEDTLS_PSK_MAX_LEN 32 /**< Max size of TLS pre-shared keys, in bytes (default 256 bits) */
Expand Down
Loading