mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2026-08-12 02:23:47 +08:00
Merge branch 'master' into ppp-new
This commit is contained in:
@@ -133,6 +133,7 @@ icmp_input(struct pbuf *p, struct netif *inp)
|
||||
LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: bad ICMP echo received\n"));
|
||||
goto lenerr;
|
||||
}
|
||||
#if CHECKSUM_CHECK_ICMP
|
||||
if (inet_chksum_pbuf(p) != 0) {
|
||||
LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: checksum failed for received ICMP echo\n"));
|
||||
pbuf_free(p);
|
||||
@@ -140,6 +141,7 @@ icmp_input(struct pbuf *p, struct netif *inp)
|
||||
snmp_inc_icmpinerrors();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#if LWIP_ICMP_ECHO_CHECK_INPUT_PBUF_LEN
|
||||
if (pbuf_header(p, (PBUF_IP_HLEN + PBUF_LINK_HLEN))) {
|
||||
/* p is not big enough to contain link headers
|
||||
@@ -324,7 +326,9 @@ icmp_send_response(struct pbuf *p, u8_t type, u8_t code)
|
||||
|
||||
/* calculate checksum */
|
||||
icmphdr->chksum = 0;
|
||||
#if CHECKSUM_GEN_ICMP
|
||||
icmphdr->chksum = inet_chksum(icmphdr, q->len);
|
||||
#endif
|
||||
ICMP_STATS_INC(icmp.xmit);
|
||||
/* increase number of messages attempted to send */
|
||||
snmp_inc_icmpoutmsgs();
|
||||
|
||||
@@ -772,11 +772,11 @@ err_t ip_output_if_opt(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest,
|
||||
if (ip_addr_cmp(dest, &netif->ip_addr)) {
|
||||
/* Packet to self, enqueue it for loopback */
|
||||
LWIP_DEBUGF(IP_DEBUG, ("netif_loop_output()"));
|
||||
return netif_loop_output(netif, p, dest);
|
||||
return netif_loop_output(netif, p);
|
||||
}
|
||||
#if LWIP_IGMP
|
||||
if ((p->flags & PBUF_FLAG_MCASTLOOP) != 0) {
|
||||
netif_loop_output(netif, p, dest);
|
||||
netif_loop_output(netif, p);
|
||||
}
|
||||
#endif /* LWIP_IGMP */
|
||||
#endif /* ENABLE_LOOPBACK */
|
||||
|
||||
@@ -578,7 +578,9 @@ ip_reass(struct pbuf *p)
|
||||
IPH_OFFSET_SET(fraghdr, 0);
|
||||
IPH_CHKSUM_SET(fraghdr, 0);
|
||||
/* @todo: do we need to set calculate the correct checksum? */
|
||||
#if CHECKSUM_GEN_IP
|
||||
IPH_CHKSUM_SET(fraghdr, inet_chksum(fraghdr, IP_HLEN));
|
||||
#endif /* CHECKSUM_GEN_IP */
|
||||
|
||||
p = ipr->p;
|
||||
|
||||
@@ -818,7 +820,9 @@ ip_frag(struct pbuf *p, struct netif *netif, ip_addr_t *dest)
|
||||
IPH_OFFSET_SET(iphdr, htons(tmp));
|
||||
IPH_LEN_SET(iphdr, htons(cop + IP_HLEN));
|
||||
IPH_CHKSUM_SET(iphdr, 0);
|
||||
#if CHECKSUM_GEN_IP
|
||||
IPH_CHKSUM_SET(iphdr, inet_chksum(iphdr, IP_HLEN));
|
||||
#endif /* CHECKSUM_GEN_IP */
|
||||
|
||||
#if IP_FRAG_USES_STATIC_BUF
|
||||
if (last) {
|
||||
|
||||
@@ -96,7 +96,7 @@ icmp6_input(struct pbuf *p, struct netif *inp)
|
||||
|
||||
icmp6hdr = (struct icmp6_hdr *)p->payload;
|
||||
|
||||
#if LWIP_ICMP6_CHECKSUM_CHECK
|
||||
#if CHECKSUM_CHECK_ICMP6
|
||||
if (ip6_chksum_pseudo(p, IP6_NEXTH_ICMP6, p->tot_len, ip6_current_src_addr(),
|
||||
ip6_current_dest_addr()) != 0) {
|
||||
/* Checksum failed */
|
||||
@@ -105,7 +105,7 @@ icmp6_input(struct pbuf *p, struct netif *inp)
|
||||
ICMP6_STATS_INC(icmp6.drop);
|
||||
return;
|
||||
}
|
||||
#endif /* LWIP_ICMP6_CHECKSUM_CHECK */
|
||||
#endif /* CHECKSUM_CHECK_ICMP6 */
|
||||
|
||||
switch (icmp6hdr->type) {
|
||||
case ICMP6_TYPE_NA: /* Neighbor advertisement */
|
||||
@@ -179,8 +179,10 @@ icmp6_input(struct pbuf *p, struct netif *inp)
|
||||
/* Set fields in reply. */
|
||||
((struct icmp6_echo_hdr *)(r->payload))->type = ICMP6_TYPE_EREP;
|
||||
((struct icmp6_echo_hdr *)(r->payload))->chksum = 0;
|
||||
#if CHECKSUM_GEN_ICMP6
|
||||
((struct icmp6_echo_hdr *)(r->payload))->chksum = ip6_chksum_pseudo(r,
|
||||
IP6_NEXTH_ICMP6, r->tot_len, reply_src, ip6_current_src_addr());
|
||||
#endif /* CHECKSUM_GEN_ICMP6 */
|
||||
|
||||
/* Send reply. */
|
||||
ICMP6_STATS_INC(icmp6.xmit);
|
||||
@@ -327,8 +329,10 @@ icmp6_send_response(struct pbuf *p, u8_t code, u32_t data, u8_t type)
|
||||
|
||||
/* calculate checksum */
|
||||
icmp6hdr->chksum = 0;
|
||||
#if CHECKSUM_GEN_ICMP6
|
||||
icmp6hdr->chksum = ip6_chksum_pseudo(q, IP6_NEXTH_ICMP6, q->tot_len,
|
||||
reply_src, reply_dest);
|
||||
#endif /* CHECKSUM_GEN_ICMP6 */
|
||||
|
||||
ICMP6_STATS_INC(icmp6.xmit);
|
||||
ip6_output_if(q, reply_src, reply_dest, LWIP_ICMP6_HL, 0, IP6_NEXTH_ICMP6, netif);
|
||||
|
||||
@@ -802,10 +802,17 @@ ip6_output_if(struct pbuf *p, ip6_addr_t *src, ip6_addr_t *dest,
|
||||
ip6_debug_print(p);
|
||||
|
||||
#if ENABLE_LOOPBACK
|
||||
/* TODO implement loopback for v6
|
||||
if (ip6_addr_cmp(dest, netif_ip6_addr(0))) {
|
||||
return netif_loop_output(netif, p, dest);
|
||||
}*/
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++) {
|
||||
if (ip6_addr_isvalid(netif_ip6_addr_state(netif, i)) &&
|
||||
ip6_addr_cmp(dest, netif_ip6_addr(netif, i))) {
|
||||
/* Packet to self, enqueue it for loopback */
|
||||
LWIP_DEBUGF(IP6_DEBUG, ("netif_loop_output()\n"));
|
||||
return netif_loop_output(netif, p);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* ENABLE_LOOPBACK */
|
||||
#if LWIP_IPV6_FRAG
|
||||
/* don't fragment if interface has mtu set to 0 [loopif] */
|
||||
@@ -814,7 +821,7 @@ ip6_output_if(struct pbuf *p, ip6_addr_t *src, ip6_addr_t *dest,
|
||||
}
|
||||
#endif /* LWIP_IPV6_FRAG */
|
||||
|
||||
LWIP_DEBUGF(IP6_DEBUG, ("netif->output_ip6()"));
|
||||
LWIP_DEBUGF(IP6_DEBUG, ("netif->output_ip6()\n"));
|
||||
return netif->output_ip6(netif, p, dest);
|
||||
}
|
||||
|
||||
|
||||
@@ -563,8 +563,10 @@ mld6_send(struct mld_group *group, u8_t type)
|
||||
mld_hdr->reserved = 0;
|
||||
ip6_addr_set(&(mld_hdr->multicast_address), &(group->group_address));
|
||||
|
||||
#if CHECKSUM_GEN_ICMP6
|
||||
mld_hdr->chksum = ip6_chksum_pseudo(p, IP6_NEXTH_ICMP6, p->len,
|
||||
src_addr, &(group->group_address));
|
||||
#endif /* CHECKSUM_GEN_ICMP6 */
|
||||
|
||||
/* Add hop-by-hop headers options: router alert with MLD value. */
|
||||
ip6_options_add_hbh_ra(p, IP6_NEXTH_ICMP6, IP6_ROUTER_ALERT_VALUE_MLD);
|
||||
|
||||
@@ -838,8 +838,10 @@ nd6_send_ns(struct netif * netif, ip6_addr_t * target_addr, u8_t flags)
|
||||
target_addr = &multicast_address;
|
||||
}
|
||||
|
||||
#if CHECKSUM_GEN_ICMP6
|
||||
ns_hdr->chksum = ip6_chksum_pseudo(p, IP6_NEXTH_ICMP6, p->len, src_addr,
|
||||
target_addr);
|
||||
#endif /* CHECKSUM_GEN_ICMP6 */
|
||||
|
||||
/* Send the packet out. */
|
||||
ND6_STATS_INC(nd6.xmit);
|
||||
@@ -910,8 +912,10 @@ nd6_send_na(struct netif * netif, ip6_addr_t * target_addr, u8_t flags)
|
||||
dest_addr = ip6_current_src_addr();
|
||||
}
|
||||
|
||||
#if CHECKSUM_GEN_ICMP6
|
||||
na_hdr->chksum = ip6_chksum_pseudo(p, IP6_NEXTH_ICMP6, p->len, src_addr,
|
||||
dest_addr);
|
||||
#endif /* CHECKSUM_GEN_ICMP6 */
|
||||
|
||||
/* Send the packet out. */
|
||||
ND6_STATS_INC(nd6.xmit);
|
||||
@@ -977,8 +981,10 @@ nd6_send_rs(struct netif * netif)
|
||||
SMEMCPY(lladdr_opt->addr, netif->hwaddr, netif->hwaddr_len);
|
||||
}
|
||||
|
||||
#if CHECKSUM_GEN_ICMP6
|
||||
rs_hdr->chksum = ip6_chksum_pseudo(p, IP6_NEXTH_ICMP6, p->len, src_addr,
|
||||
&multicast_address);
|
||||
#endif /* CHECKSUM_GEN_ICMP6 */
|
||||
|
||||
/* Send the packet out. */
|
||||
ND6_STATS_INC(nd6.xmit);
|
||||
|
||||
@@ -88,7 +88,19 @@ static u8_t netif_num;
|
||||
static err_t netif_null_output_ip6(struct netif *netif, struct pbuf *p, ip6_addr_t *ipaddr);
|
||||
#endif /* LWIP_IPV6 */
|
||||
|
||||
#if LWIP_IPV6
|
||||
#define ipX_input(in, netif) (IP6H_V((const struct ip6_hdr *)in->payload) == 6) ? ip6_input(in, netif) : ip_input(in, netif)
|
||||
#else
|
||||
#define ipX_input(in, netif) ip_input(in, netif)
|
||||
#endif
|
||||
|
||||
#if LWIP_HAVE_LOOPIF
|
||||
static err_t netif_loop_output_ipv4(struct netif *netif, struct pbuf *p, ip_addr_t* addr);
|
||||
#if LWIP_IPV6
|
||||
static err_t netif_loop_output_ipv6(struct netif *netif, struct pbuf *p, ip6_addr_t* addr);
|
||||
#endif
|
||||
|
||||
|
||||
static struct netif loop_netif;
|
||||
|
||||
/**
|
||||
@@ -108,7 +120,10 @@ netif_loopif_init(struct netif *netif)
|
||||
|
||||
netif->name[0] = 'l';
|
||||
netif->name[1] = 'o';
|
||||
netif->output = netif_loop_output;
|
||||
netif->output = netif_loop_output_ipv4;
|
||||
#if LWIP_IPV6
|
||||
netif->output_ip6 = netif_loop_output_ipv6;
|
||||
#endif
|
||||
return ERR_OK;
|
||||
}
|
||||
#endif /* LWIP_HAVE_LOOPIF */
|
||||
@@ -127,6 +142,15 @@ netif_init(void)
|
||||
#else /* NO_SYS */
|
||||
netif_add(&loop_netif, &loop_ipaddr, &loop_netmask, &loop_gw, NULL, netif_loopif_init, tcpip_input);
|
||||
#endif /* NO_SYS */
|
||||
|
||||
#if LWIP_IPV6
|
||||
loop_netif.ip6_addr[0].addr[0] = 0;
|
||||
loop_netif.ip6_addr[0].addr[1] = 0;
|
||||
loop_netif.ip6_addr[0].addr[2] = 0;
|
||||
loop_netif.ip6_addr[0].addr[3] = PP_HTONL(0x00000001UL);
|
||||
loop_netif.ip6_addr_state[0] = IP6_ADDR_VALID;
|
||||
#endif /* LWIP_IPV6 */
|
||||
|
||||
netif_set_up(&loop_netif);
|
||||
|
||||
#endif /* LWIP_HAVE_LOOPIF */
|
||||
@@ -655,13 +679,11 @@ void netif_set_link_callback(struct netif *netif, netif_status_callback_fn link_
|
||||
*
|
||||
* @param netif the lwip network interface structure
|
||||
* @param p the (IP) packet to 'send'
|
||||
* @param ipaddr the ip address to send the packet to (not used)
|
||||
* @return ERR_OK if the packet has been sent
|
||||
* ERR_MEM if the pbuf used to copy the packet couldn't be allocated
|
||||
*/
|
||||
err_t
|
||||
netif_loop_output(struct netif *netif, struct pbuf *p,
|
||||
ip_addr_t *ipaddr)
|
||||
netif_loop_output(struct netif *netif, struct pbuf *p)
|
||||
{
|
||||
struct pbuf *r;
|
||||
err_t err;
|
||||
@@ -679,7 +701,6 @@ netif_loop_output(struct netif *netif, struct pbuf *p,
|
||||
#endif /* LWIP_HAVE_LOOPIF */
|
||||
#endif /* LWIP_SNMP */
|
||||
SYS_ARCH_DECL_PROTECT(lev);
|
||||
LWIP_UNUSED_ARG(ipaddr);
|
||||
|
||||
/* Allocate a new pbuf */
|
||||
r = pbuf_alloc(PBUF_LINK, p->tot_len, PBUF_RAM);
|
||||
@@ -741,6 +762,23 @@ netif_loop_output(struct netif *netif, struct pbuf *p,
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
static err_t
|
||||
netif_loop_output_ipv4(struct netif *netif, struct pbuf *p, ip_addr_t* addr)
|
||||
{
|
||||
LWIP_UNUSED_ARG(addr);
|
||||
return netif_loop_output(netif, p);
|
||||
}
|
||||
|
||||
#if LWIP_IPV6
|
||||
static err_t
|
||||
netif_loop_output_ipv6(struct netif *netif, struct pbuf *p, ip6_addr_t* addr)
|
||||
{
|
||||
LWIP_UNUSED_ARG(addr);
|
||||
return netif_loop_output(netif, p);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* Call netif_poll() in the main loop of your application. This is to prevent
|
||||
* reentering non-reentrant functions like tcp_input(). Packets passed to
|
||||
@@ -804,7 +842,7 @@ netif_poll(struct netif *netif)
|
||||
snmp_add_ifinoctets(stats_if, in->tot_len);
|
||||
snmp_inc_ifinucastpkts(stats_if);
|
||||
/* loopback packets are always IP packets! */
|
||||
if (ip_input(in, netif) != ERR_OK) {
|
||||
if (ipX_input(in, netif) != ERR_OK) {
|
||||
pbuf_free(in);
|
||||
}
|
||||
/* Don't reference the packet any more! */
|
||||
|
||||
@@ -86,7 +86,7 @@ stats_display_proto(struct stats_proto *proto, const char *name)
|
||||
LWIP_PLATFORM_DIAG(("cachehit: %"STAT_COUNTER_F"\n", proto->cachehit));
|
||||
}
|
||||
|
||||
#if IGMP_STATS
|
||||
#if IGMP_STATS || MLD6_STATS
|
||||
void
|
||||
stats_display_igmp(struct stats_igmp *igmp, const char *name)
|
||||
{
|
||||
@@ -106,7 +106,7 @@ stats_display_igmp(struct stats_igmp *igmp, const char *name)
|
||||
LWIP_PLATFORM_DIAG(("tx_leave: %"STAT_COUNTER_F"\n\t", igmp->tx_leave));
|
||||
LWIP_PLATFORM_DIAG(("tx_report: %"STAT_COUNTER_F"\n\t", igmp->tx_report));
|
||||
}
|
||||
#endif /* IGMP_STATS */
|
||||
#endif /* IGMP_STATS || MLD6_STATS */
|
||||
|
||||
#if MEM_STATS || MEMP_STATS
|
||||
void
|
||||
|
||||
@@ -1261,11 +1261,16 @@ tcp_rexmit_rto(struct tcp_pcb *pcb)
|
||||
for (seg = pcb->unacked; seg->next != NULL; seg = seg->next);
|
||||
/* concatenate unsent queue after unacked queue */
|
||||
seg->next = pcb->unsent;
|
||||
#if TCP_OVERSIZE && TCP_OVERSIZE_DBGCHECK
|
||||
/* if last unsent changed, we need to update unsent_oversize */
|
||||
if (pcb->unsent == NULL) {
|
||||
pcb->unsent_oversize = seg->oversize_left;
|
||||
}
|
||||
#endif /* TCP_OVERSIZE && TCP_OVERSIZE_DBGCHECK*/
|
||||
/* unsent queue is the concatenated queue (of unacked, unsent) */
|
||||
pcb->unsent = pcb->unacked;
|
||||
/* unacked queue is now empty */
|
||||
pcb->unacked = NULL;
|
||||
/* last unsent hasn't changed, no need to reset unsent_oversize */
|
||||
|
||||
/* increment number of retransmissions */
|
||||
++pcb->nrtx;
|
||||
|
||||
Reference in New Issue
Block a user