Commit Graph

4810 Commits

Author SHA1 Message Date
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
Dirk Ziegelmeier
3cc7b319d9 Add MQTT to CHANGELOG (too late for 2.0.1 release...) 2017-01-08 19:45:28 +01:00
Dirk Ziegelmeier
19f075a92a Put 2.0.1 version tag in UPGRADING document 2017-01-08 19:33:52 +01:00
Dirk Ziegelmeier
e3435401f1 Add David's changes from patch #9208 to CHANGELOG 2017-01-08 19:29:46 +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
52f448978f MQTT: Add check that WILL topic length must be > 0 2017-01-08 19:08:54 +01:00
Dirk Ziegelmeier
6d5ddb7139 MQTT: Fix possible bug in connect message generation that WILL flag can be set without appending a will message
The boolean condition of setting the WILL flag differs from that of appending the will message
Found by Axel Lin
(I fixed it the same way as Axel suggested, but I wanted a different commit message)
2017-01-08 19:07:43 +01:00
Axel Lin
a2915b7142 mqtt: Slightly improve mqtt_create_request
Mainly for better readability, also save NULL test while iterating the for loop.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
2017-01-07 20:39:41 +01:00
Axel Lin
7faa4bcbe2 mqtt: Prevent NULL pointer dereference before assertion checking
Signed-off-by: Axel Lin <axel.lin@ingics.com>
2017-01-06 12:15:03 +01:00
Erik Ekman
6c9a9b9d99 Remove duplicate netif_dhcp_data() macro
Fix compilation of unit tests
2017-01-05 21:14:43 +01:00
Dirk Ziegelmeier
02eec304c3 Update version to 2.0.2 DEVELOPMENT in master branch 2017-01-05 15:03:09 +01:00
Dirk Ziegelmeier
3a20ae3830 Add missing #include in netdb.c for atoi() 2017-01-05 08:55:12 +01:00
Dirk Ziegelmeier
0ffaccaec3 Add missing #include in httpd.c for atoi() 2017-01-05 08:53:26 +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
sg
8760fb677f fixed warnings in mdns unit tests 2017-01-04 15:25:52 +01:00
Erik Ekman
d2631e6a53 mqtt: Fix pedantic enum warning
src/apps/mqtt/mqtt.c:81:17: error: comma at end of enumerator list [-Werror=pedantic]
2017-01-04 00:24:00 +01:00
Dirk Ziegelmeier
4059748b47 I was not satisfied with the previous debugging options structure. Improve it again. 2017-01-02 19:50:46 +01:00
Dirk Ziegelmeier
644a21b8a5 Improve debugging options documentation 2017-01-02 19:32:56 +01:00
Dirk Ziegelmeier
a3876314b7 Add debugging options to documentation 2017-01-02 19:25:23 +01:00
Dirk Ziegelmeier
e3c2b8a339 Add note about high resource-consumption in LWIP_PLATFORM_DIAG and LWIP_PLATFORM_ASSERT default implementations 2017-01-02 19:06:33 +01:00
Dirk Ziegelmeier
e12bb2a4eb Fix comma at end of enum list in mqtt.h 2017-01-01 20:26:28 +01:00
Dirk Ziegelmeier
2096f1a657 Fix C++ style comment in mqtt.c 2017-01-01 20:23:11 +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
Axel Lin
edfeab7932 mqtt: Trivial coding style fix
Add proper blank for if/for/while statements.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
2017-01-01 19:20:24 +01:00
Dirk Ziegelmeier
b8bc7b7c71 arch.h: Add #includes necessary for default implentation of LWIP_PLATFORM_DIAG and LWIP_PLATFORM_ASSERT 2017-01-01 12:40:23 +01:00
Dirk Ziegelmeier
f874d15185 Add #include <string.h> in snmp_netconn.c because memset() is used 2017-01-01 12:38:34 +01:00
Dirk Ziegelmeier
ee034bd811 Document PACK_STRUCT_USE_INCLUDES #define 2017-01-01 12:31:02 +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
1884c7e83f Fix TCP unit tests after changes from "Add hook for TCP Initial Sequence Number generation" commit
(pcb->lastack and friends are not initialized during allocation any more, but by connect() / bind() call)
2016-12-31 11:46:27 +01:00
Dirk Ziegelmeier
1466b7ac61 Several mqtt documentation fixes found by clang 2016-12-29 09:44:07 +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
Dirk Ziegelmeier
3a8368ef04 Provide struct packing macros on GCC/clang out of the box 2016-12-29 09:28:28 +01:00
Dirk Ziegelmeier
c1258e5c72 Compile fix in lwip/arch.h "extra tokens at end of #ifndef directive" 2016-12-29 09:05:52 +01:00
Dirk Ziegelmeier
211a71cf11 Minor documentation update in lwip/arch.h 2016-12-28 21:52:10 +01:00
Dirk Ziegelmeier
55199fc62c More documentation updates in lwip/arch.h 2016-12-28 10:14:36 +01:00
Dirk Ziegelmeier
45ad6f2e61 Minor documentation updates in lwip/arch.h 2016-12-28 09:53:11 +01:00
Dirk Ziegelmeier
df365adf9a Trivial typo fix in arch.h docs 2016-12-26 10:53:41 +01:00
Axel Lin
7b40d1eb6f doc: mqtt_client: Update example code after adding port parameter to mqtt_client_connect()
Signed-off-by: Axel Lin <axel.lin@ingics.com>
2016-12-24 15:10:56 +01:00
Dirk Ziegelmeier
c1d16c61eb Forgot documentation on MQTT port #define 2016-12-24 12:06:53 +01:00
Dirk Ziegelmeier
83b1c397a0 Add #define with default MQTT port for convenience 2016-12-24 12:05:27 +01:00
Axel Lin
bfa0358a52 mqtt: Allow setting server port to connect
This is a mqtt client, so it does not make sense to determinate the server port
at compile time. Update mqtt_client_connect() function to allow setting server
port.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
2016-12-23 09:52:31 +01:00
Dirk Ziegelmeier
2e4b368c8c Revert "Fix bug #49914: lwip_sendmsg uses PBUF_REF pbufs"
This reverts commit 4e34851c57.
2016-12-23 09:51:26 +01:00