mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-11-04 14:29:39 +00:00
Included switch LWIP_UDPLITE (enabled by default) to switch off UDP-Lite support if not needed (reduces udp.c code size)
This commit is contained in:
parent
df0e4492a7
commit
95f4c02381
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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 */
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user