Minor changes (but in lot of files): add #if/#endif for options where they could miss. #if LWIP_xxx if always put after #include "lwip/opt.h" (note this one indirectly include cc.h). Move others includes inside #if/#endif block.

This commit is contained in:
fbernon
2007-09-07 23:01:59 +00:00
parent 027a70a415
commit e3cd1ac1f9
62 changed files with 241 additions and 214 deletions

View File

@@ -39,14 +39,16 @@
/* This is the part of the API that is linked with
the application */
#include <string.h>
#include "lwip/opt.h"
#if LWIP_NETCONN /* don't build if not configured for use in lwipopts.h */
#include "lwip/api.h"
#include "lwip/api_msg.h"
#include "lwip/tcpip.h"
#include "lwip/memp.h"
#if !NO_SYS
#include <string.h>
/**
* Create a new netconn (of a specific type) that has a callback function.
@@ -185,9 +187,12 @@ netconn_peer(struct netconn *conn, struct ip_addr *addr, u16_t *port)
{
LWIP_ERROR("netconn_peer: invalid conn", (conn != NULL), return ERR_ARG;);
switch (NETCONNTYPE_GROUP(conn->type)) {
#if LWIP_RAW
case NETCONN_RAW:
/* return an error as connecting is only a helper for upper layers */
return ERR_CONN;
#endif /* LWIP_RAW */
#if LWIP_UDP
case NETCONN_UDP:
if (conn->pcb.udp == NULL ||
((conn->pcb.udp->flags & UDP_FLAGS_CONNECTED) == 0))
@@ -195,12 +200,15 @@ netconn_peer(struct netconn *conn, struct ip_addr *addr, u16_t *port)
*addr = (conn->pcb.udp->remote_ip);
*port = conn->pcb.udp->remote_port;
break;
#endif /* LWIP_UDP */
#if LWIP_TCP
case NETCONN_TCP:
if (conn->pcb.tcp == NULL)
return ERR_CONN;
*addr = (conn->pcb.tcp->remote_ip);
*port = conn->pcb.tcp->remote_port;
break;
#endif /* LWIP_TCP */
}
return ERR_OK;
}
@@ -221,18 +229,24 @@ netconn_addr(struct netconn *conn, struct ip_addr **addr, u16_t *port)
LWIP_ERROR("netconn_addr: invalid addr", (addr != NULL), return ERR_ARG;);
LWIP_ERROR("netconn_addr: invalid port", (port != NULL), return ERR_ARG;);
switch (NETCONNTYPE_GROUP(conn->type)) {
#if LWIP_RAW
case NETCONN_RAW:
*addr = &(conn->pcb.raw->local_ip);
*port = conn->pcb.raw->protocol;
break;
#endif /* LWIP_RAW */
#if LWIP_UDP
case NETCONN_UDP:
*addr = &(conn->pcb.udp->local_ip);
*port = conn->pcb.udp->local_port;
break;
#endif /* LWIP_UDP */
#if LWIP_TCP
case NETCONN_TCP:
*addr = &(conn->pcb.tcp->local_ip);
*port = conn->pcb.tcp->local_port;
break;
#endif /* LWIP_TCP */
}
return ERR_OK;
}
@@ -607,4 +621,4 @@ netconn_join_leave_group(struct netconn *conn,
}
#endif /* LWIP_IGMP */
#endif /* !NO_SYS */
#endif /* LWIP_NETCONN */

View File

@@ -37,15 +37,15 @@
*/
#include "lwip/opt.h"
#include "lwip/arch.h"
#if LWIP_NETCONN /* don't build if not configured for use in lwipopts.h */
#include "lwip/api_msg.h"
#include "lwip/memp.h"
#include "lwip/sys.h"
#include "lwip/tcpip.h"
#include "lwip/igmp.h"
#if !NO_SYS
/* forward declarations */
#if LWIP_TCP
static err_t do_writemore(struct netconn *conn);
@@ -931,4 +931,4 @@ do_join_leave_group(struct api_msg_msg *msg)
}
#endif /* LWIP_IGMP */
#endif /* !NO_SYS */
#endif /* LWIP_NETCONN */

View File

@@ -36,11 +36,15 @@
*
*/
#include <string.h>
#include "lwip/opt.h"
#if LWIP_NETCONN /* don't build if not configured for use in lwipopts.h */
#include "lwip/netbuf.h"
#include "lwip/memp.h"
#include <string.h>
/**
* Create (allocate) and initialize a new netbuf.
* The netbuf doesn't yet contain a packet buffer!
@@ -227,3 +231,5 @@ netbuf_first(struct netbuf *buf)
LWIP_ERROR("netbuf_free: invalid buf", (buf != NULL), return;);
buf->ptr = buf->p;
}
#endif /* LWIP_NETCONN */

