Commit Graph

1198 Commits

Author SHA1 Message Date
goldsimon
44f7a3cb0d work on -Wconversion... 2017-07-05 22:31:58 +02:00
goldsimon
41177cfd1c work on -Wconversion... 2017-06-30 22:10:16 +02:00
Axel Lin
ca9eae26e1 PPP, VJ: Use vj_uncompress_err at appropriate places
Use vj_uncompress_err() instead of duplicating the same code.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Sylvain Rochet <gradator@gradator.net>
2017-06-29 11:44:11 +02:00
Axel Lin
79f2200b27 PPP, PPPoS: Fix update SNMP ifoutoctets counter in pppos_output_last()
Current code does not correctly update ifoutoctets counter because nb->tot_len
is always 0. Fix it by setting nb->tot_len to actual payload length so we can
update ifoutoctets correctly.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Sylvain Rochet <gradator@gradator.net>
2017-06-29 11:44:08 +02:00
Dirk Ziegelmeier
d02a73c285 Replace usages of tcpip_callback_with_block(foo, bar, 0) with tcpip_try_callback() 2017-06-22 08:14:02 +02:00
goldsimon
c094fcc086 Try to make gcc work without -Wno-address 2017-06-21 16:07:36 +02:00
Axel Lin
faf74b36a4 PPP, VJ: Use pbuf_take instead of duplicate copy code
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: goldsimon <goldsimon@gmx.de>
2017-06-20 20:26:01 +02:00
Axel Lin
10abb6b5ec ethernetif: Add #if LWIP_IPV4 guard around netif->output
netif->output and etharp_output are only available when LWIP_IPV4=1.
Fix the skeleton file.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: goldsimon <goldsimon@gmx.de>
2017-05-22 20:42:19 +02:00
Sylvain Rochet
4171f39a72 PPP: remove ppp_singlebuf
We don't have to keep a helper function just for the sake of a PBUF_RAW
constant. Inline ppp_singlebuf function.

