diff options
Diffstat (limited to 'src/VBox/Devices/Network')
33 files changed, 427 insertions, 161 deletions
diff --git a/src/VBox/Devices/Network/lwip-new/CHANGELOG b/src/VBox/Devices/Network/lwip-new/CHANGELOG index 68954d963..cf7728633 100644 --- a/src/VBox/Devices/Network/lwip-new/CHANGELOG +++ b/src/VBox/Devices/Network/lwip-new/CHANGELOG @@ -6,6 +6,10 @@ HISTORY ++ New features: + 2014-01-17: Jiri Engelthaler + * icmp, icmp6, opt.h: patch #8027: Completed HW checksuming for IPv4 and + IPv6 ICMP's + 2012-03-25: Simon Goldschmidt (idea by Mason) * posix/*: added posix-compatibility include files posix/netdb.h and posix/sys/socket.h which are a simple wrapper to the correct lwIP include files. @@ -80,6 +84,46 @@ HISTORY ++ Bugfixes: + 2014-01-08: Stathis Voukelatos + * memp_std.h: patch #7928 Fixed size calculation in MALLOC memory pool + creation macro + + 2014-01-18: Brian Fahs + * tcp_out.c: patch #8237: tcp_rexmit_rto fails to update pcb->unsent_oversize + when necessary + + 2014-01-17: Grant Erickson, Jay Logue, Simon Goldschmidt + * ipv6.c, netif.c: patch #7913 Enable Support for IPv6 Loopback + + 2014-01-16: Stathis Voukelatos + * netif.c: patch #7902 Fixed netif_poll() operation when LWIP_LOOPBACK_MAX_PBUFS > 0 + + 2014-01-14: "Freddie Chopin" + * snmp.h, mib2.c: fixed constness and spelling of sysdescr + + 2014-01-14: Simon Goldschmidt (patch by Thomas Faber) + * tcpip.c: patch #8241: Fix implicit declaration of ip_input with + LWIP_TCPIP_CORE_LOCKING_INPUT disabled + + 2014-01-14: chrysn + * timers.c: patch #8244 make timeouts usable reliably from outside of the + timeout routine + + 2014-01-10: Simon Goldschmidt + * ip_frag.c, ip6_frag.c: fixed bug #41041 Potential use-after-free in IPv6 reassembly + + 2014-01-10: Simon Goldschmidt + * memp.c: fixed bug #41188 Alignment error in memp_init() when MEMP_SEPARATE_POOLS==1 + + 2014-01-10: Simon Goldschmidt + * tcp.c: fixed bug #39898 tcp_fasttmr() possible lock due to infinte queue process loop + + 2013-06-29: Simon Goldschmidt + * inet.h, sockets.h: partially fixed bug #37585: IPv6 compatibility (in socket structs) + + 2013-06-29: Simon Goldschmidt + * inet6.h: bug #37585/task #12600: fixed struct in6_addr.s6_addr to conform to spec + 2013-04-24: patch by Liam <morepork> * api_msg.c: patch #8008 Fix a potential null pointer dereference in assert diff --git a/src/VBox/Devices/Network/lwip-new/Makefile.kmk b/src/VBox/Devices/Network/lwip-new/Makefile.kmk index 396ec80a3..0a8bee545 100644 --- a/src/VBox/Devices/Network/lwip-new/Makefile.kmk +++ b/src/VBox/Devices/Network/lwip-new/Makefile.kmk @@ -15,13 +15,6 @@ # hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. # -# -# Recommended kmk flags: -# -# VBOX_WITH_NAT_SERVICE=1 -# VBOX_WITH_LWIP_NAT=1 -# - LWIP_INCS += \ src/include \ src/include/ipv4 \ @@ -101,9 +94,6 @@ LWIP_SOURCES += \ # src/netif/ppp/vj.c -define def_vbox_lwip_flags # VAR_BaseName, path/to/lwip/dir - $(strip $1)_INCS += $(foreach incdir, $(LWIP_INCS), $(strip $2)/$(incdir)) -endef define _def_vbox_lwip_use # VAR_BaseName, path/to/lwip/dir $(strip $1)_SOURCES += \ @@ -113,6 +103,25 @@ define _def_vbox_lwip_use # VAR_BaseName, path/to/lwip/dir # $(strip $2)/src/foo/bar.c_CFLAGS += -magic endef + +define def_vbox_lwip_flags # PROTO_BaseName, VAR_BaseName, path/to/lwip/dir + # add anything configured for the component via PROTO_BaseName + $(foreach suffix, INCS DEFS, + $(if $(value $(strip $1)_LWIP_$(suffix)), + $(eval # + $(strip $2)_$(suffix) += $(value $(strip $1)_LWIP_$(suffix)) + ))) + + # add lwip's own includes + $(strip $2)_INCS += $(foreach incdir, $(LWIP_INCS), $(strip $3)/$(incdir)) + + # disable lwip assertions for some build types + $(strip $2)_DEFS.release += LWIP_NOASSERT + $(strip $2)_DEFS.profile += LWIP_NOASSERT + $(strip $2)_DEFS.kprofile += LWIP_NOASSERT +endef + + ### ### Call this if you want to expose lwip to your component as a whole. ### In this case individual lwip files (added to _SOURCES of your @@ -123,9 +132,10 @@ endef ### define def_vbox_lwip_public # VAR_BaseName, path/to/lwip/dir $(eval $(call _def_vbox_lwip_use, $1, $2)) - $(eval $(call def_vbox_lwip_flags, $1, $2)) + $(eval $(call def_vbox_lwip_flags, $1, $1, $2)) endef + ### ### Call this if you want to expose lwip only to a few selected files. ### In this case each lwip file is configured with lwip includes etc @@ -137,7 +147,7 @@ endef define def_vbox_lwip_private # VAR_BaseName, path/to/lwip/dir $(eval $(call _def_vbox_lwip_use, $1, $2)) $(foreach file, $(LWIP_SOURCES), \ - $(eval $(call def_vbox_lwip_flags, $(strip $2)/$(file), $2))) + $(eval $(call def_vbox_lwip_flags, $1, $(strip $2)/$(file), $2))) endef diff --git a/src/VBox/Devices/Network/lwip-new/src/api/tcpip.c b/src/VBox/Devices/Network/lwip-new/src/api/tcpip.c index f959b5830..7d4afbfdf 100644 --- a/src/VBox/Devices/Network/lwip-new/src/api/tcpip.c +++ b/src/VBox/Devices/Network/lwip-new/src/api/tcpip.c @@ -46,6 +46,7 @@ #include "lwip/pbuf.h" #include "lwip/tcpip.h" #include "lwip/init.h" +#include "lwip/ip.h" #include "netif/etharp.h" #include "netif/ppp_oe.h" diff --git a/src/VBox/Devices/Network/lwip-new/src/core/ipv4/icmp.c b/src/VBox/Devices/Network/lwip-new/src/core/ipv4/icmp.c index 464d14e9b..85e67eb87 100644 --- a/src/VBox/Devices/Network/lwip-new/src/core/ipv4/icmp.c +++ b/src/VBox/Devices/Network/lwip-new/src/core/ipv4/icmp.c @@ -145,6 +145,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); @@ -152,6 +153,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 @@ -427,7 +429,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(); diff --git a/src/VBox/Devices/Network/lwip-new/src/core/ipv4/ip4.c b/src/VBox/Devices/Network/lwip-new/src/core/ipv4/ip4.c index 4cb40fe25..ab051d4b0 100644 --- a/src/VBox/Devices/Network/lwip-new/src/core/ipv4/ip4.c +++ b/src/VBox/Devices/Network/lwip-new/src/core/ipv4/ip4.c @@ -879,11 +879,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 */ diff --git a/src/VBox/Devices/Network/lwip-new/src/core/ipv4/ip_frag.c b/src/VBox/Devices/Network/lwip-new/src/core/ipv4/ip_frag.c index 8d184345d..f68cc351b 100644 --- a/src/VBox/Devices/Network/lwip-new/src/core/ipv4/ip_frag.c +++ b/src/VBox/Devices/Network/lwip-new/src/core/ipv4/ip_frag.c @@ -481,7 +481,6 @@ ip_reass(struct pbuf *p) struct ip_reass_helper *iprh; u16_t offset, len; u8_t clen; - struct ip_reassdata *ipr_prev = NULL; IPFRAG_STATS_INC(ip_frag.recv); snmp_inc_ipreasmreqds(); @@ -527,7 +526,6 @@ ip_reass(struct pbuf *p) IPFRAG_STATS_INC(ip_frag.cachehit); break; } - ipr_prev = ipr; } if (ipr == NULL) { @@ -565,6 +563,7 @@ ip_reass(struct pbuf *p) /* find the right place to insert this pbuf */ /* @todo: trim pbufs if fragments are overlapping */ if (ip_reass_chain_frag_into_datagram_and_validate(ipr, p)) { + struct ip_reassdata *ipr_prev; /* the totally last fragment (flag more fragments = 0) was received at least * once AND all fragments are received */ ipr->datagram_len += IP_HLEN; @@ -579,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; @@ -592,6 +593,14 @@ ip_reass(struct pbuf *p) pbuf_cat(p, r); r = iprh->next_pbuf; } + + /* find the previous entry in the linked list */ + for (ipr_prev = reassdatagrams; ipr_prev != NULL; ipr_prev = ipr->next) { + if (ipr_prev->next == ipr) { + break; + } + } + /* release the sources allocate for the fragment queue entry */ ip_reass_dequeue_datagram(ipr, ipr_prev); @@ -811,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) { diff --git a/src/VBox/Devices/Network/lwip-new/src/core/ipv6/icmp6.c b/src/VBox/Devices/Network/lwip-new/src/core/ipv6/icmp6.c index 09d598f82..28d6611d5 100644 --- a/src/VBox/Devices/Network/lwip-new/src/core/ipv6/icmp6.c +++ b/src/VBox/Devices/Network/lwip-new/src/core/ipv6/icmp6.c @@ -101,7 +101,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 */ @@ -110,7 +110,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 */ @@ -184,8 +184,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); @@ -218,8 +220,6 @@ void icmp6_proxy_input(struct pbuf *p, struct netif *inp) { struct icmp6_hdr *icmp6hdr; - struct pbuf * r; - ip6_addr_t * reply_src; ICMP6_STATS_INC(icmp6.recv); @@ -394,8 +394,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); diff --git a/src/VBox/Devices/Network/lwip-new/src/core/ipv6/ip6.c b/src/VBox/Devices/Network/lwip-new/src/core/ipv6/ip6.c index b890073d6..43a1d2164 100644 --- a/src/VBox/Devices/Network/lwip-new/src/core/ipv6/ip6.c +++ b/src/VBox/Devices/Network/lwip-new/src/core/ipv6/ip6.c @@ -947,10 +947,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] */ @@ -959,7 +966,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); } diff --git a/src/VBox/Devices/Network/lwip-new/src/core/ipv6/mld6.c b/src/VBox/Devices/Network/lwip-new/src/core/ipv6/mld6.c index 6b45ca043..f91f7efaa 100644 --- a/src/VBox/Devices/Network/lwip-new/src/core/ipv6/mld6.c +++ b/src/VBox/Devices/Network/lwip-new/src/core/ipv6/mld6.c @@ -566,8 +566,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); diff --git a/src/VBox/Devices/Network/lwip-new/src/core/ipv6/nd6.c b/src/VBox/Devices/Network/lwip-new/src/core/ipv6/nd6.c index e0a063c2a..2eb74a7d3 100644 --- a/src/VBox/Devices/Network/lwip-new/src/core/ipv6/nd6.c +++ b/src/VBox/Devices/Network/lwip-new/src/core/ipv6/nd6.c @@ -888,8 +888,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); @@ -960,8 +962,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); @@ -1027,8 +1031,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); diff --git a/src/VBox/Devices/Network/lwip-new/src/core/memp.c b/src/VBox/Devices/Network/lwip-new/src/core/memp.c index 6d109797f..d2743736b 100644 --- a/src/VBox/Devices/Network/lwip-new/src/core/memp.c +++ b/src/VBox/Devices/Network/lwip-new/src/core/memp.c @@ -201,7 +201,7 @@ static const char *memp_desc[MEMP_MAX] = { * extern u8_t __attribute__((section(".onchip_mem"))) memp_memory_UDP_PCB_base[]; */ #define LWIP_MEMPOOL(name,num,size,desc) u8_t memp_memory_ ## name ## _base \ - [((num) * (MEMP_SIZE + MEMP_ALIGN_SIZE(size)))]; + [LWIP_MEM_ALIGN_BUFFER((num) * (MEMP_SIZE + MEMP_ALIGN_SIZE(size)))]; #include "lwip/memp_std.h" /** This array holds the base of each memory pool. */ @@ -213,7 +213,7 @@ static u8_t *const memp_bases[] = { #else /* MEMP_SEPARATE_POOLS */ /** This is the actual memory used by the pools (all pools in one big block). */ -static u8_t memp_memory[MEM_ALIGNMENT - 1 +static u8_t memp_memory[MEM_ALIGNMENT - 1 /* XXX: LWIP_MEM_ALIGN_BUFFER */ #define LWIP_MEMPOOL(name,num,size,desc) + ( (num) * (MEMP_SIZE + MEMP_ALIGN_SIZE(size) ) ) #include "lwip/memp_std.h" ]; @@ -334,7 +334,7 @@ memp_overflow_check_all(void) #endif /* !MEMP_SEPARATE_POOLS */ for (i = 0; i < MEMP_MAX; ++i) { #if MEMP_SEPARATE_POOLS - p = (struct memp *)(memp_bases[i]); + p = (struct memp *)LWIP_MEM_ALIGN(memp_bases[i]); #endif /* MEMP_SEPARATE_POOLS */ for (j = 0; j < memp_num[i]; ++j) { memp_overflow_check_element_overflow(p, i); @@ -346,7 +346,7 @@ memp_overflow_check_all(void) #endif /* !MEMP_SEPARATE_POOLS */ for (i = 0; i < MEMP_MAX; ++i) { #if MEMP_SEPARATE_POOLS - p = (struct memp *)(memp_bases[i]); + p = (struct memp *)LWIP_MEM_ALIGN(memp_bases[i]); #endif /* MEMP_SEPARATE_POOLS */ for (j = 0; j < memp_num[i]; ++j) { memp_overflow_check_element_underflow(p, i); @@ -370,7 +370,7 @@ memp_overflow_init(void) #endif /* !MEMP_SEPARATE_POOLS */ for (i = 0; i < MEMP_MAX; ++i) { #if MEMP_SEPARATE_POOLS - p = (struct memp *)(memp_bases[i]); + p = (struct memp *)LWIP_MEM_ALIGN(memp_bases[i]); #endif /* MEMP_SEPARATE_POOLS */ for (j = 0; j < memp_num[i]; ++j) { #if MEMP_SANITY_REGION_BEFORE_ALIGNED > 0 @@ -415,7 +415,7 @@ memp_init(void) VALGRIND_CREATE_MEMPOOL(&memp_tab[i], MEMP_VALGRIND_RED_ZONE, 0); #endif #if MEMP_SEPARATE_POOLS - memp = (struct memp*)memp_bases[i]; + memp = (struct memp*)LWIP_MEM_ALIGN(memp_bases[i]); #endif /* MEMP_SEPARATE_POOLS */ /* create a linked list of memp elements */ for (j = 0; j < memp_num[i]; ++j) { diff --git a/src/VBox/Devices/Network/lwip-new/src/core/netif.c b/src/VBox/Devices/Network/lwip-new/src/core/netif.c index 1004ed126..385711fe9 100644 --- a/src/VBox/Devices/Network/lwip-new/src/core/netif.c +++ b/src/VBox/Devices/Network/lwip-new/src/core/netif.c @@ -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 @@ -769,16 +807,22 @@ netif_poll(struct netif *netif) if (in != NULL) { struct pbuf *in_end = in; #if LWIP_LOOPBACK_MAX_PBUFS - u8_t clen = pbuf_clen(in); - /* adjust the number of pbufs on queue */ - LWIP_ASSERT("netif->loop_cnt_current underflow", - ((netif->loop_cnt_current - clen) < netif->loop_cnt_current)); - netif->loop_cnt_current -= clen; + u8_t clen = 1; #endif /* LWIP_LOOPBACK_MAX_PBUFS */ while (in_end->len != in_end->tot_len) { LWIP_ASSERT("bogus pbuf: len != tot_len but next == NULL!", in_end->next != NULL); in_end = in_end->next; +#if LWIP_LOOPBACK_MAX_PBUFS + clen++; +#endif /* LWIP_LOOPBACK_MAX_PBUFS */ } +#if LWIP_LOOPBACK_MAX_PBUFS + /* adjust the number of pbufs on queue */ + LWIP_ASSERT("netif->loop_cnt_current underflow", + ((netif->loop_cnt_current - clen) < netif->loop_cnt_current)); + netif->loop_cnt_current -= clen; +#endif /* LWIP_LOOPBACK_MAX_PBUFS */ + /* 'in_end' now points to the last pbuf from 'in' */ if (in_end == netif->loop_last) { /* this was the last pbuf in the list */ @@ -798,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! */ diff --git a/src/VBox/Devices/Network/lwip-new/src/core/snmp/mib2.c b/src/VBox/Devices/Network/lwip-new/src/core/snmp/mib2.c index dcd3b62c1..fe1bf6d71 100644 --- a/src/VBox/Devices/Network/lwip-new/src/core/snmp/mib2.c +++ b/src/VBox/Devices/Network/lwip-new/src/core/snmp/mib2.c @@ -772,8 +772,8 @@ static const s32_t sysservices = SNMP_SYSSERVICES; /** mib-2.system.sysDescr */ static const u8_t sysdescr_len_default = 4; static const u8_t sysdescr_default[] = "lwIP"; -static u8_t* sysdescr_len_ptr = (u8_t*)&sysdescr_len_default; -static u8_t* sysdescr_ptr = (u8_t*)&sysdescr_default[0]; +static const u8_t* sysdescr_len_ptr = &sysdescr_len_default; +static const u8_t* sysdescr_ptr = &sysdescr_default[0]; /** mib-2.system.sysContact */ static const u8_t syscontact_len_default = 0; static const u8_t syscontact_default[] = ""; @@ -902,7 +902,7 @@ static u32_t snmpinpkts = 0, * @param src points to source * @param n number of octets to copy. */ -static void ocstrncpy(u8_t *dst, u8_t *src, u16_t n) +static void ocstrncpy(u8_t *dst, const u8_t *src, u16_t n) { u16_t i = n; while (i > 0) { @@ -918,7 +918,7 @@ static void ocstrncpy(u8_t *dst, u8_t *src, u16_t n) * @param src points to source * @param n number of sub identifiers to copy. */ -void objectidncpy(s32_t *dst, s32_t *src, u8_t n) +void objectidncpy(s32_t *dst, const s32_t *src, u8_t n) { u8_t i = n; while(i > 0) { @@ -933,7 +933,7 @@ void objectidncpy(s32_t *dst, s32_t *src, u8_t n) * @param str if non-NULL then copy str pointer * @param len points to string length, excluding zero terminator */ -void snmp_set_sysdesr(u8_t *str, u8_t *len) +void snmp_set_sysdescr(const u8_t *str, const u8_t *len) { if (str != NULL) { diff --git a/src/VBox/Devices/Network/lwip-new/src/core/stats.c b/src/VBox/Devices/Network/lwip-new/src/core/stats.c index 06fbe0f2c..ff97853fa 100644 --- a/src/VBox/Devices/Network/lwip-new/src/core/stats.c +++ b/src/VBox/Devices/Network/lwip-new/src/core/stats.c @@ -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 diff --git a/src/VBox/Devices/Network/lwip-new/src/core/tcp.c b/src/VBox/Devices/Network/lwip-new/src/core/tcp.c index 7596562e3..ebf6f48d5 100644 --- a/src/VBox/Devices/Network/lwip-new/src/core/tcp.c +++ b/src/VBox/Devices/Network/lwip-new/src/core/tcp.c @@ -1005,7 +1005,12 @@ tcp_slowtmr_start: * (to the real destination - as done by proxy hanlder). */ /* Check if this PCB has stayed too long in SYN-RCVD */ - if (pcb->state == SYN_RCVD || pcb->state == SYN_RCVD_0) { + if (pcb->state == SYN_RCVD +#if LWIP_CONNECTION_PROXY + || pcb->state == SYN_RCVD_0 +#endif + ) + { if ((u32_t)(tcp_ticks - pcb->tmr) > TCP_SYN_RCVD_TIMEOUT / TCP_SLOW_INTERVAL) { ++pcb_remove; @@ -1154,6 +1159,8 @@ tcp_fasttmr_start: } } pcb = next; + } else { + pcb = pcb->next; } } } diff --git a/src/VBox/Devices/Network/lwip-new/src/core/tcp_out.c b/src/VBox/Devices/Network/lwip-new/src/core/tcp_out.c index 0fcd0f12a..9884efa2c 100644 --- a/src/VBox/Devices/Network/lwip-new/src/core/tcp_out.c +++ b/src/VBox/Devices/Network/lwip-new/src/core/tcp_out.c @@ -1262,11 +1262,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; diff --git a/src/VBox/Devices/Network/lwip-new/src/core/timers.c b/src/VBox/Devices/Network/lwip-new/src/core/timers.c index 02fef0fdd..601a905f2 100644 --- a/src/VBox/Devices/Network/lwip-new/src/core/timers.c +++ b/src/VBox/Devices/Network/lwip-new/src/core/timers.c @@ -79,7 +79,7 @@ static int tcpip_tcp_timer_active; #if LWIP_CONNECTION_PROXY /** global variable that shows if proxy timer is currently scheduled or not */ static int proxy_udp_timer_active; -#endif /* LWIP_TCP */ +#endif /* LWIP_CONNECTION_PROXY */ #if LWIP_TCP @@ -368,16 +368,34 @@ sys_timeout(u32_t msecs, sys_timeout_handler handler, void *arg) #endif /* LWIP_DEBUG_TIMERNAMES */ { struct sys_timeo *timeout, *t; +#if NO_SYS + u32_t now, diff; +#endif timeout = (struct sys_timeo *)memp_malloc(MEMP_SYS_TIMEOUT); if (timeout == NULL) { LWIP_ASSERT("sys_timeout: timeout != NULL, pool MEMP_SYS_TIMEOUT is empty", timeout != NULL); return; } + +#if NO_SYS + now = sys_now(); + if (next_timeout == NULL) { + diff = 0; + timeouts_last_time = now; + } else { + diff = now - timeouts_last_time; + } +#endif + timeout->next = NULL; timeout->h = handler; timeout->arg = arg; +#if NO_SYS + timeout->time = msecs + diff; +#else timeout->time = msecs; +#endif #if LWIP_DEBUG_TIMERNAMES timeout->handler_name = handler_name; LWIP_DEBUGF(TIMERS_DEBUG, ("sys_timeout: %p msecs=%"U32_F" handler=%s arg=%p\n", @@ -479,7 +497,7 @@ sys_check_timeouts(void) if (tmptimeout && (tmptimeout->time <= diff)) { /* timeout has expired */ had_one = 1; - timeouts_last_time = now; + timeouts_last_time += tmptimeout->time; diff -= tmptimeout->time; next_timeout = tmptimeout->next; handler = tmptimeout->h; diff --git a/src/VBox/Devices/Network/lwip-new/src/include/ipv4/lwip/autoip.h b/src/VBox/Devices/Network/lwip-new/src/include/ipv4/lwip/autoip.h index e62b72e8c..b9f18733f 100644 --- a/src/VBox/Devices/Network/lwip-new/src/include/ipv4/lwip/autoip.h +++ b/src/VBox/Devices/Network/lwip-new/src/include/ipv4/lwip/autoip.h @@ -94,6 +94,9 @@ struct autoip /** Set a struct autoip allocated by the application to work with */ void autoip_set_struct(struct netif *netif, struct autoip *autoip); +/** Remove a struct autoip previously set to the netif using autoip_set_struct() */ +#define autoip_remove_struct(netif) do { (netif)->autoip = NULL; } while (0) + /** Start AutoIP client */ err_t autoip_start(struct netif *netif); diff --git a/src/VBox/Devices/Network/lwip-new/src/include/ipv4/lwip/inet.h b/src/VBox/Devices/Network/lwip-new/src/include/ipv4/lwip/inet.h index 7bff49b59..a6d2eda48 100644 --- a/src/VBox/Devices/Network/lwip-new/src/include/ipv4/lwip/inet.h +++ b/src/VBox/Devices/Network/lwip-new/src/include/ipv4/lwip/inet.h @@ -40,9 +40,14 @@ extern "C" { #endif +/* If your port already typedef's in_addr_t, define IN_ADDR_T_DEFINED + to prevent this code from redefining it. */ +#if !defined(in_addr_t) && !defined(IN_ADDR_T_DEFINED) +typedef u32_t in_addr_t; +#endif /** For compatibility with BSD code */ struct in_addr { - u32_t s_addr; + in_addr_t s_addr; }; /** 255.255.255.255 */ @@ -89,6 +94,15 @@ struct in_addr { #define IN_LOOPBACKNET IP_LOOPBACKNET +#ifndef INET_ADDRSTRLEN +#define INET_ADDRSTRLEN IP4ADDR_STRLEN_MAX +#endif +#if LWIP_IPV6 +#ifndef INET6_ADDRSTRLEN +#define INET6_ADDRSTRLEN IP6ADDR_STRLEN_MAX +#endif +#endif + #define inet_addr_from_ipaddr(target_inaddr, source_ipaddr) ((target_inaddr)->s_addr = ip4_addr_get_u32(source_ipaddr)) #define inet_addr_to_ipaddr(target_ipaddr, source_inaddr) (ip4_addr_set_u32(target_ipaddr, (source_inaddr)->s_addr)) /* ATTENTION: the next define only works because both s_addr and ip_addr_t are an u32_t effectively! */ diff --git a/src/VBox/Devices/Network/lwip-new/src/include/ipv4/lwip/ip4_addr.h b/src/VBox/Devices/Network/lwip-new/src/include/ipv4/lwip/ip4_addr.h index 923d4b066..af76856cf 100644 --- a/src/VBox/Devices/Network/lwip-new/src/include/ipv4/lwip/ip4_addr.h +++ b/src/VBox/Devices/Network/lwip-new/src/include/ipv4/lwip/ip4_addr.h @@ -228,6 +228,9 @@ u8_t ip4_addr_netmask_valid(u32_t netmask); #define ip4_addr3_16(ipaddr) ((u16_t)ip4_addr3(ipaddr)) #define ip4_addr4_16(ipaddr) ((u16_t)ip4_addr4(ipaddr)) +#define IP4ADDR_STRLEN_MAX 16 +#define IPADDR_STRLEN_MAX IP4ADDR_STRLEN_MAX + /** For backwards compatibility */ #define ip_ntoa(ipaddr) ipaddr_ntoa(ipaddr) diff --git a/src/VBox/Devices/Network/lwip-new/src/include/ipv6/lwip/inet6.h b/src/VBox/Devices/Network/lwip-new/src/include/ipv6/lwip/inet6.h index dbf98df01..8359521b5 100644 --- a/src/VBox/Devices/Network/lwip-new/src/include/ipv6/lwip/inet6.h +++ b/src/VBox/Devices/Network/lwip-new/src/include/ipv6/lwip/inet6.h @@ -58,7 +58,7 @@ struct in6_addr { u8_t u8_addr[16]; u32_t u32_addr[4]; } un; -#define s6_addr un.u32_addr +#define s6_addr un.u8_addr }; #define IN6ADDR_ANY_INIT {0,0,0,0} diff --git a/src/VBox/Devices/Network/lwip-new/src/include/ipv6/lwip/ip6_addr.h b/src/VBox/Devices/Network/lwip-new/src/include/ipv6/lwip/ip6_addr.h index 56da0d34b..4e5f4a25d 100644 --- a/src/VBox/Devices/Network/lwip-new/src/include/ipv6/lwip/ip6_addr.h +++ b/src/VBox/Devices/Network/lwip-new/src/include/ipv6/lwip/ip6_addr.h @@ -85,8 +85,6 @@ extern const ip6_addr_t ip6_addr_any; #define IP6_ADDR_ANY ((ip6_addr_t *)&ip6_addr_any) - - #if BYTE_ORDER == BIG_ENDIAN /** Set an IPv6 partial address given by byte-parts. */ #define IP6_ADDR(ip6addr, index, a,b,c,d) \ @@ -146,7 +144,6 @@ Little-endian version, stored in network order (no htonl). */ (dest)->addr[3] = (src) == NULL ? 0 : htonl((src)->addr[3]);}while(0) - /** * Determine if two IPv6 address are on the same network. * @@ -170,6 +167,10 @@ Little-endian version, stored in network order (no htonl). */ ((ip6addr)->addr[2] == 0) && \ ((ip6addr)->addr[3] == 0))) +#define ip6_addr_isloopback(ip6addr) (((ip6addr)->addr[0] == 0UL) && \ + ((ip6addr)->addr[1] == 0UL) && \ + ((ip6addr)->addr[2] == 0UL) && \ + ((ip6addr)->addr[3] == PP_HTONL(0x00000001UL))) #define ip6_addr_isglobal(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xe0000000UL)) == PP_HTONL(0x20000000UL)) @@ -270,6 +271,8 @@ Little-endian version, stored in network order (no htonl). */ ipaddr != NULL ? IP6_ADDR_BLOCK7(ipaddr) : 0, \ ipaddr != NULL ? IP6_ADDR_BLOCK8(ipaddr) : 0)) +#define IP6ADDR_STRLEN_MAX 46 + int ip6addr_aton(const char *cp, ip6_addr_t *addr); /** returns ptr to static buffer; not reentrant! */ char *ip6addr_ntoa(const ip6_addr_t *addr); diff --git a/src/VBox/Devices/Network/lwip-new/src/include/lwip/debug.h b/src/VBox/Devices/Network/lwip-new/src/include/lwip/debug.h index 0fe041396..fe66d4e47 100644 --- a/src/VBox/Devices/Network/lwip-new/src/include/lwip/debug.h +++ b/src/VBox/Devices/Network/lwip-new/src/include/lwip/debug.h @@ -76,6 +76,8 @@ #endif /* LWIP_ERROR */ #ifdef LWIP_DEBUG +/* let VBox override it to use logging */ +#ifndef LWIP_DEBUGF /** print debug message only if debug message type is enabled... * AND is of correct type AND is at least LWIP_DBG_LEVEL */ @@ -90,8 +92,12 @@ } \ } \ } while(0) - +#endif /* !LWIP_DEBUGF */ #else /* LWIP_DEBUG */ +#ifdef LWIP_DEBUG +/* sanity check, this is going to fail with undefined variables anyway */ +#error LWIP_DEBUGF is defined without LWIP_DEBUG +#endif #define LWIP_DEBUGF(debug, message) #endif /* LWIP_DEBUG */ diff --git a/src/VBox/Devices/Network/lwip-new/src/include/lwip/memp_std.h b/src/VBox/Devices/Network/lwip-new/src/include/lwip/memp_std.h index 592a2824e..8e1c99c40 100644 --- a/src/VBox/Devices/Network/lwip-new/src/include/lwip/memp_std.h +++ b/src/VBox/Devices/Network/lwip-new/src/include/lwip/memp_std.h @@ -12,7 +12,7 @@ #ifndef LWIP_MALLOC_MEMPOOL /* This treats "malloc pools" just like any other pool. The pools are a little bigger to provide 'size' as the amount of user data. */ -#define LWIP_MALLOC_MEMPOOL(num, size) LWIP_MEMPOOL(POOL_##size, num, (size + sizeof(struct memp_malloc_helper)), "MALLOC_"#size) +#define LWIP_MALLOC_MEMPOOL(num, size) LWIP_MEMPOOL(POOL_##size, num, (size + LWIP_MEM_ALIGN_SIZE(sizeof(struct memp_malloc_helper))), "MALLOC_"#size) #define LWIP_MALLOC_MEMPOOL_START #define LWIP_MALLOC_MEMPOOL_END #endif /* LWIP_MALLOC_MEMPOOL */ diff --git a/src/VBox/Devices/Network/lwip-new/src/include/lwip/netif.h b/src/VBox/Devices/Network/lwip-new/src/include/lwip/netif.h index 322d2d0ed..b2c8d87a7 100644 --- a/src/VBox/Devices/Network/lwip-new/src/include/lwip/netif.h +++ b/src/VBox/Devices/Network/lwip-new/src/include/lwip/netif.h @@ -359,7 +359,7 @@ void netif_set_link_callback(struct netif *netif, netif_status_callback_fn link_ #endif /* LWIP_IGMP */ #if ENABLE_LOOPBACK -err_t netif_loop_output(struct netif *netif, struct pbuf *p, ip_addr_t *dest_ip); +err_t netif_loop_output(struct netif *netif, struct pbuf *p); void netif_poll(struct netif *netif); #if !LWIP_NETIF_LOOPBACK_MULTITHREADING void netif_poll_all(void); diff --git a/src/VBox/Devices/Network/lwip-new/src/include/lwip/netifapi.h b/src/VBox/Devices/Network/lwip-new/src/include/lwip/netifapi.h index 33318efaf..648151b6b 100644 --- a/src/VBox/Devices/Network/lwip-new/src/include/lwip/netifapi.h +++ b/src/VBox/Devices/Network/lwip-new/src/include/lwip/netifapi.h @@ -96,6 +96,9 @@ err_t netifapi_netif_common ( struct netif *netif, #define netifapi_netif_set_default(n) netifapi_netif_common(n, netif_set_default, NULL) #define netifapi_dhcp_start(n) netifapi_netif_common(n, NULL, dhcp_start) #define netifapi_dhcp_stop(n) netifapi_netif_common(n, dhcp_stop, NULL) +#define netifapi_dhcp_inform(n) netifapi_netif_common(n, dhcp_inform, NULL) +#define netifapi_dhcp_renew(n) netifapi_netif_common(n, NULL, dhcp_renew) +#define netifapi_dhcp_release(n) netifapi_netif_common(n, NULL, dhcp_release) #define netifapi_autoip_start(n) netifapi_netif_common(n, NULL, autoip_start) #define netifapi_autoip_stop(n) netifapi_netif_common(n, NULL, autoip_stop) diff --git a/src/VBox/Devices/Network/lwip-new/src/include/lwip/opt.h b/src/VBox/Devices/Network/lwip-new/src/include/lwip/opt.h index 0da6fad50..1cec8d464 100644 --- a/src/VBox/Devices/Network/lwip-new/src/include/lwip/opt.h +++ b/src/VBox/Devices/Network/lwip-new/src/include/lwip/opt.h @@ -1881,6 +1881,13 @@ #endif /** + * CHECKSUM_GEN_ICMP6==1: Generate checksums in software for outgoing ICMP6 packets. + */ +#ifndef CHECKSUM_GEN_ICMP6 +#define CHECKSUM_GEN_ICMP6 1 +#endif + +/** * CHECKSUM_CHECK_IP==1: Check checksums in software for incoming IP packets. */ #ifndef CHECKSUM_CHECK_IP @@ -1902,6 +1909,20 @@ #endif /** + * CHECKSUM_CHECK_ICMP==1: Check checksums in software for incoming ICMP packets. + */ +#ifndef CHECKSUM_CHECK_ICMP +#define CHECKSUM_CHECK_ICMP 1 +#endif + +/** + * CHECKSUM_CHECK_ICMP6==1: Check checksums in software for incoming ICMPv6 packets + */ +#ifndef CHECKSUM_CHECK_ICMP6 +#define CHECKSUM_CHECK_ICMP6 1 +#endif + +/** * LWIP_CHECKSUM_ON_COPY==1: Calculate checksum when copying data from * application buffers to pbufs. */ @@ -1958,13 +1979,6 @@ #endif /** - * LWIP_ICMP6_CHECKSUM_CHECK==1: verify checksum on ICMPv6 packets - */ -#ifndef LWIP_ICMP6_CHECKSUM_CHECK -#define LWIP_ICMP6_CHECKSUM_CHECK 1 -#endif - -/** * LWIP_IPV6_MLD==1: Enable multicast listener discovery protocol. */ #ifndef LWIP_IPV6_MLD diff --git a/src/VBox/Devices/Network/lwip-new/src/include/lwip/snmp.h b/src/VBox/Devices/Network/lwip-new/src/include/lwip/snmp.h index 2ed043dd5..7844cc11e 100644 --- a/src/VBox/Devices/Network/lwip-new/src/include/lwip/snmp.h +++ b/src/VBox/Devices/Network/lwip-new/src/include/lwip/snmp.h @@ -98,7 +98,7 @@ struct snmp_obj_id }; /* system */ -void snmp_set_sysdesr(u8_t* str, u8_t* len); +void snmp_set_sysdescr(const u8_t* str, const u8_t* len); void snmp_set_sysobjid(struct snmp_obj_id *oid); void snmp_get_sysobjid_ptr(struct snmp_obj_id **oid); void snmp_inc_sysuptime(void); @@ -231,7 +231,7 @@ void snmp_get_snmpenableauthentraps(u8_t *value); #else /* system */ -#define snmp_set_sysdesr(str, len) +#define snmp_set_sysdescr(str, len) #define snmp_set_sysobjid(oid); #define snmp_get_sysobjid_ptr(oid) #define snmp_inc_sysuptime() diff --git a/src/VBox/Devices/Network/lwip-new/src/include/lwip/sockets.h b/src/VBox/Devices/Network/lwip-new/src/include/lwip/sockets.h index 73461374b..853beea80 100644 --- a/src/VBox/Devices/Network/lwip-new/src/include/lwip/sockets.h +++ b/src/VBox/Devices/Network/lwip-new/src/include/lwip/sockets.h @@ -48,33 +48,54 @@ extern "C" { #endif +/* If your port already typedef's sa_family_t, define SA_FAMILY_T_DEFINED + to prevent this code from redefining it. */ +#if !defined(sa_family_t) && !defined(SA_FAMILY_T_DEFINED) +typedef u8_t sa_family_t; +#endif +/* If your port already typedef's in_port_t, define IN_PORT_T_DEFINED + to prevent this code from redefining it. */ +#if !defined(in_port_t) && !defined(IN_PORT_T_DEFINED) +typedef u16_t in_port_t; +#endif + /* members are in network byte order */ struct sockaddr_in { - u8_t sin_len; - u8_t sin_family; - u16_t sin_port; - struct in_addr sin_addr; + u8_t sin_len; + sa_family_t sin_family; + in_port_t sin_port; + struct in_addr sin_addr; #define SIN_ZERO_LEN 8 - char sin_zero[SIN_ZERO_LEN]; + char sin_zero[SIN_ZERO_LEN]; }; #if LWIP_IPV6 struct sockaddr_in6 { - u8_t sin6_len; /* length of this structure */ - u8_t sin6_family; /* AF_INET6 */ - u16_t sin6_port; /* Transport layer port # */ - u32_t sin6_flowinfo; /* IPv6 flow information */ - struct in6_addr sin6_addr; /* IPv6 address */ + u8_t sin6_len; /* length of this structure */ + sa_family_t sin6_family; /* AF_INET6 */ + in_port_t sin6_port; /* Transport layer port # */ + u32_t sin6_flowinfo; /* IPv6 flow information */ + struct in6_addr sin6_addr; /* IPv6 address */ }; #endif /* LWIP_IPV6 */ struct sockaddr { - u8_t sa_len; - u8_t sa_family; + u8_t sa_len; + sa_family_t sa_family; #if LWIP_IPV6 - u8_t sa_data[22]; + char sa_data[22]; #else /* LWIP_IPV6 */ - u8_t sa_data[14]; + char sa_data[14]; +#endif /* LWIP_IPV6 */ +}; + +struct sockaddr_storage { + u8_t s2_len; + sa_family_t ss_family; + char s2_data1[2]; + u32_t s2_data2[3]; +#if LWIP_IPV6 + u32_t s2_data3[2]; #endif /* LWIP_IPV6 */ }; @@ -146,10 +167,12 @@ struct linger { #define PF_UNSPEC AF_UNSPEC #define IPPROTO_IP 0 +#define IPPROTO_ICMP 1 #define IPPROTO_TCP 6 #define IPPROTO_UDP 17 #if LWIP_IPV6 #define IPPROTO_IPV6 41 +#define IPPROTO_ICMPV6 58 #endif /* LWIP_IPV6 */ #define IPPROTO_UDPLITE 136 diff --git a/src/VBox/Devices/Network/lwip-new/vbox/VBoxLwipCore.cpp b/src/VBox/Devices/Network/lwip-new/vbox/VBoxLwipCore.cpp index db07f70c7..f848e7b9e 100644 --- a/src/VBox/Devices/Network/lwip-new/vbox/VBoxLwipCore.cpp +++ b/src/VBox/Devices/Network/lwip-new/vbox/VBoxLwipCore.cpp @@ -74,7 +74,7 @@ static DECLCALLBACK(void) lwipCoreUserCallback(void *pvArg) pUserClbk->pfn(pUserClbk->pvUser); /* wake up caller on EMT/main */ - lwip_sys_sem_signal(&g_LwipCore.LwipTcpIpSem); + sys_sem_signal(&g_LwipCore.LwipTcpIpSem); LogFlowFuncLeave(); } @@ -129,14 +129,14 @@ int vboxLwipCoreInitialize(PFNRT1 pfnCallback, void *pvCallbackArg) if (g_LwipCore.iLWIPInitiatorCounter == 0) { - lwipRc = lwip_sys_sem_new(&g_LwipCore.LwipTcpIpSem, 0); + lwipRc = sys_sem_new(&g_LwipCore.LwipTcpIpSem, 0); if (lwipRc != ERR_OK) { LogFlow(("%s: sys_sem_new error %d\n", __FUNCTION__, lwipRc)); goto done; } - lwip_tcpip_init(lwipCoreInitDone, &callback); + tcpip_init(lwipCoreInitDone, &callback); } else { @@ -148,7 +148,7 @@ int vboxLwipCoreInitialize(PFNRT1 pfnCallback, void *pvCallbackArg) } } - lwip_sys_sem_wait(&g_LwipCore.LwipTcpIpSem, 0); + sys_sem_wait(&g_LwipCore.LwipTcpIpSem); ++g_LwipCore.iLWIPInitiatorCounter; } done: @@ -211,7 +211,7 @@ void vboxLwipCoreFinalize(PFNRT1 pfnCallback, void *pvCallbackArg) } if (lwipRc == ERR_OK) - lwip_sys_sem_wait(&g_LwipCore.LwipTcpIpSem, 0); + sys_sem_wait(&g_LwipCore.LwipTcpIpSem); } LogFlowFuncLeave(); diff --git a/src/VBox/Devices/Network/lwip-new/vbox/include/lwip-log.h b/src/VBox/Devices/Network/lwip-new/vbox/include/lwip-log.h new file mode 100644 index 000000000..f66ca8de1 --- /dev/null +++ b/src/VBox/Devices/Network/lwip-new/vbox/include/lwip-log.h @@ -0,0 +1,93 @@ +/* -*- indent-tabs-mode: nil; -*- */ +#ifndef __VBOX_LWIP_LOG_H__ +#define __VBOX_LWIP_LOG_H__ + +#include <VBox/log.h> + +#ifdef LWIP_DEBUG +/* + * All LWIP_DBG_* constants fit into a byte, so we use upper bits to + * encode the VBox log group. + * + * Mapping between FOO_DEBUG and LOG_GROUP_LWIP_FOO is straightforward + * except for IP4 where extra '4' was added to the group names to make + * it possible to specify lwip_ip4* instead of lwip_ip*, where the + * latter would enable both IP4 and IP6 logging. + * + * We ignore LWIP_DBG_STATE &c since in our scheme they would traslate + * into additional log groups and require combinatorial explosion. We + * probably can use LWIP_DBG_TYPES_ON for finer selection if need be + * (for internal debugging only, as it requires recompilation). + * + * Debug levels are mapped to RT debug levels so lwip's default level + * ends up as RT's level4. Non-default levels are currently not used + * much in lwip sources, so enable l4 to get the logs. + */ + +#define LWIP_DEBUGF_LOG_GROUP_SHIFT 8 +#define LWIP_DEBUGF_LOG_GROUP(_g) \ + (((_g) << LWIP_DEBUGF_LOG_GROUP_SHIFT) | LWIP_DBG_ON) + +#define API_LIB_DEBUG LWIP_DEBUGF_LOG_GROUP(LOG_GROUP_LWIP_API_LIB) +#define API_MSG_DEBUG LWIP_DEBUGF_LOG_GROUP(LOG_GROUP_LWIP_API_MSG) +#define ETHARP_DEBUG LWIP_DEBUGF_LOG_GROUP(LOG_GROUP_LWIP_ETHARP) +#define ICMP_DEBUG LWIP_DEBUGF_LOG_GROUP(LOG_GROUP_LWIP_ICMP) +#define IGMP_DEBUG LWIP_DEBUGF_LOG_GROUP(LOG_GROUP_LWIP_IGMP) +#define INET_DEBUG LWIP_DEBUGF_LOG_GROUP(LOG_GROUP_LWIP_INET) +#define IP_DEBUG LWIP_DEBUGF_LOG_GROUP(LOG_GROUP_LWIP_IP4) +#define IP_REASS_DEBUG LWIP_DEBUGF_LOG_GROUP(LOG_GROUP_LWIP_IP4_REASS) +#define IP6_DEBUG LWIP_DEBUGF_LOG_GROUP(LOG_GROUP_LWIP_IP6) +#define MEM_DEBUG LWIP_DEBUGF_LOG_GROUP(LOG_GROUP_LWIP_MEM) +#define MEMP_DEBUG LWIP_DEBUGF_LOG_GROUP(LOG_GROUP_LWIP_MEMP) +#define NETIF_DEBUG LWIP_DEBUGF_LOG_GROUP(LOG_GROUP_LWIP_NETIF) +#define PBUF_DEBUG LWIP_DEBUGF_LOG_GROUP(LOG_GROUP_LWIP_PBUF) +#define RAW_DEBUG LWIP_DEBUGF_LOG_GROUP(LOG_GROUP_LWIP_RAW) +#define SOCKETS_DEBUG LWIP_DEBUGF_LOG_GROUP(LOG_GROUP_LWIP_SOCKETS) +#define SYS_DEBUG LWIP_DEBUGF_LOG_GROUP(LOG_GROUP_LWIP_SYS) +#define TCP_CWND_DEBUG LWIP_DEBUGF_LOG_GROUP(LOG_GROUP_LWIP_TCP_CWND) +#define TCP_DEBUG LWIP_DEBUGF_LOG_GROUP(LOG_GROUP_LWIP_TCP) +#define TCP_FR_DEBUG LWIP_DEBUGF_LOG_GROUP(LOG_GROUP_LWIP_TCP_FR) +#define TCP_INPUT_DEBUG LWIP_DEBUGF_LOG_GROUP(LOG_GROUP_LWIP_TCP_INPUT) +#define TCP_OUTPUT_DEBUG LWIP_DEBUGF_LOG_GROUP(LOG_GROUP_LWIP_TCP_OUTPUT) +#define TCP_QLEN_DEBUG LWIP_DEBUGF_LOG_GROUP(LOG_GROUP_LWIP_TCP_QLEN) +#define TCP_RST_DEBUG LWIP_DEBUGF_LOG_GROUP(LOG_GROUP_LWIP_TCP_RST) +#define TCP_RTO_DEBUG LWIP_DEBUGF_LOG_GROUP(LOG_GROUP_LWIP_TCP_RTO) +#define TCP_WND_DEBUG LWIP_DEBUGF_LOG_GROUP(LOG_GROUP_LWIP_TCP_WND) +#define TCPIP_DEBUG LWIP_DEBUGF_LOG_GROUP(LOG_GROUP_LWIP_TCPIP) +#define TIMERS_DEBUG LWIP_DEBUGF_LOG_GROUP(LOG_GROUP_LWIP_TIMERS) +#define UDP_DEBUG LWIP_DEBUGF_LOG_GROUP(LOG_GROUP_LWIP_UDP) + +/* + * The following symbols are for debugging of modules that are not + * compiled in. They are listed here for reference but there're no + * log groups defined for them currently. + */ +#undef AUTOIP_DEBUG +#undef DHCP_DEBUG +#undef DNS_DEBUG +#undef PPP_DEBUG +#undef SLIP_DEBUG +#undef SNMP_MIB_DEBUG +#undef SNMP_MSG_DEBUG + +#ifdef LOG_ENABLED + +#define LWIP_DEBUGF(_when, _args) \ + do { \ + const VBOX_LOGGROUP _group = (_when) >> LWIP_DEBUGF_LOG_GROUP_SHIFT; \ + if (_group >= LOG_GROUP_DEFAULT) { \ + /* severe => l1; serious => l2; warning => l3; default => l4 */ \ + const unsigned int _level = \ + 1 << (LWIP_DBG_MASK_LEVEL+1 - ((_when) & LWIP_DBG_MASK_LEVEL)); \ + LogIt(LOG_INSTANCE, _level, _group, _args); \ + } \ + } while (0) + +#else /* !LOG_ENABLED */ + +#define LWIP_DEBUGF(_when, _args) do { } while (0) + +#endif /* !LOG_ENABLED */ + +#endif /* LWIP_DEBUG */ +#endif /* __VBOX_LWIP_LOG_H__ */ diff --git a/src/VBox/Devices/Network/lwip-new/vbox/include/lwip-namespace.h b/src/VBox/Devices/Network/lwip-new/vbox/include/lwip-namespace.h index f5e3f35f0..41c0ffeda 100644 --- a/src/VBox/Devices/Network/lwip-new/vbox/include/lwip-namespace.h +++ b/src/VBox/Devices/Network/lwip-new/vbox/include/lwip-namespace.h @@ -88,11 +88,14 @@ #define netif_set_netmask lwip_netif_set_netmask #define netif_set_up lwip_netif_set_up #if MEM_LIBC_MALLOC == 0 -#define mem_free lwip_mem_free +#if MEM_USE_POOLS == 0 #define mem_init lwip_mem_init +#define mem_trim lwip_mem_trim +#endif /* !MEM_USE_POOLS */ #define mem_malloc lwip_mem_malloc -#define mem_realloc lwip_mem_realloc -#endif +#define mem_calloc lwip_mem_calloc +#define mem_free lwip_mem_free +#endif /* !MEM_LIBC_MALLOC */ #define memp_free lwip_memp_free #define memp_init lwip_memp_init #define memp_malloc lwip_memp_malloc @@ -147,7 +150,7 @@ #define sys_sem_free lwip_sys_sem_free #define sys_sem_new lwip_sys_sem_new #define sys_sem_signal lwip_sys_sem_signal -#define lwip_sys_sem_wait lwip_sys_arch_sem_wait +#define lwip_sys_sem_wait sys_sem_wait #define sys_arch_sem_wait lwip_sys_arch_sem_wait #endif #define sys_timeout_debug lwip_sys_timeout_debug @@ -221,19 +224,4 @@ #define lwip_pbuf_init() #define lwip_etharp_init() -#ifndef htons -# define htons lwip_htons -#endif - -#ifndef ntohs -# define ntohs lwip_ntohs -#endif - -#ifndef htonl -# define htonl lwip_htonl -#endif - -#ifndef ntohl -# define ntohl lwip_ntohl -#endif #endif /* _VBOX_LWIP_NAMESPACE_H_ */ diff --git a/src/VBox/Devices/Network/lwip-new/vbox/include/lwipopts.h b/src/VBox/Devices/Network/lwipopts.h index befb1d2d3..bc7193168 100644 --- a/src/VBox/Devices/Network/lwip-new/vbox/include/lwipopts.h +++ b/src/VBox/Devices/Network/lwipopts.h @@ -110,23 +110,21 @@ #define SYS_LIGHTWEIGHT_PROT 1 /** Attempt to get rid of htons etc. macro issues. */ -#define LWIP_PREFIX_BYTEORDER_FUNCS - -#define LWIP_NOASSERT 0 +#undef LWIP_PREFIX_BYTEORDER_FUNCS #define LWIP_TCPIP_CORE_LOCKING_INPUT 0 #define LWIP_TCPIP_CORE_LOCKING 0 #define LWIP_TCP 1 #define LWIP_SOCKET 1 #define LWIP_ARP 1 -#define ARP_PROXY 1 +#define ARP_PROXY 0 #define LWIP_ETHERNET 1 #define LWIP_COMPAT_SOCKETS 0 #define LWIP_COMPAT_MUTEX 1 #define LWIP_IPV6 1 -#define LWIP_IPV6_FORWARD 1 -#define LWIP_ND6_PROXY 1 +#define LWIP_IPV6_FORWARD 0 +#define LWIP_ND6_PROXY 0 #define LWIP_ND6_ALLOW_RA_UPDATES (!LWIP_IPV6_FORWARD) #define LWIP_IPV6_SEND_ROUTER_SOLICIT (!LWIP_IPV6_FORWARD) @@ -143,8 +141,8 @@ /** * aka Slirp mode. */ -#define LWIP_CONNECTION_PROXY 1 -#define IP_FORWARD 1 +#define LWIP_CONNECTION_PROXY 0 +#define IP_FORWARD 0 /* MEMP_NUM_SYS_TIMEOUT: the number of simultaneously active timeouts. */ @@ -156,51 +154,8 @@ /* Debugging stuff. */ #ifdef DEBUG -/* filter in debugging severity */ -# define DBG_TYPES_ON (LWIP_DBG_ON | LWIP_DBG_TRACE | LWIP_DBG_STATE | LWIP_DBG_FRESH | LWIP_DBG_HALT) -# define DBG_MIN_LEVEL 0 - -# define LWIP_DEBUG LWIP_DBG_ON -/* Ethernet & ARP debugging */ -# define ETHARP_DEBUG LWIP_DBG_ON -/* IPv4 debugging */ -# define IP_DEBUG LWIP_DBG_ON -# define IP_REASS_DEBUG LWIP_DBG_ON -/* IPv6 debugging */ -# define IP6_DEBUG LWIP_DBG_ON -/* ICMP debugging */ -# define ICMP_DEBUG LWIP_DBG_ON -/* TCP debugging */ -# define TCP_DEBUG LWIP_DBG_ON -# define TCP_INPUT_DEBUG LWIP_DBG_ON -# define TCP_FR_DEBUG LWIP_DBG_ON -# define TCP_RTO_DEBUG LWIP_DBG_ON -# define TCP_CWND_DEBUG LWIP_DBG_ON -# define TCP_WND_DEBUG LWIP_DBG_ON -# define TCP_OUTPUT_DEBUG LWIP_DBG_ON -# define TCP_RST_DEBUG LWIP_DBG_ON -# define TCP_QLEN_DEBUG LWIP_DBG_ON -/* RAW API debugging */ -/* API debugging */ -# define NETIF_DEBUG LWIP_DBG_ON -# define PBUF_DEBUG LWIP_DBG_ON -# define API_LIB_DEBUG LWIP_DBG_ON -# define API_MSG_DEBUG LWIP_DBG_ON -# define SOCKETS_DEBUG LWIP_DBG_ON - -# define INET_DEBUG LWIP_DBG_ON -# define RAW_DEBUG LWIP_DBG_ON -# define MEM_DEBUG LWIP_DBG_ON -# define MEMP_DEBUG LWIP_DBG_ON -# define SYS_DEBUG LWIP_DBG_ON - -# define UDP_DEBUG LWIP_DBG_ON -# define TCPIP_DEBUG LWIP_DBG_ON -# define DHCP_DEBUG LWIP_DBG_ON - -# define LWIP_PROXY_DEBUG LWIP_DBG_ON -/* Debug checks */ -# define TCP_OVERSIZE_DBGCHECK 1 +# define LWIP_DEBUG +# include "lwip-log.h" #endif /* DEBUG */ /* printf formatter definitions */ |
