Commit Graph

2555 Commits

Author SHA1 Message Date
Jisu Kim
bd94297115 icmp6_send_response() sends the pointer in network byte order (see patch #9455: IPv6 ready test on RFC2460)
Signed-off-by: goldsimon <goldsimon@gmx.de>
2017-09-16 22:46:42 +02:00
Jisu Kim
27b7ed17fc First step to passing IPV6 Ready test: time out IPv6 fragments after 60 seconds
(added IPV6_REASS_MAXAGE as an option that is independent of the IPv4 setting)

Signed-off-by: goldsimon <goldsimon@gmx.de>
2017-09-16 22:41:35 +02:00
goldsimon
14919e34a1 icmp_input: fix possibly unused variable (used for debug output only) 2017-09-15 11:44:22 +02:00
Jakub Schmidtke
b7e5de389e Fixed removing unneeded TCP SACKs
TCP SACKs were removed after some changes in the ooseq queue,
but before all unneeded packets were removed from it.
Because of that, we would sometimes include SACKs
for data already delivered in-order.

Signed-off-by: goldsimon <goldsimon@gmx.de>
2017-09-09 21:51:13 +02:00
goldsimon
86abfbe087 Fix bug #51937 by checking TF_CLOSED at the end of all pcb callbacks in tcp_input() 2017-09-09 21:46:41 +02:00
goldsimon
a8ac37f419 refactor tcp_input a bit in preparation of a fix for bug #51937 2017-09-09 21:41:06 +02:00
Our Air Quality
dc7a9c8c37 tcp_in: correct some loops continuing without maintaining a prev pointer.
This problem would appear to have only affected systems with multiple
interfaces. It was noted causing tcp resets when the pcb was lost, and there
might have been other associated problems.

Signed-off-by: Dirk Ziegelmeier <dirk@ziegelmeier.net>
2017-09-04 07:48:37 +02:00
Joel Cunningham
28e519b72d tcp_output: move useg assignment to right before segment while loop
There were a couple cases in-between that could cause an exit from
tcp_output which don't use useg. With large send buffers, pcb->unacked
may be large and calculating useg is wasted in these exit cases

Some compilers may be re-ordering this already, but it doesn't hurt to
correctly arrange the code
2017-08-29 16:59:39 -05:00
goldsimon
1d4ca0bff6 Fix bug #51687 (tcp_close(): is it OK to return ERR_MEM if TF_CLOSEPEND is set?) 2017-08-28 21:59:05 +02:00
goldsimon
c7edfdf987 Fix bug #51765 and fix commit 90873d6: call tcp_rexmit_fast() more than once on dupacks since the actual transmission is guarded by TF_INFR, not by pcb->dupacks 2017-08-25 21:16:59 +02:00
Joel Cunningham
f582c88339 tcp: persist timer re-work (bug #50837)
This re-works the persist timer to have the following behavior:

  1) Only start persist timer when a buffered segment doesn't fit within
     the current window and there is no in-fligh data.  Previously, the
     persist timer was always started when the window went to zero even
     if there was no buffered data (since timer was managed in receive
     pathway rather than transmit pathway)
  2) Upon first fire of persist timer, fill the remaining window if
     non-zero by splitting the unsent segment.  If split segment is sent,
     persist timer is stopped, RTO timer is now ensuring reliable window
     updates
  3) If window is already zero when persist timer fires, send 1 byte probe
  4) Persist timer and zero window probe should only be active when the
     following are true:
       * no in-flight data (pcb->unacked == NULL)
       * when there is buffered data (pcb->unsent != NULL)
       * when pcb->unsent->len > pcb->snd_wnd