Signed-off-by: Sylvain Rochet <gradator@gradator.net>
2017-05-05 15:42:15 +02:00
Axel Lin
3e909bafa8 PPP: use pbuf_coalesce() instead of private ppp_singlebuf()
pbuf_coalesce() creates a single pbuf out of a chain of pbufs, which is
exactly what ppp_singlebuf() need.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Sylvain Rochet <gradator@gradator.net>
2017-05-05 15:36:26 +02:00
goldsimon
749e078d36 6lowpan: fix compiling with !LWIP_UDP 2017-05-05 09:19:02 +02:00
goldsimon
f00d7db409 backport of "variable assigned but not used" warnings from STM (why don't people report such things?) 2017-05-03 20:31:29 +02:00
Dirk Ziegelmeier
b71878f02e Fix bug #50739: 6lowpan - IPHC de-compression bug
Apply fix provided by Aigner B.
2017-04-21 22:30:23 +02:00
goldsimon
26d3466f50 Add macro ETH_ADDR() to initialize a struct eth_addr with its 6 bytes and taking care of correct braces 2017-04-11 08:49:15 +02: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
Dirk Ziegelmeier
0f4ad57033 Fix build error in bridgeif.c 2017-04-05 08:11:37 +02:00
goldsimon
9c78909857 bridgeif: sanity-check init_data->max_ports <= BRIDGEIF_MAX_PORTS 2017-04-04 22:12:38 +02:00
goldsimon
77df9ccd5a bridgeif: fix that max_fdb_static_entries was used to init dynamic FDB 2017-04-04 22:09:31 +02:00
goldsimon
97f4033a8a bridgeif: improve documentation 2017-04-04 21:54:52 +02:00
goldsimon
8ed2bd4771 bridgeif: gracefully handle out-of-memory in bridgeif_fdb_init 2017-04-04 21:54:30 +02:00
goldsimon
1c57c84200 vj_uncompress_uncomp: copy from/to bigger buffers (used for checks before) instead of cs->cs_ip and ip; just to help static code analysis to see this is correct ;-) 2017-03-30 21:54:42 +02:00
goldsimon
5d600f72d2 bridgeif_input: check netif != NULL before calling netif_get_client_data() 2017-03-29 22:27:00 +02:00
goldsimon
1ab89ed5e6 bridgeif: fixed IPv6-only build 2017-03-26 20:52:05 +02:00
Dirk Ziegelmeier
d9b279d150 Cleanup documentation a bit: rename "Addons" to "NETIFs" - its a more appropriate name 2017-03-15 20:03:55 +01:00
Dirk Ziegelmeier
6328da87aa Add bridge interface to documentation 2017-03-15 19:58:32 +01:00
goldsimon
2dcf31d6b1 bridgeif: better separation between bridgeif and fdb (todo: move fdb to contrib?), tried to fix the build for LWIP_NUM_NETIF_CLIENT_DATA==0 2017-03-15 16:50:55 +01:00
goldsimon
51a07661cc Added a simple multi-netif 802.1d bridge implementation to show that a multi-port netif works (see task #14369) 2017-03-15 12:31:12 +01:00
Sylvain Rochet
e16d10ade6 PPP: remove unused and confusing return values other than ERR_OK for ppp_connect and ppp_listen
User should not use ppp_connect or ppp_listen return value to retry
later, it must wait for the callback to be called. This is primarily
done this way to have a consistent behavior with and without the
holdoff feature.

Remove returned error value from PPP link level API connect and listen
callbacks because we are not using them anymore, then make ppp_connect
or ppp_listen to always return ERR_OK, thus we are not breaking the PPP
user API.

We don't need the return code here, all PPP link level drivers can't
fail at all (e.g. PPPoS) or retry if necessary (PPPoE and PPPoL2TP).
2017-03-08 22:17:40 +01:00
Dirk Ziegelmeier
0a7734cf64 Preparation for task #14369: Define ways to work with a netif having multiple ports
Let ethernet_input() fill in pbuf's if_idx (if not already set by driver or an L2 bridge)
2017-02-23 16:36:40 +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
Dirk Ziegelmeier
46f4584796 Fix cast from pointer to numeric in slipif.c 2017-02-05 12:53:42 +01:00
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
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
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
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
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
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
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
1687721600 Fix compile when IPv4 is disabled 2016-12-05 22:01:58 +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
Sylvain Rochet
8c3c96baf7 PPP, L2TP: fix PPPOL2TP_AUTH_SUPPORT == 0 support
Fix compiler warnings on unused parameters and a function signature
mismatch in PPPAPI.
2016-11-22 22:13:24 +01:00
Sylvain Rochet
c4eb52dcff PPP: set protocol_list[] const
This array is a constant list of protocols, save some ram space by
adding the const modifier it deserves.
2016-11-06 20:00:31 +01:00
Sylvain Rochet
1e6c4ac017 PPP, IPCP: check that the peer is allowed to use the IP address it wants
This is done in the pppd upstream and was disabled because we don't have
the allowed addresses list required for the auth_ip_addr function.

This is mostly necessary for PPP in server mode to prevent the peer to
use the IP address it wants instead of the one we want, which is
currently allowed.

Rewrite auth_ip_addr in a simple way where we forbid PPP peer to use
loopback net, a multicast address or a reserved class address. Added
to that we consider that PPP in server mode with peer required to
authenticate must provide the peer IP address, reject any IP address
wanted by peer different than the one we wanted. This is actually
an allowed addresses "list" of one entry that follows what is done
in the unused auth_ip_addr function.
2016-11-06 17:39:59 +01:00
Sylvain Rochet
b978d17ca0 PPP, IPCP: remove obvious FIXME
No-op. This is now unused code and it is pretty self explanatory what
int_option do; it checks that passed parameter is an unsigned integer.
2016-11-06 12:54:26 +01:00
Sylvain Rochet
dde55c6c0e PPP, IPCP: fix reset state before reconnecting
Commit 7df5496e7b revealed a regression introduced in commit 5a71509353
which broke IPCP reset state.

ask_for_local was set to 0 if ouraddr initial value is 0, if
ask_for_local was false go->ouraddr was cleared in reset callback,
commit 5a71509353 breaks it by removing this clearing. This regression
was silent because the whole ppp pcb runtime data was cleared before
reconnecting until commit 7df5496e7b which removed this giant clearing.

Fix it by reintroducing ask_for_local boolean value, with proper initial
value following what unused function ip_check_options do.

Fixes: 7df5496e7b ("PPP, rework initial/reconnect cleanup")
Fixes: 5a71509353 ("PPP, CORE, IPCP: removed useless ask_for_local boolean")
2016-11-05 22:07:04 +01:00
Dirk Ziegelmeier
f6e27940bd Make lwIP compile with clang -Wdocumentation -> several documentation fixes 2016-10-09 12:21:39 +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
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
537bd836c9 Minor: More documentation updates 2016-08-25 22:23:11 +02:00