diff --git a/CHANGELOG b/CHANGELOG index 1681f0ca..d9329c1d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -145,6 +145,20 @@ HISTORY ++ Bugfixes: + 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 diff --git a/src/api/tcpip.c b/src/api/tcpip.c index 72794f12..1c5209e8 100644 --- a/src/api/tcpip.c +++ b/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/pppoe.h" diff --git a/src/core/netif.c b/src/core/netif.c index e7a87c3c..068c3e5d 100644 --- a/src/core/netif.c +++ b/src/core/netif.c @@ -769,16 +769,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); + 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 */ - 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; - } + /* 'in_end' now points to the last pbuf from 'in' */ if (in_end == netif->loop_last) { /* this was the last pbuf in the list */ diff --git a/src/core/snmp/mib2.c b/src/core/snmp/mib2.c index dcd3b62c..fe1bf6d7 100644 --- a/src/core/snmp/mib2.c +++ b/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/core/timers.c b/src/core/timers.c index c8ead4e7..94e8029a 100644 --- a/src/core/timers.c +++ b/src/core/timers.c @@ -326,16 +326,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", @@ -437,7 +455,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/include/ipv6/lwip/ip6_addr.h b/src/include/ipv6/lwip/ip6_addr.h index 89b5b811..555f77c1 100644 --- a/src/include/ipv6/lwip/ip6_addr.h +++ b/src/include/ipv6/lwip/ip6_addr.h @@ -170,6 +170,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)) diff --git a/src/include/lwip/snmp.h b/src/include/lwip/snmp.h index 2ed043dd..7844cc11 100644 --- a/src/include/lwip/snmp.h +++ b/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/include/lwip/sockets.h b/src/include/lwip/sockets.h index 4d6e055a..853beea8 100644 --- a/src/include/lwip/sockets.h +++ b/src/include/lwip/sockets.h @@ -167,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