2017-08-25 09:35:10 -05:00
goldsimon
1ed1cfe83a TCP: simplify trimming left edge & use pbuf_remove_header() instead of pbuf_header() 2017-08-21 22:34:44 +02:00
goldsimon
bd8709bc82 Simplify pbuf_remove_header() a bit 2017-08-21 22:33:01 +02:00
goldsimon
3c5398403d fix pbuf_split_64k() for zero-length pbufs 2017-08-21 22:08:53 +02:00
Joel Cunningham
9844049cb1 lwip_itoa: fix converting 0 (bug #51729)
lwip_itoa would output the number 0 as \0.  This fixes the issue by
adding a special check before the normal conversion loop

This was found via shell cmd idxtoname and win32 port.  "lo0" should
be returned for index 1
2017-08-11 13:38:51 -05:00
Joel Cunningham
3d82155d29 tcp: use TCP_WND_INC for dupack > 3 case
TCP_WND_INC abstracts the rollover handling and allows the window to
reach it's maximum value
2017-08-09 16:28:55 -05:00
Joel Cunningham
b8a3cf3a4a tcp: use tcp_set_flags() rather than manually setting flag 2017-08-09 12:15:52 -05:00
Joel Cunningham
ba7a3204cb tcp: use tcp_ack_now rather than manually setting TF_ACK_NOW 2017-08-09 10:13:41 -05:00
goldsimon
90873d6c71 Continue fixing the spirit of bug #51663: don't change pcb state if retransmission can't be done because segments are still queued for transmission
- add a better-documented static function tcp_output_segment_busy
- try to reduce the number of checks
- tcp_rexmit_rto: iterate pcb->unacked only once
- no need to check for ref==1 in tcp_rexmit_fast when tcp_rexmit does
- call tcp_rexmit_fast if dupacks >= 3 (not == 3) and use TF_INFR flag to guard the fast-rexmit case (that way, it's triggered again on the next dupack)
2017-08-08 23:02:14 +02:00
Our Air Quality
6a01607004 tcp_out rto: delay re-transmission earlier if link writes are deferred.
There is already a guard in tcp_output_segment() for a pbuf still being
referenced by the netif driver due to deferred transmission, however the callers
are modifying state even when this gives up.

It seems cleaner to have the callers guard this case and avoid modifying their
state.

tcp_rexmit_rto() might better avoid re-transmission of any segments if any of
the unacked segments are deferred, to avoid loading the link further if it is
struggling to flush its buffered writes. Link level queues can be limited on
some devices and need spares for link management.
2017-08-08 22:20:02 +02:00
goldsimon
991f751305 Even more pbuf_header -> pbuf_add/remove_header replacements (also in strings) 2017-08-08 20:51:57 +02:00
goldsimon
07434aa73a More pbuf_header -> pbuf_add/remove_header replacements 2017-08-08 20:40:26 +02:00
goldsimon
6d28e9de79 Some cleanups after applying David Girault's altcp patches 2017-08-08 12:59:49 +02:00
David Girault
ee89d906ec altcp_tcp: some fixes
- expose `altcp_tcp_setup()` so we can wrap altcp over existing tcp pcb.
- avoid calling tcp_close() with NULL pcb.
- free altcp_pcb struct when error callback called.

According to `mqtt_tcp_err_cb()` in src/apps/mqtt/mqtt.c, altcp socket should
work the same way than raw tcp socket. So freeing altcp_pcb ensure this.
2017-08-08 12:59:46 +02:00
David Girault
9d120c59ea altcp: fix altcp_free
call dealloc function in altcp_free() so it can be propagate it to inner_conn.
2017-08-08 12:59:45 +02:00
Dirk Ziegelmeier
60dd518887 Implement task #14594: Improve consistency of ip route API parameters
reverse parameters of ip4_route_src to be consistent with other ip*_route* functions
This commit will break applications using this function!
2017-08-08 12:41:19 +02:00
goldsimon
ae7c76c773 Rework pbuf_add_header_impl to only modify the pbuf after all checks passed 2017-08-08 12:19:06 +02:00
Dirk Ziegelmeier
6209c8d347 Fix bug #51686: pbuf_remove_header: silence unused variable warning
but in another way than the provided patch
2017-08-08 12:13:45 +02:00
Dirk Ziegelmeier
e65a388c1f ip4.c does not need to #include prot/dhcp.h any more 2017-08-08 11:49:00 +02:00
Dirk Ziegelmeier
1c91118f4a Add DHCP ports to iana.h 2017-08-08 11:46:15 +02:00
Dirk Ziegelmeier
5193844ac4 iana.h: Prefix #defines with LWIP_ 2017-08-08 11:21:11 +02:00
Dirk Ziegelmeier
79a08c9fee tcp.c: Remove side-effects from boolean expressions 2017-08-08 11:05:23 +02:00
Dirk Ziegelmeier
629ec98dd8 Work on task #14587: Create common header for IANA assigned numbers
Create include/lwip/prot/iana.h
Move DHCP and ARP #define in there
2017-08-07 21:06:19 +02:00
goldsimon
4fb7fab850 Fix docs on dhcp_option_trailer() 2017-08-07 08:08:24 +02:00
Our Air Quality
ff588fc771 dhcp: quieten a compile unused variable warning 2017-08-06 21:21:10 +02:00
goldsimon
a1c7924cb6 task #14597: cleanup pbuf_header usages (use pbuf_add_header/pbuf_remove_header instead) 2017-08-04 22:38:11 +02:00
goldsimon
a681f6b04f Fix using LWIP_HOOK_DHCP_PARSE_OPTION after recent dhcp changes 2017-08-04 21:53:24 +02:00
goldsimon
cd80e38db8 Clean up DHCP a bit: no need keep msg_out and msg_in as members in struct dhcp
They are used in a call stack only (p_out and options_out_len as well)
2017-08-04 21:26:29 +02:00
goldsimon
65ac160e99 Wconversion-related cleanup: split pbuf_header(s16_t) into pbuf_add_header(size_t) and pbuf_remove_header(size_t)
The new functions both take size_t as increment/decrement argument instead of s16_t (which needed to be range-checked before conversion everywhere) - in most places, the direction (increment or decrement) is known anyway, so no need to encode it in a sign bit
2017-08-04 13:16:18 +02:00
Joel Cunningham
6fa5d02435 tcp: remove extra seg == NULL checks
In tcp_output() there were a number of blocks of code performing
duplicate checks of 'if (seg == NULL)'.  This combines them together
to reduce duplicate checks

TCP_OUTPUT_DEBUG and TCP_CWND_DEBUG also don't need to be guarded
by #if/#endif since the LWIP_DEBUGF infrastructure already compiles them
out when LWIP_DEBUG is not defined
2017-08-03 10:37:16 -05:00
goldsimon
5ea7f507c3 Fixed bugs #51606 and #51535: IPv4 reassembly could be finished although there are holes 2017-08-02 21:11:53 +02:00
Axel Lin
2781d7abd7 ip6_reass: Move update ip6_frag.drop stats to nullreturn
The ip6_frag.drop counter is updated before all the code paths calling
goto nullreturn, so let's move updating ip6_frag.drop stats to nullreturn.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
2017-08-01 20:48:08 +02:00
goldsimon
a81b19aa62 Fixed bug #51623: DHCP request XID should probably be regenerated for INIT-REBOOT 2017-07-31 20:20:31 +02:00
Joel Cunningham
2b2ea50cb1 ip4: fix swapped src/dst params with ip4_route_src
This fixes a couple of occurrences where the src and dst parameters to
ip4_route_src() were swapped. This was most likely due to confusion between
ip_route(src, dst) and ip4_route_src(dst, src)

This was found in a system where LWIP_IPV4_SRC_ROUTING is 0

The UDP case was an application socket bound to INADDR_ANY with
IP_MULTICAST_IF set. Transmits would result in calling ip4_route(dst) where
dst was pcb->local_addr (which was INADDR_ANY) instead of pcb->mcast_ip4.
This resulted in a routing failure

The ICMP issue was found through code analysis only
2017-07-31 08:57:11 -05:00
Dirk Ziegelmeier
006bb84368 Fix bug #50883: struct eth_addr alignment does not fit with ETHADDR16_COPY
... by simply removing ETHADDR16_COPY since noone advocated to keep it
2017-07-30 17:48:16 +02:00
goldsimon
500598658d ip4_reass: fixed bug #51596 (Insufficient overlap check) 2017-07-28 10:11:45 +02:00
goldsimon
3dedfa3d1f ip4_reass: fixed bug #51597 (Last fragment is assumed to have arrived even if it was discarded) 2017-07-28 09:46:56 +02:00
goldsimon
f1072fee8a ip4_reass: fixed bug #51595 (ip_reass_pbufcount may be updated incorectly) 2017-07-28 09:41:00 +02:00
Our Air Quality
ff03ae6f55 dhcp: restart dhcp after releasing.
There were uses of dhcp_release() followed immediately by dhcp_discover() but
dhcp_release() now stops dhcp so discovery would fail, so call dhcp_start()
after release which restarts discovery.

Signed-off-by: Dirk Ziegelmeier <dirk@ziegelmeier.net>
2017-07-28 07:57:50 +02:00
Axel Lin
925f3944d3 init: Correct minimal MEMP_NUM_SYS_TIMEOUT setting check
According to commit 1f780e86d5 ("PPP timeouts required depend on the number of allowed PPP sessions"):
Per PPP needs 6 timeouts (AUTH + PAP|CHAP|EAP + LCP + IPCP + IP6CP + PPPoE).

So update the minimal MEMP_NUM_SYS_TIMEOUT setting check accordingly.
Since we have LWIP_NUM_SYS_TIMEOUT_INTERNAL so just switch to use it.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: goldsimon <goldsimon@gmx.de>
2017-07-27 20:51:11 +02:00
goldsimon
a2e4dd2de7 Minor whitespace cleanups 2017-07-25 21:48:17 +02:00
Matthias Hofmann
9b06d71aeb Fix using DHCP IP configuration after lease time is expired.
Signed-off-by: goldsimon <goldsimon@gmx.de>
2017-07-25 21:46:57 +02:00
goldsimon
9b5d8f14a9 tcp_getoptbyte() -> tcp_get_next_optbyte() (to make it clearer that this function modifies something - not only a getter) 2017-07-25 21:38:06 +02:00
Pascal Quantin
2e78b6dcae Fixed bug #51528 (Bug when parsing WND_SCALE option)
Signed-off-by: goldsimon <goldsimon@gmx.de>
2017-07-24 21:38:47 +02:00
goldsimon
26771d0800 Add @todo: scope ip6addr? 2017-07-18 19:17:17 +02:00
Our Air Quality
5eff45cac0 Correct a few uses of sizeof(ip6_addr_t) to sizeof(ip6_addr_p_t)
The ip6_addr_t structure may have an addition slot so is not necessarily
the size of an ipv6 address, so some uses of sizeof(ip6_addr_t) were not
correct.

Signed-off-by: goldsimon <goldsimon@gmx.de>
2017-07-18 19:17:17 +02:00
Joel Cunningham
7b13fae833 docs: update references to global igmp_group_list
This updates documentation to refer to netif specific igmp group list rather
than the old global igmp_group_list
2017-07-17 14:25:14 -05:00
Dirk Ziegelmeier
328134fdba Fix two -Wconversion warnings 2017-07-15 10:25:45 +02:00
Dirk Ziegelmeier
aa317dcb18 Fix dhcp documentation 2017-07-12 11:09:36 +02:00
Dirk Ziegelmeier
d021972785 Fix "no previous prototype" warning when TCP_QUEUE_OOSEQ is disabled 2017-07-11 09:59:11 +02:00
Dirk Ziegelmeier
449eb64fcb Fix my last commit - break is missing 2017-07-10 09:52:48 +02:00
Dirk Ziegelmeier
57b1471254 Avoid return in case statement, makes function control flow equal to other case statement paths 2017-07-10 09:40:21 +02:00
Dirk Ziegelmeier
9130d37df7 Add "fall through" statement to Axel's patch 2017-07-10 09:37:59 +02:00
Axel Lin
6f28a874b8 pbuf: Simplify pbuf_alloc a bit
No need to have additional if statement for PBUF_REF/PBUF_ROM.
It can be merged to the existing swtich(type) cases.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
2017-07-10 09:37:07 +02:00
goldsimon
f3c860958f -Wconversion (still far from finished) and other minor compilation fixes... 2017-07-06 22:47:11 +02:00
goldsimon
b8ecfe640c work on -Wconversion... 2017-07-06 12:38:50 +02:00
goldsimon
694fc7e472 work on -Wconversion... 2017-07-06 11:22:38 +02:00
goldsimon
9d61e36466 work on -Wconversion, fixed some const bug in ip4 2017-07-06 09:01:03 +02:00
goldsimon
44f7a3cb0d work on -Wconversion... 2017-07-05 22:31:58 +02:00
goldsimon
c5607d3889 Fix compiling ASSERT (broken some commits ago) 2017-07-05 12:22:02 +02:00
goldsimon
ba6b504cc0 work on -Wconversion... 2017-07-05 12:20:26 +02:00
goldsimon
9a40597ced work on -Wconversion... 2017-07-04 21:31:30 +02:00
goldsimon
debf34ff9c work on -Wconversion... 2017-07-04 21:26:30 +02:00
goldsimon
2b2fa0ed71 Ensure SACKs are deleted when pbuf_free_ooseq() frees ooseq pbufs (because of memory shortage) 2017-07-04 20:10:23 +02:00
goldsimon
0b91888eb1 remove invalid TODO comment 2017-07-04 20:09:41 +02:00
goldsimon
1a1c360f1d Fixed LWIP_TCP_SACK_VALID and its usage 2017-07-03 21:41:34 +02:00
goldsimon
6796bcf7ad Cleaned up a bit after merging SACK_OUT support (mostly coding style) 2017-07-03 21:20:56 +02:00
Jakub Schmidtke
b1a3c37c3c Partial SACK (RFC 2018) support
Adds partial support for selective acknowledgements (RFC 2018).
This change makes lwIP negotiate SACK support, and include SACK
data in outgoing empty ACK packets. It does not include it
in outgoing packets with data payload.
It also does not add support for handling incoming SACKs.

Signed-off-by: goldsimon <goldsimon@gmx.de>
2017-07-03 20:17:30 +02:00
goldsimon
d262132b92 work on -Wconversion... 2017-07-03 20:15:02 +02:00
Dirk Ziegelmeier
94beb4eddf Make inet_chksum.c compile with -Wconversion 2017-06-30 22:17:32 +02:00
goldsimon
41177cfd1c work on -Wconversion... 2017-06-30 22:10:16 +02:00
goldsimon
c636072362 pbuf.c: work on -Wconversion... 2017-06-29 22:49:39 +02:00
goldsimon
5bddbdd914 tcp_output: faster return when nothing is to send (pcb->unsent == NULL) 2017-06-29 08:47:26 +02:00
goldsimon
48e55b1e5d tcp_output: slightly move the jump target 'output_done': when nothing is to send, pcb->unsent cannot be NULL; add a 2017-06-29 08:43:59 +02:00
goldsimon
092c6c1f07 DNS_MAX_SOURCE_PORTS is PP-checked to be <= 255... 2017-06-26 08:48:17 +02:00
goldsimon
5efe26ebd3 Fix the fix for LWIP_LOOPBACK_MAX_PBUFS :-) 2017-06-26 08:21:53 +02:00
goldsimon
5b15234833 work on -Wconversion... 2017-06-25 23:01:57 +02:00
goldsimon
197166d906 LWIP_LOOPBACK_MAX_PBUFS: fix compilation or memory leak for LWIP_LOOPBACK_MAX_PBUFS > 255 2017-06-25 20:31:09 +02:00
goldsimon
af0f4d4020 Start making the source compile correctly with gcc -Wconversion enabled 2017-06-23 21:15:36 +02:00
Dirk Ziegelmeier
d02a73c285 Replace usages of tcpip_callback_with_block(foo, bar, 0) with tcpip_try_callback() 2017-06-22 08:14:02 +02:00
goldsimon
c094fcc086 Try to make gcc work without -Wno-address 2017-06-21 16:07:36 +02:00
goldsimon
79d69ce526 Slightly optimize pbuf_alloc: encode 'header offset' in 'enum pbuf_layer' instead of switch/case (which was duplicated in pbuf_alloc and pbuf_alloced_custom) 2017-06-21 13:37:05 +02:00
goldsimon
11da4ef024 Use ip_addr_debug_print_val instead of ip_addr_debug_print where applicable 2017-06-21 13:26:55 +02:00
Axel Lin
aa98747d6f timeouts: Trivial comment fix for cyclic_timer
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: goldsimon <goldsimon@gmx.de>
2017-06-21 13:11:48 +02:00
goldsimon
f13b1340f2 Refine comment changed by last commit 2017-06-20 20:53:39 +02:00
Jakub Schmidtke
112e370457 Sending TCP timestamp option in SYN packets
TCP timestamps were only sent if the remote side
requested it first. This enables the use of timestamps
for outgoing connections as well.

Signed-off-by: goldsimon <goldsimon@gmx.de>
2017-06-20 20:51:50 +02:00
Our Air Quality
6e62b6090b Silence some unsed variable warnings. 2017-06-19 14:09:07 +02:00
Axel Lin
02aaf12f48 stats: Use proper format modifier in stats_display_mem/stats_display_sys
Use proper format modifier and remove unnecessary cast.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
2017-06-19 14:07:31 +02:00
Dirk Ziegelmeier
c923d00340 Fix bug #51238: LWIP_ARRAYSIZE() can't be used on lwip_cyclic_timers
Add const int variable containing number of array elements
2017-06-14 23:07:55 +02:00
goldsimon
67d1970059 pbuf_alloced_custom(): less code duplication, please :-) 2017-06-14 21:39:53 +02:00
Dirk Ziegelmeier
d5cdb91611 Fix compile of Axel Lin's patch 2017-06-14 12:30:55 +02:00
Axel Lin
6b4cc984ad pbuf: Allow pass flags to pbuf_init_alloced_pbuf()
Then we can reuse pbuf_init_alloced_pbuf() in pbuf_alloced_custom().

