httpd/altcp: add forgotten functions

This commit is contained in:
goldsimon 2017-03-28 14:04:20 +02:00
parent 7599706808
commit 537c258efa
7 changed files with 110 additions and 14 deletions

View File

@ -938,6 +938,9 @@ const struct altcp_functions altcp_mbedtls_functions = {
altcp_mbedtls_mss, altcp_mbedtls_mss,
altcp_default_sndbuf, altcp_default_sndbuf,
altcp_default_sndqueuelen, altcp_default_sndqueuelen,
altcp_default_nagle_disable,
altcp_default_nagle_enable,
altcp_default_nagle_disabled,
altcp_default_setprio, altcp_default_setprio,
altcp_mbedtls_dealloc, altcp_mbedtls_dealloc,
altcp_default_get_tcp_addrinfo, altcp_default_get_tcp_addrinfo,

View File

@ -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 /* ensure nagle is normally enabled (only disabled for persistent connections
when all data has been enqueued but the connection stays open for the next when all data has been enqueued but the connection stays open for the next
request */ request */
tcp_nagle_enable(pcb); altcp_nagle_enable(pcb);
#endif #endif
return err; return err;
@ -656,7 +656,7 @@ http_eof(struct altcp_pcb *pcb, struct http_state *hs)
hs->keepalive = 1; hs->keepalive = 1;
http_add_connection(hs); http_add_connection(hs);
/* ensure nagle doesn't interfere with sending all data as fast as possible: */ /* ensure nagle doesn't interfere with sending all data as fast as possible: */
tcp_nagle_disable(pcb); altcp_nagle_disable(pcb);
} else } else
#endif /* LWIP_HTTPD_SUPPORT_11_KEEPALIVE */ #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; u16_t hdrlen, sendlen;
/* How much data can we send? */ /* How much data can we send? */
len = tcp_sndbuf(pcb); len = altcp_sndbuf(pcb);
sendlen = len; sendlen = len;
while(len && (hs->hdr_index < NUM_FILE_HDR_STRINGS) && sendlen) { 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); count = LWIP_MIN(hs->buf_len, bytes_left);
} else { } else {
/* We don't have a send buffer so allocate one now */ /* We don't have a send buffer so allocate one now */
count = tcp_sndbuf(pcb); count = altcp_sndbuf(pcb);
if(bytes_left < count) { if(bytes_left < count) {
count = bytes_left; 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 !LWIP_HTTPD_SSI_INCLUDE_TAG
if(ssi->tag_started <= hs->file) { if(ssi->tag_started <= hs->file) {
/* pretend to have sent the tag, too */ /* 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*/ #endif /* !LWIP_HTTPD_SSI_INCLUDE_TAG*/
hs->file += len; 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 !LWIP_HTTPD_SSI_INCLUDE_TAG
if(ssi->tag_started <= hs->file) { if(ssi->tag_started <= hs->file) {
/* pretend to have sent the tag, too */ /* 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*/ #endif /* !LWIP_HTTPD_SSI_INCLUDE_TAG*/
hs->file += len; hs->file += len;
@ -1853,7 +1853,7 @@ void httpd_post_data_recved(void *connection, u16_t recved_len)
} }
if (hs->pcb != NULL) { if (hs->pcb != NULL) {
if (len != 0) { if (len != 0) {
tcp_recved(hs->pcb, len); altcp_recved(hs->pcb, len);
} }
if ((hs->post_content_len_left == 0) && (hs->unrecved_bytes == 0)) { if ((hs->post_content_len_left == 0) && (hs->unrecved_bytes == 0)) {
/* finished handling POST */ /* finished handling POST */
@ -1882,7 +1882,7 @@ http_continue(void *connection)
if (http_send(hs->pcb, hs)) { if (http_send(hs->pcb, hs)) {
/* If we wrote anything to be sent, go ahead and send it now. */ /* If we wrote anything to be sent, go ahead and send it now. */
LWIP_DEBUGF(HTTPD_DEBUG | LWIP_DBG_TRACE, ("tcp_output\n")); 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); LWIP_UNUSED_ARG(closed);
#if LWIP_HTTPD_ABORT_ON_CLOSE_MEM_ERROR #if LWIP_HTTPD_ABORT_ON_CLOSE_MEM_ERROR
if (closed == ERR_MEM) { if (closed == ERR_MEM) {
tcp_abort(pcb); altcp_abort(pcb);
return ERR_ABRT; return ERR_ABRT;
} }
#endif /* LWIP_HTTPD_ABORT_ON_CLOSE_MEM_ERROR */ #endif /* LWIP_HTTPD_ABORT_ON_CLOSE_MEM_ERROR */

View File

@ -104,7 +104,7 @@ static const tHTTPHeader g_psHTTPHeaders[] =
{ "xsl", HTTP_HDR_XML}, { "xsl", HTTP_HDR_XML},
{ "pdf", HTTP_HDR_PDF}, { "pdf", HTTP_HDR_PDF},
{ "json", HTTP_HDR_JSON}, { "json", HTTP_HDR_JSON},
#if HTTPD_ADDITIONAL_CONTENT_TYPES #ifdef HTTPD_ADDITIONAL_CONTENT_TYPES
/* If you need to add content types not listed here: /* 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")} * #define HTTPD_ADDITIONAL_CONTENT_TYPES {"ct1", HTTP_CONTENT_TYPE("text/ct1")}, {"exe", HTTP_CONTENT_TYPE("application/exe")}
*/ */

View File

@ -308,6 +308,31 @@ altcp_sndqueuelen(struct altcp_pcb *conn)
return 0; 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 * @ingroup altcp
* @see tcp_setprio() * @see tcp_setprio()
@ -430,6 +455,31 @@ altcp_default_sndqueuelen(struct altcp_pcb *conn)
return 0; 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 void
altcp_default_setprio(struct altcp_pcb *conn, u8_t prio) altcp_default_setprio(struct altcp_pcb *conn, u8_t prio)
{ {

View File

@ -333,6 +333,34 @@ altcp_tcp_sndqueuelen(struct altcp_pcb *conn)
return tcp_sndqueuelen(pcb); 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 static void
altcp_tcp_setprio(struct altcp_pcb *conn, u8_t prio) 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_mss,
altcp_tcp_sndbuf, altcp_tcp_sndbuf,
altcp_tcp_sndqueuelen, altcp_tcp_sndqueuelen,
altcp_nagle_disable,
altcp_nagle_enable,
altcp_nagle_disabled,
altcp_tcp_setprio, altcp_tcp_setprio,
altcp_tcp_dealloc, altcp_tcp_dealloc,
altcp_tcp_get_tcp_addrinfo, altcp_tcp_get_tcp_addrinfo,

View File

@ -109,6 +109,9 @@ err_t altcp_output(struct altcp_pcb *conn);
u16_t altcp_mss(struct altcp_pcb *conn); u16_t altcp_mss(struct altcp_pcb *conn);
u16_t altcp_sndbuf(struct altcp_pcb *conn); u16_t altcp_sndbuf(struct altcp_pcb *conn);
u16_t altcp_sndqueuelen(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); void altcp_setprio(struct altcp_pcb *conn, u8_t prio);

View File

@ -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_mss_fn)(struct altcp_pcb *conn);
typedef u16_t (*altcp_sndbuf_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 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); typedef void (*altcp_setprio_fn)(struct altcp_pcb *conn, u8_t prio);
@ -99,6 +102,9 @@ struct altcp_functions {
altcp_mss_fn mss; altcp_mss_fn mss;
altcp_sndbuf_fn sndbuf; altcp_sndbuf_fn sndbuf;
altcp_sndqueuelen_fn sndqueuelen; 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_setprio_fn setprio;
altcp_dealloc_fn dealloc; altcp_dealloc_fn dealloc;
altcp_get_tcp_addrinfo_fn addrinfo; altcp_get_tcp_addrinfo_fn addrinfo;
@ -108,8 +114,8 @@ struct altcp_functions {
#endif #endif
}; };
void altcp_default_set_poll(struct altcp_pcb *conn, u8_t interval); 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_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_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_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); 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_mss(struct altcp_pcb *conn);
u16_t altcp_default_sndbuf(struct altcp_pcb *conn); u16_t altcp_default_sndbuf(struct altcp_pcb *conn);
u16_t altcp_default_sndqueuelen(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_nagle_disable(struct altcp_pcb *conn);
void altcp_default_dealloc(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); 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); ip_addr_t *altcp_default_get_ip(struct altcp_pcb *conn, int local);
#ifdef LWIP_DEBUG #ifdef LWIP_DEBUG