diff --git a/src/apps/altcp_tls/altcp_tls_mbedtls.c b/src/apps/altcp_tls/altcp_tls_mbedtls.c index 12ea5006..ada6a8ab 100644 --- a/src/apps/altcp_tls/altcp_tls_mbedtls.c +++ b/src/apps/altcp_tls/altcp_tls_mbedtls.c @@ -938,6 +938,9 @@ const struct altcp_functions altcp_mbedtls_functions = { altcp_mbedtls_mss, altcp_default_sndbuf, altcp_default_sndqueuelen, + altcp_default_nagle_disable, + altcp_default_nagle_enable, + altcp_default_nagle_disabled, altcp_default_setprio, altcp_mbedtls_dealloc, altcp_default_get_tcp_addrinfo, diff --git a/src/apps/httpd/httpd.c b/src/apps/httpd/httpd.c index 9d5280aa..10e7fe8b 100644 --- a/src/apps/httpd/httpd.c +++ b/src/apps/httpd/httpd.c @@ -569,7 +569,7 @@ http_write(struct altcp_pcb *pcb, const void* ptr, u16_t *length, u8_t apiflags) /* ensure nagle is normally enabled (only disabled for persistent connections when all data has been enqueued but the connection stays open for the next request */ - tcp_nagle_enable(pcb); + altcp_nagle_enable(pcb); #endif return err; @@ -656,7 +656,7 @@ http_eof(struct altcp_pcb *pcb, struct http_state *hs) hs->keepalive = 1; http_add_connection(hs); /* ensure nagle doesn't interfere with sending all data as fast as possible: */ - tcp_nagle_disable(pcb); + altcp_nagle_disable(pcb); } else #endif /* LWIP_HTTPD_SUPPORT_11_KEEPALIVE */ { @@ -985,7 +985,7 @@ http_send_headers(struct altcp_pcb *pcb, struct http_state *hs) u16_t hdrlen, sendlen; /* How much data can we send? */ - len = tcp_sndbuf(pcb); + len = altcp_sndbuf(pcb); sendlen = len; while(len && (hs->hdr_index < NUM_FILE_HDR_STRINGS) && sendlen) { @@ -1093,7 +1093,7 @@ http_check_eof(struct altcp_pcb *pcb, struct http_state *hs) count = LWIP_MIN(hs->buf_len, bytes_left); } else { /* We don't have a send buffer so allocate one now */ - count = tcp_sndbuf(pcb); + count = altcp_sndbuf(pcb); if(bytes_left < count) { count = bytes_left; } @@ -1386,7 +1386,7 @@ http_send_data_ssi(struct altcp_pcb *pcb, struct http_state *hs) #if !LWIP_HTTPD_SSI_INCLUDE_TAG if(ssi->tag_started <= hs->file) { /* pretend to have sent the tag, too */ - len += ssi->tag_end - ssi->tag_started; + len += (u16_t)(ssi->tag_end - ssi->tag_started); } #endif /* !LWIP_HTTPD_SSI_INCLUDE_TAG*/ hs->file += len; @@ -1432,7 +1432,7 @@ http_send_data_ssi(struct altcp_pcb *pcb, struct http_state *hs) #if !LWIP_HTTPD_SSI_INCLUDE_TAG if(ssi->tag_started <= hs->file) { /* pretend to have sent the tag, too */ - len += ssi->tag_end - ssi->tag_started; + len += (u16_t)(ssi->tag_end - ssi->tag_started); } #endif /* !LWIP_HTTPD_SSI_INCLUDE_TAG*/ hs->file += len; @@ -1853,7 +1853,7 @@ void httpd_post_data_recved(void *connection, u16_t recved_len) } if (hs->pcb != NULL) { if (len != 0) { - tcp_recved(hs->pcb, len); + altcp_recved(hs->pcb, len); } if ((hs->post_content_len_left == 0) && (hs->unrecved_bytes == 0)) { /* finished handling POST */ @@ -1882,7 +1882,7 @@ http_continue(void *connection) if (http_send(hs->pcb, hs)) { /* If we wrote anything to be sent, go ahead and send it now. */ LWIP_DEBUGF(HTTPD_DEBUG | LWIP_DBG_TRACE, ("tcp_output\n")); - tcp_output(hs->pcb); + altcp_output(hs->pcb); } } } @@ -2398,7 +2398,7 @@ http_poll(void *arg, struct altcp_pcb *pcb) LWIP_UNUSED_ARG(closed); #if LWIP_HTTPD_ABORT_ON_CLOSE_MEM_ERROR if (closed == ERR_MEM) { - tcp_abort(pcb); + altcp_abort(pcb); return ERR_ABRT; } #endif /* LWIP_HTTPD_ABORT_ON_CLOSE_MEM_ERROR */ diff --git a/src/apps/httpd/httpd_structs.h b/src/apps/httpd/httpd_structs.h index d05fbc51..4b829072 100644 --- a/src/apps/httpd/httpd_structs.h +++ b/src/apps/httpd/httpd_structs.h @@ -104,7 +104,7 @@ static const tHTTPHeader g_psHTTPHeaders[] = { "xsl", HTTP_HDR_XML}, { "pdf", HTTP_HDR_PDF}, { "json", HTTP_HDR_JSON}, -#if HTTPD_ADDITIONAL_CONTENT_TYPES +#ifdef HTTPD_ADDITIONAL_CONTENT_TYPES /* If you need to add content types not listed here: * #define HTTPD_ADDITIONAL_CONTENT_TYPES {"ct1", HTTP_CONTENT_TYPE("text/ct1")}, {"exe", HTTP_CONTENT_TYPE("application/exe")} */ diff --git a/src/core/altcp.c b/src/core/altcp.c index 7e2e5501..7ad7b28f 100644 --- a/src/core/altcp.c +++ b/src/core/altcp.c @@ -308,6 +308,31 @@ altcp_sndqueuelen(struct altcp_pcb *conn) return 0; } +void +altcp_nagle_disable(struct altcp_pcb *conn) +{ + if (conn && conn->fns && conn->fns->nagle_disable) { + conn->fns->nagle_disable(conn); + } +} + +void +altcp_nagle_enable(struct altcp_pcb *conn) +{ + if (conn && conn->fns && conn->fns->nagle_enable) { + conn->fns->nagle_enable(conn); + } +} + +int +altcp_nagle_disabled(struct altcp_pcb *conn) +{ + if (conn && conn->fns && conn->fns->nagle_disabled) { + return conn->fns->nagle_disabled(conn); + } + return 0; +} + /** * @ingroup altcp * @see tcp_setprio() @@ -430,6 +455,31 @@ altcp_default_sndqueuelen(struct altcp_pcb *conn) return 0; } +void +altcp_default_nagle_disable(struct altcp_pcb *conn) +{ + if (conn && conn->inner_conn) { + altcp_nagle_disable(conn->inner_conn); + } +} + +void +altcp_default_nagle_enable(struct altcp_pcb *conn) +{ + if (conn && conn->inner_conn) { + altcp_nagle_enable(conn->inner_conn); + } +} + +int +altcp_default_nagle_disabled(struct altcp_pcb *conn) +{ + if (conn && conn->inner_conn) { + return altcp_nagle_disabled(conn->inner_conn); + } + return 0; +} + void altcp_default_setprio(struct altcp_pcb *conn, u8_t prio) { diff --git a/src/core/altcp_tcp.c b/src/core/altcp_tcp.c index 67eccb86..cca1a8f1 100644 --- a/src/core/altcp_tcp.c +++ b/src/core/altcp_tcp.c @@ -333,6 +333,34 @@ altcp_tcp_sndqueuelen(struct altcp_pcb *conn) return tcp_sndqueuelen(pcb); } +static void +altcp_tcp_nagle_disable(struct altcp_pcb *conn) +{ + if (conn && conn->state) { + struct tcp_pcb *pcb = (struct tcp_pcb *)conn->state; + tcp_nagle_disable(pcb); + } +} + +static void +altcp_tcp_nagle_enable(struct altcp_pcb *conn) +{ + if (conn && conn->state) { + struct tcp_pcb *pcb = (struct tcp_pcb *)conn->state; + tcp_nagle_enable(pcb); + } +} + +static int +altcp_tcp_nagle_disabled(struct altcp_pcb *conn) +{ + if (conn && conn->state) { + struct tcp_pcb *pcb = (struct tcp_pcb *)conn->state; + return tcp_nagle_disabled(pcb); + } + return 0; +} + static void altcp_tcp_setprio(struct altcp_pcb *conn, u8_t prio) { @@ -402,6 +430,9 @@ const struct altcp_functions altcp_tcp_functions = { altcp_tcp_mss, altcp_tcp_sndbuf, altcp_tcp_sndqueuelen, + altcp_nagle_disable, + altcp_nagle_enable, + altcp_nagle_disabled, altcp_tcp_setprio, altcp_tcp_dealloc, altcp_tcp_get_tcp_addrinfo, diff --git a/src/include/lwip/altcp.h b/src/include/lwip/altcp.h index 8ac0e7d7..ebfbc648 100644 --- a/src/include/lwip/altcp.h +++ b/src/include/lwip/altcp.h @@ -109,6 +109,9 @@ err_t altcp_output(struct altcp_pcb *conn); u16_t altcp_mss(struct altcp_pcb *conn); u16_t altcp_sndbuf(struct altcp_pcb *conn); u16_t altcp_sndqueuelen(struct altcp_pcb *conn); +void altcp_nagle_disable(struct altcp_pcb *conn); +void altcp_nagle_enable(struct altcp_pcb *conn); +int altcp_nagle_disabled(struct altcp_pcb *conn); void altcp_setprio(struct altcp_pcb *conn, u8_t prio); diff --git a/src/include/lwip/priv/altcp_priv.h b/src/include/lwip/priv/altcp_priv.h index 110c3c73..c3ed1cbe 100644 --- a/src/include/lwip/priv/altcp_priv.h +++ b/src/include/lwip/priv/altcp_priv.h @@ -73,6 +73,9 @@ typedef err_t (*altcp_output_fn)(struct altcp_pcb *conn); typedef u16_t (*altcp_mss_fn)(struct altcp_pcb *conn); typedef u16_t (*altcp_sndbuf_fn)(struct altcp_pcb *conn); typedef u16_t (*altcp_sndqueuelen_fn)(struct altcp_pcb *conn); +typedef void (*altcp_nagle_disable_fn)(struct altcp_pcb *conn); +typedef void (*altcp_nagle_enable_fn)(struct altcp_pcb *conn); +typedef int (*altcp_nagle_disabled_fn)(struct altcp_pcb *conn); typedef void (*altcp_setprio_fn)(struct altcp_pcb *conn, u8_t prio); @@ -99,6 +102,9 @@ struct altcp_functions { altcp_mss_fn mss; altcp_sndbuf_fn sndbuf; altcp_sndqueuelen_fn sndqueuelen; + altcp_nagle_disable_fn nagle_disable; + altcp_nagle_enable_fn nagle_enable; + altcp_nagle_disabled_fn nagle_disabled; altcp_setprio_fn setprio; altcp_dealloc_fn dealloc; altcp_get_tcp_addrinfo_fn addrinfo; @@ -108,8 +114,8 @@ struct altcp_functions { #endif }; -void altcp_default_set_poll(struct altcp_pcb *conn, u8_t interval); -void altcp_default_recved(struct altcp_pcb *conn, u16_t len); +void altcp_default_set_poll(struct altcp_pcb *conn, u8_t interval); +void altcp_default_recved(struct altcp_pcb *conn, u16_t len); err_t altcp_default_bind(struct altcp_pcb *conn, const ip_addr_t *ipaddr, u16_t port); err_t altcp_default_shutdown(struct altcp_pcb *conn, int shut_rx, int shut_tx); err_t altcp_default_write(struct altcp_pcb *conn, const void *dataptr, u16_t len, u8_t apiflags); @@ -117,8 +123,11 @@ err_t altcp_default_output(struct altcp_pcb *conn); u16_t altcp_default_mss(struct altcp_pcb *conn); u16_t altcp_default_sndbuf(struct altcp_pcb *conn); u16_t altcp_default_sndqueuelen(struct altcp_pcb *conn); -void altcp_default_setprio(struct altcp_pcb *conn, u8_t prio); -void altcp_default_dealloc(struct altcp_pcb *conn); +void altcp_default_nagle_disable(struct altcp_pcb *conn); +void altcp_default_nagle_enable(struct altcp_pcb *conn); +int altcp_default_nagle_disabled(struct altcp_pcb *conn); +void altcp_default_setprio(struct altcp_pcb *conn, u8_t prio); +void altcp_default_dealloc(struct altcp_pcb *conn); err_t altcp_default_get_tcp_addrinfo(struct altcp_pcb *conn, int local, ip_addr_t *addr, u16_t *port); ip_addr_t *altcp_default_get_ip(struct altcp_pcb *conn, int local); #ifdef LWIP_DEBUG