Commit Graph

4877 Commits

Author SHA1 Message Date
Dirk Ziegelmeier
ef758082ed Fix that slipif used netif->num to pass parameters to slipif_init.
Use netif->state now, interpreted as u8_t port number (not a pointer any more!)
2017-02-05 12:35:42 +01:00
Dirk Ziegelmeier
1fd56658b8 Add IPv6 scopes to CHANGELOG 2017-02-04 18:44:30 +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
David van Moolenbroek
2903b476c7 ip6: fix parentheses in ip6_addr_has_scope
Both of the multicast checks should be skipped if the address type
is unicast. This bug accidentally caused only one of them to be
skipped, resulting in some unnecessary performance overhead.

Reported by Axel Lin.
2017-02-04 18:38:02 +01:00
Dirk Ziegelmeier
f60a2e8f85 Fix a few build problems after merging IPv6 zones 2017-02-04 11:59:35 +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
855ea02b15 netdb: Use LWIP_MEM_ALIGN_BUFFER instead of open coded
Signed-off-by: Axel Lin <axel.lin@ingics.com>
2017-02-03 08:57:45 +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
Joel Cunningham
b6c995fed8 Rename if.c to if_api.c
This renames if.c to if_api.c in order to avoid using a common source
file name which may collide with other source files from non-LwIP
projects. See discussion in task #14314
2017-02-02 08:59:50 -06: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
2ad03b0ebd Add documentation for LWIP_PROVIDE_ERRNO in arch.h 2017-02-02 09:18:30 +01:00
Dirk Ziegelmeier
29b7c75a72 Revert fixes "bug #50162: Minor bug in errno.h"
They are a breaking change :-(
This reverts commit abef0b44a8.
2017-02-02 08:42:09 +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
goldsimon
4b091cfc2a Fix comment on lwip_shutdown() (it's not unimplemented any more) 2017-02-01 10:09:37 +01:00
goldsimon
48d2243845 Clarify/add LWIP_PROVIDE_ERRNO comments 2017-01-31 12:38:53 +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
a1df0c5d77 Fix build failue in err.h reported by Axel Lin
In file included from ../../../../lwip/src/include/lwip/sockets.h:49:0,
                 from ../../../../lwip/src/core/init.c:47:
../../../../lwip/src/include/lwip/errno.h:46:5: error:
"LWIP_PROVIDE_ERRNO" is not defined [-Werror=undef]
 #if LWIP_PROVIDE_ERRNO
     ^~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
../Common.mk:93: recipe for target 'init.o' failed
make: *** [init.o] Error 1
2017-01-31 08:57:25 +01:00
David van Moolenbroek
2e528ad510 PPP: clear address state before clearing address
netif_ip6_addr_set_state() relies on being able to access the old
address on invalidation, for example in order to invalidate PCBs
and leave the correct solicited-node MLD group.
2017-01-27 19:07:14 +01:00
Dirk Ziegelmeier
abef0b44a8 bug #50162: Minor bug in errno.h
#ifdef -> #if
2017-01-27 09:09:21 +01:00
Dirk Ziegelmeier
ee3154999a Add CHANGELOG to lwIP HTML documentation 2017-01-24 11:45:51 +01:00
Dirk Ziegelmeier
7a99d2f8e9 Fix documentation on netif_index_to_name 2017-01-24 11:39:34 +01:00
Joel Cunningham
6fbec25c8f if.c include lwip/if.h
if.c was not including lwip/if.h and failed to build with
-Werror=missing-prototypes on gcc/clang
2017-01-23 17:40:36 -06: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
Dirk Ziegelmeier
0ef298b21f Fix warning about shadowing a global variable "index" in netifapi.c 2017-01-23 21:12:29 +01:00
Dirk Ziegelmeier
9e0b36747a Fix warning about shadowing a global variable "index" in if.c 2017-01-23 20:21:49 +01:00
Ajay Bhargav
b5011e7012 api:if: Handle case when LWIP_NETIF_API is not defined
When LWIP_NETIF_API is not enabled in lwipopts.h. Return error from if
APIs

Signed-off-by: Ajay Bhargav <contact@rickeyworld.info>
2017-01-23 09:30:00 -06: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
Dirk Ziegelmeier
edac92d03a Minor compile fix in netifapi.c: Use LWIP_CONST_CAST to cast away constness 2017-01-20 21:27:05 +01: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
c362c6a02c Add note about bug #50064 to CHANGELOG 2017-01-18 12:33:26 +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
sg
b198c877db fix compiling TCP unit tests with IPv6 enabled 2017-01-16 14:21:08 +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
861dab5b22 Set lwIP version to 2.0.2 in doxygen script 2017-01-15 09:22:33 +01:00
Dirk Ziegelmeier
5c58e25de5 Minor code readability improvement in mqtt.c 2017-01-15 09:22:13 +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