mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-10-01 12:24:22 +00:00
altcp_tls: rename altcp_tls_new -> altcp_tls_wrap, add altcp_tls_new
The new altcp_tls_new() is a type safe version of altcp_tls_alloc() Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
This commit is contained in:
parent
6229f9ef71
commit
a044c807f8
@ -605,7 +605,7 @@ altcp_mbedtls_setup(void *conf, struct altcp_pcb *conn, struct altcp_pcb *inner_
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct altcp_pcb *
|
struct altcp_pcb *
|
||||||
altcp_tls_new(struct altcp_tls_config *config, struct altcp_pcb *inner_pcb)
|
altcp_tls_wrap(struct altcp_tls_config *config, struct altcp_pcb *inner_pcb)
|
||||||
{
|
{
|
||||||
struct altcp_pcb *ret;
|
struct altcp_pcb *ret;
|
||||||
if (inner_pcb == NULL) {
|
if (inner_pcb == NULL) {
|
||||||
|
@ -418,7 +418,7 @@ altcp_proxyconnect_tls_alloc(void *arg, u8_t ip_type)
|
|||||||
struct altcp_pcb *tls_pcb;
|
struct altcp_pcb *tls_pcb;
|
||||||
|
|
||||||
proxy_pcb = altcp_proxyconnect_new_tcp(&cfg->proxy, ip_type);
|
proxy_pcb = altcp_proxyconnect_new_tcp(&cfg->proxy, ip_type);
|
||||||
tls_pcb = altcp_tls_new(cfg->tls_config, proxy_pcb);
|
tls_pcb = altcp_tls_wrap(cfg->tls_config, proxy_pcb);
|
||||||
|
|
||||||
if (tls_pcb == NULL) {
|
if (tls_pcb == NULL) {
|
||||||
altcp_close(proxy_pcb);
|
altcp_close(proxy_pcb);
|
||||||
|
@ -2685,10 +2685,7 @@ void
|
|||||||
httpd_inits(struct altcp_tls_config *conf)
|
httpd_inits(struct altcp_tls_config *conf)
|
||||||
{
|
{
|
||||||
#if LWIP_ALTCP_TLS
|
#if LWIP_ALTCP_TLS
|
||||||
struct altcp_pcb *pcb_tls;
|
struct altcp_pcb *pcb_tls = altcp_tls_new(conf, IPADDR_TYPE_ANY);
|
||||||
struct altcp_pcb *pcb_tcp = altcp_tcp_new_ip_type(IPADDR_TYPE_ANY);
|
|
||||||
LWIP_ASSERT("httpd_init: tcp_new failed", pcb_tcp != NULL);
|
|
||||||
pcb_tls = altcp_tls_new(conf, pcb_tcp);
|
|
||||||
LWIP_ASSERT("httpd_init: altcp_tls_new failed", pcb_tls != NULL);
|
LWIP_ASSERT("httpd_init: altcp_tls_new failed", pcb_tls != NULL);
|
||||||
httpd_init_pcb(pcb_tls, HTTPD_SERVER_PORT_HTTPS);
|
httpd_init_pcb(pcb_tls, HTTPD_SERVER_PORT_HTTPS);
|
||||||
#else /* LWIP_ALTCP_TLS */
|
#else /* LWIP_ALTCP_TLS */
|
||||||
|
@ -1362,20 +1362,17 @@ mqtt_client_connect(mqtt_client_t *client, const ip_addr_t *ip_addr, u16_t port,
|
|||||||
return ERR_MEM;
|
return ERR_MEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
client->conn = altcp_tcp_new();
|
#if LWIP_ALTCP && LWIP_ALTCP_TLS
|
||||||
|
if (client_info->tls_config) {
|
||||||
|
client->conn = altcp_tls_new(client_info->tls_config, IP_GET_TYPE(ip_addr));
|
||||||
|
} else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
client->conn = altcp_tcp_new_ip_type(IP_GET_TYPE(ip_addr));
|
||||||
|
}
|
||||||
if (client->conn == NULL) {
|
if (client->conn == NULL) {
|
||||||
return ERR_MEM;
|
return ERR_MEM;
|
||||||
}
|
}
|
||||||
#if LWIP_ALTCP && LWIP_ALTCP_TLS
|
|
||||||
if (client_info->tls_config) {
|
|
||||||
struct altcp_pcb *pcb_tls = altcp_tls_new(client_info->tls_config, client->conn);
|
|
||||||
if (pcb_tls == NULL) {
|
|
||||||
altcp_close(client->conn);
|
|
||||||
return ERR_MEM;
|
|
||||||
}
|
|
||||||
client->conn = pcb_tls;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Set arg pointer for callbacks */
|
/* Set arg pointer for callbacks */
|
||||||
altcp_arg(client->conn, client);
|
altcp_arg(client->conn, client);
|
||||||
|
@ -460,18 +460,15 @@ smtp_setup_pcb(struct smtp_session *s, const ip_addr_t* remote_ip)
|
|||||||
struct altcp_pcb* pcb;
|
struct altcp_pcb* pcb;
|
||||||
LWIP_UNUSED_ARG(remote_ip);
|
LWIP_UNUSED_ARG(remote_ip);
|
||||||
|
|
||||||
pcb = altcp_tcp_new_ip_type(IP_GET_TYPE(remote_ip));
|
|
||||||
if (pcb != NULL) {
|
|
||||||
#if LWIP_ALTCP && LWIP_ALTCP_TLS
|
#if LWIP_ALTCP && LWIP_ALTCP_TLS
|
||||||
if (smtp_server_tls_config) {
|
if (smtp_server_tls_config) {
|
||||||
struct altcp_pcb *pcb_tls = altcp_tls_new(smtp_server_tls_config, pcb);
|
pcb = altcp_tls_new(smtp_server_tls_config, IP_GET_TYPE(remote_ip));
|
||||||
if (pcb_tls == NULL) {
|
} else
|
||||||
altcp_close(pcb);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
pcb = pcb_tls;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
{
|
||||||
|
pcb = altcp_tcp_new_ip_type(IP_GET_TYPE(remote_ip));
|
||||||
|
}
|
||||||
|
if (pcb != NULL) {
|
||||||
altcp_arg(pcb, s);
|
altcp_arg(pcb, s);
|
||||||
altcp_recv(pcb, smtp_tcp_recv);
|
altcp_recv(pcb, smtp_tcp_recv);
|
||||||
altcp_err(pcb, smtp_tcp_err);
|
altcp_err(pcb, smtp_tcp_err);
|
||||||
|
@ -58,23 +58,29 @@
|
|||||||
/** This standard allocator function creates an altcp pcb for
|
/** This standard allocator function creates an altcp pcb for
|
||||||
* TLS over TCP */
|
* TLS over TCP */
|
||||||
struct altcp_pcb *
|
struct altcp_pcb *
|
||||||
altcp_tls_alloc(void *arg, u8_t ip_type)
|
altcp_tls_new(struct altcp_tls_config *config, u8_t ip_type)
|
||||||
{
|
{
|
||||||
struct altcp_pcb *inner_conn, *ret;
|
struct altcp_pcb *inner_conn, *ret;
|
||||||
struct altcp_tls_config *config = (struct altcp_tls_config *)arg;
|
|
||||||
LWIP_UNUSED_ARG(ip_type);
|
LWIP_UNUSED_ARG(ip_type);
|
||||||
|
|
||||||
inner_conn = altcp_tcp_new_ip_type(ip_type);
|
inner_conn = altcp_tcp_new_ip_type(ip_type);
|
||||||
if (inner_conn == NULL) {
|
if (inner_conn == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
ret = altcp_tls_new(config, inner_conn);
|
ret = altcp_tls_wrap(config, inner_conn);
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
altcp_close(inner_conn);
|
altcp_close(inner_conn);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** This standard allocator function creates an altcp pcb for
|
||||||
|
* TLS over TCP */
|
||||||
|
struct altcp_pcb *
|
||||||
|
altcp_tls_alloc(void *arg, u8_t ip_type)
|
||||||
|
{
|
||||||
|
return altcp_tls_new((struct altcp_tls_config *)arg, ip_type);
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* LWIP_ALTCP_TLS */
|
#endif /* LWIP_ALTCP_TLS */
|
||||||
|
|
||||||
|
@ -85,14 +85,20 @@ struct altcp_tls_config *altcp_tls_create_config_client_2wayauth(const u8_t *ca,
|
|||||||
void altcp_tls_free_config(struct altcp_tls_config *conf);
|
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 wrapping an existing pcb as inner connection (e.g. TLS over TCP)
|
||||||
*/
|
*/
|
||||||
struct altcp_pcb *altcp_tls_new(struct altcp_tls_config *config, struct altcp_pcb *inner_pcb);
|
struct altcp_pcb *altcp_tls_wrap(struct altcp_tls_config *config, struct altcp_pcb *inner_pcb);
|
||||||
|
|
||||||
/** @ingroup altcp_tls
|
/** @ingroup altcp_tls
|
||||||
* Create new ALTCP_TLS layer
|
* Create new ALTCP_TLS pcb and its inner tcp pcb
|
||||||
* This allocator function fits to @ref altcp_allocator_t / @ref altcp_new.
|
*/
|
||||||
* 'arg' must contain a struct altcp_tls_config *.
|
struct altcp_pcb *altcp_tls_new(struct altcp_tls_config *config, u8_t ip_type);
|
||||||
|
|
||||||
|
/** @ingroup altcp_tls
|
||||||
|
* Create new ALTCP_TLS layer pcb and its inner tcp pcb.
|
||||||
|
* Same as @ref altcp_tls_new but this allocator function fits to
|
||||||
|
* @ref altcp_allocator_t / @ref altcp_new.\n
|
||||||
|
'arg' must contain a struct altcp_tls_config *.
|
||||||
*/
|
*/
|
||||||
struct altcp_pcb *altcp_tls_alloc(void *arg, u8_t ip_type);
|
struct altcp_pcb *altcp_tls_alloc(void *arg, u8_t ip_type);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user