Commit Graph

2703 Commits

Author SHA1 Message Date
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
Dirk Ziegelmeier
e8d5499d72 Code cleanup: add some parentheses in tcp.c and tcp_out.c 2017-02-01 15:28:10 +01:00
Axel Lin
2685d742e8 stats: Remove superfluous /t in end of stats display
The debug message after the stats display looks odd because the /t in end of
stats display.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
2017-01-31 08:57:26 +01:00
Dirk Ziegelmeier
7a99d2f8e9 Fix documentation on netif_index_to_name 2017-01-24 11:39:34 +01:00
Joel Cunningham
fbfe987ae8 netif: clean up remaining index shadowing from if APIs
This commit cleans up the remaining instance of global variable
"index" shadowing caused by using local variables and function
parameters named "index"

These were introduced in the recent interface index API commits
2017-01-23 17:23:54 -06:00
Dirk Ziegelmeier
d297d466ed Fix some more variables named "index" - found by Joel Cunningham 2017-01-23 21:46:11 +01:00
Joel Cunningham
e158f87286 Netif: add allowance for init to override netif->num
Adjusts assert logic from 9c80a66253
to allow for a netif driver's init callback to manually override
the number.  When the init function is taking care of the unique
assignment, the assert simply checks that a valid number was provided
2017-01-20 14:55:29 -06:00
Joel Cunningham
1b20e664bf Task #14314: Add interface name/index APIs
This commit adds the following sets of interface name/index APIs:

Interface Identification APIs from RFC 3493:
  * lwip_if_nametoindex (COMPAT macro if_nametoindex)
  * lwip_if_indextoname (COMPAT macro if_indextoname)

netifapi:
  * netifapi_netif_name_to_index
  * netifapi_netif_index_to_name

netif:
  * netif_name_to_index
  * netif_index_to_name
  * netif_num_to_index
  * netif_index_to_num
