diff --git a/CHANGELOG b/CHANGELOG index 873476a1..f384f4c7 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -19,6 +19,11 @@ HISTORY ++ New features: + 2007-06-10 Simon Goldschmidt + * udp.h, opt.h, api_msg.c, ip.c, udp.c: Included switch LWIP_UDPLITE (enabled + by default) to switch off UDP-Lite support if not needed (reduces udp.c code + size) + 2007-06-09 Dominik Spies (integrated by Frédéric Bernon) * autoip.h, autoip.c, dhcp.h, dhcp.c, netif.h, netif.c, etharp.h, etharp.c, opt.h: AutoIP implementation available for IPv4, with new options LWIP_AUTOIP and diff --git a/src/api/api_msg.c b/src/api/api_msg.c index c4b81fa0..dd0d5ed4 100644 --- a/src/api/api_msg.c +++ b/src/api/api_msg.c @@ -308,7 +308,9 @@ pcb_new(struct api_msg_msg *msg) msg->conn->err = ERR_MEM; break; } +#if LWIP_UDPLITE if (msg->conn->type==NETCONN_UDPLITE) udp_setflags(msg->conn->pcb.udp, UDP_FLAGS_UDPLITE); +#endif if (msg->conn->type==NETCONN_UDPNOCHKSUM) udp_setflags(msg->conn->pcb.udp, UDP_FLAGS_NOCHKSUM); udp_recv(msg->conn->pcb.udp, recv_udp, msg->conn); break; diff --git a/src/core/ipv4/ip.c b/src/core/ipv4/ip.c index 94aab42c..48bcddf1 100644 --- a/src/core/ipv4/ip.c +++ b/src/core/ipv4/ip.c @@ -365,7 +365,9 @@ ip_input(struct pbuf *p, struct netif *inp) { switch (IPH_PROTO(iphdr)) { #if LWIP_UDP case IP_PROTO_UDP: +#if LWIP_UDPLITE case IP_PROTO_UDPLITE: +#endif snmp_inc_ipindelivers(); udp_input(p, inp); break; diff --git a/src/core/udp.c b/src/core/udp.c index fbfdb00c..496980f2 100644 --- a/src/core/udp.c +++ b/src/core/udp.c @@ -178,6 +178,7 @@ udp_input(struct pbuf *p, struct netif *inp) /* Check checksum if this is a match or if it was directed at us. */ if (pcb != NULL || ip_addr_cmp(&inp->ip_addr, &iphdr->dest)) { LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_TRACE, ("udp_input: calculating checksum\n")); +#if LWIP_UDPLITE if (IPH_PROTO(iphdr) == IP_PROTO_UDPLITE) { /* Do the UDP Lite checksum */ #if CHECKSUM_CHECK_UDP @@ -192,8 +193,10 @@ udp_input(struct pbuf *p, struct netif *inp) pbuf_free(p); goto end; } -#endif - } else { +#endif /* CHECKSUM_CHECK_UDP */ + } else +#endif /* LWIP_UDPLITE */ + { #if CHECKSUM_CHECK_UDP if (udphdr->chksum != 0) { if (inet_chksum_pseudo(p, (struct ip_addr *)&(iphdr->src), @@ -208,7 +211,7 @@ udp_input(struct pbuf *p, struct netif *inp) goto end; } } -#endif +#endif /* CHECKSUM_CHECK_UDP */ } if(pbuf_header(p, -UDP_HLEN)) { /* Can we cope with this failing? Just assert for now */ @@ -389,6 +392,7 @@ udp_send(struct udp_pcb *pcb, struct pbuf *p) LWIP_DEBUGF(UDP_DEBUG, ("udp_send: sending datagram of length %"U16_F"\n", q->tot_len)); +#if LWIP_UDPLITE /* UDP Lite protocol? */ if (pcb->flags & UDP_FLAGS_UDPLITE) { LWIP_DEBUGF(UDP_DEBUG, ("udp_send: UDP LITE packet length %"U16_F"\n", q->tot_len)); @@ -401,13 +405,15 @@ udp_send(struct udp_pcb *pcb, struct pbuf *p) /* chksum zero must become 0xffff, as zero means 'no checksum' */ if (udphdr->chksum == 0x0000) udphdr->chksum = 0xffff; -#else +#else /* CHECKSUM_CHECK_UDP */ udphdr->chksum = 0x0000; -#endif +#endif /* CHECKSUM_CHECK_UDP */ /* output to IP */ LWIP_DEBUGF(UDP_DEBUG, ("udp_send: ip_output_if (,,,,IP_PROTO_UDPLITE,)\n")); err = ip_output_if(q, src_ip, &pcb->remote_ip, pcb->ttl, pcb->tos, IP_PROTO_UDPLITE, netif); - } else { /* UDP */ + } else +#endif /* LWIP_UDPLITE */ + { /* UDP */ LWIP_DEBUGF(UDP_DEBUG, ("udp_send: UDP packet length %"U16_F"\n", q->tot_len)); udphdr->len = htons(q->tot_len); /* calculate checksum */ @@ -417,9 +423,9 @@ udp_send(struct udp_pcb *pcb, struct pbuf *p) /* chksum zero must become 0xffff, as zero means 'no checksum' */ if (udphdr->chksum == 0x0000) udphdr->chksum = 0xffff; } -#else +#else /* CHECKSUM_CHECK_UDP */ udphdr->chksum = 0x0000; -#endif +#endif /* CHECKSUM_CHECK_UDP */ LWIP_DEBUGF(UDP_DEBUG, ("udp_send: UDP checksum 0x%04"X16_F"\n", udphdr->chksum)); LWIP_DEBUGF(UDP_DEBUG, ("udp_send: ip_output_if (,,,,IP_PROTO_UDP,)\n")); /* output to IP */ diff --git a/src/include/lwip/opt.h b/src/include/lwip/opt.h index 43f1ac6b..b5ee2b9c 100644 --- a/src/include/lwip/opt.h +++ b/src/include/lwip/opt.h @@ -348,6 +348,11 @@ a lot of data that needs to be copied, this should be set high. */ #define LWIP_UDP 1 #endif +/* Enable the UDP-Lite protocol (only makes sense if LWIP_UDP=1) */ +#ifndef LWIP_UDPLITE +#define LWIP_UDPLITE 1 +#endif + #ifndef UDP_TTL #define UDP_TTL (IP_DEFAULT_TTL) #endif diff --git a/src/include/lwip/udp.h b/src/include/lwip/udp.h index 90d4d302..43e773ae 100644 --- a/src/include/lwip/udp.h +++ b/src/include/lwip/udp.h @@ -68,9 +68,11 @@ struct udp_pcb { /* ports are in host byte order */ u16_t local_port, remote_port; +#if LWIP_UDPLITE /* used for UDP_LITE only */ u16_t chksum_len; - +#endif /* LWIP_UDPLITE */ + /* addr and port are in same byte order as in the pcb */ void (* recv)(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *addr, u16_t port);