From dc34636598ed89919403f1501e33554ddca74ca4 Mon Sep 17 00:00:00 2001 From: Simon Goldschmidt Date: Thu, 13 Oct 2011 19:25:11 +0200 Subject: [PATCH] fixed bug #34540: compiler error when CORE_LOCKING is used and not all protocols are enabled --- CHANGELOG | 4 ++++ src/api/api_lib.c | 15 ++++++++++++--- src/api/sockets.c | 21 ++++++++++++++++----- 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 36ca4151..e2fe0a23 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -69,6 +69,10 @@ HISTORY ++ Bugfixes: + 2011-10-13: Simon Goldschmidt + * sockets.c, api_lib.c: fixed bug #34540: compiler error when CORE_LOCKING is + used and not all protocols are enabled + 2011-10-12: Simon Goldschmidt * pbuf.c: fixed bug #34534: Error in sending fragmented IP if MEM_ALIGNMENT > 4 diff --git a/src/api/api_lib.c b/src/api/api_lib.c index e1018046..cbae2214 100644 --- a/src/api/api_lib.c +++ b/src/api/api_lib.c @@ -372,7 +372,10 @@ netconn_recv_data(struct netconn *conn, void **new_buf) #endif /* LWIP_SO_RCVTIMEO*/ #if LWIP_TCP - if (NETCONNTYPE_GROUP(conn->type) == NETCONN_TCP) { +#if (LWIP_UDP || LWIP_RAW) + if (NETCONNTYPE_GROUP(conn->type) == NETCONN_TCP) +#endif /* (LWIP_UDP || LWIP_RAW) */ + { if (!netconn_get_noautorecved(conn) || (buf == NULL)) { /* Let the stack know that we have taken the data. */ /* TODO: Speedup: Don't block and wait for the answer here @@ -461,7 +464,10 @@ netconn_recv(struct netconn *conn, struct netbuf **new_buf) LWIP_ERROR("netconn_accept: invalid recvmbox", sys_mbox_valid(&conn->recvmbox), return ERR_CONN;); #if LWIP_TCP - if (NETCONNTYPE_GROUP(conn->type) == NETCONN_TCP) { +#if (LWIP_UDP || LWIP_RAW) + if (NETCONNTYPE_GROUP(conn->type) == NETCONN_TCP) +#endif /* (LWIP_UDP || LWIP_RAW) */ + { struct pbuf *p = NULL; /* This is not a listening netconn, since recvmbox is set */ @@ -485,8 +491,11 @@ 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 */ +#if LWIP_TCP && (LWIP_UDP || LWIP_RAW) + else +#endif /* LWIP_TCP && (LWIP_UDP || LWIP_RAW) */ { #if (LWIP_UDP || LWIP_RAW) return netconn_recv_data(conn, (void **)new_buf); diff --git a/src/api/sockets.c b/src/api/sockets.c index 1734d63d..081709ab 100644 --- a/src/api/sockets.c +++ b/src/api/sockets.c @@ -914,18 +914,29 @@ lwip_sendto(int s, const void *data, size_t size, int flags, to, &remote_addr_tmp, remote_port); remote_addr = &remote_addr_tmp; } else { - remote_addr = &sock->conn->pcb.raw->remote_ip; - if (NETCONNTYPE_GROUP(sock->conn->type) == NETCONN_RAW) { - remote_port = 0; - } else { + remote_addr = &sock->conn->pcb.ip->remote_ip; +#if LWIP_UDP + if (NETCONNTYPE_GROUP(sock->conn->type) == NETCONN_UDP) { remote_port = sock->conn->pcb.udp->remote_port; + } else +#endif /* LWIP_UDP */ + { + remote_port = 0; } } LOCK_TCPIP_CORE(); if (NETCONNTYPE_GROUP(netconn_type(sock->conn)) == NETCONN_RAW) { +#if LWIP_RAW err = sock->conn->last_err = raw_sendto(sock->conn->pcb.raw, p, ipX_2_ip(remote_addr)); - } else { +#else /* LWIP_RAW */ + err = ERR_ARG; +#endif /* LWIP_RAW */ + } +#if LWIP_UDP && LWIP_RAW + else +#endif /* LWIP_UDP && LWIP_RAW */ + { #if LWIP_UDP #if LWIP_CHECKSUM_ON_COPY && LWIP_NETIF_TX_SINGLE_PBUF err = sock->conn->last_err = udp_sendto_chksum(sock->conn->pcb.udp, p,