2017-01-20 14:06:42 -06:00
Joel Cunningham
9c80a66253 Netif: add netif_num overflow assert
This commit adds an LWIP_ASSERT to detect when netif_num overflows and
we no longer have unique numbers per netif.  Unique netif numbers are
needed to support interface indexes (task #14314)

The only cases where this could occur are with a deployment that attempts
to use the maximum 256 netifs at the same time or where netifs are being
constantly adding and removed.  Neither of these use cases fit the
lightweight goals of LwIP

See discussion in task #14314 for more details
2017-01-20 14:03:54 -06:00
Dirk Ziegelmeier
645ca84704 Retry 1 to fix bug #50064
Accidentally used the wrong destination HW addr
2017-01-18 13:43:01 +01:00
Dirk Ziegelmeier
7aaa888d1d Optimize my last fix in etharp.c, I missed the variable declaration at the beginning of the function 2017-01-18 13:21:11 +01:00
Dirk Ziegelmeier
47bac3c11f Remove special ARP reply optimization from etharp.c
- Code duplication with etharp_raw()
- No great effect on perfomance
- May make reworking PBUF handling code more complicated (see bug #49914)
- The check for p->type == PBUF_REF is a strange special case, too
- Simon also voted to remove it
2017-01-18 12:25:09 +01:00
Dirk Ziegelmeier
199c38de29 Fix bug #50064: Zero-copy RX: ARP reply fails with PBUF_REF
Kept the optimized version intact, see discussion in savannah bug tracker
2017-01-18 10:15:02 +01:00
Axel Lin
141b5def46 tcp_out: Use LWIP_MIN instead of open-coded for better readability
Make the intention of code more clear by using LWIP_MIN instead of open-coded.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
2017-01-16 10:25:10 +01:00
Axel Lin
30aedfc3f7 tcp_out: Fix comment for last_unsent->oversize_left and tcp_pcb.unsent_oversize
Both last_unsent->unsent_oversize and tcp_pcb.unsent_oversized fields are not
exist, fix the comments.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
2017-01-16 08:51:53 +01:00
Dirk Ziegelmeier
df8e404abd Add some parentheses for better code readability in tcp_in.c 2017-01-16 08:51:27 +01:00
Dirk Ziegelmeier
9898d406bc Fix bug #50040: pbuf_alloc(..., 65534, PBUF_RAM) succeeds
Check for integer overflow when calculating memory allocation size
2017-01-15 17:36:33 +01:00
Dirk Ziegelmeier
0043bf78b6 Minor typo fix in tcp_out.c 2017-01-15 16:37:25 +01:00
Axel Lin
e1598b0b11 tcp_out: Fix oversize vs. space assertion test
oversize_used is always 0 at this point, should test oversize instead.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
2017-01-15 16:36:48 +01:00
Dirk Ziegelmeier
1d7f375992 Fix compile error in ip6_frag.c
../../../../lwip/src/core/ipv6/ip6_frag.c: In function ‘ip6_reass’:
../../../../lwip/src/core/ipv6/ip6_frag.c:567:7: error: ISO C90 forbids mixed declarations and code [-Werror=pedantic]
2017-01-14 09:31:06 +01:00
Dirk Ziegelmeier
92511f4711 Fix part 2 of bug #50042: ETHADDR16_COPY from netif->hwaddr
Eliminate ETHADDR32_COPY macro - it cannot be used in ETH_PAD_SIZE case. I could have kept it by defining it to ETHADDR16_COPY in case of ETH_PAD_SIZE, but I did not consider it worth another #ifdef mess.
2017-01-13 08:18:33 +01:00
Axel Lin
2c3538cb8f IPv6: Fix compile error of ip6_frag.c
Fix below compile error:
../../../../lwip/src/core/ipv6/ip6_frag.c: In function ‘ip6_reass’:
../../../../lwip/src/core/ipv6/ip6_frag.c:533:20: error: declaration of ‘next_pbuf’ shadows a previous local [-Werror=shadow]
       struct pbuf* next_pbuf = iprh->next_pbuf;
                    ^~~~~~~~~
../../../../lwip/src/core/ipv6/ip6_frag.c:272:20: note: shadowed declaration is here
   struct pbuf *q, *next_pbuf;
                    ^~~~~~~~~
cc1: all warnings being treated as errors
../Common.mk:93: recipe for target 'ip6_frag.o' failed
make: *** [ip6_frag.o] Error 1

Fixes: 7cedf7ae71 ("IPv6: fragment reassembly fixes")
Signed-off-by: Axel Lin <axel.lin@ingics.com>
2017-01-11 16:16:41 +01:00
David van Moolenbroek
9713baea55 ip6: improve length checks for extension headers
Malformed packets could cause the extension header iteration code to
read from up to two bytes beyond the end of the packet's first pbuf.
2017-01-11 14:05:24 +01:00
David van Moolenbroek
7cedf7ae71 IPv6: fragment reassembly fixes
This patch aims to fix three closely related issues.

o The implementation of IPV6_FRAG_COPYHEADER was fundamentally
  incompatible with the presence of extension headers between the
  IPv6 header and the Fragment Header. This patch changes the
  implementation to support such extension headers as well, with
  pretty much the same memory requirements. As a result, we can
  remove the check that prevented such packets from being reassembled
  in all cases, even with IPV6_FRAG_COPYHEADER off.

o Given that temporary data is stored in the Fragment Header of
  packets saved for the purpose of reassembly, but ICMPv6 "Fragment
  Reassembly Time Exceeded" packets contain part of the original
  packet, such ICMPv6 packets could actually end up containing part
  of the temporary data, which may even include a pointer value. The
  ICMPv6 packet should contain the original, unchanged packet, so
  save the original header data before overwriting it even if
  IPV6_FRAG_COPYHEADER is disabled. This does add some extra memory
  consumption.

o Previously, the reassembly would leave the fragment header in the
  reassembled packet, which is not permitted by RFC 2460 and prevents
  reassembly of particularly large packets (close to 65535 bytes
  after reassembly). This patch gets rid of the fragment header. It
  does require an implementation of memmove() for that purpose.

Note that this patch aims to improve correctness.  Future changes
might restore some of the previous functionality in order to regain
optimal performance for certain cases (at the cost of more code).
2017-01-11 14:05:22 +01:00
Dirk Ziegelmeier
2e265310c4 Fix (bogus) MSVC 2010 warning about uninitialized variable usage in ip6.c
It's wrong because the variables are initialized during first loop iteration due to best_addr == NULL
2017-01-11 08:08:05 +01:00
David van Moolenbroek
713146eeba nd6: cull destination cache on router removal
As per RFC requirements, upon removing a router from the default
router list, remove any entries pointing to it from the destination
cache. While here, synchronize timing out entries in the default
router list with the rest of the timer code.

When removing a netif, clear the destination cache altogether
in order to prevent more general inconsistency. When this happens,
the entries for other netifs will have to be rebuilt, but removing
netifs should be sufficiently rare that this is not worth optimizing.
2017-01-11 07:54:17 +01:00
David van Moolenbroek
a1130f8c7b nd6: some work on basic RFC 4861 compliance
The current ND implementation does not yet implement the most basic
required ('MUST') checks for message validation and generation.

- implement some of the required checks for message validation;
- document the remaining missing message validation checks;
- hardcode the hop limit of Neighbor Discovery messages rather than
  having it depend on lwIP configuration which, if changed, would
  cause all of ND to cease working.
2017-01-11 07:54:15 +01:00
David van Moolenbroek
0b9d7a386c ip6: improve source address selection
The introduction of address lifetimes also means that lwIP correctly
supports transitions between PREFERRED and DEPRECATED address states,
and that means that the source address selection must be changed to
take this into account. Adding this feature to the previous algorithm
would have resulted in a mess, so this patch rewrites the algorithm to
stay close to the rules described in RFC 6724 (formerly 3484) Sec. 5.
This yields the following changes:

- Rule 2 ("prefer appropriate scope") is now fully implemented, most
  importantly allowing larger-scope addresses to be picked if no
  smaller-scope addresses are available (e.g., a global address may
  now be used to connect to a unique-local address);
- Rule 3 ("avoid deprecated addresses") is now also fully implemented;
- unknown-scope addresses are also supported, with lowest priority;
- the link between the prescribed rules and the actual algorithm is
  made much more explicit, hopefully allowing future improvements to
  be made more easily.

For reasons explained in comments, one previous deviation from the RFC
on Rule 2 is retained for now.
2017-01-11 07:54:14 +01:00
David van Moolenbroek
08de0e9617 ip6/nd6: route using on-link prefixes, not addresses
As laid out in RFC 5942, the assumption that a dynamically assigned
(SLAAC/DHCPv6) address implies an on-link subnet, is wrong. lwIP does
currently make that assumption, routing packets according to local
address subnets rather than the on-link prefix list. The result is
that packets may not make it to their destination due to incorrect
routing decisions.

This patch changes the routing algorithms to be (more) compliant with
RFC 5942, by implementing the following new routing policies:

- all routing decisions check the on-link prefix list first, and
  select a default router for off-link routing only if there is no
  matching entry in the on-link prefix list;
- dynamically assigned addresses (from address autoconfiguration) are
  considered /128 assignments, and thus, no routing decisions are taken
  based on matches against their (/64) subnet anymore;
- more generally, all addresses that have a lifetime are considered
  dynamically assigned and thus of size /128, which is the required
  behavior for externally implemented SLAAC clients and DHCPv6;
- statically assigned (i.e., manually configured) addresses are still
  considered /64 assignments, and thus, their associated subnet is
  considered for routing decisions, in order to behave as generally
  expected by end users and to retain backward compatibility;
- the link-local address in IPv6 address slot #0 is considered static
  and thus has no lifetime and an implied /64 subnet, although link-
  local routing is currently always handled separately anyway.

IPv6 source address selection is kept as is, as the subnet tests in
the algorithm serve as poor man's longest-common-prefix equivalent
there (RFC 6724 Sec. 5, Rule 8).
2017-01-11 07:54:12 +01:00
David van Moolenbroek
22c2fd1b58 nd6: improve router selection
Previously, IPv6 routing could select a next-hop router on a netif
that was down or disconnected, potentially resulting in packets being
dropped unnecessarily. This patch changes router selection to take
into account the state of the router's associated netif, eliminating
such unnecessary packet loss.

Also, this patch fixes the test for router validity, which was
erroneously based on the router's invalidation timer rather than its
neighbor cache entry state. Given that an expired router has no
associated neighbor cache entry, no invalid routers would previously
ever be returned.

Finally, this patch also adds round-robin selection of routers that
are not known to be reachable or probably reachable, as per RFC 4861
Sec. 6.3.6 point (2). Support for this feature was partially present
but not actually functional.
2017-01-11 07:54:10 +01:00
David van Moolenbroek
901664eca1 netif: more ip6 state changes invoke status callback
For applications that use NETIF_STATUS_CALLBACK to help keep track of
extra per-address shadow state of IPv6 addresses, even in the light of
autogenerated addresses (which may "spontaneously" appear/disappear),
state transitions between tentative, duplicated, and invalid are
important as well. Therefore, invoke the status callback for all such
state transitions. Continue to filter out state changes between
various levels of progress of the tentative state, though.
2017-01-11 07:54:09 +01:00
David van Moolenbroek
d99334573b nd6: fix Duplicate Address Detection
Previously, Duplicate Address Detection (DAD) would work only for the
link-local address. For DAD-spawned Neighbor Solicitation requests for
any other address, the request would use the link-local address as the
source, meaning the other side would send a targeted reply (RFC 4861
Sec. 7.2.4). However, the nd6 implementation currently does not
consider targeted replies for DAD--even though technically an RFC 4862
Sec. 5.4.4 violation--supposedly because no real-world scenario could
trigger that case. The combination of these factors resulted in DAD
being entirely ineffective for non-link-local addresses.

This patch forces all DAD-spawned Neighbor Solicitation packets to use
the unspecified ('any') address as source, as per RFC 4862 Sec. 5.4.2.
As a result, other nodes would reply with multicast replies, for which
there is appropriate DAD checking code.

The patch also makes a slight rearrangement of statements such that
MLD join messages are sent before the NS packets, rather than after.
2017-01-11 07:54:07 +01:00
David van Moolenbroek
2ff04a931a nd6: check link status before sending packets
In the cases that nd6 checks whether the interface is up before
sending a packet, also check whether the link is up.  Without this
additional check, temporary link downtime could easily result in
unnecessary false negatives for Duplicate Address Detection.

In addition, use the netif abstraction macros to perform the checks.
2017-01-11 07:54:05 +01:00
David van Moolenbroek
e0c5e1988f nd6: improve address autoconfiguration support
In summary, this patch aims to resolve bugs #47923 and #48162, by
decoupling address autoconfiguration from the on-link prefix list,
since those are not related. Important necessary changes are needed
to meet this goal, ultimately bringing the lwIP ND6 implementation
closer to compliance with RFC 4862. The main changes are:

  1. support for address lifetimes, and,
  2. addition of a new DUPLICATED address state.

The decoupling implies that the prefix list can no longer be used to
maintain state for address autoconfiguration. Most importantly, the
lifetime of each address, which was previously derived from the
prefix slot's lifetime, must now be associated with the address
itself. This patch implements address lifetime tracking, maintaining
both a valid and a preferred lifetime for each address, along with
the corresponding address state changes (e.g., between PREFERRED and
DEPRECATED), all as required by RFC 4862.

The support for address lifetimes can be enabled with a new
LWIP_IPV6_ADDRESS_LIFETIMES setting in lwipopts.h. It is required for
autoconfiguration and enabled by default if autoconfiguration is
enabled as well, but it may also be enabled separately, so as to allow
application-controlled lifetime management (e.g., if autoconfiguration
is implemented in a separate application). A special valid-lifetime of
zero is used to denote a static address--that is, an address that was
configured manually, that does not have lifetimes, and that should be
left alone by the autoconfiguration functionality. Addresses assigned
without setting a lifetime are deemed static, thus preserving
compatibility with existing lwIP-based applications in this respect.

Similarly, the decoupling implies that the prefix list can no longer
be used to remember cases of address duplication. Previously, the
detection of a duplicated address would simply result in removal of
the address altogether. Instead, this patch introduces a new state
"DUPLICATED", indicating that the address, while technically still
present, has been found to conflict with other node addresses, and no
attempt should be made to produce an autoconfiguration address for
that prefix.

Manually added addresses, including the link-local address, once set
to DUPLICATED, will remain in that state until manual intervention.
Autoconfigured DUPLICATED addresses will expire according to their
valid-lifetime, essentially preserving the current behavior but
without the use of the prefix list. As a first attempt to approach
compliance with RFC 4862 Sec. 5.4.5, if the link-local address is
detected to be duplicated, all derived addresses are marked duplicated
as well, and no new addresses will be autoconfigured. More work is to
be done for full compliance with that section, however.

Together, those two main changes indeed do fully decouple address
autoconfiguration from the on-link prefix list. Changes to the latter
thus no longer affect the former, resolving bug #47923. Moreover, as a
result, autoconfiguration can, and does, now also take place on
advertised prefixes that do not have the on-link flag set, resolving
bug #48162. The routing changes mentioned in the discussion of that
bug are left to a separate patch, though.
2017-01-11 07:54:03 +01:00
David van Moolenbroek
b59472cf63 raw: core support for IP_HDRINCL socket option
This patch adds a new RAW_FLAGS_HDRINCL flag to the raw core
implementation. When this flag is set on a RAW PCB, the raw send
routines expect the caller to supply an IP header for the given
packet, and will use that IP header instead of prepending one to
the packet themselves.

This feature allows the IP_HDRINCL socket option to be implemented
in higher layers with no further effort. Even thoguh that option is
traditionally supported for IPv4 sockets only (e.g., see RFC 3542
Sec. 3), the RAW_FLAGS_HDRINCL flag supports both IPv4 and IPv6, as
much of the lower-level infrastructure was already in place anyway.
2017-01-08 19:26:30 +01:00
David van Moolenbroek
162cc4d343 raw: split off raw_sendto_if_src() from raw_sendto()
Similar to the core UDP API, the new function may be used to implement
IPV6_PKTINFO (RFC 3542 Sec. 4), for example. This patch makes no
further functional changes; it merely moves code around a bit.
2017-01-08 19:26:24 +01:00
David van Moolenbroek
aea7062223 raw: extend support for connected sockets
The support for connecting raw sockets is extended to match the
support for UDP sockets, while keeping the current API unchanged:

- for connected sockets, filter incoming packets on source address;
- use a flag to indicate whether a socket is connected, at no extra
  memory cost; the application may check this flag if needed;
- added raw_disconnect(), which so far existed in documentation only.
2017-01-08 19:26:19 +01:00
Dirk Ziegelmeier
e94c9ffa70 Fix warning about bad cast in pbuf_skip() 2017-01-05 08:14:39 +01:00
Dirk Ziegelmeier
72316bdb5b Move macros to access DHCP and AUTOIP data to headers, users may want to access the members 2017-01-05 08:09:00 +01:00
Dirk Ziegelmeier
803a711e6a Fix warning that local variable may be used uninitialized in mem.c 2017-01-05 08:07:41 +01:00
Axel Lin
1f3c18fcbe tcp: Make tcp_listen_with_backlog_and_err return NULL if the address/port is already used
The caller of tcp_listen_with_backlog_and_err() usually check if the return
pcb is NULL before checking the err reason. I think the commit adding
tcp_listen_with_backlog_and_err() accidently change the behavior, Fix it.

Fixes: 98fc82fa71 ("added function tcp_listen_with_backlog_and_err() to get the error reason when listening fails")
Signed-off-by: Axel Lin <axel.lin@ingics.com>
2017-01-01 19:53:51 +01:00
sg
a2a16d4193 nd6 rdnss: fixed dual-stack compilation 2016-12-31 15:51:59 +01:00
sg
98fc82fa71 added function tcp_listen_with_backlog_and_err() to get the error reason when listening fails (bug #49861) 2016-12-31 15:36:31 +01:00
Dirk Ziegelmeier
748e2e925b Create documentation section "porting" and move it under lwIP section (instead of infrastructure) 2016-12-29 09:29:24 +01:00
Dirk Ziegelmeier
1fd69ddee9 Minor documentation update in def.c 2016-12-29 09:28:45 +01:00
David van Moolenbroek
71810d0415 ipv6: adjust MLD membership on address state changes
If MLD support is enabled, each locally assigned IPv6 address in the
appropriate state must be a member of the solicited-node multicast
group corresponding to that address.  Ensure that this is always the
case by (re-)deciding on the membership upon every address state
change.  By doing so, this patch enforces that user-initiated state
changes to addresses (e.g., deletion) never cause a desynchronization
with the corresponding solicited-node multicast group membership,
thereby making such user-initiated state changes simpler and safer.
2016-12-20 22:28:02 +01:00
Dirk Ziegelmeier
dd96c71253 Fix a few -Wconversion warnings (there are many more to do) 2016-12-20 14:22:51 +01:00
Dirk Ziegelmeier
e0c0ba7e1b Fix compile with LWIP_NOASSERT
Pointed out by Nirav Desai
2016-12-19 10:11:23 +01:00
Axel Lin
f488c5b7bc igmp: Fix optimized code for igmp_remove_group
The code in the for loop checks tmp_group->next == group, so current code
actually checks from the 3rd entry in the linked groups list. Fix it.

Fixes: 5c1dd6a4c6 ("Optimization in igmp_remove_group() pointed out by Axel Lin")
Signed-off-by: Axel Lin <axel.lin@ingics.com>
2016-12-17 22:01:30 +01:00
Dirk Ziegelmeier
5c1dd6a4c6 Optimization in igmp_remove_group() pointed out by Axel Lin
No need to handle special case "first in list" since this is always the allsystems group that shall not be removed
2016-12-17 15:06:33 +01:00
Dirk Ziegelmeier
102a50fa96 Fix bug #39145: IGMP membership report for 224.0.0.1
Ensure allsystems group is always first in linked list
2016-12-17 13:36:24 +01:00
Joel Cunningham
cceea73c3f bug #49631: handle zero-window probe and refused_data
This commit adds support for responding to a zero-window probe when
the refused_data pointer is set

A zero-window probe is a data segment received when rcv_ann_wnd
is 0. This corrects a standards violation where LwIP would not
respond to a zero-window probe with its current ACK value (RCV.NXT)
when it has refused data, thus leading to the probing TCP closing
out the connection
2016-12-16 09:37:54 -06:00
Dirk Ziegelmeier
b5f51dbd0c ND6: Don't misuse ip6_current_dest_addr() to create an aligned copy of an IPv6 address
We never know what side effect in application code this could trigger...
2016-12-16 08:51:06 +01:00
David van Moolenbroek
a8b986bbb6 Add hook for TCP Initial Sequence Number generation
lwIP produces a TCP Initial Sequence Number (ISN) for each new TCP
connection. The current algorithm is simple and predictable however.
The result is that lwIP TCP connections may be the target of TCP
spoofing attacks.  The problem of such attacks is well known, and a
recommended ISN generation algorithm is standardized in RFC 6528.
This algorithm requires a high-resolution timer and cryptographic
hashing function, though.  The implementation (or best-effort
approximation) of both of these aspects is well beyond the scope of
lwIP itself.

For that reason, this patch adds LWIP_HOOK_TCP_ISN, a hook that
allows each platform to implement its own ISN generation using
locally available means.  The hook provides full flexibility, in
that the hook may generate anything from a simple random number
(by being set to LWIP_RAND()) to a full RFC 6528 implementation.

Implementation note:

Users of the hook would typically declare the function prototype of
the hook function in arch/cc.h, as this is the last place where such
prototypes can be supplied.  However, at that point, the ip_addr_t
type has not yet been defined.  For that reason, this patch removes
the leading underscore from "struct _ip_addr", so that a prototype
of the hook function can use "struct ip_addr" instead of "ip_addr_t".

Signed-off-by: sg <goldsimon@gmx.de>
2016-12-15 20:18:08 +01:00
goldsimon
da15132aa0 Make nd6_new_router() handle already existing routers (this is a special case for 2 netifs on the same subnet - e.g. wifi and cable) see bug #46506 2016-12-15 09:25:44 +01:00
Axel Lin
e3925cc359 nd6: Fix build error if LWIP_ND6_RDNSS_MAX_DNS_SERVERS == 0
Fix below build error when LWIP_ND6_RDNSS_MAX_DNS_SERVERS == 0
../../../../lwip/src/core/ipv6/nd6.c: In function ‘nd6_input’:
../../../../lwip/src/core/ipv6/nd6.c:400:10: error: unused variable ‘rdnss_server_idx’ [-Werror=unused-variable]
     u8_t rdnss_server_idx = 0;
          ^~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
../Common.mk:93: recipe for target 'nd6.o' failed
make: *** [nd6.o] Error 1

Fixes: 6b1950ec24 ("nd6: add support for RDNSS option (as per RFC 6106)")
Signed-off-by: Axel Lin <axel.lin@ingics.com>
2016-12-15 08:11:34 +01:00
sg
6b1950ec24 nd6: add support for RDNSS option (as per RFC 6106) 2016-12-14 22:12:14 +01:00
sg
4e3cf61571 opt.h: added LWIP_DHCP_MAX_DNS_SERVERS to configure the maximum number of DNS servers configured from dhcp.c(v4) (if any; guarded with LWIP_DNS) 2016-12-14 22:04:08 +01:00
sg
53b9f2a5bd dhcp: covert DHCP_OPTION_IDX_* from defines to enum (mainly to ease offset calculation) 2016-12-14 21:56:39 +01:00
David van Moolenbroek
cd5dfa2bc5 nd6: minor 'static' consistency fix 2016-12-14 21:25:55 +01:00
sg
60cd25c6a1 Moved nd6 implementation details to new file nd6_priv.h (possible after David's cleanups) 2016-12-14 21:04:53 +01:00
sg
4c16ea920c Minor: nd6_packet_send_check() -> nd6_get_next_hop_addr_or_queue() (too long, but a little more self-explaining); cosmetics... 2016-12-14 20:52:44 +01:00
David van Moolenbroek
69a7039f75 nd6: centralize link-local packet send decision
Previously, ethip6 and lowpan6 each had their own copy of code that
used internal nd6 data structures to decide whether to send a packet
on the local link right away, or queue it while nd6 performed local
address resolution.  This patch moves that code into nd6, thereby
eliminating all remaining cases of external access to internal nd6
data structures, as well as the need to expose two specific nd6
functions.

As a side effect, the patch effectively fixes two bugs in the lowpan6
code that were already fixed in the ethip6 code.
2016-12-14 20:19:50 +01:00
David van Moolenbroek
06ff89cbe4 nd6: use default_router_list internally only
This patch rearranges the code division between nd6.c and ip6.c such
that the latter does not need to access ND6-internal data structures
(specifically, "default_router_list") directly anymore.
2016-12-14 20:16:38 +01:00
David van Moolenbroek
cee59ba8cd nd6: add nd6_clear_destination_cache() function
The new function, while currently not used internally, allows external
code to clear the ND destination cache in the case that it may have
become inconsistent with the current situation, for example as the
result of a change of locally assigned addresses, or a change in
routing tables implemented through the LWIP_HOOK_ND6_GET_GW hook.
2016-12-14 20:12:40 +01:00
goldsimon
d4fad5929c nd6_input(): allow using NA without lladdr_opt for DAD 2016-12-14 13:11:13 +01:00
David van Moolenbroek
7d119fd86b nd6: add LWIP_HOOK_ND6_GET_GW hook 2016-12-14 08:36:57 +01:00
goldsimon
74a5537e15 Revert "Added LWIP_HOOK_ETHIP6_GET_GW()"
This reverts commit 86b01e4f29.
2016-12-14 08:36:47 +01:00
goldsimon
afb21603dc Add a check for correct implementation of LWIP_CONST_CAST() to lwip_init() 2016-12-14 08:31:09 +01:00
David van Moolenbroek
002e077dbd ethip6: forward correct error code
On failure, nd6_get_next_hop_entry() returns an ERR_ type negative
error code.  ethip6_output() erroneously assumed that that error would
always be ERR_MEM, even though it may also be ERR_RTE in practice.
With this patch, ethip6_output() simply forwards the returned error.
2016-12-14 08:29:36 +01:00
sg
9d199a6d72 netif_create_ip6_linklocal_address(): use macros to assign address state to ensure callbacks are triggered; netif_add_ip6_address(): only overwrite invalid addresses, not tentative addresses 2016-12-13 21:54:49 +01:00
Pradip De
86b01e4f29 Added LWIP_HOOK_ETHIP6_GET_GW()
Signed-off-by: sg <goldsimon@gmx.de>
2016-12-13 21:53:07 +01:00
Dirk Ziegelmeier
e5f9f187ad Continue to fix incorrect casts via size_t for some platforms
Now also for casts:
- to remove alignment warnings
- casts between pointers and ints
2016-12-12 10:17:33 +01:00
Dirk Ziegelmeier
f2a5aa2866 Fix bug #49827: wrong cast to size_t on 16-bit x86 architecture
I hope I caught all of them.
TODO: Same for casts to get rid of alignment warnings, these are also casts via size_t
2016-12-12 10:07:00 +01:00
Dirk Ziegelmeier
7a1b38db6e Minor: Save an #ifdef in ip4_frag.c 2016-12-09 21:26:53 +01:00
Dirk Ziegelmeier
26e02e84a6 Fix bug #48963: ip6_frag does not support LWIP_NETIF_TX_SINGLE_PBUF
Implemented.
2016-12-09 21:26:21 +01:00
goldsimon
5774fdfe75 dns: added one-shot multicast DNS queries 2016-12-09 09:20:46 +01:00
Dirk Ziegelmeier
89cb7b7aa1 Try to remove #include <stdlib.h> from many files. Does not seem necessary any more and might cause problems when porting lwIP. 2016-12-08 11:05:01 +01:00
goldsimon
9c3bbcf4e6 removed old disabled code 2016-12-08 10:24:56 +01:00
Dirk Ziegelmeier
aae0fc4908 Use new IPv6 init macro in netif.c 2016-12-07 22:19:37 +01:00
goldsimon
b31b0c8148 remove bogus LWIP_MAKE_U16() define and use PP_NTOHS() in ip4.c instead 2016-12-07 12:44:57 +01:00
goldsimon
c87855423c DNS: added compile-time check for some defines to fit into an u8_t (bug #49658) 2016-12-07 09:09:45 +01:00
Dirk Ziegelmeier
1687721600 Fix compile when IPv4 is disabled 2016-12-05 22:01:58 +01:00
Axel Lin
92183bb354 icmp: Increment mib2.icmpintimeexcds counter if got ICMP_TE
Increment mib2.icmpintimeexcds rather than mib2.icmpindestunreachs if got ICMP_TE.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
2016-12-05 12:30:09 +01:00
Joel Cunningham
7f48289fcd Increment ip.drop when dropping due to NULL netif
This commit increments the ip.drop statistic when an IP packet is
dropped due to no matching netif found and forwarding is disabled

This adds parity to the other places where mib2.ipinaddrerrors and
mib2.ipindiscards are incremented which also increment ip.drop
2016-11-30 08:49:22 -06:00
Dirk Ziegelmeier
182d7c138a Add #include <stddef.h> to a central place (arch.h) instead of #including it in several other files throughout lwip since size_t is needed in many places
See http://lwip.100.n7.nabble.com/Issue-in-arch-h-for-lwIP-2-0-0-td27948.html
2016-11-30 07:43:59 +01:00
goldsimon
6f1304e03e patch by Ambroz Bizjak: fixed bug #49717 (window size in received SYN and SYN-ACK assumed scaled) 2016-11-28 10:27:21 +01:00
Axel Lin
cac3dc8a46 netif: Trivial indent fix
Signed-off-by: Axel Lin <axel.lin@ingics.com>
2016-11-28 10:24:23 +01:00
Axel Lin
1d4cbe768d netif: Add proper lock protect for accessing netif->loop_first
All the reset part of the code accessing netif->loop_first has lock protection,
the only missing part is "while (netif->loop_first != NULL)".
Fix it by adding lock protect around the while loop.

Also convert the code to use while{} loop instead of do .. while{} loop,
then we can avoid NULL test for in pointer in each loop and reduce a level of indent.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
2016-11-25 13:02:23 +01:00
goldsimon
0e07ed4b13 fixed bug #49676 (Possible endless loop when parsing dhcp options) & added unit test for that 2016-11-25 10:03:43 +01:00
Ambroz Bizjak
8ba7363d11 Optimize passing contiguous nocopy buffers to tcp_write
While TCP_OVERSIZE works only when tcp_write() is used with
TCP_WRITE_FLAG_COPY, this new code achieves
similar benefits for the use case that the caller manages their own
send buffers and passes successive chunks of those to tcp_write()
without TCP_WRITE_FLAG_COPY.

In particular, if a buffer is passed to
tcp_write() that is adjacent in memory to the previously passed
buffer, it will be combined into the previous ROM pbuf reference
whenever possible, thus extending that ROM pbuf rather than allocating
a new ROM pbuf.

For the aforementioned use case, the advantages of this code are
twofold:
1) fewer ROM pbufs need to be allocated to send the same data, and,
2) the MAC layer gets outgoing TCP packets with shorter pbuf chains.

Original patch by Ambroz Bizjak <ambrop7@gmail.com>
Edited by David van Moolenbroek <david@minix3.org>
Signed-off-by: goldsimon <goldsimon@gmx.de>
2016-11-24 11:27:34 +01:00
Dirk Ziegelmeier
09547832ba Fix bug #49662: UDP layer should filter incoming multicast datagrams against the bound IP address
Change lwIP UDP API to match socket behavior. Multicast traffic is now only received on a UDP PCB (and therefore on a UDP socket/netconn) when the PCB is bound to IP_ADDR_ANY.
2016-11-23 12:46:35 +01:00
sg
03a9aac157 dns_enqueue(): minor readability improvement: add local variable "age" to store result of subtraction 2016-11-22 21:34:12 +01:00
David van Moolenbroek
68ec20fffc ipv4/ipv6: restrict loopback-destined traffic
Generally speaking, packets with a loopback destination address -
127.0.0.1 for IPv4 and ::1 for IPv6 - should not be accepted on
non-loopback interfaces.  For IPv4, this is implied by RFC 1122
Sec. 3.2.1.3.  For IPv6, it is mandated by RFC 4291 Sec. 2.5.3.
Failure to perform this filtering may have security implications, as
applications that bind sockets to loopback addresses may not expect
that nodes on the local external network be able to produce traffic
that will arrive at such sockets.

With this patch, lwIP drops packets that are sent to a loopback
address but do not originate from the interface that has the loopback
address assigned to it.  This approach works regardless of whether it
is lwIP or the system using it that implements a loopback netif.  The
only exception that must be made is for configurations that enable
netif packet loopback but disable the lwIP loopback netif: in that
case, loopback packets are routed across non-loopback netifs and would
thus be lost by the new filter as well.

For IPv6, loopback-destined packets are also no longer forwarded; the
IPv4 forwarding code already had a check for that.

As a small performance improvement, the IPv6 link-local/loopback
address check is now performed only once per packet rather than
repeatedly for every candidate netif.
2016-11-22 20:51:36 +01:00
Dirk Ziegelmeier
4076b12ee9 Revert "Apply patch #9165: Allowing udp src port to be 0 in cases when we don't care about outgoing port"
This reverts commit 31b0237c50.
2016-11-22 14:35:45 +01:00
David van Moolenbroek
0034abfa45 Always check whether netif_default is NULL
In general, netif_default may be NULL, and various places in the code
already check for this case before attempting to dereference the
netif_default pointer.  Some places do not perform this check though,
and may cause null pointer dereferences if netif_default is not set.
This patch adds NULL checks to those places as well.
2016-11-21 10:16:28 +01:00
Dirk Ziegelmeier
31b0237c50 Apply patch #9165: Allowing udp src port to be 0 in cases when we don't care about outgoing port 2016-11-18 08:13:15 +01:00
Dirk Ziegelmeier
80a24c0399 raw, udp, tcp connect() does NOT need to match exact IP type - when PCB is bound to IPADDR_ANY_TYPE, it is OK to connect to IPv4 or IPv6
This should finally implement task #14187: Dual Stack sendto with socket APIs
2016-11-16 23:39:43 +01:00
Dirk Ziegelmeier
d026a3954a Dual-stack fixes in raw/udp/tcp
bind() may change IP type when previous type is IPADDR_TYPE_ANY
connect() IP type must exactly match bind IP type
Use correct IPADDRx_ANY type when calling ip_route()
2016-11-16 23:30:19 +01:00
Dirk Ziegelmeier
b99b7577fc memp.c: Only check for overflow/underflow if an element could be allocated
In other words: Don't dereference NULL pointers
2016-11-16 20:15:51 +01:00
Joel Cunningham
f79eabd24b bug #49533: start persist timer when unsent seg can't fit in window
This commit returns LwIP to previous behavior where if the next unsent
segment can't be sent due to the current send window, we start the
persist timer. This is done to engage window probing in the case that
the subsequent window update from the receiver is dropped, thus
preventing connection deadlock

This commit refines the previous logic to only target the following case:
 1) Next unsent segment doesn't fit within the send window (not
    congestion) and there is some room in the window
 2) Unacked queue is empty (otherwise data is inflight and the RTO timer
    will take care of any dropped window updates)

