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:
Simon Goldschmidt
2018-09-24 22:29:54 +02:00
parent 6229f9ef71
commit a044c807f8
7 changed files with 38 additions and 35 deletions

View File

@@ -605,7 +605,7 @@ altcp_mbedtls_setup(void *conf, struct altcp_pcb *conn, struct altcp_pcb *inner_
}
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;
if (inner_pcb == NULL) {

View File

@@ -418,7 +418,7 @@ altcp_proxyconnect_tls_alloc(void *arg, u8_t ip_type)
struct altcp_pcb *tls_pcb;
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) {
altcp_close(proxy_pcb);

View File

@@ -2685,10 +2685,7 @@ void
httpd_inits(struct altcp_tls_config *conf)
{
#if LWIP_ALTCP_TLS
struct altcp_pcb *pcb_tls;
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);
struct altcp_pcb *pcb_tls = altcp_tls_new(conf, IPADDR_TYPE_ANY);
LWIP_ASSERT("httpd_init: altcp_tls_new failed", pcb_tls != NULL);
httpd_init_pcb(pcb_tls, HTTPD_SERVER_PORT_HTTPS);
#else /* LWIP_ALTCP_TLS */

View File

@@ -1362,20 +1362,17 @@ mqtt_client_connect(mqtt_client_t *client, const ip_addr_t *ip_addr, u16_t port,
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) {
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 */
altcp_arg(client->conn, client);

View File

@@ -460,18 +460,15 @@ smtp_setup_pcb(struct smtp_session *s, const ip_addr_t* remote_ip)
struct altcp_pcb* pcb;
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 (smtp_server_tls_config) {
struct altcp_pcb *pcb_tls = altcp_tls_new(smtp_server_tls_config, pcb);
if (pcb_tls == NULL) {
altcp_close(pcb);
return NULL;
}
pcb = pcb_tls;
}
if (smtp_server_tls_config) {
pcb = altcp_tls_new(smtp_server_tls_config, IP_GET_TYPE(remote_ip));
} else
#endif
{
pcb = altcp_tcp_new_ip_type(IP_GET_TYPE(remote_ip));
}
if (pcb != NULL) {
altcp_arg(pcb, s);
altcp_recv(pcb, smtp_tcp_recv);
altcp_err(pcb, smtp_tcp_err);