View File

@@ -32,12 +32,12 @@
*/
#include "lwip/opt.h"
#include "lwip/arch.h"
#if LWIP_NETIF_API /* don't build if not configured for use in lwipopts.h */
#include "lwip/netifapi.h"
#include "lwip/tcpip.h"
#if LWIP_NETIF_API
/**
* Call netif_add() in a thread-safe way by running that function inside the
* tcpip_thread context.

View File

@@ -38,20 +38,19 @@
*
*/
#include "lwip/sockets.h"
#include <string.h>
#include "lwip/opt.h"
#if LWIP_SOCKET /* don't build if not configured for use in lwipopts.h */
#include "lwip/sockets.h"
#include "lwip/api.h"
#include "lwip/arch.h"
#include "lwip/sys.h"
#include "lwip/igmp.h"
#include "lwip/inet.h"
#include "lwip/tcp.h"
#include "lwip/tcpip.h"
#if !NO_SYS
#include <string.h>
#define NUM_SOCKETS MEMP_NUM_NETCONN
@@ -1081,11 +1080,13 @@ int lwip_getsockopt(int s, int level, int optname, void *optval, socklen_t *optl
if (*optlen < sizeof(int)) {
err = EINVAL;
}
#if LWIP_UDP
if ((sock->conn->type != NETCONN_UDP) ||
((udp_flags(sock->conn->pcb.udp) & UDP_FLAGS_UDPLITE) != 0)) {
/* this flag is only available for UDP, not for UDP lite */
err = EAFNOSUPPORT;
}
#endif /* LWIP_UDP */
break;
default:
@@ -1278,9 +1279,11 @@ static void lwip_getsockopt_internal(void *arg)
*(int *)optval = sock->conn->recv_timeout;
break;
#endif /* LWIP_SO_RCVTIMEO */
#if LWIP_UDP
case SO_NO_CHECK:
*(int*)optval = (udp_flags(sock->conn->pcb.udp) & UDP_FLAGS_NOCHKSUM) ? 1 : 0;
break;
#endif /* LWIP_UDP*/
} /* switch (optname) */
break;
@@ -1405,11 +1408,13 @@ int lwip_setsockopt(int s, int level, int optname, const void *optval, socklen_t
if (optlen < sizeof(int)) {
err = EINVAL;
}
#if LWIP_UDP
if ((sock->conn->type != NETCONN_UDP) ||
((udp_flags(sock->conn->pcb.udp) & UDP_FLAGS_UDPLITE) != 0)) {
/* this flag is only available for UDP, not for UDP lite */
err = EAFNOSUPPORT;
}
#endif /* LWIP_UDP */
break;
default:
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, SOL_SOCKET, UNIMPL: optname=0x%x, ..)\n",
@@ -1585,11 +1590,12 @@ static void lwip_setsockopt_internal(void *arg)
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, SOL_SOCKET, optname=0x%x, ..) -> %s\n",
s, optname, (*(int*)optval?"on":"off")));
break;
#if LWIP_SO_RCVTIMEO
#if LWIP_SO_RCVTIMEO
case SO_RCVTIMEO:
sock->conn->recv_timeout = ( *(int*)optval );
break;
#endif /* LWIP_SO_RCVTIMEO */
#if LWIP_UDP
case SO_NO_CHECK:
if (*(int*)optval) {
udp_setflags(sock->conn->pcb.udp, udp_flags(sock->conn->pcb.udp) | UDP_FLAGS_NOCHKSUM);
@@ -1597,6 +1603,7 @@ static void lwip_setsockopt_internal(void *arg)
udp_setflags(sock->conn->pcb.udp, udp_flags(sock->conn->pcb.udp) & ~UDP_FLAGS_NOCHKSUM);
}
break;
#endif /* LWIP_UDP */
} /* switch (optname) */
break;
@@ -1755,4 +1762,4 @@ int lwip_ioctl(int s, long cmd, void *argp)
} /* switch (cmd) */
}
#endif /* !NO_SYS */
#endif /* LWIP_SOCKET */

View File

@@ -38,21 +38,17 @@
#include "lwip/opt.h"
#include "lwip/sys.h"
#if !NO_SYS /* don't build if not configured for use in lwipopts.h */
#include "lwip/sys.h"
#include "lwip/memp.h"
#include "lwip/pbuf.h"
#include "netif/etharp.h"
#include "netif/ppp_oe.h"
#include "lwip/ip_frag.h"
#include "lwip/igmp.h"
#include "lwip/tcpip.h"
#include "lwip/init.h"
#if !NO_SYS
#include "netif/etharp.h"
#include "netif/ppp_oe.h"
/* global variables */
static void (* tcpip_init_done)(void *arg) = NULL;