See commit d8f090a759 (which removed this
behavior) to reference the old logic. The old logic falsely started the
persit timer when the RTO timer was already running.
2016-11-16 09:12:47 -06:00
Roberto Barbieri Carrera
81a32e9b06 Fixed bug #49610: Sometimes, autoIP fails to reuse the same address
Signed-off-by: goldsimon <goldsimon@gmx.de>
2016-11-16 12:24:57 +01:00
Joel Cunningham
6dc3a2108a WND_SCALE: duplicate define check & doc cleanup
This commit cleans up a duplicate #if check for LWIP_WND_SCALE in init.c
which was already under #if LWIP_WND_SCALE

This commit also improves documentation for TCP_WND in the window scaling
case to communicate TCP_WND is always the calculated (scaled) window value,
not the value reported in the TCP header

Our developers were confused by having to set both the window and scaling
factor and only after studying the usage of TCP_WND throughout the code, was
it determined to be the calculated (scaled) window
2016-11-11 16:06:54 -06:00
Dirk Ziegelmeier
f965034366 Fix inconsistent return value in udp_sendto_if() - ERR_RTE should always be returned when there is no available route 2016-11-11 11:13:26 +01:00
Axel Lin
d5dd5241e7 dhcp: Use DHCP_MAX_MSG_LEN_MIN_REQUIRED instead of hard-coded value
Signed-off-by: Axel Lin <axel.lin@ingics.com>
2016-11-07 12:36:38 +01:00
Dirk Ziegelmeier
54d76ffd6d Remove superfluous local variable in raw.c 2016-11-05 15:13:57 +01:00
David van Moolenbroek
1c9e603299 netif: fix reset of IPv6 addresses in netif_add()
Previously, only the state of the first IPv6 address would be reset,
thus possibly keeping other addresses valid (even though zeroed).
2016-11-04 20:18:25 +01:00
Axel Lin
1a7ba24d13 memp: Fix memp_overflow_check_all failure
p needs to point to LWIP_MEM_ALIGN(memp_pools[i]->base) otherwise it will cause
assertion in overflow checking.

Fixes: c838e1ed5b ("Implement possibility to declare private memory pools")
Signed-off-by: Axel Lin <axel.lin@ingics.com>
2016-11-04 20:16:24 +01:00
Erik Ekman
a82ec4499f memp: Check for null in memp_free
When memp_free_pool was split out from memp_free (c838e1ed5b),
the check for freeing the null pointer was lost.

This resulted in the null value being put back in the list of free
objects, causing all subsequent allocations of that type to fail.
2016-11-03 12:17:01 +01:00
Joel Cunningham
7d8989e3ea TCP documentation: fix tcp_pbuf_prealloc typo
This commit fixes a typo in the tcp_pbuf_prealloc documentation that
used "willo" in place of "will"
2016-11-02 14:10:20 -05:00
Dirk Ziegelmeier
5079e4552c Document non-standard functions in sys abstraction layer 2016-10-23 10:34:52 +02:00
David van Moolenbroek
760281207e mld6: fix conditional checksumming
The mld_group structure no longer has a 'netif' field, as such
structures are now linked from the corresponding netif structure.
For conditional checksumming, use the calling function's netif
reference instead.
2016-10-23 10:00:47 +02:00
Axel Lin
20fde0be6c ip4_frag: Use LWIP_MIN instead of open-coded
Signed-off-by: Axel Lin <axel.lin@ingics.com>
2016-10-19 08:37:39 +02:00
Dirk Ziegelmeier
67895e7bdd Fixup new IPv4 fragmentation code - thanks to Zach Smith 2016-10-19 08:36:43 +02:00
Dirk Ziegelmeier
801f26ee0c Minor documentation update 2016-10-16 19:07:55 +02:00
Dirk Ziegelmeier
f5f8ab5acf Fix bug #49328: Crash error in ip6_frag due to Assertion Fail 2016-10-13 08:50:47 +02:00
Dirk Ziegelmeier
e3a9f01fe4 Implement task #14180: IPv6 code should not reuse ip6_current_dest_addr() as temporary storage 2016-10-12 21:41:02 +02:00
goldsimon
6edde498e3 pbuf_copy: try to fix GCC const warning 2016-10-11 09:52:44 +02:00
goldsimon
d5bfec2e52 ip4_frag: restore "lwip_ntohs" after last change 2016-10-11 09:52:20 +02:00
goldsimon
576f49ee2b Fixed bug #46467: ip_frag() shouldn't modify pbuf in case of a retransmission 2016-10-11 09:47:03 +02:00
goldsimon
697be5c2c3 Make some pbuf functions take const pbuf pointers 2016-10-11 09:23:45 +02:00
Axel Lin
c9cfbe27c1 tcp_out: Remove misleading comment in tcp_pbuf_prealloc()
This comment is incorrect since commit 7d0dab9d7d
"partly fixed bug #25882: TCP hangs on MSS > pcb->snd_wnd
(by not creating segments bigger than half the window)".

