mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-10-04 05:39:53 +00:00
altcp_tls: some fixes
- added `altcp_tls_free_config()`. - added `altcp_tls_context()` function to allow mbedtls parameter tweak. Since state structure isn't exported, this allow application to get internal context (port dependent) to tweak it. - free altcp_pcb when lower error callback called.
This commit is contained in:
parent
ee89d906ec
commit
0486100a2b
@ -537,10 +537,11 @@ altcp_mbedtls_lower_err(void *arg, err_t err)
|
|||||||
{
|
{
|
||||||
struct altcp_pcb *conn = (struct altcp_pcb *)arg;
|
struct altcp_pcb *conn = (struct altcp_pcb *)arg;
|
||||||
if (conn) {
|
if (conn) {
|
||||||
/* @todo: deallocate/close this connection? */
|
conn->inner_conn = NULL; /* already freed */
|
||||||
if (conn->err) {
|
if (conn->err) {
|
||||||
conn->err(conn->arg, err);
|
conn->err(conn->arg, err);
|
||||||
}
|
}
|
||||||
|
altcp_free(conn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -606,6 +607,16 @@ altcp_tls_new(struct altcp_tls_config* config, struct altcp_pcb *inner_pcb)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void *
|
||||||
|
altcp_tls_context (struct altcp_pcb *conn)
|
||||||
|
{
|
||||||
|
if (conn && conn->state) {
|
||||||
|
altcp_mbedtls_state_t *state = conn->state;
|
||||||
|
return &state->ssl_context;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
#if ALTCP_MBEDTLS_DEBUG != LWIP_DBG_OFF
|
#if ALTCP_MBEDTLS_DEBUG != LWIP_DBG_OFF
|
||||||
static void
|
static void
|
||||||
altcp_mbedtls_debug(void *ctx, int level, const char *file, int line, const char *str)
|
altcp_mbedtls_debug(void *ctx, int level, const char *file, int line, const char *str)
|
||||||
@ -755,6 +766,13 @@ altcp_tls_create_config_client(const u8_t *cert, size_t cert_len)
|
|||||||
return conf;
|
return conf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
altcp_tls_free_config(struct altcp_tls_config *conf)
|
||||||
|
{
|
||||||
|
altcp_mbedtls_free_config (conf);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* "virtual" functions */
|
/* "virtual" functions */
|
||||||
static void
|
static void
|
||||||
altcp_mbedtls_set_poll(struct altcp_pcb *conn, u8_t interval)
|
altcp_mbedtls_set_poll(struct altcp_pcb *conn, u8_t interval)
|
||||||
@ -954,9 +972,13 @@ altcp_mbedtls_dealloc(struct altcp_pcb *conn)
|
|||||||
mbedtls_ssl_free(&state->ssl_context);
|
mbedtls_ssl_free(&state->ssl_context);
|
||||||
state->flags = 0;
|
state->flags = 0;
|
||||||
altcp_mbedtls_free(state->conf, state);
|
altcp_mbedtls_free(state->conf, state);
|
||||||
}
|
|
||||||
conn->state = NULL;
|
conn->state = NULL;
|
||||||
}
|
}
|
||||||
|
if (conn->inner_conn) {
|
||||||
|
altcp_free(conn->inner_conn);
|
||||||
|
conn->inner_conn = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct altcp_functions altcp_mbedtls_functions = {
|
const struct altcp_functions altcp_mbedtls_functions = {
|
||||||
|
@ -72,11 +72,22 @@ struct altcp_tls_config *altcp_tls_create_config_server_privkey_cert(const u8_t
|
|||||||
*/
|
*/
|
||||||
struct altcp_tls_config *altcp_tls_create_config_client(const u8_t *cert, size_t cert_len);
|
struct altcp_tls_config *altcp_tls_create_config_client(const u8_t *cert, size_t cert_len);
|
||||||
|
|
||||||
|
/** @ingroup altcp_tls
|
||||||
|
* Free an ALTCP_TLS configuration handle
|
||||||
|
*/
|
||||||
|
void altcp_tls_free_config(struct altcp_tls_config *conf);
|
||||||
|
|
||||||
/** @ingroup altcp_tls
|
/** @ingroup altcp_tls
|
||||||
* Create new ALTCP_TLS layer
|
* Create new ALTCP_TLS layer
|
||||||
*/
|
*/
|
||||||
struct altcp_pcb *altcp_tls_new(struct altcp_tls_config* config, struct altcp_pcb *inner_pcb);
|
struct altcp_pcb *altcp_tls_new(struct altcp_tls_config* config, struct altcp_pcb *inner_pcb);
|
||||||
|
|
||||||
|
/** @ingroup altcp_tls
|
||||||
|
* Return pointer to internal TLS context so application can tweak it.
|
||||||
|
* Real type depends on port (e.g. mbedtls)
|
||||||
|
*/
|
||||||
|
void *altcp_tls_context (struct altcp_pcb *conn);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user