mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2025-08-03 21:14:40 +08: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:
|
++ 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)
|
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.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
|
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;
|
msg->conn->err = ERR_MEM;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
#if LWIP_UDPLITE
|
||||||
if (msg->conn->type==NETCONN_UDPLITE) udp_setflags(msg->conn->pcb.udp, UDP_FLAGS_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);
|
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);
|
udp_recv(msg->conn->pcb.udp, recv_udp, msg->conn);
|
||||||
break;
|
break;
|
||||||
|
@ -365,7 +365,9 @@ ip_input(struct pbuf *p, struct netif *inp) {
|
|||||||
switch (IPH_PROTO(iphdr)) {
|
switch (IPH_PROTO(iphdr)) {
|
||||||
#if LWIP_UDP
|
#if LWIP_UDP
|
||||||
case IP_PROTO_UDP:
|
case IP_PROTO_UDP:
|
||||||
|
#if LWIP_UDPLITE
|
||||||
case IP_PROTO_UDPLITE:
|
case IP_PROTO_UDPLITE:
|
||||||
|
#endif
|
||||||
snmp_inc_ipindelivers();
|
snmp_inc_ipindelivers();
|
||||||
udp_input(p, inp);
|
udp_input(p, inp);
|
||||||
break;
|
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. */
|
/* 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)) {
|
if (pcb != NULL || ip_addr_cmp(&inp->ip_addr, &iphdr->dest)) {
|
||||||
LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_TRACE, ("udp_input: calculating checksum\n"));
|
LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_TRACE, ("udp_input: calculating checksum\n"));
|
||||||
|
#if LWIP_UDPLITE
|
||||||
if (IPH_PROTO(iphdr) == IP_PROTO_UDPLITE) {
|
if (IPH_PROTO(iphdr) == IP_PROTO_UDPLITE) {
|
||||||
/* Do the UDP Lite checksum */
|
/* Do the UDP Lite checksum */
|
||||||
#if CHECKSUM_CHECK_UDP
|
#if CHECKSUM_CHECK_UDP
|
||||||
@ -192,8 +193,10 @@ udp_input(struct pbuf *p, struct netif *inp)
|
|||||||
pbuf_free(p);
|
pbuf_free(p);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* CHECKSUM_CHECK_UDP */
|
||||||
} else {
|
} else
|
||||||
|
#endif /* LWIP_UDPLITE */
|
||||||
|
{
|
||||||
#if CHECKSUM_CHECK_UDP
|
#if CHECKSUM_CHECK_UDP
|
||||||
if (udphdr->chksum != 0) {
|
if (udphdr->chksum != 0) {
|
||||||
if (inet_chksum_pseudo(p, (struct ip_addr *)&(iphdr->src),
|
if (inet_chksum_pseudo(p, (struct ip_addr *)&(iphdr->src),
|
||||||
@ -208,7 +211,7 @@ udp_input(struct pbuf *p, struct netif *inp)
|
|||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* CHECKSUM_CHECK_UDP */
|
||||||
}
|
}
|
||||||
if(pbuf_header(p, -UDP_HLEN)) {
|
if(pbuf_header(p, -UDP_HLEN)) {
|
||||||
/* Can we cope with this failing? Just assert for now */
|
/* 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));
|
LWIP_DEBUGF(UDP_DEBUG, ("udp_send: sending datagram of length %"U16_F"\n", q->tot_len));
|
||||||
|
|
||||||
|
#if LWIP_UDPLITE
|
||||||
/* UDP Lite protocol? */
|
/* UDP Lite protocol? */
|
||||||
if (pcb->flags & UDP_FLAGS_UDPLITE) {
|
if (pcb->flags & UDP_FLAGS_UDPLITE) {
|
||||||
LWIP_DEBUGF(UDP_DEBUG, ("udp_send: UDP LITE packet length %"U16_F"\n", q->tot_len));
|
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' */
|
/* chksum zero must become 0xffff, as zero means 'no checksum' */
|
||||||
if (udphdr->chksum == 0x0000)
|
if (udphdr->chksum == 0x0000)
|
||||||
udphdr->chksum = 0xffff;
|
udphdr->chksum = 0xffff;
|
||||||
#else
|
#else /* CHECKSUM_CHECK_UDP */
|
||||||
udphdr->chksum = 0x0000;
|
udphdr->chksum = 0x0000;
|
||||||
#endif
|
#endif /* CHECKSUM_CHECK_UDP */
|
||||||
/* output to IP */
|
/* output to IP */
|
||||||
LWIP_DEBUGF(UDP_DEBUG, ("udp_send: ip_output_if (,,,,IP_PROTO_UDPLITE,)\n"));
|
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);
|
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));
|
LWIP_DEBUGF(UDP_DEBUG, ("udp_send: UDP packet length %"U16_F"\n", q->tot_len));
|
||||||
udphdr->len = htons(q->tot_len);
|
udphdr->len = htons(q->tot_len);
|
||||||
/* calculate checksum */
|
/* 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' */
|
/* chksum zero must become 0xffff, as zero means 'no checksum' */
|
||||||
if (udphdr->chksum == 0x0000) udphdr->chksum = 0xffff;
|
if (udphdr->chksum == 0x0000) udphdr->chksum = 0xffff;
|
||||||
}
|
}
|
||||||
#else
|
#else /* CHECKSUM_CHECK_UDP */
|
||||||
udphdr->chksum = 0x0000;
|
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: UDP checksum 0x%04"X16_F"\n", udphdr->chksum));
|
||||||
LWIP_DEBUGF(UDP_DEBUG, ("udp_send: ip_output_if (,,,,IP_PROTO_UDP,)\n"));
|
LWIP_DEBUGF(UDP_DEBUG, ("udp_send: ip_output_if (,,,,IP_PROTO_UDP,)\n"));
|
||||||
/* output to IP */
|
/* 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
|
#define LWIP_UDP 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Enable the UDP-Lite protocol (only makes sense if LWIP_UDP=1) */
|
||||||
|
#ifndef LWIP_UDPLITE
|
||||||
|
#define LWIP_UDPLITE 1
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef UDP_TTL
|
#ifndef UDP_TTL
|
||||||
#define UDP_TTL (IP_DEFAULT_TTL)
|
#define UDP_TTL (IP_DEFAULT_TTL)
|
||||||
#endif
|
#endif
|
||||||
|
@ -68,8 +68,10 @@ struct udp_pcb {
|
|||||||
/* ports are in host byte order */
|
/* ports are in host byte order */
|
||||||
u16_t local_port, remote_port;
|
u16_t local_port, remote_port;
|
||||||
|
|
||||||
|
#if LWIP_UDPLITE
|
||||||
/* used for UDP_LITE only */
|
/* used for UDP_LITE only */
|
||||||
u16_t chksum_len;
|
u16_t chksum_len;
|
||||||
|
#endif /* LWIP_UDPLITE */
|
||||||
|
|
||||||
/* addr and port are in same byte order as in the pcb */
|
/* addr and port are in same byte order as in the pcb */
|
||||||
void (* recv)(void *arg, struct udp_pcb *pcb, struct pbuf *p,
|
void (* recv)(void *arg, struct udp_pcb *pcb, struct pbuf *p,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user