Signed-off-by: Axel Lin <axel.lin@ingics.com>
2016-10-11 09:11:47 +02:00
Dirk Ziegelmeier
ed239c4e71 Apply patch #9139: Invalid format string in dhcp.c
by Thomas Mueller
2016-10-10 09:57:07 +02:00
Dirk Ziegelmeier
695c81762c Minor: Fix comment in etharp.c 2016-10-09 12:28:34 +02:00
Dirk Ziegelmeier
f6e27940bd Make lwIP compile with clang -Wdocumentation -> several documentation fixes 2016-10-09 12:21:39 +02:00
Dirk Ziegelmeier
4e74ae4bc9 Minor: documentation updates 2016-10-09 10:23:36 +02:00
Dirk Ziegelmeier
5477aa5a42 Minor: Documentation update 2016-10-09 09:41:26 +02:00
Ari Suutari
70ccea9207 Make sys_restart_timeouts public also for !NO_SYS targets 2016-10-07 20:31:15 +02:00
Dirk Ziegelmeier
13fb616bb2 Cleanup hton*/ntoh* function handling and platform abstraction
Let lwip use functions/macros prefixed by lwip_ internally to avoid naming clashes with external #includes.
Remove over-complicated #define handling in def.h
Make functions easier to override in cc.h. The following is sufficient now (no more LWIP_PLATFORM_BYTESWAP):
#define lwip_htons(x) <your_htons>
#define lwip_htonl(x) <your_htonl>
2016-10-06 12:55:57 +02:00
Dirk Ziegelmeier
0c06073819 Avoid code duplication in def.c 2016-10-06 09:26:59 +02:00
Elias Reichart
60a507f88b ETHARP_TABLE_MATCH_NETIF is also used in the etharp_output shortcut 2016-10-04 22:15:59 +02:00
David van Moolenbroek
0d7805a86a tcp: fix FIN ACK handling with unsent data
TCP's snd_nxt represents the next sequence number after sent data, and
as such does not cover any unsent data queued on the connection.  The
current implementation does not take the latter point into account
when processing FIN acknowledgments, mistakenly assuming that an
outgoing FIN is ACK'ed when the acknowledgment covers up to snd_nxt
while there is still unsent data.  This patch adds a check for unsent
data to correct this, effectively preventing that TCP connections are
closed prematurely.
2016-10-04 22:12:13 +02:00
David van Moolenbroek
9ba9dee2aa tcp: advance next seq nr for zero window probes
It is possible that the byte sent as a zero window probe is accepted
and acknowledged by the receiver side without the window being opened.
In that case, the stream has effectively advanced by one byte, and
since lwIP did not take this into account on the sender side, the
result was a desynchronization between the sender and the receiver.
That situation could occur even on a lwIP loopback device, after
filling up the receiver side's receive buffer, and resulted in an ACK
storm. This patch corrects the problem by advancing the sender's next
sequence number by one as needed when sending a zero window probe.
2016-10-04 22:06:05 +02:00
Dirk Ziegelmeier
bef7873042 ND6: Always set neighbor_cache.state together with counter value to avoid inconsistency 2016-10-04 13:59:05 +02:00
Dirk Ziegelmeier
ee27daffc4 Fix bug #48876: nd6: timers should be in ticks, not ms
delay_time and stale_time are ticks now.
reachable_time and invalidation_timer are untouched since they may originate from telegram values -> not converting them to ticks avoids an integer division
2016-10-04 13:30:23 +02:00
Dirk Ziegelmeier
eb77c839fc Minor: comment in pbuf.c 2016-10-03 09:45:59 +02:00
Axel Lin
5e15125b3d igmp: Fix optimized code by always skipping the first entry in the linked groups list
commit 8c52afb6ca ("igmp: Optimize code by always skipping the first entry in the linked groups list - it is always the "allsystems" entry")
accidently changes the code logic. it should check groupref rather than group.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
2016-10-02 19:36:59 +02:00
Dirk Ziegelmeier
8f8f56914b Fix bug #47731: IGMP state transition missing
Set state variable according to RFC 2236 on timeout in delaying member state
2016-10-01 21:27:00 +02:00
Dirk Ziegelmeier
8c52afb6ca igmp: Optimize code by always skipping the first entry in the linked groups list - it is always the "allsystems" entry 2016-10-01 17:28:36 +02:00
Dirk Ziegelmeier
df5a79966d Fix bug #48886: raw pcbs are not handled on netif address change 2016-10-01 17:13:33 +02:00
Dirk Ziegelmeier
149701b347 Fix bug #49218: pbuf_clen() overflow as a result of tcp_write concatenation
Let pbuf_clen() return u16_t
2016-09-30 09:04:36 +02:00
Dirk Ziegelmeier
65796cd827 "Fix" bug #49078: lwip cannot establish ipv6 connection, because of failed to fill ipv6 source address in Neighbor Solicitation Message by adding a note to netif_add not to forget to create a link-local IPv6 address 2016-09-29 12:02:50 +02:00
Dirk Ziegelmeier
17e6c9dd02 Add #include <string.h> in def.c since lwip_strnstr uses strlen and strcmp 2016-09-29 08:08:26 +02:00
Dirk Ziegelmeier
0e7f48d81c Fix compile of new functions in def.c - I accidentally put them in a #ifdef section
Thanks to Daniel Elstner
2016-09-28 22:26:55 +02:00
Dirk Ziegelmeier
4144d54642 Fix implementation of lwip_itoa to take more parameters 2016-09-28 22:05:18 +02:00
Dirk Ziegelmeier
1f68b32485 Cleanup handling of non-standard functions in lwIP
- itoa
- strnicmp, stricmp/strcasecmp
- strnstr
Related to patch #9115: httpd.c: strcasecmp for GCC and stricmp for Windows
2016-09-28 21:52:11 +02:00
Dirk Ziegelmeier
633696c153 Implement consistent IPx_ADDR_ANYx macro naming between IPv4 and IPv6
- rename IP4_ADDR_ANY to IP4_ADDR_ANY4
- IP4_ADDR_ANY (= IP_ADDR_ANY) is now IPv4 any address in ip_addr_t format
2016-09-28 12:56:57 +02:00
Dirk Ziegelmeier
6abcd00f71 Convert IP address type numbers to an enum to improve documentation 2016-09-27 09:46:51 +02:00
Dirk Ziegelmeier
97b774ceb9 Minor: Documentation updates 2016-09-26 21:45:29 +02:00
Daniel Elstner
2f085aa441 ND6: Join/leave groups directly on the netif 2016-09-26 11:44:00 +02:00
Daniel Elstner
354e385453 Fix infinite loop in new MLD6 code 2016-09-26 11:43:59 +02:00
Dirk Ziegelmeier
c7c6b7ce93 Rework IGMP and MLD6 code to store group info per-netif.
Reasoning:
- Makes code in single-netif case perform better and smaller
- IGMP / MLD6 code is a little bit easier to read and understand
- Easier to get multicast groups per netif when implementing drivers

Downside: In multi-netif mode, there are two more pointers on each netif, even if IGMP/MLD6 is not used on it. But these systems should not be so memory-constrained that this will matter.
2016-09-21 13:33:33 +02:00
Dirk Ziegelmeier
c25de8f317 Update comment in MDNS and pbuf.c 2016-09-21 12:37:31 +02:00
Dirk Ziegelmeier
eb3a08308d Improve my last docs 2016-09-20 09:14:32 +02:00
Dirk Ziegelmeier
470dae613e Documentation: Add example for zero-copy RX using custom PBUF 2016-09-20 09:03:49 +02:00
Daniel Elstner
22907c7b27 bug #74921: check prefix_length, not length 2016-09-19 18:38:05 +02:00
Dirk Ziegelmeier
623f9ce046 Remove one debug message from Daniel's patch 2016-09-19 12:32:43 +02:00
Daniel Elstner
4d4710dadf Bug #49125 addendum: Remove group from list before callback
When leaving a multicast group, remove the group from the list
before invoking the MAC filter callback. This avoids the need
for the callee to skip over the group that is about to be deleted.
2016-09-19 12:26:51 +02:00
Dirk Ziegelmeier
ee4cd45c98 Fix bug #49125: Need a way to iterate multicast groups for MAC filtering
-> let list heads be a public symbol
2016-09-19 08:45:57 +02:00
Dirk Ziegelmeier
8cd43a3dd9 Documentation: Add one more note PCB is already freed in tcp_err callback. 2016-09-09 17:36:49 +02:00
Joel Cunningham
b7c2553b46 bug #48964: Make PBUF_POOL sanity checks contingent on PBUF_POOL_SIZE
This commit adds support to the sanity checks in init.c to ensure that
PBUF_POOL is in use

