diff --git a/CHANGELOG b/CHANGELOG index c979f18b..420b8c05 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -169,6 +169,10 @@ HISTORY ++ Bugfixes: + 2010-03-26: Simon Goldschmidt + * various files: Fixed compiling with different options disabled (TCP/UDP), + triggered by bug #29345; don't allocate acceptmbox if LWIP_TCP is disabled + 2010-03-25: Simon Goldschmidt * sockets.c: Fixed bug #29332: lwip_select() processes readset incorrectly diff --git a/src/api/api_lib.c b/src/api/api_lib.c index 294c49be..42a59552 100644 --- a/src/api/api_lib.c +++ b/src/api/api_lib.c @@ -79,7 +79,9 @@ netconn_new_with_proto_and_callback(enum netconn_type t, u8_t proto, netconn_cal LWIP_ASSERT("freeing conn without freeing pcb", conn->pcb.tcp == NULL); LWIP_ASSERT("conn has no op_completed", sys_sem_valid(&conn->op_completed)); LWIP_ASSERT("conn has no recvmbox", sys_mbox_valid(&conn->recvmbox)); +#if LWIP_TCP LWIP_ASSERT("conn->acceptmbox shouldn't exist", !sys_mbox_valid(&conn->acceptmbox)); +#endif /* LWIP_TCP */ sys_sem_free(&conn->op_completed); sys_mbox_free(&conn->recvmbox); memp_free(MEMP_NETCONN, conn); @@ -268,6 +270,7 @@ netconn_listen_with_backlog(struct netconn *conn, u8_t backlog) err_t netconn_accept(struct netconn *conn, struct netconn **new_conn) { +#if LWIP_TCP struct netconn *newconn; err_t err; #if TCP_LISTEN_BACKLOG @@ -313,6 +316,11 @@ netconn_accept(struct netconn *conn, struct netconn **new_conn) *new_conn = newconn; /* don't set conn->last_err: it's only ERR_OK, anyway */ return ERR_OK; +#else /* LWIP_TCP */ + LWIP_UNUSED_ARG(conn); + LWIP_UNUSED_ARG(new_conn); + return ERR_ARG; +#endif /* LWIP_TCP */ } /** @@ -327,10 +335,12 @@ netconn_accept(struct netconn *conn, struct netconn **new_conn) static err_t netconn_recv_data(struct netconn *conn, void **new_buf) { - struct api_msg msg; void *buf = NULL; u16_t len; err_t err; +#if LWIP_TCP + struct api_msg msg; +#endif /* LWIP_TCP */ LWIP_ERROR("netconn_recv: invalid pointer", (new_buf != NULL), return ERR_ARG;); *new_buf = NULL; @@ -432,16 +442,18 @@ netconn_recv_tcp_pbuf(struct netconn *conn, struct pbuf **new_buf) err_t netconn_recv(struct netconn *conn, struct netbuf **new_buf) { +#if LWIP_TCP struct netbuf *buf = NULL; err_t err; +#endif /* LWIP_TCP */ LWIP_ERROR("netconn_recv: invalid pointer", (new_buf != NULL), return ERR_ARG;); *new_buf = NULL; LWIP_ERROR("netconn_recv: invalid conn", (conn != NULL), return ERR_ARG;); LWIP_ERROR("netconn_accept: invalid recvmbox", sys_mbox_valid(&conn->recvmbox), return ERR_CONN;); - if (conn->type == NETCONN_TCP) { #if LWIP_TCP + if (conn->type == NETCONN_TCP) { struct pbuf *p = NULL; /* This is not a listening netconn, since recvmbox is set */ @@ -465,8 +477,9 @@ netconn_recv(struct netconn *conn, struct netbuf **new_buf) *new_buf = buf; /* don't set conn->last_err: it's only ERR_OK, anyway */ return ERR_OK; + } else #endif /* LWIP_TCP */ - } else { + { #if (LWIP_UDP || LWIP_RAW) return netconn_recv_data(conn, (void **)new_buf); #endif /* (LWIP_UDP || LWIP_RAW) */ diff --git a/src/api/api_msg.c b/src/api/api_msg.c index 823ae4b8..7c17b83a 100644 --- a/src/api/api_msg.c +++ b/src/api/api_msg.c @@ -602,7 +602,9 @@ netconn_alloc(enum netconn_type t, netconn_callback callback) return NULL; } +#if LWIP_TCP sys_mbox_set_invalid(&conn->acceptmbox); +#endif conn->state = NETCONN_NONE; #if LWIP_SOCKET /* initialize socket to -1 since 0 is a valid socket */ @@ -636,8 +638,10 @@ netconn_free(struct netconn *conn) LWIP_ASSERT("PCB must be deallocated outside this function", conn->pcb.tcp == NULL); LWIP_ASSERT("recvmbox must be deallocated before calling this function", !sys_mbox_valid(&conn->recvmbox)); +#if LWIP_TCP LWIP_ASSERT("acceptmbox must be deallocated before calling this function", !sys_mbox_valid(&conn->acceptmbox)); +#endif /* LWIP_TCP */ sys_sem_free(&conn->op_completed); sys_sem_set_invalid(&conn->op_completed); @@ -657,13 +661,16 @@ static void netconn_drain(struct netconn *conn) { void *mem; +#if LWIP_TCP struct pbuf *p; +#endif /* LWIP_TCP */ /* This runs in tcpip_thread, so we don't need to lock against rx packets */ /* Delete and drain the recvmbox. */ if (sys_mbox_valid(&conn->recvmbox)) { while (sys_mbox_tryfetch(&conn->recvmbox, &mem) != SYS_MBOX_EMPTY) { +#if LWIP_TCP if (conn->type == NETCONN_TCP) { if(mem != NULL) { p = (struct pbuf*)mem; @@ -673,7 +680,9 @@ netconn_drain(struct netconn *conn) } pbuf_free(p); } - } else { + } else +#endif /* LWIP_TCP */ + { netbuf_delete((struct netbuf *)mem); } } @@ -682,6 +691,7 @@ netconn_drain(struct netconn *conn) } /* Delete and drain the acceptmbox. */ +#if LWIP_TCP if (sys_mbox_valid(&conn->acceptmbox)) { while (sys_mbox_tryfetch(&conn->acceptmbox, &mem) != SYS_MBOX_EMPTY) { /* Only tcp pcbs have an acceptmbox, so no need to check conn->type */ @@ -694,6 +704,7 @@ netconn_drain(struct netconn *conn) sys_mbox_free(&conn->acceptmbox); sys_mbox_set_invalid(&conn->acceptmbox); } +#endif /* LWIP_TCP */ } #if LWIP_TCP diff --git a/src/core/init.c b/src/core/init.c index b4689aa1..b22b3a83 100644 --- a/src/core/init.c +++ b/src/core/init.c @@ -81,6 +81,9 @@ #if (!LWIP_UDP && LWIP_IGMP) #error "If you want to use IGMP, you have to define LWIP_UDP=1 in your lwipopts.h" #endif +#if (!LWIP_UDP && LWIP_SNMP) + #error "If you want to use SNMP, you have to define LWIP_UDP=1 in your lwipopts.h" +#endif #if (!LWIP_UDP && LWIP_DNS) #error "If you want to use DNS, you have to define LWIP_UDP=1 in your lwipopts.h" #endif diff --git a/src/core/pbuf.c b/src/core/pbuf.c index 0e986cdf..fe4b049b 100644 --- a/src/core/pbuf.c +++ b/src/core/pbuf.c @@ -81,9 +81,9 @@ aligned there. Therefore, PBUF_POOL_BUFSIZE_ALIGNED can be used here. */ #define PBUF_POOL_BUFSIZE_ALIGNED LWIP_MEM_ALIGN_SIZE(PBUF_POOL_BUFSIZE) -#if !TCP_QUEUE_OOSEQ || NO_SYS +#if !LWIP_TCP || !TCP_QUEUE_OOSEQ || NO_SYS #define PBUF_POOL_IS_EMPTY() -#else /* !TCP_QUEUE_OOSEQ || NO_SYS */ +#else /* !LWIP_TCP || !TCP_QUEUE_OOSEQ || NO_SYS */ /** Define this to 0 to prevent freeing ooseq pbufs when the PBUF_POOL is empty */ #ifndef PBUF_POOL_FREE_OOSEQ #define PBUF_POOL_FREE_OOSEQ 1 @@ -145,7 +145,7 @@ pbuf_pool_is_empty(void) } } #endif /* PBUF_POOL_FREE_OOSEQ */ -#endif /* !TCP_QUEUE_OOSEQ || NO_SYS */ +#endif /* !LWIP_TCP || !TCP_QUEUE_OOSEQ || NO_SYS */ /** * Allocates a pbuf of the given type (possibly a chain for PBUF_POOL type). diff --git a/src/include/lwip/api.h b/src/include/lwip/api.h index 9363e2f9..2537f1cd 100644 --- a/src/include/lwip/api.h +++ b/src/include/lwip/api.h @@ -150,9 +150,11 @@ struct netconn { /** mbox where received packets are stored until they are fetched by the netconn application thread (can grow quite big) */ sys_mbox_t recvmbox; +#if LWIP_TCP /** mbox where new connections are stored until processed by the application thread */ sys_mbox_t acceptmbox; +#endif LWIP_TCP /** only used for socket layer */ #if LWIP_SOCKET int socket;