Signed-off-by: Axel Lin <axel.lin@ingics.com>
2017-06-14 12:28:29 +02:00
goldsimon
7b45f3fa3f Fix sys_timeouts_init() for LWIP_TCP==0 (see patch #9375) 2017-06-13 22:04:57 +02:00
Axel Lin
e1ce5dc491 mem: Move LWIP_DEBUGF out of critical section in mem_malloc
Signed-off-by: Axel Lin <axel.lin@ingics.com>
2017-06-13 22:02:17 +02:00
Joel Cunningham
3eaf976152 tcp: fix cwnd rollover introduced by ABC
Changes for TCP Appropriate Byte Counting introduce a potential cwnd
rollover by not taking into account integer promotion on tcpwnd_size_t
during inequality comparisions

This fixes the issue by introducing a macro TCP_WND_INC which detects
the rollover correctly and now holds the tcpwnd_size_t at the maximum
value rather than not incrementing the window.  This provides a slight
performance improvement by allowing full use of the tcpwnd_size_t number
space for the congestion window
2017-06-01 12:34:57 -05:00
David Girault
dc2bdc2a21 memp: allow initialization of pool memory if not in standard section 2017-05-31 19:11:33 +02:00
Axel Lin
3aca7885a7 pbuf: Init pbuf if_idx to NETIF_NO_INDEX in pbuf_alloced_custom
Otherwise the p->pbuf.if_idx is uninitialized.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
2017-05-31 19:10:00 +02:00
goldsimon
ba1cf2fa44 memp malloc: move LWIP_DEBUGF out of critical section (bug #51142) 2017-05-30 11:39:42 +02:00
Tim Cussins
84502e5ae0 etharp.c: Ensure etharp_query() allocates adequate pbuf if copying/consolidating.
etharp_query() queues packets, instead of sending, if a relevant arp-request is
pending.

Code walks the packet (a pbuf chain) to determine whether any pbufs are marked
'volatile': If so, we cannot simply enqueue the packet, and instead allocate a
new pbuf from RAM, copying the original packet, and enqueueing this new pbuf.

The bug here is that the allocation refers to the tot_len field of a temp pbuf*,
'p', instead of the head, 'q'.

In the case where the first pbuf of the chain is non-volatile but the second pbuf
*is* volatile, then we'll request an allocation that uses the tot_len field of
the second pbuf. If the first pbuf is non-zero length, the allocated pbuf (chain)
will be too small to allow the copy.

Signed-off-by: goldsimon <goldsimon@gmx.de>
2017-05-29 21:48:51 +02:00
Our Air Quality
fb9fabb87c Initialize the tcp listen pcb netif_idx to NETIF_NO_INDEX.
Signed-off-by: goldsimon <goldsimon@gmx.de>
2017-05-29 21:48:51 +02:00
Axel Lin
cbbfb1356c pbuf: Make pbuf_init_alloced_pbuf take pbuf_type instead of u8_t for type parameter
All callers pass pbuf_type to pbuf_init_alloced_pbuf(), so make it take
pbuf_type instead of u8_t.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: goldsimon <goldsimon@gmx.de>
2017-05-24 12:19:32 +02:00
goldsimon
356da76cc8 Work on bug #3031/task #7896: change pbuf->type/enum pbuf_type to be more generic (see UPGRADING) 2017-05-22 22:30:55 +02:00
goldsimon
5c65402fd6 minor: whitespace change only to make the next diff smaller :-) 2017-05-22 22:30:19 +02:00
goldsimon
20fd844935 fixed typo in docs 2017-05-11 21:26:34 +02:00
Joel Cunningham
c03fef9a3c bug #50837: add zero-window probe timeout
This commit adds a timeout to the zero-window probing (persist timer)
mechanism. LwIP has not historically had a timeout for the persist
timer, leading to unbounded blocking if connection drops during the
zero-window condition

This commit also adds two units test, one to check the RTO timeout
and a second to check the zero-window probe timeout
2017-05-09 09:01:03 -05:00
Dirk Ziegelmeier
a942582b4b Minor #ifdef cleanup in netif.c 2017-05-05 11:11:19 +02:00
Axel Lin
89d825f603 netif: Fix IPv6-only build
Fix below build error if LWIP_IPV4 == 0.
cc -g -Wall -DLWIP_DEBUG -pedantic -Werror -Wparentheses -Wsequence-point -Wswitch-default -Wextra -Wundef -Wshadow -Wpointer-arith -Wcast-qual -Wc++-compat -Wwrite-strings -Wold-style-definition -Wcast-align -Wmissing-prototypes -Wredundant-decls -Wnested-externs -Wno-address -Wunreachable-code -Wuninitialized -Wlogical-op -I. -I../../.. -I../../../../lwip/src/include -I../../../ports/unix/port/include -I../../../../mbedtls/include -Wno-redundant-decls -DLWIP_HAVE_MBEDTLS=1 -c ../../../../lwip/src/core/netif.c
../../../../lwip/src/core/netif.c: In function ‘netif_add’:
../../../../lwip/src/core/netif.c:284:7: error: ‘ipaddr’ undeclared (first use in this function)
   if (ipaddr == NULL) {
       ^~~~~~
../../../../lwip/src/core/netif.c:284:7: note: each undeclared identifier is reported only once for each function it appears in
../../../../lwip/src/core/netif.c:285:14: error: implicit declaration of function ‘ip_2_ip4’ [-Werror=implicit-function-declaration]
     ipaddr = ip_2_ip4(IP4_ADDR_ANY);
              ^~~~~~~~
../../../../lwip/src/core/netif.c:285:5: error: nested extern declaration of ‘ip_2_ip4’ [-Werror=nested-externs]
     ipaddr = ip_2_ip4(IP4_ADDR_ANY);
     ^~~~~~
../../../../lwip/src/core/netif.c:285:23: error: ‘IP4_ADDR_ANY’ undeclared (first use in this function)
     ipaddr = ip_2_ip4(IP4_ADDR_ANY);
                       ^~~~~~~~~~~~
../../../../lwip/src/core/netif.c:287:7: error: ‘netmask’ undeclared (first use in this function)
   if (netmask == NULL) {
       ^~~~~~~
../../../../lwip/src/core/netif.c:290:7: error: ‘gw’ undeclared (first use in this function)
   if (gw == NULL) {
       ^~
cc1: all warnings being treated as errors
../../Common.allports.mk:94: recipe for target 'netif.o' failed
make: *** [netif.o] Error 1

Fixes: 5967380c20 ("netif_add: avoid passing NULL pointers to subsequent functions")
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Dirk Ziegelmeier <dirk@ziegelmeier.net>
2017-05-05 10:39:15 +02:00
Dirk Ziegelmeier
5967380c20 netif_add: avoid passing NULL pointers to subsequent functions (reported by Axel Lin) 2017-05-05 09:07:40 +02:00
Axel Lin
9bbb741247 tcp: Remove unreachable code in tcp_close_shutdown_fin
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Dirk Ziegelmeier <dirk@ziegelmeier.net>
2017-05-05 08:58:09 +02:00
goldsimon
72a8db7867 tcp_fasttmr: adapt comment (to delayed FIN implementation) 2017-05-03 21:42:59 +02:00
goldsimon
eff97c04ef backport of "unreachable code" warnings from STM (why don't people report such things?) 2017-05-03 20:30:38 +02:00
Dirk Ziegelmeier
6c236b047e ip_route() can be called with IP_ANY_TYPE in src parameter, so remove code associated to that 2017-05-03 16:42:30 +02:00
Joel Cunningham
ddf4e17411 tcp: indentation fix in tcp_receive()
TCP_OVERSIZE block was moved out from inside the while loop and thus
should be on column 7
2017-05-03 09:29:02 -05:00
goldsimon
4cf6f9ed51 tcp_free_acked_segments: fix debug printf parameter errors, fix unused parameters for !LWIP_DEBUG and/or LWIP_NOASSERT 2017-05-03 13:49:24 +02:00
goldsimon
778206798e task #14433: TCP: combine unsent/unacked queue loops in tcp_receive() 2017-05-03 12:32:01 +02:00
goldsimon
b9c47c5089 tcp_route: add comment, fixed whitespace 2017-05-03 09:56:08 +02:00
goldsimon
5c0aab7bd5 udp SO_REUSE_RXTOALL: don't copy IP header in duplicated pbuf 2017-05-03 09:54:46 +02:00
Dirk Ziegelmeier
2b9a132772 Fix compile in tcp_route when IPv4 only is used and source-based routing is disabled 2017-05-03 09:09:37 +02:00
Dirk Ziegelmeier
d32492e953 Make patch 4 of David's Minix3 patches superfluous: Use PBUF_POOL to duplicate incoming packets in UDP
... which would have been the correct way to do it anyway :-)
http://git.minix3.org/index.cgi?p=minix.git;a=blob;f=minix/lib/liblwip/patches/0004-MINIX-3-only-avoid-large-contiguous-allocations.patch;h=f23143c7e8d372b3b35b599a97975d79924f73c1;hb=HEAD
2017-05-03 09:02:56 +02:00
goldsimon
7defe372b9 fixed compiling pbuf.c with LWIP_TCP==0 2017-05-03 09:02:06 +02:00
Dirk Ziegelmeier
676dd74140 Minor cleanup and documentation updates 2017-05-03 08:51:00 +02:00
Dirk Ziegelmeier
e835707814 Cleanup and simplify tcp_connect() code 2017-05-03 08:46:06 +02:00
Dirk Ziegelmeier
5800cf51be Work on task #14494: Implement SO_BINDTODEVICE
TCP needs additional netif handling
2017-05-03 08:00:06 +02:00
Axel Lin
c144e5b1ec pbuf_coalesce: Replace pbuf_alloc+pbuf_copy with pbuf_clone
Avoid duplicate the same implementation.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: goldsimon <goldsimon@gmx.de>
2017-05-02 20:36:00 +02:00
Axel Lin
bc0fafdeca udp: Fix compiling for IPv6-only build
Fix below build error when LWIP_IPV6 && !LWIP_IPV4:
cc -g -Wall -DLWIP_DEBUG -pedantic -Werror -Wparentheses -Wsequence-point -Wswitch-default -Wextra -Wundef -Wshadow -Wpointer-arith -Wcast-qual -Wc++-compat -Wwrite-strings -Wold-style-definition -Wcast-align -Wmissing-prototypes -Wredundant-decls -Wnested-externs -Wno-address -Wunreachable-code -Wuninitialized -Wlogical-op -I. -I../../.. -I../../../../lwip/src/include -I../../../ports/unix/port/include -I../../../../mbedtls/include -Wno-redundant-decls -DLWIP_HAVE_MBEDTLS=1 -c ../../../../lwip/src/core/udp.c
../../../../lwip/src/core/udp.c: In function ‘udp_input_local_match’:
../../../../lwip/src/core/udp.c:130:58: error: unused parameter ‘inp’ [-Werror=unused-parameter]
 udp_input_local_match(struct udp_pcb *pcb, struct netif *inp, u8_t broadcast)
                                                          ^~~

Fixes: 13ffc86aef ("Start working task #14494: Implement SO_BINDTODEVICE")
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Dirk Ziegelmeier <dirk@ziegelmeier.net>
2017-05-02 15:55:32 +02:00
Dirk Ziegelmeier
eab2ae5d78 Cleanup netif_name_to_index() implementation 2017-05-02 12:51:25 +02:00
goldsimon
0545eba002 Fixed copy&paste error found by travis-ci... 2017-05-02 10:42:59 +02:00
Dirk Ziegelmeier
13ffc86aef Start working task #14494: Implement SO_BINDTODEVICE
Implement binding TCP, UDP and RAW PCBs to a netif
2017-05-02 09:39:48 +02:00
Dirk Ziegelmeier
20fed63297 Add custom pbuf usage example to pbuf_alloced_custom() docs 2017-04-28 13:19:32 +02:00
Dirk Ziegelmeier
1aa24ee21b Add new DHCP hooks to DHCP docs 2017-04-27 12:42:14 +02:00
Dirk Ziegelmeier
a09a8e4a06 Some documentation updates and fixes
Dedicated Zero-copy RX page
Fix doxygen warnings
2017-04-27 12:41:08 +02:00
goldsimon
6aac9377ee Clean up LWIP_NETIF_HWADDRHINT a bit: create a struct holding the hint(s) and pass a pointer to that struct around. That way we are free to add more hints if required (e.g. see task #11620) 2017-04-27 12:39:54 +02:00
Axel Lin
4c9b316e6b pbuf: Fix allocate zero length pbuf
Current code fails to allocate zero length pbuf (e.g. for PBUF_RAW PBUF_POOL),
fix it.

Fixes: eb269e61b5 ("First step to clean up pbuf implementation: add pbuf_alloc_reference() to allocate pbufs referencing external payload; move member initialization to common function; simplify PBUF_POOL chain allocator")
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: goldsimon <goldsimon@gmx.de>
2017-04-26 20:15:22 +02:00
goldsimon
eb269e61b5 First step to clean up pbuf implementation: add pbuf_alloc_reference() to allocate pbufs referencing external payload; move member initialization to common function; simplify PBUF_POOL chain allocator 2017-04-25 23:04:12 +02:00
goldsimon
e57552d401 pbuf_alloc_copy -> pbuf_clone 2017-04-25 22:02:07 +02:00
goldsimon
2fef874494 task #14270: DHCP should support user-defined additional options: added two hooks for adding and parsing user defined DHCP options 2017-04-25 20:18:59 +02:00
Axel Lin
471daba011 tcp_out: Fix LWIP_NETIF_TX_SINGLE_PBUF guard for not executing phase 2
This fixes build error if LWIP_NETIF_TX_SINGLE_PBUF==1.

Fixes: dd811bca06 ("Fix bug #50694 (TX exist more pbufs after enable LWIP_NETIF_TX_SINGLE_PBUF) by not executing phase 2 for LWIP_NETIF_TX_SINGLE_PBUF==1")
Signed-off-by: Axel Lin <axel.lin@ingics.com>
2017-04-25 20:17:47 +02:00
goldsimon
ca961b9bc2 minor whitespace cleanups only 2017-04-25 12:07:28 +02:00
goldsimon
d02bc6481f Fixed bug #50816 (netif_add() prototype depends on configuration) by adding a new function netif_add_noaddrthat doesn't change 2017-04-25 12:05:05 +02:00
goldsimon
135d506065 minor whitespace fixes only 2017-04-25 12:03:52 +02:00
goldsimon
dd811bca06 Fix bug #50694 (TX exist more pbufs after enable LWIP_NETIF_TX_SINGLE_PBUF) by not executing phase 2 for LWIP_NETIF_TX_SINGLE_PBUF==1 2017-04-25 11:18:36 +02:00
goldsimon
dcb2cb99a1 Added 'pbuf_alloc_copy' e.g. as a single function for use with non scatter-gather drivers 2017-04-25 10:08:31 +02:00
goldsimon
9c6da979ca fixed copy&paste error in last change to lwip_itoa() 2017-04-24 13:33:43 +02:00
goldsimon
16a71473c1 Better fix for bug #50838 (mem.c needs SYS_ARCH_PROTECTION around MEM_STATS): only lock where necessary 2017-04-24 12:23:05 +02:00
Joel Cunningham
ad779e5c9c doc: clarify RST handling comment
This clarifies the documentation around RST handling to document
the approach follows RFC 5961 and is not a standards violation
2017-04-21 09:27:54 -05:00
Joel Cunningham
de90d03e48 tcp: task #14128 - Appropriate Byte Counting support
This commit adds TCP Appropriate Byte Counting (ABC) support based on
RFC 3465

ABC replaces the previous congestion window growth mechanism and has been
configured with limit of 2 SMSS.  See task #14128 for discussion on
defaults, but the goal is to mitigate the performance impact of delayed
ACKs on congestion window growth

This commit also introduces a mechanism to track when the stack is
undergoing a period following an RTO where data is being retransmitted.

Lastly, this adds a unit test to verify RTO period tracking and some
basic ABC cwnd checking
2017-04-20 15:59:24 -05:00
goldsimon
131d656c23 lwip_itoa: check 'bufsize' instead of ignoring it; ensure code is not stolen from GPL 2017-04-20 21:57:03 +02:00
Dirk Ziegelmeier
32aa9a41e2 Apply patch from Kudratov Olimjon: Array index used before limits check
while ((q != NULL) && (options[offset] != DHCP_OPTION_END) && (offset < offset_max)) {
should be
while ((q != NULL) && (offset < offset_max) && (options[offset] != DHCP_OPTION_END)) {

See https://jira.reactos.org/browse/CORE-8978 for more info.
2017-04-19 06:35:07 +02:00
Joel Cunningham
f28c1c851b loopif: set pbuf if_idx during poll
This sets the pbuf's if_idx during the loopif poll function (the
equivalent netif input function).  This was found during IP_PKTINFO
development where p->if_idx is read and was uninitialized
2017-04-15 11:31:38 -05:00
Joel Cunningham
557a11047d Patch #9307: Replace mem_malloc+memset with mem_calloc
Aside from reducing source code, on systems which use MEM_LIBC_MALLOC,
this has the potential to improve performance depending on the underlying
memory allocator

See http://stackoverflow.com/questions/2688466/why-mallocmemset-is-slower-than-calloc
2017-04-05 14:53:24 -05:00
goldsimon
b34f2d5605 altcp: allocate altcp_pcbs from a pool, not from heap (new option MEMP_NUM_ALTCP_PCB defaults to MEMP_NUM_TCP_PCB) 2017-04-05 12:18:48 +02:00
goldsimon
2a30fedbea fix passing NULL to netif_set_gw & netif_set_netmask (or netif_set_addr or netif_add) (broken on 18.03.2017 by 2d9ef2215b) 2017-04-04 22:08:37 +02:00
goldsimon
e65a0950b2 mem_calloc: check for mem_size_t overflow when multiplying 2 mem_size_t input values 2017-04-04 21:52:01 +02:00
goldsimon
33466ee6a8 dhcp_parse_reply: return ERR_VAL instead of asserting on offset-out-of-pbuf 2017-03-30 22:30:27 +02:00
goldsimon
3aa854409a pbuf_copy_partial: remove double-check of 'buf' and 'dataptr' 2017-03-30 21:29:53 +02:00
goldsimon
51dbd1a7c0 altcp: added altcp_get_port() 2017-03-30 14:19:31 +02:00
Joel Cunningham
c722261142 tcp: bug #50614: move unsent queue check/pcb->snd_buf update
This commit corrects what looks like an ancient incorrect organization
of the logic for processing an ACK which acks new data.  Once moved,
we can also change to using TCP_SEQ_LEQ on ackno instead of TCP_BETWEEN
because ackno has already been checked against snd_nxt

The work of checking the unsent queue and updating pcb->snd_buf (both
steps required for new data ACK) should be located under the conditional
that checks TCP_SEQ_BETWEEN(ackno, pcb->lastack+1, pcb->snd_nxt)

The comment following the unsent queue check/pcb->snd_buf update even
indicates "End of ACK for new data processing" when the logic is clearly
outside of this check

From what I can tell, this mis-organization isn't causing any incorrect
behavior since the unsent queue checked that ackno was between start of
segment and snd_nxt and recv_acked would be 0 during pcb->snd_buf update.
Instead this is waisted work for duplicate ACKS (can be common) and other
old ACKs
2017-03-29 16:24:54 -05:00
Dirk Ziegelmeier
fbcdb4d9f1 Fix function name in altcp.c 2017-03-29 08:22:35 +02:00
goldsimon
b09b3fa4e6 altcp_tcp: some more debug checks 2017-03-28 16:20:20 +02:00
goldsimon
537c258efa httpd/altcp: add forgotten functions 2017-03-28 14:04:40 +02:00
goldsimon
1dfe916808 altcp_tcp: use 'void* state' to store tcp_pcb, not 'altcp_pcb* inner_conn' 2017-03-28 09:09:13 +02:00
goldsimon
425b2dda61 altcp_get_ip: added altcp_get_ip(), added default functions that only defer a call to the inner_conn (moved from tls_mbedtls to generic altcp) 2017-03-26 22:26:40 +02:00
goldsimon
540b527cf4 remove LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS config option (this is implicitly done via #ifdef LWIP_RAND) 2017-03-24 14:29:06 +01:00
Dirk Ziegelmeier
ab736a4764 Add altcp to doxygen docs 2017-03-22 23:32:32 +01:00
Dirk Ziegelmeier
7e12240af3 Improve TCP documentation a bit 2017-03-22 23:32:17 +01:00
Dirk Ziegelmeier
060a47f88a Add altcp to Filelists.mk
Some compile fixes in altcp_tcp.c and httpd.c
2017-03-22 22:57:50 +01:00
goldsimon
c18393b52b altcp: added 'addrinfo' and 'tcp_state' functions 2017-03-22 22:29:11 +01:00
goldsimon
e8e247f22e Add "application layered TCP connection API (altcp)"
altcp is an abstraction layer that prevents applications linking against the
tcp.h functions but provides the same functionality. It is used to e.g. add
SSL/TLS or proxy-connect support to an application written for the tcp callback
API without that application knowing the protocol details.
Applications written against the altcp API are directly linked against the
tcp callback API for LWIP_ALTCP==0, but then cannot use layered protocols.
2017-03-22 21:31:14 +01:00
goldsimon
ec24a2a4e8 Revert "httpd: regenerate example fs (fsdata.c) with current makefsdata"
This reverts commit 66fb52ff5c.
2017-03-21 12:57:56 +01:00
goldsimon
66fb52ff5c httpd: regenerate example fs (fsdata.c) with current makefsdata 2017-03-20 22:19:54 +01:00
Dirk Ziegelmeier
2d9ef2215b Fix bug #50576: LWIP_NSC_IPV4_GATEWAY/NETMASK/SETTINGS_CHANGED should check if the setting is actually being changed 2017-03-18 15:30:20 +01:00
goldsimon
aef2accfa3 try to satisfy clang's '-Wempty-body' 2017-03-17 11:22:30 +01:00
goldsimon
946b231516 lwip_init(): at least IAR warns about "LWIP_UNUSED_ARG(a)" accessing an uninitialized variable... Try to fix this by initializing it (it will be optimized away anyway) 2017-03-15 16:47:59 +01:00
goldsimon
7ffe5bfb3c tcp: watch out for pcb->nrtx overflows and tcp_backoff indexing overflow 2017-03-09 13:29:41 +01:00
David van Moolenbroek
5827c168c2 tcp: do not keep sending SYNs when getting ACKs
If a locally generated TCP SYN packet is replied to with an ACK
packet, lwIP immediately sends a RST packet followed by resending the
SYN packet.  This is expected, but on loopback interfaces the resent
SYN packet may immediately get another ACK reply, typically when the
other endpoint is in TIME_WAIT state (which ignores the RSTs).  The
result is an endless loop of SYN, ACK, RST packets.

This patch applies the normal SYN retransmission limit in this
scenario, such that the endless loop is limited to a brief storm.
2017-03-09 13:22:49 +01:00
Joel Cunningham
b90a54f989 bug #50476: initialize ssthresh to TCP_SND_BUF
This commit changes ssthresh to be the largest effective congestion
window (amount of in-flight data). This follows the guidance of RFC
5681 which recommends setting ssthresh arbitrarily high.

LwIP was previously using the receive window value at the end of the
3-way handshake and in the case of an active open where the receiver
used window scaling and/or window auto-tuning, this resulted in a very
small ssthresh value even though the window ramped up once the connection
was established
2017-03-08 16:36:35 -06:00
goldsimon
49414826af pbuf: added new function pbuf_free_header() to gradually hide bytes and free pbufs from the front of a pbuf chain 2017-03-06 21:53:48 +01:00
goldsimon
5f0fbdcde9 fixed warning about potentially unused variable 'netif' after changing ip4/6_input_accept to return in, not netif* 2017-03-01 21:46:36 +01:00
goldsimon
0d585d55d3 Added LWIP_SINGLE_NETIF for small targets with only one netif (see task #13515, there might be more optimizations to come with this option) 2017-03-01 16:10:50 +01:00
goldsimon
f978a7ed31 let ip4/6_input_accept return int instead of netif* 2017-03-01 14:16:27 +01:00
goldsimon
18c7c5d81c fixed my last commit (NETIF_FOREACH does not yet exist :) 2017-03-01 14:12:50 +01:00
goldsimon
7c9a6317b9 refactor ip4/ip6 packet-to-netif matching to remove the ugly 'first' flag 2017-03-01 14:09:18 +01:00
Dirk Ziegelmeier
ec4f00179d Fix bug #50242: dhcp_release does not stop autoip (in coop mode)
Create new function dhcp_release_and_stop() that stops DHCP statemachine and sends release message if needed. Also stops AUTOIP if in coop mode.
Old dhcp_release() and dhcp_stop() function internally call dhcp_release_and_stop() now.
2017-03-01 13:18:37 +01:00
goldsimon
f85eed0ab3 tcp: fixed bug #50418: LWIP_EVENT_API: fix invalid calbacks for SYN_RCVD pcb 2017-02-28 12:13:26 +01:00
David van Moolenbroek
d3fc398580 arp/ndp: allow overriding the decision to copy pbufs
lwIP aims to support zero-copy TX, and thus, must internally handle
all cases that pbufs are referenced rather than copied upon low-level
output.  However, in the current situation, the arp/ndp packet queuing
routines conservatively copy entire packets, even when unnecessary in
cases where lwIP is used in a zero-copy compliant manner.  This patch
moves the decision whether to copy into a centralized macro, allowing
zero-copy compliant applications to override the macro to avoid the
unnecessary copies.  The macro defaults to the safe behavior, though.
2017-02-28 09:37:21 +01:00
Dirk Ziegelmeier
27c835aa56 Remove netif_invoke_ext_callback() from doxygen docs, it is intended for internal use only 2017-02-27 09:36:33 +01:00
Dirk Ziegelmeier
01f9a04e4a Add pbuf_get_contiguous() to doxygen docs 2017-02-26 09:44:16 +01:00
Dirk Ziegelmeier
08931b33c1 Fix documentation on pbuf_get_contiguous() 2017-02-25 17:03:14 +01:00
goldsimon
0da9cf70ea Added pbuf_get_contiguous() to get data in one piece (either zero copy from pbuf or memcpied into a supplied buffer) 2017-02-24 21:36:49 +01:00
goldsimon
01cc06bcb8 netif_add: ensure netif->num is unique even if more than 255 netifs have been added/removed since system startup (e.g. by ppp) 2017-02-23 20:41:54 +01:00
goldsimon
76763c9bcd pbuf_ref: assert-check for 'ref' overflow 2017-02-23 20:16:51 +01:00
Dirk Ziegelmeier
2cf3bbddd4 pbuf_free: Use correct type LWIP_PBUF_REF_T for local variable 2017-02-23 18:08:26 +01:00
Dirk Ziegelmeier
0f6d8ccd90 Revert "Improve pbuf refcount underflow check by checking the local variable on the stack that was assigned in a protected region"
This reverts commit 62c44138da.

Didn't notice due to local changes the ASSERTION was already inside the locks...
2017-02-23 18:04:30 +01:00
Dirk Ziegelmeier
62c44138da Improve pbuf refcount underflow check by checking the local variable on the stack that was assigned in a protected region
The old code was vulnerable to race conditions since it checked ref to be >0 without locks
2017-02-23 16:55:14 +01:00
Dirk Ziegelmeier
0eeb10d4bb Preparation for task #14369: Define ways to work with a netif having multiple ports
Add if_idx member to struct pbuf
2017-02-23 16:34:28 +01:00
sg
ff3fe1f489 Fixed bug #50231 (nd6: several option size related issues in Router Advertisement message processing) 2017-02-17 21:59:08 +01:00
goldsimon
deaa6e9406 Improved DNS_LOCAL_HOSTLIST interface (bug #50325) 2017-02-17 10:08:49 +01:00
Dirk Ziegelmeier
498913b982 Third draft of task #14283: Add more detailed status callback
Implement Joel's idea of a union
2017-02-15 10:14:06 +01:00
Dirk Ziegelmeier
454927151d Continue working on ext netif callback
Docs, better callback points (e.g. before netif is set down)
2017-02-14 21:02:38 +01:00
Dirk Ziegelmeier
d46d8bcda2 Add some asserts to netif callback functions 2017-02-14 20:35:48 +01:00
Dirk Ziegelmeier
4434762a08 Some minor documentation fixes 2017-02-14 20:28:43 +01:00
Dirk Ziegelmeier
bbedb35bf3 Fix name clash between typedef and struct definition.
Interesting, all three compilers in Erik Ekman's travis-ci don't complain. But my gcc at home does...
2017-02-14 20:17:27 +01:00
Dirk Ziegelmeier
f4f204b850 Implement a better way to initialize all fields in ip address than using memset() (better fix than my last commit) 2017-02-14 14:20:39 +01:00
Dirk Ziegelmeier
feba38a1f4 Fix unportable struct initializer I introcduced while working on task #14283: Add more detailed status callback 2017-02-14 13:54:14 +01:00
Dirk Ziegelmeier
8025b85694 Second draft of task #14283: Add more detailed status callback 2017-02-14 10:59:28 +01:00
Dirk Ziegelmeier
7dd21e93c4 Fix my last commits (unused variable warning)
my gcc at home did not show this warning...
2017-02-13 22:27:59 +01:00
Dirk Ziegelmeier
3c1713406e Work on task #14283: Add more detailed status callback
Cleanups and IPv6 address status
2017-02-13 21:52:55 +01:00
Dirk Ziegelmeier
58c48af58f Start working on task #14283: Add more detailed status callback
IPv6 stuff is not implemented
2017-02-13 21:40:08 +01:00
Joel Cunningham
0b257f71e7 Fix comment typo from bug #47485
tcp_close_shutdown_impl() should be tcp_close_shutdown_fin()
2017-02-13 11:25:05 -06:00
Dirk Ziegelmeier
45f3c28eb2 Fix netif_find() function for many netifs (should use atoi) and move it to the bottom of the file where similar functions are located 2017-02-13 13:35:30 +01:00
Dirk Ziegelmeier
400c41ffd9 Also base netif_index_to_name function on netif_get_by_index 2017-02-13 13:26:54 +01:00
Dirk Ziegelmeier
d4d8fd819d Some code cleanup related to netif index handling
Made the macro "netif_index_to_num" private, if someone needs it externally, please complain.
2017-02-13 13:21:45 +01:00
Dirk Ziegelmeier
c01096097c Move struct ip4_addr2 and corresponding copy macros from ip4_addr.h to prot/etharp.h where they belong
Also rename struct not to clash with IP4_ADDR2 macro definition, and rework copy macros to contain a source/dest direction
2017-02-13 12:34:38 +01:00
goldsimon
44068e3109 minor: mark variable "unused" after assigning it 2017-02-13 11:43:56 +01:00
goldsimon
693a74c286 For tiny targtes, LWIP_RAND is optional -> fix compile time checks 2017-02-13 11:43:25 +01:00
Dirk Ziegelmeier
de05424ff6 Fix build in IPv4 only case when source based routing is disabled 2017-02-10 22:52:43 +01:00
David van Moolenbroek
6ce9a01c3e raw: add core support for multicast TX options
The patch simply copies the relevant bits from the UDP implementation.
Perhaps most notably, the patch does *not* copy the IPv4-only UDP
support for IP_MULTICAST_IF, because that option can also be
implemented using the interface index based approach. Largely thanks
to this omission, at least on 32-bit platforms, this patch does not
increase the RAW PCB size at all.
2017-02-10 22:37:35 +01:00
David van Moolenbroek
ab8119360e udp: add core-level multicast support for IPv6
So far, the UDP core module implemented only IPv4 multicast support.
This patch extends the module with the features necessary for socket
layers on top to implement IPv6 multicast support as well:

o If a UDP PCB is bound to an IPv6 multicast address, a unicast source
  address is selected and used to send the packet instead, as is
  required (and was the case for IPv4 multicast already).

o Unlike IPv4's IP_MULTICAST_IF socket option, which takes a source
  IPv4 address, the IPV6_MULTICAST_IF socket option (from RFC 3493)
  takes an interface identifier to denote the interface to use for
  outgoing multicast-destined packets. A new pair of UDP PCB API
  calls, udp_[gs]et_multicast_netif_index(), are added to support
  this. The new definition "NETIF_NO_INDEX" may be used to indicate
  that lwIP should pick an interface instead.

  IPv4 socket implementations may now also choose to map the given
  source address to an interface index immediately and use the new
  facility instead of the old udp_[gs]et_multicast_netif_addr() one.
  A side effect of limiting the old facility to IPv4 is that for dual-
  stack configurations with multicast support, the UDP PCB size is
  reduced by (up to) 16 bytes.

o For configurations that enable loopback interface support, the IPv6
  code now also supports multicast loopback (IPV6_MULTICAST_LOOP).

o The LWIP_MULTICAST_TX_OPTIONS opt.h setting now covers both IPv4
  and IPv6, and as such is no longer strictly linked to IGMP. It is
  therefore placed in its own lwIP options subgroup in opt.h.

The IPV6_MULTICAST_HOPS socket option can already be implemented using
the existing IP_MULTICAST_TTL support, and thus requires no additional
changes. Overall, this patch should not break any existing code.
2017-02-10 22:37:29 +01:00
sg
a3fc38037a minor: move assert to a slightly better place 2017-02-10 21:30:07 +01:00
David van Moolenbroek
240cf62056 tcp: fix accept event on closed listening PCBs
If LWIP_CALLBACK_API is not defined, but TCP_LISTEN_BACKLOG is, then
the LWIP_EVENT_ACCEPT TCP event may be triggered for closed listening
sockets.  This case is just as disastrous for the event API as it is
for the callback API, as there is no way for the event hook to tell
whether the listening PCB is still around.  Add the same protection
against this case for TCP_LISTEN_BACKLOG as was already in place for
LWIP_CALLBACK_API.

Also remove one NULL check for LWIP_CALLBACK_API that had already
become redundant for all callers, making the TCP_EVENT_ACCEPT code
for that callback wrapper more in line with the rest of the wrappers.
2017-02-10 21:28:18 +01:00
Dirk Ziegelmeier
239498f37c Implement task #14367: Hooks need a better place to be defined
We now have a #define for a header file name that is #included in every .c file that provides hooks.
2017-02-10 13:25:04 +01:00
goldsimon
bc07fd9db5 Fixed bug #47485 (tcp_close() should not fail on memory error) by retrying to send FIN from tcp_fasttmr 2017-02-10 09:42:38 +01:00
Joel Cunningham
852993029d Add sockets_priv.h header
This commit introduces a sockets_priv.h header for socket API internal
implementations intended to be used by sockets API C files, but not
applications

This commit moves struct lwip_setgetsockopt_data to the private header
because this is not part of the public sockets API, but needs to be
shared between sockets.c and memp.c

This header lays ground work for sharing other internal sockets types
/macros between API files (sockets.c and if_api.c)
2017-02-09 22:04:30 -06:00
sg
c396dd4554 Clean up icmp6.c a bit after adding IPv6 scopes 2017-02-09 21:18:40 +01:00
Dirk Ziegelmeier
702091d548 igmp.c: igmp_lookup_group() should be static 2017-02-09 21:08:40 +01:00
Dirk Ziegelmeier
4d8fec3b67 Rename "IPv6 mapped IPv4 addresses" to their correct name from RFC4191: "IPv4-mapped IPv6 address" 2017-02-09 21:02:12 +01:00
Dirk Ziegelmeier
eae4129863 Documentation updates related to Joel's if_api changes 2017-02-09 19:39:07 +01:00
Luc Revardel
819bfbb943 Fix bug #50220 (mld6_leavegroup does not send ICMP6_TYPE_MLD, even if last reporter)
Signed-off-by: sg <goldsimon@gmx.de>
2017-02-08 22:29:32 +01:00
David van Moolenbroek
03f47e58a3 udp/raw: prevent packet length overflows
Previously, on netifs with unrestricted MTUs (typically loopback
interfaces), it was possible to give a packet to the UDP/RAW API
calls that is so large that when prepending headers, the pbuf's
tot_len field would overflow. This could easily result in
undesirable behavior at lower layers, e.g. a crash when copying
the packet for later delivery.

This patch models such overflows as memory allocation errors, thus
resulting in clean failures. Checks have to be added in multiple
places to cover (hopefully) all cases.
2017-02-08 22:19:46 +01:00
David van Moolenbroek
fffd61c746 Patch #9250 (slightly changed): fix source substitution in ip6_output_if() (broken in 2014 with be75c483d0)
Signed-off-by: sg <goldsimon@gmx.de>
2017-02-08 22:16:32 +01:00
sg
21737f57e5 Fixed bug #50090 (ast_unsent->oversize_left can become wrong value in tcp_write error path) 2017-02-08 21:42:30 +01:00
Dirk Ziegelmeier
8a34570b83 Fix compile without IPv6 zone support
Fixed warning about unreachable code because ip6_addr_has_zone is always 0
2017-02-05 13:33:10 +01:00
Dirk Ziegelmeier
d857344aa8 patch #9249: tcp: Fix unused parameter 'dest' build warning if !LWIP_IPV6
Apply modified version of Axel Lin's patch, without #ifdef
2017-02-05 12:44:32 +01:00
Axel Lin
be7ae5e36b dns: Slightly improve dns_alloc_random_port implementation
Having the variable namining ret for a pointer makes the code looks odd,
ret looks like a value variable. Rename ret to pcb.
Also simplify the code in the do {} while() loop.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
2017-02-04 18:42:14 +01:00
Joel Cunningham
4fb7d74165 task #14314: include cleanups
Couple of more cleanups for task #14314 involving includes:
  1) if.h name should match if_api.c due to LwIP convention and history.
     Standard if.h include can be used with compatibility header in
     posix/net/if.h
  2) API header (if.h) should not be included in core code. This include
     has been eliminated by moving the definition of IF_NAMESIZE to
     netif.h as NETIF_NAMESIZE.  This is now the canonical definition
     and IF_NAMESIZE just maps to it to provide the standard type
2017-02-03 16:45:29 -06:00
David van Moolenbroek
3d80e51b2a tcp: eliminate some redundant route lookups
Now that tcp_connect() always determines the outgoing netif with a
route lookup, we can compute the effective MSS without doing the same
route lookup again. The outgoing netif is already known from one
other location that computes the MSS, so we can eliminate a redundant
route lookup there too. Reduce some macro clutter as a side effect.
2017-02-03 22:30:08 +01:00
David van Moolenbroek
29ddfd1d71 Add support for IPv6 address scopes
This patch adds full support for IPv6 address scopes, thereby aiming
to be compliant with IPv6 standards in general and RFC 4007 in
particular. The high-level summary is that link-local addresses are
now meaningful only in the context of their own link, guaranteeing
full isolation between links (and their addresses) in this respect.
This isolation even allows multiple interfaces to have the same
link-local addresses locally assigned.

The implementation achieves this by extending the lwIP IPv6 address
structure with a zone field that, for addresses that have a scope,
carries the scope's zone in which that address has meaning. The zone
maps to one or more interfaces. By default, lwIP uses a policy that
provides a 1:1 mapping between links and interfaces, and considers
all other addresses unscoped, corresponding to the default policy
sketched in RFC 4007 Sec. 6. The implementation allows for replacing
the default policy with a custom policy if desired, though.

The lwIP core implementation has been changed to provide somewhat of
a balance between correctness and efficiency on on side, and backward
compatibility on the other. In particular, while the application would
ideally always provide a zone for a scoped address, putting this in as
a requirement would likely break many applications. Instead, the API
accepts both "properly zoned" IPv6 addresses and addresses that, while
scoped, "lack" a zone. lwIP will try to add a zone as soon as possible
for efficiency reasons, in particular from TCP/UDP/RAW PCB bind and
connect calls, but this may fail, and sendto calls may bypass that
anyway. Ultimately, a zone is always added when an IP packet is sent
when needed, because the link-layer lwIP code (and ND6 in particualar)
requires that all addresses be properly zoned for correctness: for
example, to provide isolation between links in the ND6 destination
cache. All this applies to packet output only, because on packet
input, all scoped addresses will be given a zone automatically.

It is also worth remarking that on output, no attempt is made to stop
outgoing packets with addresses for a zone not matching the outgoing
interface. However, unless the application explicitly provides
addresses that will result in such zone violations, the core API
implementation (and the IPv6 routing algorithm in particular) itself
will never take decisions that result in zone violations itself.

This patch adds a new header file, ip6_zone.h, which contains comments
that explain several implementation aspects in a bit more detail.

For now, it is possible to disable scope support by changing the new
LWIP_IPV6_SCOPES configuration option. For users of the core API, it
is important to note that scoped addresses that are locally assigned
to a netif must always have a zone set; the standard netif address
assignment functions always do this on behalf of the caller, though.
Also, core API users will want to enable LWIP_IPV6_SCOPES_DEBUG at
least initially when upgrading, to ensure that all addresses are
properly initialized.
2017-02-03 22:29:57 +01:00
sg
1839153609 minor: dhcp_network_changed(): assert for valid state, fix coding style 2017-02-03 21:20:39 +01:00
Axel Lin
3e30dbc75c dns: Clean up unneeded #if guard for DNS_LOCAL_HOSTLIST/DNS_LOOKUP_LOCAL_EXTERN
This is a leftover of commit e77e18f8c4 "Worked on IPv6-only stack", fix it.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
2017-02-03 08:57:44 +01:00
Dirk Ziegelmeier
ff04c2046e Fix bug #50206: UDP Netconn bind to IP6_ADDR_ANY fails
The tests were in to catch user errors, but they seem to get in the way of application programming :-)
The checks in *_send() remain active to catch when PCB source and destination address types do not match
2017-02-02 10:25:05 +01:00