In ports with drivers/netifs that use PBUF_REF for the RX pathway, there
is no need for the PBUF_POOL memory pool.  This allows the port to define
PBUF_POOL_SIZE to 0
2016-09-07 09:11:19 -05:00
Axel Lin
f8a95aa27f dns: Drop unnecessary txid variable in dns_check_entry
Signed-off-by: Axel Lin <axel.lin@ingics.com>
2016-09-07 14:56:01 +02:00
Dirk Ziegelmeier
d66442ba91 Fix compile when TCP, UDP and RAW are disabled 2016-09-07 08:11:30 +02:00
sg
34682facd1 Remove ip4_frag IP_FRAG_USES_STATIC_BUF code: nearly the same as the other code, but IP_FRAG_USES_STATIC_BUF doesn't work when queuing pbufs 2016-08-31 21:00:10 +02:00
Dirk Ziegelmeier
ac6b64cf66 Implement a more readable fix for pbuf_memcmp than my last fix 2016-08-31 20:24:37 +02:00
Dirk Ziegelmeier
4325aca0f7 Fix pbuf_memcmp() implementation by using pbuf_try_get_at() instead of pbuf_get_at(). Payload out-of-bounds access was not handled correctly. 2016-08-31 10:35:42 +02:00
sg
23147b0e21 added more out of range checks to dns_recv() (see bug #48924) 2016-08-30 22:18:10 +02:00
sg
a08ed9148d added pbuf_try_get_at() (much like pbuf_get_at() but can return out-of-pbuf error) 2016-08-30 21:35:37 +02:00
Dirk Ziegelmeier
8d45162a59 Fix usage of uninitialized data in dhcp.c by checking pbuf_copy_partial() return value 2016-08-30 21:33:43 +02:00
Dirk Ziegelmeier
2137f49d32 Fix usage of uninitialized data in nd6.c because of unchecked pbuf_copy_partial() return value 2016-08-30 21:20:58 +02:00
Dirk Ziegelmeier
aef3d2cb87 Minor coding style fix in pbuf.c 2016-08-30 21:09:24 +02:00
Dirk Ziegelmeier
840d1e60fa Fix bug #48924: Potential out of bound reads in DNS codes of lwip project by adding checks for pbuf_copy_partial() return values.
Add some comments to clarify handling of untrusted network data handling.
2016-08-30 21:09:24 +02:00
Axel Lin
198fa5dbfa Remove duplicated include for lwip/inet_chksum.h
Include it once is enough.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Dirk Ziegelmeier <dirk@ziegelmeier.net>
2016-08-30 09:47:43 +02:00
Axel Lin
db6aa82a10 memp: Fix comment for memp_overflow_check_element_overflow/underflow
These functions now take desc rather than memp_type as second parameter.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
2016-08-28 20:33:57 +02:00
Dirk Ziegelmeier
4b45baee10 Add some dual-stack notes to documentation 2016-08-26 15:58:18 +02:00
Dirk Ziegelmeier
0d510dd66d Add API macros for netif client data handling and update documentation accordingly 2016-08-26 11:21:49 +02:00
Dirk Ziegelmeier
57468b8a30 Minor: Several documentation updates 2016-08-25 22:04:04 +02:00
goldsimon
89aa4e7d79 fixed bug #47921: link-local prefix in router advertisement must not be processes for SLAAC (patch by abhishek ambure) 2016-08-25 14:21:30 +02:00
goldsimon
3e23eb764b fixed compiling TCP_OOSEQ_MAX_BYTES || TCP_OOSEQ_MAX_PBUFS (local variable 'p' was hidden) 2016-08-25 14:21:29 +02:00
Axel Lin
a2ca85a260 tcp: Make tcp_state_str/tcp_backoff/tcp_persist_backoff static
They are only referenced in tcp.c, so make them static.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: goldsimon <goldsimon@gmx.de>
2016-08-25 11:20:10 +02:00
sg
4c390ad39c update netif address change triggers to tpc & udp to work with IPv6, too 2016-08-24 20:51:05 +02:00
Erik Ekman
a1db05c11e Fix const argument warning in netif_ip6_addr_set
../../../../../lwip/src/netif/ppp/ppp.c:1276:37: error: passing
      'const ip6_addr_t *' (aka 'const struct ip6_addr *') to parameter of type
      'ip6_addr_t *' (aka 'struct ip6_addr *') discards qualifiers
      [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
  netif_ip6_addr_set(pcb->netif, 0, IP6_ADDR_ANY6);
                                    ^~~~~~~~~~~~~
../../../../../lwip/src/include/lwip/ip_addr.h:340:24: note: expanded from macro
      'IP6_ADDR_ANY6'
                       ^~~~~~~~~~~~~~~~~~~~~~~~~
../../../../../lwip/src/include/lwip/netif.h:436:73: note: passing argument to
      parameter 'addr6' here
void netif_ip6_addr_set(struct netif *netif, s8_t addr_idx, ip6_addr_t *addr6);
2016-08-24 14:41:48 +02:00
Axel Lin
bf5866b27d tcp: Prevents a 0 sized (invalid) backlog
commit 44e1a2d8e2 accidently includes below changes in tcp_listen_with_backlog
 -  tcp_backlog_set(lpcb, backlog);
 +  lpcb->backlog = backlog;

Thus pass 0 to the backlog parameter of netconn_listen_with_backlog() fails.

Fixes: 44e1a2d8e2 ("define tcp_backlog_set() as dummy-define when backlog feature is disable")
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: goldsimon <goldsimon@gmx.de>
2016-08-24 12:20:28 +02:00
goldsimon
298ec340e5 set netif IPv6 address & state via function to implement change triggers (task #13517) 2016-08-24 09:19:53 +02:00
Dirk Ziegelmeier
8426dfa14d Remove misleading comments from udp_send() and raw_send(). A pbuf may be added automatically in front of the chain to be able to send PBUF_REFs 2016-08-24 08:45:37 +02:00
Dirk Ziegelmeier
6fc7f84497 Minor: documentation updates 2016-08-24 08:19:51 +02:00
Dirk Ziegelmeier
c719c466b3 Remove SIZEOF_ETHARP_PACKET_TX #define, it is not needed any more after my last cleanups 2016-08-23 20:41:37 +02:00
Dirk Ziegelmeier
31778193da Work on bug #48868: Cleanup etharp.c not to use struct eth_hdr: Cleanup etharp_input() to use ethernet_output() 2016-08-23 17:23:21 +02:00
Dirk Ziegelmeier
6caa7b9927 Cleanup etharp_arp_input() signature to match the sig of other input functions (pbuf, netif). Rename to etharp_input() 2016-08-23 17:03:51 +02:00
Dirk Ziegelmeier
979bee386c Work on bug #48868: Cleanup etharp.c not to use struct eth_hdr: Cleanup etharp_raw() to use ethernet_output() 2016-08-23 16:58:17 +02:00
goldsimon
e4c74109cd fixed bug #47652: there is always a delay to send the first Neighbor Solicitation for the new add INCOMPLETE state neighbor entry 2016-08-23 15:50:48 +02:00
goldsimon
fd5b34ae43 ip4_forward(): fixed compiling IP_FORWARD_ALLOW_TX_ON_RX_NETIF==1 2016-08-23 15:26:05 +02:00
goldsimon
306171c93b DHCP: fixed compiling LWIP_DHCP_BOOTP_FILE==1 2016-08-23 15:25:39 +02:00
goldsimon
d99d91dae9 removed ETHARP_TRUST_IP_MAC since it is insecure and we don't need it any more after implementing unicast ARP renewal towards arp entry timeout 2016-08-23 13:00:15 +02:00
Dirk Ziegelmeier
4456c7d230 Fix regression in etharp.c: Allocate correct pbuf layer 2016-08-23 12:32:57 +02:00
Dirk Ziegelmeier
bae4d6398c Fix some comments to reference ethernet_output now 2016-08-23 10:23:59 +02:00
Dirk Ziegelmeier
18136c047b Work on bug #48824: ethernet.c extensions: Implement ethernet_output();
Fixes bug #48862: ethip6 does not support setting vlan
2016-08-23 10:15:03 +02:00
Axel Lin
1c5c96a50a pbuf: Use SYS_ARCH_INC in pbuf_ref()
Use SYS_ARCH_INC to simplify the code.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: goldsimon <goldsimon@gmx.de>
2016-08-23 08:59:10 +02:00
Axel Lin
40f2bed5c4 mem: Simplify the code for try bigger pool in mem_malloc
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: sg <goldsimon@gmx.de>
2016-08-20 11:29:57 +02:00
Axel Lin
a032ccafe7 mem: Fix trivial comment typo about using custom pools
Signed-off-by: Axel Lin <axel.lin@ingics.com>
2016-08-20 09:17:37 +02:00
goldsimon
4f4d16260f minor: fixed typo 2016-08-19 15:40:36 +02:00
goldsimon
6b1e1af3d1 combine MAC filter actions for IGMP and MLD6 (IGMP has compatibility defines for old code, MLD6 filter functions must be adapted) 2016-08-19 13:54:14 +02:00
Axel Lin
b3bae1b44c memp: Fix unused variable build error when MEMP_SANITY_REGION_BEFORE/AFTER is 0
MEMP_SANITY_REGION_BEFORE and MEMP_SANITY_REGION_AFTER can be overridden in
lwipopts.h, if one of it is set to 0 we got build error due to unused variable.

Fix unused variable build error when MEMP_OVERFLOW_CHECK >= 1 &&
(MEMP_SANITY_REGION_BEFORE == 0 || MEMP_SANITY_REGION_AFTER == 0).

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: goldsimon <goldsimon@gmx.de>
2016-08-19 13:47:37 +02:00
Dirk Ziegelmeier
5e36815867 init.c: Implement check for correct implementation of struct packing in lwip port 2016-08-19 13:05:51 +02:00
Dirk Ziegelmeier
6688033bc4 Move IGMP protocol struct to prot/igmp.h 2016-08-19 12:50:41 +02:00
goldsimon
ed566cceaa minor cleaup in (eth)arp 2016-08-19 12:49:02 +02:00
goldsimon
55d05092ef simplify memp.c code a bit 2016-08-19 12:25:48 +02:00
Axel Lin
0e9ef19cfb memp: Remove memp_overflow_init() function
There is only one caller using memp_overflow_init(), and at that context
calling memp_overflow_init_element() actually simplifes the code.
Thus remove memp_overflow_init() function.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: goldsimon <goldsimon@gmx.de>
2016-08-19 12:25:47 +02:00
goldsimon
14fb48cd7a minor: whitespace cleanups 2016-08-19 09:41:34 +02:00
goldsimon
9725a496b5 moved 2 enums from 'prot' headers to where they belong (dns, dhcp) 2016-08-19 09:41:33 +02:00
Dirk Ziegelmeier
8eb9db18a2 Reduce usage of netif/ethernet.h header, mostly lwip/prot/ethernet.h is sufficient 2016-08-19 08:36:00 +02:00
sg
43d6812b3e IPv6 addr: clarify tentative count/LWIP_IPV6_DUP_DETECT_ATTEMPTS 2016-08-18 22:02:57 +02:00
Dirk Ziegelmeier
2d503f4433 Work on bug #48728: headers should cleanly separate API vs. implementation
ICMP6
2016-08-18 20:52:00 +02:00
Dirk Ziegelmeier
81c68f529b Work on bug #48728: headers should cleanly separate API vs. implementation
MLD6
2016-08-18 20:36:44 +02:00
Dirk Ziegelmeier
8d68400387 Work on bug #48728: headers should cleanly separate API vs. implementation
ND6
2016-08-18 20:28:03 +02:00
Axel Lin
e24fde05db memp: Fix memp_overflow_check_element_overflow assertion
Use LWIP_MEM_ALIGN() in memp_overflow_init() to get alignment address for memp.
This fixes assertion in memp_overflow_check_element_overflow when
MEMP_OVERFLOW_CHECK is set.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
2016-08-18 19:24:34 +02:00
Axel Lin
ef31afb921 memp: Fix build error when LWIP_HOOK_MEMP_AVAILABLE is defined
Fix below build error.

../../../../../lwip/src/core/memp.c: In function ‘memp_free’:
../../../../../lwip/src/core/memp.c:490:31: error: request for member ‘tab’ in something not a structure or union
   old_first = memp_pools[type].tab;
                               ^
../../Common.mk:94: recipe for target 'memp.o' failed
make: *** [memp.o] Error 1

Fixes: de9054cb7a ("memp: cleaned up MEMP_MEM_MALLOC")
Signed-off-by: Axel Lin <axel.lin@ingics.com>
2016-08-18 19:20:26 +02:00
Dirk Ziegelmeier
97fae7e41b Code cleanup in autoip.c and dhcp.c 2016-08-18 12:49:59 +02:00
Dirk Ziegelmeier
7f60cb3889 Improve netif client data API for lwIP internal clients - these can use a compile-time constant to access their data now 2016-08-18 12:37:21 +02:00
Dirk Ziegelmeier
ebf7959880 Coding style fixes in netif.c 2016-08-18 11:44:19 +02:00
Dirk Ziegelmeier
0c7a59b5db Minor: Documentation fixes 2016-08-18 11:06:50 +02:00
Dirk Ziegelmeier
c9ad58308a Minor documentation fixes 2016-08-18 10:59:18 +02:00
Dirk Ziegelmeier
fa6a2d48cc Fix DHCP unit test after my last changes 2016-08-18 06:09:02 +02:00
Dirk Ziegelmeier
c62bfd8146 Port AUTOIP to new netif client data API 2016-08-17 21:26:08 +02:00
Dirk Ziegelmeier
1db9631e7d Port DHCP to new netif client data API 2016-08-17 21:04:44 +02:00
Dirk Ziegelmeier
c28fb298b7 Introduce an API to store arbitrary data pointers in struct netif
Let MDNS to use the new API
TODO: AutoIP, DHCP
2016-08-17 16:37:15 +02:00
Dirk Ziegelmeier
efb7b3d5f8 Rename LWIP_MDNS to LWIP_MDNS_RESPONDER 2016-08-17 12:07:38 +02:00
Dirk Ziegelmeier
c61c8f3766 Use udp_get_multicast_ttl/udp_set_multicast_ttl accessors where applicable 2016-08-16 08:08:06 +02:00
Erik Ekman
4919932c49 Apply patch #8755: Multicast DNS responder support from Erik Ekman 2016-08-14 15:07:45 +02:00
Dirk Ziegelmeier
5493220c93 Move DNS protocol structs to separate header. Needed for Erik Ekman's MDNS implementation. 2016-08-13 09:05:28 +02:00
Dirk Ziegelmeier
6dcb2b2415 Work on bug #48730: Enums should be used instead of multiple defines (where applicable) 2016-08-12 22:51:43 +02:00
goldsimon
dc7340bbd5 started with bug #48728: move protocol definitions to 'include/prot/*.h' files (started with some IPv4 protocols) 2016-08-11 14:36:09 +02:00
goldsimon
bf3e8e6a48 minor coding style fixes in IPv6 code 2016-08-11 09:23:43 +02:00
Dirk Ziegelmeier
5c0944e01a Don't document tcp_send_empty_ack and tcp_keepalive - users should never need them 2016-08-09 10:17:16 +02:00
Dirk Ziegelmeier
5a09fd3e35 Don't document ip4_route and ip6_route, users should use ip_route instead 2016-08-09 10:16:40 +02:00
Dirk Ziegelmeier
85ab39985a Fix a few incorrect uses of err_t. Found by converting lwip error codes to an enum, but I'm not sure wether I want to commit the actual enum conversion. 2016-08-08 22:15:01 +02:00
Dirk Ziegelmeier
1631307bb3 tcp.c: Partly undo Simon's changes from today (repairs doxygen docs) 2016-08-08 21:42:27 +02:00
goldsimon
eba6ae0122 minor: add a comment about where to define LWIP_RAND() 2016-08-08 09:14:50 +02:00
goldsimon
219438fb24 cleanup: move stdlib.h include to mem.c, where it belongs 2016-08-08 09:11:24 +02:00
goldsimon
08378b7d4b Improve LWIP_EVENT_API compilation 2016-08-08 08:49:14 +02:00
David van Moolenbroek
fc66fb830c Fix compilation for LWIP_EVENT_API
Without LWIP_CALLBACK_API, is no error callback function pointer in
the TCP PCB, nor is it needed, so do not attempt to access it.
2016-08-08 08:48:28 +02:00
Dirk Ziegelmeier
f55c0e7864 Move rawapi.txt description to main page - this doc really should be found and read by users 2016-08-07 20:21:27 +02:00
Axel Lin
0a7db8a9a5 PPP: remove double include for lwip/sys.h
Including it once is enough.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Sylvain Rochet <gradator@gradator.net>
2016-08-07 12:35:50 +02:00
Dirk Ziegelmeier
980a919c9a Don't document IP type specific output functions, users should use IP type independent ones 2016-08-07 10:13:50 +02:00
Dirk Ziegelmeier
8d07629b71 Some documentation cleanups and include more comments that have been already in code into doxygen docs 2016-08-07 10:05:34 +02:00
Dirk Ziegelmeier
b94c8ee76f Add some more functions and macros to documentation 2016-08-06 22:16:49 +02:00
Dirk Ziegelmeier
73131b1677 Fix doxygen warning in ip6.c 2016-08-06 20:29:35 +02:00
Dirk Ziegelmeier
87855b0e0e Update doxgen docs: PBUF layers, IPv4 and IPv6 functions, add some missing tcp raw API functions 2016-08-06 20:28:49 +02:00
Dirk Ziegelmeier
70ee63ef3d Documentation: Add example code for NO_SYS use case 2016-08-05 09:53:50 +02:00
sg
5f774270b6 minor: tabs -> spaces 2016-08-03 21:25:32 +02:00
David van Moolenbroek
02221cf5dc Rename IP_HDRINCL to LWIP_IP_HDRINCL
In the BSD socket API world, IP_HDRINCL is a socket option for "raw"
sockets that indicates whether sent packets already include an IP
header.  Within lwIP, "IP_HDRINCL" is redefined as a special value
that indicates to lwIP-internal functions that an IP header is already
included.  While somewhat related, the two meanings are different and,
on platforms that define the IP_HDRINCL socket option, this results in
a conflict.  This patch renames the lwIP one to "LWIP_IP_HDRINCL",
thus resolving the conflict.
2016-08-03 20:51:21 +02:00
Dirk Ziegelmeier
da83946e75 Add one more documentation sentence in tcp.c 2016-08-03 12:34:16 +02:00
goldsimon
3d379c97ec IPv6 is NOT experimental any more :-) 2016-08-03 12:28:56 +02:00
goldsimon
018294d287 remove doubled include (tcpip.h) 2016-08-01 09:44:18 +02:00
Dirk Ziegelmeier
2f7e6d0661 Remove hard reference from netif.c to tcpip.c - avoids pulling in unnecessary code 2016-08-01 09:32:54 +02:00
Dirk Ziegelmeier
2c2d11fa4d Update documentation of netif_input function 2016-07-30 10:40:36 +02:00
Dirk Ziegelmeier
4cb7e31d2d Add missing #include in netif.c 2016-07-30 10:36:11 +02:00
Dirk Ziegelmeier
0c7d015ec4 Further improvement to netif input function autoselection: Select between netif_input() and tcpip_input() depending on NO_SYS setting 2016-07-30 10:29:14 +02:00
Dirk Ziegelmeier
4b67c582f6 Create netif_input function that decides according to netif flags where to pass an incoming packet.
Allow to pass a NULL pointer to netif_add() input function - if so, use the function mentioned above as input function.
2016-07-30 10:19:16 +02:00
sg
23cf45d252 d'oh! (fixed messed-up timeouts.h) 2016-07-27 21:48:29 +02:00
sg
53dc94d570 added LWIP_TIMERS_CUSTOM to override the default implementation of timeouts 2016-07-27 21:46:16 +02:00
sg
a326b057b3 Fix bug #48568 (timeouts does not support late firing properly) by assuming sys_check_timeouts() jitter can' be too bad 2016-07-27 21:17:15 +02:00
Dirk Ziegelmeier
70927892e1 Fix doxygen warning about debug parameters in memp.c
Remove documentation from them, it is not important
2016-07-27 20:34:23 +02:00
Dirk Ziegelmeier
31f941e172 More documentation updates 2016-07-27 20:34:23 +02:00
Dirk Ziegelmeier
0cb1d1144d Integrate README file into doxygen docs instead of duplicating its content in main_page.h 2016-07-27 19:09:52 +02:00
Dirk Ziegelmeier
eb3261d6e0 Add some more TCP RAW API functions to documentation 2016-07-27 13:46:54 +02:00
Dirk Ziegelmeier
6c7eef7ac0 More documentation updates 2016-07-27 13:14:31 +02:00
Dirk Ziegelmeier
ef5c1b6590 Work on lwIP documentation 2016-07-27 13:09:33 +02:00
Dirk Ziegelmeier
ccc830c99c Work on lwIP documentation 2016-07-27 13:03:36 +02:00
goldsimon
af97f9b239 fixed gcc compiler error in do_memp_free_pool(): obviously, SYS_ARCH_DECL_PROTECT() must be the last declaration... 2016-07-27 08:26:42 +02:00
Dirk Ziegelmeier
6b524367a3 Documentation review with Simon, minor changes 2016-07-27 08:05:38 +02:00
Dirk Ziegelmeier
c7e20150f0 Update and restructure docs of some lwip core functions 2016-07-26 19:42:16 +02:00
Dirk Ziegelmeier
c6831648e2 Document apps in doxygen module style, create more top-level categories to structure documentation 2016-07-26 19:30:05 +02:00
Dirk Ziegelmeier
8a9de94b1f Restructure documentation. Create two top-level sections for thread-safe and callback-style APIs. 2016-07-26 18:39:53 +02:00
Dirk Ziegelmeier
67d674a59c Document IGMP and MLD6 API in doxygen module style 2016-07-26 18:20:30 +02:00
Dirk Ziegelmeier
dc0859b8d1 Document DHCP and AUTOIP API in doxygen module style 2016-07-26 18:10:05 +02:00
Dirk Ziegelmeier
9c10daba93 Document netif API in doxygen module style 2016-07-26 17:53:07 +02:00
Dirk Ziegelmeier
0fea2bc02e Document netconn API in doxygen module style 2016-07-26 17:40:55 +02:00
Dirk Ziegelmeier
ce19c59bb2 Document ip address function in doxygen module style 2016-07-26 17:11:01 +02:00
Dirk Ziegelmeier
8643782e5d Document netif and lwIP in doxygen module style 2016-07-26 16:53:27 +02:00
Dirk Ziegelmeier
bd79f6c055 Document DNS, memory pools and PBUFs as modules 2016-07-26 16:40:13 +02:00
goldsimon
e030118750 moved MEM_LIBC_MALLOC code from mem.h to mem.c:
- it's not worth littering mem.h just to save some bytes to prevent the additional call;
- MEM_STATS now also work when MEM_LIBC_MALLOC is enabled
2016-07-26 15:02:36 +02:00
Dirk Ziegelmeier
59295be4ef Some more RAW API documentation updates
Improve structure of documentation: PPP is now a module, too
2016-07-26 13:53:59 +02:00
Dirk Ziegelmeier
10acd8303d Start to document public RAW API via doxygen 2016-07-26 13:38:43 +02:00
goldsimon
168ad22761 fixed custom pools after last memp cleanup 2016-07-26 12:26:52 +02:00
goldsimon
fb75f48751 Make lwip_cyclic_timers[] const 2016-07-26 09:08:29 +02:00
sg
00598b0b46 fix mem stats for MEM_USE_POOLS==1 2016-07-25 22:08:32 +02:00
Dirk Ziegelmeier
80be1a6bf8 Add links to new documentation pages in the relevant files 2016-07-25 08:20:39 +02:00
sg
de9054cb7a memp: cleaned up MEMP_MEM_MALLOC:
- support memp stats when MEMP_MEM_MALLOC==1 (bug #48442);
- hide MEMP_MEM_MALLOC in memp.c instead of messing up the header file;
- make MEMP_OVERFLOW_CHECK work when MEMP_MEM_MALLOC==1
2016-07-21 22:17:32 +02:00
sg
413eeef5fa minor: moved sanity check from mem.c to init.c 2016-07-21 22:16:05 +02:00
goldsimon
523b11e664 fixed bug #48543 (TCP sent callback may prematurely report sent data when only part of a segment is acked) and don't include SYN/FIN in snd_buf counter (patch by Ambroz Bizjak) 2016-07-21 13:47:52 +02:00
goldsimon
e8ffac852e Fixed bug #48551 (autoip_supplied_address() does not work when address is first assigned); fixed AutoIP timeouts 2016-07-20 08:28:16 +02:00
sg
98d58ffd59 minor: fixed wrong indentation 2016-07-19 22:38:34 +02:00
sg
97b8e88e69 netif_set_addr(): when removing an address (setting address to ANY), we have to remove it *before* changing netmask/gw to ensure that tcp RST segment can be sent correctly 2016-07-19 22:34:22 +02:00
sg
24a339a609 autoip: made private things private, use etharp_* shortcuts instead of etharp_raw() 2016-07-19 22:27:20 +02:00
sg
86e419425b minor: code layout only 2016-07-19 22:06:59 +02:00
sg
d0a79ff085 fixed bug #48477 (ARP input packet might update static entry) 2016-07-19 22:01:42 +02:00
sg
dff46e3816 Fixed bug #48539 (possible crash when packet received in SYN_SENT state) 2016-07-19 21:23:21 +02:00
goldsimon
579fffd2ec fixed task #14084: make dhcp_supplied_address() usable in netif change callbacks triggered by changing the netif address assigned by dhcp 2016-07-19 12:58:21 +02:00
Dirk Ziegelmeier
5d4c1432c2 Fix bug #48436: Naming clash for timers.c (with FreeRTOS)
Rename timers.* to timeouts.*
2016-07-19 12:44:12 +02:00
goldsimon
6adeb706a6 change tcp_pcb->acked to be a global variable: used in one call stack only (idea by Ambroz Bizjak) 2016-07-19 10:38:01 +02:00
Dirk Ziegelmeier
72208cddfa Rename ip_frag.* to ip4_frag.* 2016-07-19 10:12:56 +02:00
Dirk Ziegelmeier
7037b340c1 Move etharp to core/ipv4, which is a more appropriate place for it 2016-07-19 09:29:51 +02:00
Dirk Ziegelmeier
06c7404461 Fix bug #48510, DHCP requires ARP
Use solution 2 proposed by Jens Nielsen
2016-07-19 09:10:21 +02:00
goldsimon
6c0d78caaa Fixed trying to send RST for unconnected (but bound) pcb 2016-07-19 09:05:48 +02:00
Dirk Ziegelmeier
4ec3d29168 Fix bug #48504: tcp_debug_print_pcbs reads nonexisting tcp_pcb fields 2016-07-19 08:54:44 +02:00
Dirk Ziegelmeier
4ea1d62d45 Update some doxygen comments 2016-07-16 17:56:29 +02:00
sg
421dab87e8 fixed bug #48476 (TCP sent callback called wrongly due to picking up old pcb->acked 2016-07-11 21:43:39 +02:00
Dirk Ziegelmeier
01e5d6d819 memp.c: No need to init variables located in BSS section 2016-07-08 11:44:28 +02:00
Ambroz Bizjak
18c332ae51 fixed bug #48402 (Bug in skipping over TCP options)
Signed-off-by: goldsimon <goldsimon@gmx.de>
2016-07-08 11:27:50 +02:00
goldsimon
6293a835e9 fixed compiling: forgot to move one line :-( 2016-07-08 10:16:46 +02:00
goldsimon
2df636fe77 memp: fixed STATS initialization 2016-07-08 10:06:36 +02:00
goldsimon
959042aa88 memp: fixed compiling various combinations of memp stats (display etc.) 2016-07-08 08:21:57 +02:00
Dirk Ziegelmeier
087ecab891 Add some comments to places where we cast through a void* to get rid of alignment warnings 2016-07-07 21:56:43 +02:00
Dirk Ziegelmeier
212eacd9d6 Fix bug #48356: private memp pools have no statistic counters
Implement struct stats_mem instance for each pool, let lwip_stats.mem[] point to these instances
2016-07-07 21:55:51 +02:00
Dirk Ziegelmeier
b91e47b518 Implement portable and overridable allocation of memory buffers
Fixes bug #48300 (Private mempools allocate foreign memory), bug #48354 (Portable alignment defines/include required for static allocation) and bug #47092 (Tag memory buffers like memp_memory_xxx and ram_heap with a macro so that attributes can be attached to their definitions)

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2016-07-07 13:35:13 +02:00
goldsimon
811b237bd7 dns: fixed declaration and usage of DNS_LOOKUP_LOCAL_EXTERN() 2016-07-07 13:02:47 +02:00
goldsimon
14ca418ac0 minor: coding style fixes 2016-07-05 07:36:51 +02:00
goldsimon
2fdea8b79b fixed bug #48398 (dns: entries reused during found-callback could be aborted if ttl==0) 2016-07-04 13:55:20 +02:00
Michael Brown
2e26fc9224 tcp: Avoid 3-second delay for a half-open connection
If lwIP encounters a half-open connection (e.g. due to a restarted
application reusing the same port numbers) it will correctly send a
RST but will not resend the SYN until one retransmission timeout later
(approximately three seconds).  This can increase the time taken by
lpxelinux.0 to fetch its configuration file from a few milliseconds to
around 30 seconds.

Fix by immediately retransmitting the SYN whenever a half-open
connection is detected.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: goldsimon <goldsimon@gmx.de>
2016-07-04 12:25:22 +02:00
goldsimon
fd83f4fb22 Fix bug #48359 (dns entries are not set to state DONE) 2016-07-04 10:22:20 +02:00
Sylvain Rochet
9d0546839c init: fix NO_SYS targets build
lwip/src/core/init.c:256:32: error: "LWIP_COMPAT_MUTEX" is not defined [-Werror=undef]
 #if LWIP_TCPIP_CORE_LOCKING && LWIP_COMPAT_MUTEX && !defined(LWIP_COMPAT_MUTEX_ALLOWED)
                                ^
Setting LWIP_TCPIP_CORE_LOCKING is meaningless for NO_SYS targets,
therefore checking if LWIP_COMPAT_MUTEX is set does not make sense.

Introduced by 42dfa71f97: Make LWIP_TCPIP_CORE_LOCKING==1 the default
(and warn if LWIP_COMPAT_MUTEX==1 in that case as mutexes are required
to prevent priority inversion on tcpip_thread operations)
2016-07-02 21:53:24 +02:00
sg
42dfa71f97 Make LWIP_TCPIP_CORE_LOCKING==1 the default (and warn if LWIP_COMPAT_MUTEX==1 in that case as mutexes are required to prevent priority inversion on tcpip_thread operations) 2016-06-30 22:37:37 +02:00
goldsimon
e6bc591a1e fixed bug #48170 (Vulnerable to TCP RST spoofing) (original patch by Fabian Koch) 2016-06-30 08:50:42 +02:00
goldsimon
d31d2ee882 Revert "fixed bug #48170 (patch by Fabian Koch)"
This reverts commit 236bc19422.
The fix introduced bug #48328 -> reverted
2016-06-30 08:41:50 +02:00
Erik Ekman
4047702928 Fix clang warning about unreachable code
Do check with preprocessor instead
2016-06-27 22:32:18 +02:00
Dirk Ziegelmeier
5d356c96f5 Minor: cleanup my last commit 2016-06-27 20:57:22 +02:00
Dirk Ziegelmeier
39545d2c6d Fix clang warning about unreachable code 2016-06-27 20:56:21 +02:00
goldsimon
236bc19422 fixed bug #48170 (patch by Fabian Koch) 2016-06-27 10:31:36 +02:00
Dirk Ziegelmeier
38c0255fa2 Fix a few more CLANG format string warnings (from unix check project) 2016-06-25 13:24:48 +02:00
Dirk Ziegelmeier
102f5882d5 Fix several CLANG format string warnings 2016-06-25 13:06:31 +02:00
Dirk Ziegelmeier
8dc77ef558 doxygen updates - include IPv6 in documentation. Exclude include/netif/ppp/polarssl.
Convert TODO -> @todo
2016-06-22 20:18:23 +02:00
Sylvain Rochet
cfe5182380 timers: fix wrong timings for !NO_SYS targets
issue 1:

sys_arch_sem_wait() is supposed to return an elapsed time in ms, what could
happen given a > 1 kHz calling rate for high throughput systems is that it
might always returns 0 ms. This is a problem for systems which compute the
elapsed time from a high precision clock source.

This is what is currently happening in the unix port in sys_arch_sem_wait():

start time -> 1000000000;  // ns
-- less than a ms before an event arrive --
end time   -> 1000xxxxxx;  // ns
return value -> (end time - start time)/1000000 -> 0

The return value is used to reduce the next timer interval, if
sys_arch_sem_wait() always return 0 no more timers are fired anymore

issue 2:

The current timer implementation for !NO_SYS targets only count elapsed
time while -waiting- for semaphore and doesn't count at all the time
spent by the stack to process packets. For CPU bound traffic patterns no
more timers are fired anymore.

Both are serious design issues which cannot be easily fixed without reworking
everything. This patch uses the properly implemented timers for NO_SYS targets
for !NO_SYS targets and merge them both into one single timers implementation.
2016-06-20 16:17:55 +02:00
goldsimon
6d95a34971 icmp ping response: fix invalid checksum (and possible assertion failure) when ip header contains options (is it correct that we mirror back all options) 2016-06-17 10:07:49 +02:00
goldsimon
61e067b98a Check for minimum IPv4 header length in rx packets 2016-06-17 09:36:14 +02:00
goldsimon
fda778f6b6 ip6_reass: don't crash if frag header isn't the first (or not in the first pbuf) 2016-06-16 13:51:38 +02:00
Erik Ekman
d98e25a783 nd6: Handle incorrect ICMP option length in RA
Make sure ICMPv6 options have a valid length before
parsing them.

Found with afl-fuzz.
2016-06-14 15:06:49 +02:00
sg
4e241fbf14 some minor improvements to the tcp options checking code 2016-06-13 20:41:58 +02:00
Henrik Persson
b9a2ee8aaa [PATCH] Drop instead of ASSERT in tcp_input header parsing
Since allowing input validation to trip the ASSERT handler is bad,
let's just drop the packets instead if validation fails.

Signed-off-by: sg <goldsimon@gmx.de>
2016-06-13 20:08:43 +02:00
Dirk Ziegelmeier
5e7b343d52 Fix dns_getserver to return a pointer, not a value 2016-06-13 09:00:46 +02:00
Dirk Ziegelmeier
6be7e221a5 Fix a few doxygen warnings 2016-05-24 22:29:18 +02:00
sg
631c458c55 Fixed invalid DEBUGF level SERIOUS when pbuf_header fails (it returns '1': this is not serious!) 2016-05-23 22:06:02 +02:00
Dirk Ziegelmeier
90a656ed78 Fix several doxygen errors all over the code 2016-05-23 21:18:16 +02:00
Jan Breuer
ebd103775d ipv6_addr: Render last zero in ip6addr_ntoa_r if not in first empty block 2016-05-23 09:54:54 +02:00
goldsimon
bd177ff38f added comment, fixed coding style 2016-05-23 09:47:14 +02:00
Jan Breuer
ac21a5f370 nd6: add cleanup function 2016-05-23 09:44:27 +02:00
Axel Lin
8c0f620d83 dns: Use LWIP_ARRAYSIZE instead of open coded
Signed-off-by: Axel Lin <axel.lin@ingics.com>
2016-05-11 12:20:15 +02:00
Axel Lin
7e9377a9c7 dhcp: Use LWIP_ARRAYSIZE to get the number of array entries
dhcp_discover_request_options is u8_t array, so the result is the same.
But use LWIP_ARRAYSIZE to get the number of array entries is better
because it works for all types.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
2016-05-11 12:15:12 +02:00
Sylvain Rochet
1dcd5d31d7 pbuf: fix undefined PBUF_POOL_FREE_OOSEQ if TCP_QUEUE_OOSEQ is disabled
lwip/src/core/timers.c: In function ‘sys_check_timeouts’:
lwip/src/core/timers.c:328:5: error: "PBUF_POOL_FREE_OOSEQ" is not defined [-Werror=undef]
 #if PBUF_POOL_FREE_OOSEQ

Fix it by declaring an empty PBUF_CHECK_FREE_OOSEQ() function if feature is
not enabled.
2016-05-08 03:09:51 +02:00
Dirk Ziegelmeier
49badf39a1 Fix bug #47805: dhcp_recv can dereference NULL pointer 2016-04-29 11:16:33 +02:00
Dirk Ziegelmeier
2e05856f90 Fix bug #47641: lwIP would accept IPv6 source addresses from the network that are mapped IPv4 adresses 2016-04-27 21:35:34 +02:00
goldsimon
c981b726f8 fixed bug #47601 (wrong NS request at DAD) 2016-04-27 10:19:13 +02:00
goldsimon
afd9ee9147 fixed bug #47743 (Closing listening tcp pcb is not posible without assert) 2016-04-26 13:27:17 +02:00
Dirk Ziegelmeier
bb908366a5 More PPP cleanups 2016-04-25 20:08:29 +02:00
Dirk Ziegelmeier
73d8f14ebd Fix compile when PPP is not enabled 2016-04-25 20:08:29 +02:00
Dirk Ziegelmeier
ffa340a68c task #13907: PPP cleanups: Move PPP mempools out of lwIP core to PPP code 2016-04-25 20:08:29 +02:00
Dirk Ziegelmeier
4d1a2e6699 Fix projects without PPP do not compile any more 2016-04-22 06:24:01 +02:00
Sylvain Rochet
15fbfb7363 PPP, remove useless ppp_init function
Simon says:

ppp_init() does not seem to be used. The only thing it does is calling
magic_init(), which is not required because it its called again later
from ppp_input().

Also, the time from startup is rather constant, so calling sys_jiffies()
from ppp_init() does not create a random number.
2016-04-21 23:25:48 +02:00
Joel Cunningham
8ac1b4825a udp: use netif addr as src for multicast sockets
Sockets bound to a multicast address could not transmit multicast
packets because the pcb local address did not match the netif address
even if the outgoing netif was resolved correctly.

To correct the issue, pcbs with a multicast local address will use
the outgoing netif address as the source address in IPv4.
2016-04-18 16:36:13 -04:00
Dirk Ziegelmeier
309e072238 Create new IP_IS_V4 macros and use them at instead of !IP_IS_V6 - since we now have an IPADDR_ANY_TYPE, just checking for !V6 does not mean it is V4 2016-04-06 22:31:31 +02:00
sg
ca1b8288de prepare for overriding current timeout implementation: all stack-internal caclic timers are avaliable in the lwip_cyclic_timers array 2016-04-05 23:01:57 +02:00
sg
8c7f513f4d patch #8358: allow more combinations of listening PCB for IPv6 2016-04-05 22:04:19 +02:00
sg
0731eda0b3 make autoip_supplied_address() take a const pointer, too 2016-04-05 20:38:11 +02:00
Dirk Ziegelmeier
12a4cae404 Apply [patch #8969] from Freddie Chopin: Constify netif in dhcp_supplied_address() 2016-04-05 13:18:27 +02:00
sg
27f03798b9 Fixed possible problems with tcp_backlog_delayed/tcp_backlog_accepted 2016-03-25 16:19:39 +01:00
goldsimon
5b0a47ca87 removed unused return values of tcp_listen_input & tcp_timewait_input; fixed unused variable warning 2016-03-24 15:06:31 +01:00
sg
7721b20179 call accept-callback with ERR_MEM when allocating a pcb fails on passive open to inform the application about this error; ATTENTION: applications have to handle NULL pcb in accept callback! 2016-03-23 21:57:38 +01:00
sg
c6b742812d fixed bug #38203: DHCP options are not recorded in all DHCP ack messages (patch by Florent Matignon) 2016-03-23 21:06:52 +01:00
Axel Lin
449fc98a55 tcp_alloc(): Remove superfluous initialization for pcb->keep_cnt_sent
It's already done by memset(0). This was missed in commit 5794ac2340
"tcp_alloc(): remove explicit =0 already done by memset(0)", fix it.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
2016-03-23 14:26:32 +01:00
Dirk Ziegelmeier
f97bf85fd6 udp.c: Allow udp_connect() on a dual-stack UDP PCB (type IPADDR_TYPE_ANY). This may be useful in some applications - no need to keep separate storage for target IP. 2016-03-22 15:12:16 +01:00
sg
dd80759bb9 tcp: changed accept handling to be done internally: the application does not have to call tcp_accepted() any more. Instead, when delaying accept (e.g. sockets do), call tcp_backlog_delayed()/tcp_backlog_accepted() (fixes bug #46696) 2016-03-22 07:30:44 +01:00
sg
a1c78ea7bf ignore dns response parsing errors, only abort resolving for correct responses or error responses from correct server (bug #47459) 2016-03-22 07:22:17 +01:00
sg
5794ac2340 tcp_alloc(): remove explicit =0 already done by memset(0) 2016-03-18 22:05:17 +01:00
sg
44e1a2d8e2 define tcp_backlog_set() as dummy-define when backlog feature is disable 2016-03-18 20:05:04 +01:00
sg
852d5b9c80 Optimize tcp_output runtime by not calling ip_route() for every segment sent 2016-03-16 22:31:33 +01:00
sg
b4d7238eb8 tcp_output_segment: don't count retransmitted segments in mib2.tcpoutsegs by detecting p->payload != tcphdr pointer; don't try to retransmit segments where p->ref != 1 (as it is invalid to mess up p->len/p->payload when we don't have exclusive access to the pbuf) 2016-03-16 22:22:20 +01:00
sg
5f8b5cbb20 reset rto timer on fast retransmission (see task #13757, patch by Joel Cunningham) 2016-03-16 21:49:37 +01:00
sg
8e8571da6a fixed bug #46384 Segment size calculation bug with MSS != TCP_MSS 2016-03-16 16:56:15 +01:00
Dirk Ziegelmeier
f3b7bca3cf Fix bug #47370: Port DNS client to IPv6 2016-03-09 19:25:06 +01:00
Dirk Ziegelmeier
a212210c35 Add missing #include in memp.c 2016-03-08 19:53:01 +01:00
sg
5cf802eda0 dns_gethostbyname: return error code if no valid server is set instead of calling the 'found' callback in this case (fixes bug #46887) 2016-03-07 19:47:39 +01:00
sg
f5fef6eebc fixed bug #45353: IPv6 router / neighbor relationship is not always consistent - patch by Stian Sebastian Skjelstad 2016-03-06 14:48:41 +01:00
sg
b00a17059a fixed icmp_send_response with LWIP_HOOK_IP4_ROUTE_SRC enabled 2016-03-05 15:57:40 +01:00
sg
d2bb569ee4 bug #46094: moved IPv4 routing hook functions down so that they implement actual routing (source-based IPv4 routing is not affected by this change) 2016-03-05 15:52:39 +01:00
sg
e0ab8c581d fixed bug #46093: Move IP6_ROUTE() hook to after LL processing 2016-03-05 14:11:24 +01:00
sg
6b405eccd0 Tried to fix bug #47270 by accepting all ipv4 multicast packets (at IP level) when LWIP_IGMP is disabled 2016-03-04 21:57:47 +01:00
Dirk Ziegelmeier
9a4c66006e Fix compile error in raw.c (possible unused arg) 2016-03-03 22:55:42 +01:00
Dirk Ziegelmeier
1dea649cff Fix comment in tcp.c 2016-03-03 22:48:10 +01:00
Dirk Ziegelmeier
7396d8818b Implement dual-stack in RAW API in the same way as in UDP and TCP 2016-03-03 22:47:27 +01:00
Dirk Ziegelmeier
2d80af1dcb Minor code cleanup in udp.c 2016-03-03 22:44:01 +01:00
Dirk Ziegelmeier
5358380c5f Apply patch from Derek Pravala: Fix segfault in ip6_route when there is no default netif 2016-03-03 16:12:20 +01:00
Dirk Ziegelmeier
e89b48d23f raw.c: Avoid NULL pointer dereference 2016-03-02 23:44:51 +01:00
Dirk Ziegelmeier
f9ce31f98b TCP: Implement dual stack support using new IP_ANY_TYPE introduced at UDP 2016-03-02 23:14:33 +01:00
Dirk Ziegelmeier
f3132c5290 udp: Fix possible NULL pointer dereference, update comments 2016-03-02 23:10:43 +01:00
Dirk Ziegelmeier
9885d5d9f5 Apply patch from Simon to fix buffer overflow handling tcp_in.c which was discovered by Coverity 2016-02-29 23:34:52 +01:00
Dirk Ziegelmeier
8e5663a32f Minor: Avoid ip_input() call indirection for when only IPv4 or IPv6 are enabled 2016-02-29 22:17:42 +01:00
Dirk Ziegelmeier
6aed6e659f Rework DHCP PCB handling: Old code registered one UDP PCB per netif where DHCP was active and there was a special case in udp_input() for this. New implementation uses one PCB for all netifs and removes special case in udp_input().
The old approach called udp_bind() on each of the PCBs, which puts them into udp_pcbs list. The PCBs were iterated on all non-DHCP udp_inputs() with no effect.
My cleanup removes the special handling in udp.c, and uses only one DHCP UDP PCB to catch all DHCP messages from all netifs. The dhcp_recv function then checks whether ip_current_input_netif() has DHCP enabled - if not, the message is ignored. The PCB is only created/registered when one or more PCBs have DHCP enabled.
2016-02-29 19:31:19 +01:00
Dirk Ziegelmeier
70f3e5ed05 Cleanup: Create new file ip.c and move dual-stack code from ipv4 and ipv6 folder in there 2016-02-26 23:04:51 +01:00
Dirk Ziegelmeier
d5778bad2f No need for dual-stack code in ip4.c and icmp.c -> use ip4 only versions 2016-02-26 22:50:20 +01:00
Dirk Ziegelmeier
a5214abd04 udp: udp_send and udp_send_chksum: Check for PCB NULL pointer and PCB must not be the new IP_ANY_TYPE, but a real IPv4 and IPv6 address 2016-02-26 09:20:50 +01:00
goldsimon
bf8bcfafe2 revert accidentally committed comment from a649a3eb50 2016-02-26 08:59:50 +01:00
Joel Cunningham
8cb64698aa Allow backlog to be updated
This commit adds support to the sockets and netconn layer to update the
backlog by calling listen when the netconn is already in the listen state.
When backlog is not enabled, the call returns successfully

This commit also introduces a macro for setting the backlog value that
prevents a 0 sized (invalid) backlog
2016-02-25 15:19:52 -06:00
sg
a649a3eb50 dual-stack fix: moved common definitions/code for ethernet used by etharp and ethip6 to new files ethernet.h/.c 2016-02-25 22:10:28 +01:00
Dirk Ziegelmeier
fd891081c4 minor: Cleanups in raw/tcp/udp code by using macros and reducing #ifdefs 2016-02-24 23:04:25 +01:00
Dirk Ziegelmeier
953b7bdd59 Implement UDP dual-stack PCB support
Create special IP address type "IPADDR_TYPE_ANY" for it.
SNMP uses new feature in non-netconn mode.

TODO: Same for TCP & RAW, adapt NETCONN to use this feature
2016-02-24 22:37:01 +01:00
sg
1dde3d6e56 Fixed bug #46524: "Device as dhcp server does not work after upgrade to lwip-1.4.1" 2016-02-24 22:13:58 +01:00
sg
ec49b68b38 minor: udp_input/local_match: coding style, added comments 2016-02-24 22:04:59 +01:00
Dirk Ziegelmeier
ac4b089b18 udp.c: Further udp_input simplifications
- Move local PCB matching code in a function that can be reused in SO_REUSE && SO_REUSE_RXTOALL case.
- Some checks have been written in the dual-stack version and then repeated with the ipv6-only version. Example:
IPv6 only: ip6_addr_ismulticast(ip6_current_dest_addr())
IPv4 AND IPv6: ip_addr_ismulticast(ip_current_dest_addr())
2016-02-24 19:57:20 +01:00
Dirk Ziegelmeier
005c196ed8 udp.c: Simplify and cleanup input PCB matching 2016-02-24 19:13:30 +01:00
Dirk Ziegelmeier
17fad79f71 Two compile fixes after eliminating isipv6 member in PCBs 2016-02-22 17:07:17 +01:00
Dirk Ziegelmeier
c805843e64 Change signature of ip_output, ip_output_if, ip_output_if_src, ip_output_hinted, ip_route, ip_netif_get_local_ip, ip_route_get_local_ip and tcp_eff_send_mss not to take an isipv6 parameter. Use the IP version of the destination address instead. 2016-02-22 13:38:40 +01:00
Dirk Ziegelmeier
880f1008d6 Together with Simon: Eliminate last instances of isipv6 member in pcbs;
Don't allow NULL pointers (IPv4 ANY) in connect() and sendto() functions as destinations since this does not make sense.
2016-02-22 13:03:51 +01:00
Dirk Ziegelmeier
be9cd800b0 Review with Simon: Init TCP/UDP/RAW PCBs with correct IP types in _new functions to make my changes work correct 2016-02-22 11:16:13 +01:00
Dirk Ziegelmeier
0106cf7ae0 Review with Simon: Remove dead code (since 2003) 2016-02-22 10:18:19 +01:00
Dirk Ziegelmeier
50303eea23 Reduce PCB_ISIPV6 macro usage some more 2016-02-21 19:59:08 +01:00
Dirk Ziegelmeier
339e82d7aa Eliminate IP_PCB_IPVER_EQ macro 2016-02-21 19:45:51 +01:00
Dirk Ziegelmeier
5a25652c21 Eliminate IP_PCB_IPVER_INPUT_MATCH macro 2016-02-21 19:21:36 +01:00
Dirk Ziegelmeier
8f675c37fc Reduce usage of PCB IP version flag in UDP code. Maybe we can figure out a good way for dual-stack UDP when we manage to remove the flag (nearly) entirely from the code. 2016-02-20 20:54:58 +01:00
Dirk Ziegelmeier
5809b01388 Reduce usage of PCB IP version flag in raw and tcp code. Maybe we can figure out a good way for dual-stack UDP when we manage to remove the flag (nearly) entirely from the code. 2016-02-20 20:40:04 +01:00
Dirk Ziegelmeier
10edba936b Fix tcp pcb access after it was freed in tcp.c - found by Coverity 2016-02-19 23:28:09 +01:00
goldsimon
e4cac595c2 Check TCP_SNDLOWAT for too high value (near u16_t overflow) - fixes bug #46948 2016-02-18 09:36:55 +01:00
Dirk Ziegelmeier
24bc77a935 Found some struct instances that can be const 2016-02-16 22:31:59 +01:00
Dirk Ziegelmeier
273d609bac mem.c: Fix unintended sign extension (found by Coverity)
sign_extension: Suspicious implicit sign extension: count with type unsigned short (16 bits, unsigned) is promoted in count * size to type int (32 bits, signed), then sign-extended to type unsigned long (64 bits, unsigned). If count * size is greater than 0x7FFFFFFF, the upper bits of the result will all be 1.
2016-02-10 21:21:08 +01:00
Dirk Ziegelmeier
288b4564e4 DNS: Fix potential array out of bounds access. Variable nanswers may contain bogus values. (found by Coverity) 2016-02-10 20:41:31 +01:00
Dirk Ziegelmeier
1c1587eef6 ICMP: Fix responses were always sent to default netif because of uninitialized source IP (found by Coverity) 2016-02-10 20:35:58 +01:00
Dirk Ziegelmeier
11b810721a ICMP: Fix unused value in icmp_input (found by Coverity) 2016-02-10 20:34:44 +01:00
Dirk Ziegelmeier
222155d7e2 pbuf: Make pbuf_skip function public, so it can be used in SNMP code 2016-02-03 08:37:04 +01:00
Axel Lin
f411a34af5 stats: Add proper #if guard to prevent unused-variable warning for memp_names
The usages of memp_names are under either LWIP_DEBUG in stats_init,
or under LWIP_STATS_DISPLAY in stats_display_memp.

Fix below build warning:
lwip/src/core/stats.c:53:21: error: 'memp_names' defined but not used [-Werror=unused-variable]
static const char * memp_names[] = {
^
cc1: all warnings being treated as errors

Reported-by: David Fernandez
Fixes: 2f2a75a6d9fd ("stats: Move memp_names table out of stats_init/stats_display_memp functions")
Signed-off-by: Axel Lin <axel.lin@ingics.com>
2016-01-31 13:48:38 +01:00
Axel Lin
515a4cad73 Clear addr_hint pointer after calling ip_output_if() in tcp_zero_window_probe()
This was missed in commit aa0e41c389
("task #12178: hardware checksum capabilities can be configured per netif"),
fix it.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
2016-01-29 09:21:58 +01:00
Stephan Linz
2c31beb6e7 IPv4: fix some meaningless debug messages
Signed-off-by: Stephan Linz <linz@li-pro.net>
2016-01-18 21:34:13 +01:00
Axel Lin
fe2cfe2dba raw: Fix build error
IP6_HLEN is only defined when LWIP_IPV6, IP_HLEN is only defined when LWIP_IPV4.
This fixes build error in !LWIP_IPV4 || !LWIP_IPV6 cases.

Fixes: f2c7e9c939 ("raw: Remove unnecessary #if guard around PCB_ISIPV6() calls")
Reported-by: Erik Ekman
Signed-off-by: Axel Lin <axel.lin@ingics.com>
2016-01-18 16:02:01 +01:00
Stephan Linz
80375e68dd ip_frag: fix compiler warnings, unused variable
In case of IP_REASS_FREE_OLDEST==0, the argument clen of
ip_reass_enqueue_new_datagram() will not used and leads
the compiler to a warning.

Signed-off-by: Stephan Linz <linz@li-pro.net>
2016-01-18 11:55:54 +01:00
Axel Lin
f2c7e9c939 raw: Remove unnecessary #if guard around PCB_ISIPV6() calls
PCB_ISIPV6() macro is well defined for all cases (LWIP_IPV4 && LWIP_IPV6,
LWIP_IPV4 only and LWIP_IPV6 only), thus remove the unnecessary #if guard
around PCB_ISIPV6() calls.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
2016-01-18 11:55:06 +01:00
Axel Lin
c221361874 stats: Move memp_names table out of stats_init/stats_display_memp functions
This makes the code simpler with better readability.
Also make memp_names static because it's only referenced by stats.c.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
2016-01-15 11:38:03 +01:00
Axel Lin
70ebeda7ed memp: Simplify implementation of memp_overflow_check_all
We don't really care the order of overflow/underflow checking because if
any checking fails we got assertion.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
2016-01-15 11:38:02 +01:00
Dirk Ziegelmeier
70487a43d4 Apply patch #8854: dns: Simplify #ifdef guard around dns_gethostbyname_addrtype from Axel Lin
+ Minor compile fix from me
Patch makes the code a tiny bit less lightweight (add a parameter in dns_gethostbyname which is then not used in dns_gethostbyname_addrtype) but it makes the code more readable.
2016-01-13 19:52:08 +01:00
Axel Lin
a93ae2558f tcp_rexmit_rto: Remove superfluous #if TCP_OVERSIZE guard
TCP_OVERSIZE_DBGCHECK already implies TCP_OVERSIZE is set.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
2016-01-13 19:07:08 +01:00
Axel Lin
c2a74b767b udp_bind: Omit checking for the same port if no port specified
No port specified means to use a random port.
udp_new_port() returns a new (free) local UDP port number on success.
So in this case we don't need iterating all lists to test if the port
number is used, udp_new_port() alreay ensures the port is not used.

Move the code checking for double bind and rebind of the same pcb earlier,
as this checking is necessary in all cases.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
2016-01-13 09:05:36 +01:00
Dirk Ziegelmeier
123c8dbd6a Fix bug #46837 Don't send dhcp_release message in dhcp_release function 2016-01-13 08:54:54 +01:00
Axel Lin
9f3aab6a62 tcp_out: Use LWIP_DBG_LEVEL_SERIOUS instead of hard coded number
Trivial clean up to avoid using hard coded number.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
2016-01-11 13:22:51 +01:00
Axel Lin
156ad0dbf5 udp_bind: Fix the logic to check both pcbs have REUSEADDR set
The code for #if SO_REUSE case does not match the comment.
By default, we don't allow to bind to a port that any other udp
PCB is already bound to, unless *all* PCBs with that port have tha
REUSEADDR flag set.

Which means we want to omit checking for the same port if both pcbs
have REUSEADDR set. Fix the logic accordingly.

Fixes: d0348e0c60 ("task #6995: Implement SO_REUSEADDR (correctly)")
Signed-off-by: Axel Lin <axel.lin@ingics.com>
2016-01-11 12:19:13 +01:00
Axel Lin
5056d375f2 tcp_bind/tcp_connect: Omit checking for the same port if no port specified
No port specified means to use a random port.
tcp_new_port() returns a new (free) local TCP port number on success.
So in this case we don't need iterating all lists to test if the port
number is used, tcp_new_port() alreay ensures the port is not used.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
2016-01-11 12:16:27 +01:00
Axel Lin
708beb4874 udp_bind: Allocate a random port earlier to correctly detect port conflict
Current code does not correctly detect port conflict if no port specified
because it checks ipcb->local_port == port before udp_new_port().
Fix it by allocating a random port earlier.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
2016-01-09 10:14:09 +01:00
Joel Cunningham
a82c6122d5 Correct comment word usage in ip4_frag.c
This corrects word usage in ip4_frag.c:

 * 'On' was used when it should have been 'one'
 * 'Whole' was used when it should have 'hole'
2015-12-08 10:13:56 -06:00
Axel Lin
2e56f2d780 igmp: Optimize the implementation of igmp_start_timer
When LWIP_RAND is defined, calling LWIP_RAND() is not necessary if max_time <= 2
because group->timer will be set to 1 anyway.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
2015-12-06 21:47:09 +01:00
Axel Lin
2562d637cd tcp_out: Use LWIP_DBG_LEVEL_SERIOUS instead of magic number
Trivial clean up to avoid using magic number.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
2015-12-06 21:38:12 +01:00
Axel Lin
a21144b834 memp: Fixup LWIP_HOOK_MEMP_AVAILABLE() hook
I got below build warning if LWIP_HOOK_MEMP_AVAILABLE is defined.

src/core/memp.c: In function 'memp_free_pool':
src/core/memp.c:352:16: warning: variable 'old_first' set but not used [-Wunused-but-set-variable]
   struct memp *old_first;
                ^
src/core/memp.c: In function 'memp_free':
src/core/memp.c:413:6: warning: 'old_first' may be used uninitialized in this function [-Wmaybe-uninitialized]
   if (old_first == NULL) {

The LWIP_HOOK_MEMP_AVAILABLE() hook does not work, fix it.

Fixes: c838e1ed5b ("Implement possibility to declare private memory pools")
Signed-off-by: Axel Lin <axel.lin@ingics.com>
2015-12-05 21:32:14 +01:00
Axel Lin
7f92660598 icmp: Fix memory leak in icmp_input() error paths
Ensure the newly allocated packet buffer is freed in error paths.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
2015-12-05 21:25:15 +01:00
Axel Lin
a709041b8b Remove unnecessary p->len checking for pbuf_alloc calls with PBUF_RAM type
pbuf_alloc() for PBUF_RAM type always return big enough memory on success.
So checking p->len is not necessary. Testing if p is NULL or not is enough.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
2015-12-05 21:21:59 +01:00
Axel Lin
bd4c4b5959 Use SYS_ARCH_SET macro at appropriate places
Use SYS_ARCH_SET to simplify the code a bit.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
2015-12-02 22:51:08 +01:00
Axel Lin
fb6d0f9006 ipaddr_aton: Avoid duplicate code to handle IPv4 address string conversion
Signed-off-by: Axel Lin <axel.lin@ingics.com>
2015-12-02 22:51:00 +01:00
Axel Lin
6e863ecb50 dns: Remove always true test in dns_alloc_random_port
The only way to exit the do-while loop is err != ERR_USE.
Thus get rid of the always true test.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
2015-12-02 22:37:26 +01:00
Axel Lin
764bf251cd igmp: Drop unneeded initialization for *group in igmp_lookup_group()
It's assigned to the return value of igmp_lookfor_group() immediately.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
2015-12-02 22:32:50 +01:00