From 045495056465ef56c33f7525180f9f5409a16c9c Mon Sep 17 00:00:00 2001 From: sg Date: Thu, 17 Sep 2015 22:19:37 +0200 Subject: [PATCH] fixed compiling for various config combinations --- src/api/sockets.c | 4 ++++ src/core/init.c | 4 ++-- src/core/ipv4/igmp.c | 3 --- src/core/ipv4/ip4.c | 2 ++ src/include/lwip/icmp.h | 10 +++++++++- 5 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/api/sockets.c b/src/api/sockets.c index f1187f22..04a4ff37 100644 --- a/src/api/sockets.c +++ b/src/api/sockets.c @@ -978,8 +978,10 @@ lwip_sendmsg(int s, const struct msghdr *msg, int flags) struct netbuf *chain_buf; u16_t remote_port; int i; +#if LWIP_TCP u8_t write_flags; size_t written; +#endif int size = 0; err_t err = ERR_OK; @@ -1848,6 +1850,7 @@ lwip_getsockopt_impl(int s, int level, int optname, void *optval, socklen_t *opt case SOL_SOCKET: switch (optname) { +#if LWIP_TCP case SO_ACCEPTCONN: LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB(sock, *optlen, int); if (NETCONNTYPE_GROUP(sock->conn->type) != NETCONN_TCP) { @@ -1859,6 +1862,7 @@ lwip_getsockopt_impl(int s, int level, int optname, void *optval, socklen_t *opt *(int*)optval = 0; } break; +#endif /* LWIP_TCP */ /* The option flags */ case SO_BROADCAST: diff --git a/src/core/init.c b/src/core/init.c index 1db2ef75..73430ab5 100644 --- a/src/core/init.c +++ b/src/core/init.c @@ -77,8 +77,8 @@ #if (!LWIP_UDP && LWIP_DHCP) #error "If you want to use DHCP, you have to define LWIP_UDP=1 in your lwipopts.h" #endif -#if (!LWIP_UDP && LWIP_IGMP) - #error "If you want to use IGMP, you have to define LWIP_UDP=1 in your lwipopts.h" +#if (!LWIP_UDP && LWIP_MULTICAST_TX_OPTIONS) + #error "If you want to use IGMP/LWIP_MULTICAST_TX_OPTIONS, 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" diff --git a/src/core/ipv4/igmp.c b/src/core/ipv4/igmp.c index 74f56611..aba455b4 100644 --- a/src/core/ipv4/igmp.c +++ b/src/core/ipv4/igmp.c @@ -88,9 +88,6 @@ Steve Reynolds #include "lwip/ip.h" #include "lwip/inet_chksum.h" #include "lwip/netif.h" -#include "lwip/icmp.h" -#include "lwip/udp.h" -#include "lwip/tcp.h" #include "lwip/stats.h" #include "string.h" diff --git a/src/core/ipv4/ip4.c b/src/core/ipv4/ip4.c index 714cb9ef..1fc14db5 100644 --- a/src/core/ipv4/ip4.c +++ b/src/core/ipv4/ip4.c @@ -336,8 +336,10 @@ ip4_forward(struct pbuf *p, struct ip_hdr *iphdr, struct netif *inp) /* @todo: send ICMP Destination Unreachable code 13 "Communication administratively prohibited"? */ #endif /* IP_FRAG */ } else { +#if LWIP_ICMP /* send ICMP Destination Unreachable code 4: "Fragmentation Needed and DF Set" */ icmp_dest_unreach(p, ICMP_DUR_FRAG); +#endif /* LWIP_ICMP */ } return; } diff --git a/src/include/lwip/icmp.h b/src/include/lwip/icmp.h index cf38c3e9..200a0bfc 100644 --- a/src/include/lwip/icmp.h +++ b/src/include/lwip/icmp.h @@ -108,10 +108,18 @@ void icmp_time_exceeded(struct pbuf *p, enum icmp_te_type t); #endif /* LWIP_IPV4 && LWIP_ICMP */ -#if LWIP_IPV4 && LWIP_IPV6 && LWIP_ICMP6 +#if LWIP_IPV4 && LWIP_IPV6 +#if LWIP_ICMP && LWIP_ICMP6 #define icmp_port_unreach(isipv6, pbuf) ((isipv6) ? \ icmp6_dest_unreach(pbuf, ICMP6_DUR_PORT) : \ icmp_dest_unreach(pbuf, ICMP_DUR_PORT)) +#elif LWIP_ICMP +#define icmp_port_unreach(isipv6, pbuf) do{ if(!(isipv6)) { icmp_dest_unreach(pbuf, ICMP_DUR_PORT);}}while(0) +#elif LWIP_ICMP6 +#define icmp_port_unreach(isipv6, pbuf) do{ if(isipv6) { icmp6_dest_unreach(pbuf, ICMP6_DUR_PORT);}}while(0) +#else +#define icmp_port_unreach(isipv6, pbuf) +#endif #elif LWIP_IPV6 && LWIP_ICMP6 #define icmp_port_unreach(isipv6, pbuf) icmp6_dest_unreach(pbuf, ICMP6_DUR_PORT) #elif LWIP_IPV4 && LWIP_ICMP