Commit Graph

4517 Commits

Author SHA1 Message Date
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
Dirk Ziegelmeier
4e34851c57 Fix bug #49914: lwip_sendmsg uses PBUF_REF pbufs
Use PBUF_RAM and create private copy of the data
2016-12-22 21:19:53 +01:00
Dirk Ziegelmeier
3a557baedd Move a few MQTT options from mqtt.c to mqtt_opts.h 2016-12-21 09:42:25 +01:00
Dirk Ziegelmeier
6e219b6b11 Change signature of mqtt_client_connect() to take an IP addr instead of a string 2016-12-21 09:36:28 +01:00
Dirk Ziegelmeier
ec1450bac4 Add mqtt documentation from Erik Anderson, rev 4b84fff 2016-12-21 09:29:47 +01:00
Axel Lin
5be91de56c mqtt: Trivial error message fix
Fix trivial copy-paste mistake.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
2016-12-21 08:54:57 +01:00
David van Moolenbroek
24fa1c457e opt.h: provide some hints regarding MLD settings 2016-12-20 22:28:11 +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
Axel Lin
d5bc856f45 mqtt: Check conn_state before create request for sub_unsub
This also avoid a request leak in client->conn_state == TCP_DISCONNECTED error
path.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
2016-12-20 19:45:31 +01:00
Dirk Ziegelmeier
dd96c71253 Fix a few -Wconversion warnings (there are many more to do) 2016-12-20 14:22:51 +01:00
Thomas Mueller
be57134810 Fixed bug #49895: Incorrect configuration detection in lwip/dns.h
Signed-off-by: goldsimon <goldsimon@gmx.de>
2016-12-20 14:21:26 +01:00
Dirk Ziegelmeier
16b895b466 Undo removal of mqtt_publish() from documentation in Simon's last commit (guess it was by accident) 2016-12-20 10:48:19 +01:00
Dirk Ziegelmeier
dcb761637d Minor documentation fix in MQTT 2016-12-20 10:42:56 +01:00
Axel Lin
02f4610b1c mqtt: Use LWIP_ARRAYSIZE to replace hardcoded value
Signed-off-by: Axel Lin <axel.lin@ingics.com>
2016-12-20 10:36:42 +01:00
goldsimon
b6a131edfb mqtt: fix C usage (declaration after statement), fix casting to smaller type 2016-12-20 10:27:43 +01:00
Dirk Ziegelmeier
12bc2c0425 MQTT cleanups:
- create mqtt_opts.h file and move options in there
- documentation cleanups
2016-12-20 10:08:50 +01:00
Dirk Ziegelmeier
14e36866f5 Some cleanups in MQTT client
Integrate in documentation
Compile fixes, mostly: Variables must be declared before any statement in a function
2016-12-20 09:41:21 +01:00
Dirk Ziegelmeier
1e82465766 task #14281: Add MQTT client
Thanks to Erik Andersen
Taken from https://github.com/erian747/, branch mqtt, rev 5d59470
2016-12-20 09:16:21 +01:00
goldsimon
fb07d47b82 more LWIP_NOASSERT fixes 2016-12-19 10:34:49 +01:00
goldsimon
c71733252c Fix compiling with LWIP_NOASSERT (and debug/error disabled, too) 2016-12-19 10:29:16 +01:00
Dirk Ziegelmeier
e0c0ba7e1b Fix compile with LWIP_NOASSERT
Pointed out by Nirav Desai
2016-12-19 10:11:23 +01:00
Dirk Ziegelmeier
c21763f6cb Minor code cleanup api_lib.c 2016-12-18 21:31:14 +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
Thomas Mueller
fcd2daf57c fixed race condition in return value of netconn_gethostbyname() (and thus also lwip_gethostbyname/_r() and lwip_getaddrinfo())
Signed-off-by: sg <goldsimon@gmx.de>
2016-12-16 15:44:00 +01: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
sg
d9f461e4e4 Fixed #49848 (Non-blocking socket emit a sock error while read return EWOULDBLOCK) especially for EWOULDBLOCK (added task #14275 for the general problem) 2016-12-15 22:32:46 +01:00
sg
62e340067e LWIP_HOOK_TCP_ISN: added CHANGELOG/fixed comment 2016-12-15 21:08:12 +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
bd1defc1d8 added forgoten new file nd6_priv.h :-( 2016-12-14 21:24:48 +01:00
sg
281ef5d094 minor: fixed errors in some defined __DOXYGEN__ guards 2016-12-14 21:18:50 +01:00
sg
e8461f9994 minor: corrected include guard name in tcp_priv.h 2016-12-14 21:05:22 +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
goldsimon
1a53c106e1 CHANGELOG: added LWIP_HOOK_ND6_GET_GW() 2016-12-14 08:42:11 +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
Dirk Ziegelmeier
8347d3b623 Try to fix compile warning with GCC under Linux ("large integer implicitly truncated to unsigned type") 2016-12-09 19:56:29 +01:00
Sylvain Rochet
a83c4e0897 PPP: fix build warning on wrong cast from void* to unsigned long
ppp/utils.c: In function 'ppp_vslprintf':
ppp/utils.c:251:12: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
     val = (unsigned long) va_arg(args, void *);
     ^

This is because a void* type is casted into an unsigned long type,
which obviously isn't correct on LLP64 systems such as Windows.

Actually, we are not using %p, thus we remove %p support completely
instead of trying to fix the issue in unused code.
2016-12-09 14:25:47 +01:00
goldsimon
ac4d994249 mdns.c: use group initializer constants from prot/dns.h 2016-12-09 13:10:12 +01:00
goldsimon
f308694dd4 Revert "mdns.c: use constants from dns.h/.c"
This reverts commit 0e883bbbc5.
2016-12-09 13:08:00 +01:00
goldsimon
0e883bbbc5 mdns.c: use constants from dns.h/.c 2016-12-09 12:49:49 +01:00
goldsimon
5774fdfe75 dns: added one-shot multicast DNS queries 2016-12-09 09:20:46 +01:00
Dirk Ziegelmeier
85817e7611 Minor documentation update about IP_ADDR_ANY 2016-12-08 16:56:19 +01:00
Dirk Ziegelmeier
b359b8c3e0 Minor documentation improvement 2016-12-08 13:35:34 +01:00
Dirk Ziegelmeier
bb6df52ed5 Fix doxygen parsing in my last commit 2016-12-08 12:47:30 +01:00
Dirk Ziegelmeier
8a9ab9968c Improve documentation: add compiler abstraction macros to doxygen docs 2016-12-08 12:45:21 +01:00
Dirk Ziegelmeier
a420d2530f arch.h: Add hint for struct packing #defines on GCC/clang 2016-12-08 11:13:51 +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
f446194c8a pppos.c: Use arch.h to get size_t instead of including stddef.h 2016-12-07 22:29:24 +01:00
Dirk Ziegelmeier
1dd563a0ae arch.h: Implement possibility to provide own header for size_t, default is stddef.h 2016-12-07 22:27:57 +01:00
Dirk Ziegelmeier
aae0fc4908 Use new IPv6 init macro in netif.c 2016-12-07 22:19:37 +01:00
Dirk Ziegelmeier
5bb83301dd Add macro to init an IPv6 address with U32 in host byte order 2016-12-07 22:19:16 +01:00
Dirk Ziegelmeier
0ca82df062 Cleanup byte order handling a bit.
- Create LWIP_MAKEU32(a,b,c,d) to create an U32 value from bytes
- Use PP_HTONL() in some macros to emphasize network byte order conversion
2016-12-07 20:18:58 +01:00
goldsimon
ff3656f4f5 Added improved macros for ip address initialization: IPADDR4_INIT_BYTES(), IPADDR6_INIT_HOST() and IP4_ADDR_MAKEU32() 2016-12-07 13:06:07 +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
e00a131160 Fix bug #49778: sntp_stop does not cancel all timers
Patch by Ari Suutari
2016-12-06 20:29:12 +01:00
Axel Lin
795acf020e lwiperf: Simplify #if LWIPERF_CHECK_RX_DATA guard
The variable i is equal to q->len after exit the for loop.
Check the received data should not change the logic of update packet_idx.
So let's simplify the code a bit.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
2016-12-06 11:36:25 +01:00
Dirk Ziegelmeier
cc25c2634b Cleanup: move struct ip6_addr_packed and ip6_addr_p_t type to prot/ip6.h - these types are used in prot/ip6.h and prot/mld6.h 2016-12-06 09:36:36 +01:00
Dirk Ziegelmeier
1687721600 Fix compile when IPv4 is disabled 2016-12-05 22:01:58 +01:00
Dirk Ziegelmeier
a6bc422729 Move declaration of struct ip4_addr_packed and ip4_addr_p_t to prot/ip4.h
The types are used in structs declared in ip4.h.
2016-12-05 21:53:43 +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
Sylvain Rochet
bcaf2f08aa PPP, PPPoS: fix memory leak when disconnecting if there are remaining input bytes
Art says:
  pppos_input() can call ppp_input() which can call pppos_disconnect() to
  disconnect the interface.  However, it will continue to read in
  characters and allocate a pbuf from the PBUF_POOL and keep it in
  pppos->in_head and in_tail. When a re-connect happens and pppos_connect()
  is called, this pppos->in_head and in_tail are zeroed, hence a memory
  leak. (This happens with PPP_INPROC_IRQ_SAFE not defined.)

  A fix would be inside pppos_input() to break out of the loop inputting
  characters after calling ppp_input() if pppos->open == 0.  Note that
  the loop is not even entered if pppos->open == 0.

          ppp_input(ppp, inp);
          if(pppos->open == 0) //get out if they disconnected
            break;

Fix it in a similar way which doesn't add new code by moving the
existing pppos->open check inside the byte loop.
2016-12-03 16:12:51 +01:00
Dirk Ziegelmeier
4bbed75cc4 Minor code layout cleanup in err.c and errno.h 2016-12-01 08:55:01 +01:00
Joel Cunningham
f28e63b2a3 Add netifapi macros for set link up/down
This commit extends the netifapi macros to support netif_set_link_up
and netif_set_link_down
2016-11-30 08:49:23 -06: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
Axel Lin
12e35c4c12 mdns: Fix assertion message in mdns_resp_add_service_txtitem()
So we know which function emits the assertion.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
2016-11-30 11:36:05 +01: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
Dirk Ziegelmeier
47fd67a35c Remove TODO comments and one check from sockets.c indicating IPV6_V6ONLY socket option handling does not work 2016-11-28 15:56:59 +01:00
goldsimon
b934c3f471 fixed bug #49726: setsockopt() set TCP_NODELAY TCP_KEEPALIVE ... with a listen state TCP will crash 2016-11-28 15:50:59 +01:00
goldsimon
2a882b6387 minor: fixed indent 2016-11-28 12:54:17 +01:00
goldsimon
ca9342c549 fixed bug #49725 (send-timeout: netwonn_write() can return ERR_OK without all bytes being written) 2016-11-28 12:51:45 +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
Dirk Ziegelmeier
aea872431c Fix naming of some inet_addr_* macros in inet.h
From inet4_addr_* to inet_addr_* - inet_addr is a "known word", don't change it
2016-11-25 22:13:12 +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