Commit graph

346 commits

Author SHA1 Message Date
Stephanos Ioannidis 2b9636db52 net/ieee802154: Explicitly include toolchain.h.
This commit adds an explicit inclusion of toolchain.h from
ieee802154_frame.h.

The endianness preprocessor definitions (__BYTE_ORDER__,
__ORDER_LITTLE_ENDIAN__, __ORDER_BIG_ENDIAN__) are used by
ieee802154_frame.h; these being not defined can easily go unnoticed and
cause unexpected behaviours, as detailed in PR #18922.

toolchain.h ensures that these preprocessor definitions are defined and
*must* be included in a file that uses these definitions.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2019-09-09 21:40:54 +02:00
Jukka Rissanen 792d6fc19a net: gptp: Avoid memcpy to same buffer
Do not try to memcpy() the same buffer to itself.

This one also reverts commit 112ecb7290
("net: gptp: Fix for coverity CIDs 203471 and 203464") as that
did not fully fix the issue.

Coverity-CID: 203464
Coverity-CID: 203471
Fixes #18394

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-08-27 10:33:14 -04:00
Tomasz Bursztyka 112ecb7290 net: gptp: Fix for coverity CIDs 203471 and 203464
If no challenger went to replace the best port/vector, then the best
port is still the global_ds and thus point to the same memory: no need
to update the global_ds then.

Coverity-CID: 203471
Coverity-CID: 203464
Fixes #18395

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-08-23 08:54:27 -04:00
Tomasz Bursztyka 82c315aaf5 net: ppp: Fix for coverity CID 203514
Looks like the logic to count rejection is missing. Removing count_rej
variable, and set a comment about initializing the code to the right
value once this logic will be in.

Coverity-CID: 203514
Fixes #18398

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-08-23 08:54:27 -04:00
Alexander Wachter d864f5de5b net: l2: canbus: Add support for canbus Ethernet translator
This commit adds support for a 6LoCAN Ethernet border translator.
CAN frames with the translator CAN address are translated and forwarded
to Ethernet. Ethernet frames with the first 34 bits matching the MAC
address of the translator are translated and forwarded to 6LoCAN.

Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
2019-08-08 13:25:01 +03:00
Alexander Wachter 7fe85170fc net: l2: canbus: Add support for pkt reception from translator
This commits adds support for reception of packets thats comes from
a Ethernet to 6LoCAN translator. This packets carry the Ethernet
MAC address (6 bytes) inline in the FF (First Frame).

Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
2019-08-08 13:25:01 +03:00
Alexander Wachter 35f01673ac net: l2: 6LoCAN implementation
This commit is an implementation of 6LoCAN, a 6Lo adaption layer for
Controller Area Networks. 6LoCAN is not yet standardised.

Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
2019-08-08 13:25:01 +03:00
Alexander Wachter c8c5f3bbf3 net: canbus: Rename canbus to canbus_raw
Rename the socket_can implementation from CANBUS to CANBUS_RAW.
This is a preperation for 6LoCAN which is a CANBUS L2 for IPv6.

Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
2019-08-08 13:25:01 +03:00
Jukka Rissanen 5c05ef5101 net: Move include files outside of extern "C" block
This is related to findings in #17997 and changes network related
header files to have include files outside of extern "C" { } block.

Declarations that use C linkage should be placed within extern "C"
so the language linkage is correct when the header is included by
a C++ compiler.

Similarly #include directives should be outside the extern "C" to
ensure the language-specific default linkage is applied to any
declarations provided by the included header.

See: https://en.cppreference.com/w/cpp/language/language_linkage

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-08-06 14:46:36 +03:00
Joakim Andersson c1a754f665 Bluetooth: Host: Print error codes in hex
Error codes are listed in header files and in the core spec as hex
values. Always print them in hex in debug for easier error code
checking.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-08-05 12:18:17 +02:00
Jukka Rissanen 4a322c6a7c net: ppp: Handle received Discard-Request
We must discard the received Discard-Request silently.
See RFC 1661 chapter 5.9 for details.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-29 10:24:46 +03:00
Jukka Rissanen c4a692a85f net: ppp: Add proper support to receive Echo-Reply message
Currently only net-shell calls net_ppp_ping() command, so make
it return the amount of time that it took to receive Echo-Reply
so the net-shell can print the round trip time value.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-29 10:24:46 +03:00
Jukka Rissanen eff46a5232 net: ppp: Reject unhandled protocols
If we receive a protocol that we do not currently handle, then
return Protocol-Reject to peer.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-29 10:24:46 +03:00
Jukka Rissanen 3e481f9d07 net: ppp: Allow delay of PPP protocol handshakes
By default PPP is started immediately when the network interface
goes up. This can be problematic especially when debugging the beast
so allow user to delay the startup.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-29 10:24:46 +03:00
Jukka Rissanen 4a5543db25 net: shell: Add ppp network interface support
Print point-to-point network information properly.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-29 10:24:46 +03:00
Jukka Rissanen 02239a99a2 net: ppp: Add IPV6CP support
Initial version for PPP IPv6 Control Protocol.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-29 10:24:46 +03:00
Jukka Rissanen f95938da0f net: ppp: Initial support for point-to-point protocol
This implements ppp L2 component, LCP and IPCP modules.

Fixes #14034

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-29 10:24:46 +03:00
Markus Becker 3178555878 net: openthread: Allow DHCP configuration of OpenThread in Zephyr
Certain Thread implementations (notably ARMs) require a DHCPv6
implementation.
Allow the usage of the relevant OpenThread configuration parameters in
Zephyr.

Signed-off-by: Markus Becker <markus.becker@tridonic.com>
2019-07-22 13:23:05 +03:00
Joakim Andersson 0ac83180fd Bluetooth: host: Move address string parsing to bluetooth API
Bluetooth address parsing has been duplicated across the different
sub-shell files. Also missing parsing of identity/resolved addresses.
Move parsing of string close to parsing to string for a symmetrical API

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-07-16 12:44:18 +02:00
Joakim Andersson 7a93e948a9 kernel: lib: Add convert functions for hex strings and binary arrays
Move duplicate hex2bin and add bin2hex function so that application can
use the functions and avoid code duplication.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-07-16 12:44:18 +02:00
Tomasz Bursztyka c8f7c329a2 net/lldp: Simplify Kconfig file
Let's remove depends on NET_LLDP from all the options. It avoids this:
 # CONFIG_NET_LLDP is not set
 # CONFIG_NET_LLDP_LOG_LEVEL_OFF is not set
 # CONFIG_NET_LLDP_LOG_LEVEL_ERR is not set
 # CONFIG_NET_LLDP_LOG_LEVEL_WRN is not set
 # CONFIG_NET_LLDP_LOG_LEVEL_INF is not set
 # CONFIG_NET_LLDP_LOG_LEVEL_DBG is not set
 CONFIG_NET_LLDP_LOG_LEVEL_DEFAULT=y
 CONFIG_NET_LLDP_LOG_LEVEL=3
 CONFIG_NET_LLDP_CHASSIS_ID="CHASSIS_ID_PLACEHOLDER"
 CONFIG_NET_LLDP_PORT_ID="PORT_ID_PLACEHOLDER"

And instead it will generate this:
 # CONFIG_NET_LLDP is not set

Make the menu as an enablement config option as well.

Adapting lldp header file relevantly.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-07-10 15:24:32 +03:00
Tomasz Bursztyka 845f070c1e net/ethernet: Cleanup a bit on the usage of ifdefs
ARP, LLDP and GPTP functions have dummies in case of being disabled so
let's use IS_ENABLED() accordingly.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-07-10 15:24:32 +03:00
Robert Lubos 1ee8e0b055 net: openthread: Verify iface in net_mgmt event handler
OpenThread did not verify if the interface provided in the net_mgmt
handler is actually an OpenThread interface. In result, when multiple
network interfaces were used, different interfaces were processed by the
OpenThread handler, ending up in a crash.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2019-07-03 19:51:34 +03:00
Anas Nashif a2fd7d70ec cleanup: include/: move misc/util.h to sys/util.h
move misc/util.h to sys/util.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif 536dd5a71f cleanup: include/: move misc/slist.h to sys/slist.h
move misc/slist.h to sys/slist.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif 9ab2a56751 cleanup: include/: move misc/printk.h to sys/printk.h
move misc/printk.h to sys/printk.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif 5eb90ec169 cleanup: include/: move misc/__assert.h to sys/__assert.h
move misc/__assert.h to sys/__assert.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Jukka Rissanen 95e8498c27 net: ptp: Add usermode support to net_eth_get_ptp_clock_by_index()
Make net_eth_get_ptp_clock_by_index() clock API to work with user space.
Create also unit test for testing this user mode support.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-06-25 15:22:51 +03:00
Jukka Rissanen 11b06fab76 net: ethernet: Add net_eth_get_ptp_clock_by_index() function
This can be used to get the PTP clock if only network interface
index is known.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-06-25 15:22:51 +03:00
Jukka Rissanen def6b14aa7 net: ptp: clock: Create a dummy inline func for net_eth_get_ptp_clock()
Follow the style in other similar functions in this file.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-06-25 15:22:51 +03:00
Nicolas Pitre 3c6c8ed063 gptp: don't cast pointers to ints
Let's use longs here so 64-bit pointers will fit.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2019-06-25 10:18:20 +03:00
Anas Nashif f2cb20c772 docs: fix misspelling across the tree
Found a few annoying typos and figured I better run script and
fix anything it can find, here are the results...

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-19 15:34:13 -05:00
Tomasz Bursztyka 344d4bdce0 net/arp: No need of 64bits timer precision on ARP requests
The 32bits one can hold up to about 50 days, this is more than enough
knowing that ARP request timeout is 2 seconds.

So reducing the request start time to 32bits.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-05-23 22:22:16 +03:00
Jukka Rissanen 19b48687ec net: ethernet: Drop pkt if MAC dst is bcast address but IP is not
Drop packet if it has broadcast destination MAC address but the IPv4
destination address is not multicast or broadcast address.
See RFC 1122 ch 3.3.6 for details.

Fixes #16276

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-05-21 16:43:38 +03:00
Jukka Rissanen 9552796361 net: arp: Drop request where src hw address is our address
We replied to an ARP request that has the same Sender Hardware Address
than that of ours. Such an ARP request must be discarded, no reply
should be sent and translation table should not be updated.

Fixes #16110

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-05-14 12:36:07 +03:00
Jukka Rissanen a84e9345a6 net: arp: Use proper dest hw address after receiving a request
If a packet is received with Ethernet source address different
from ARP's sender hardware address field, then DUT must use the
latter address in response packets.

Fixes #16098

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-05-14 12:35:48 +03:00
Jukka Rissanen 9a6bbbfb69 net: Check device driver API pointer
It is possible that the device driver API pointer is null.
For example if the device driver returns an error, the device
code will make the API pointer NULL so that the API would not
be used. This can cause errors in networking code where we
typically do not check the NULL value.

Fixes #15003

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-05-07 15:41:15 +03:00
Luiz Augusto von Dentz 5506a4d228 net: bt: Set NET_IF_NO_AUTO_START flag
This make use of NET_IF_NO_AUTO_START flag so Bluetooth interfaces are
not automatically enabled after initialized.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2019-05-07 11:16:29 +03:00
Luiz Augusto von Dentz 95cadb7bfe net: bt: Add multi-link support
This adds support for having multiple connections based on BT_MAX_CONN.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2019-05-07 11:16:29 +03:00
David B. Kinder c5112327a7 doc: fix mentions of Wi-Fi trademark name
The approved trademark name is Wi-Fi so update references to WiFi and
other spellings to Wi-Fi in documentation and Kconfig help strings.
(Note that use of spelling variatios of "wifi" in module names, CONFIG
names, link names and such are untouched.)

https://www.wi-fi.org/

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2019-05-06 20:10:59 -04:00
Jukka Rissanen c4fcc604e6 net: arp: No need to check pkt for NULL
The pkt variable cannot be NULL at this point so the check for
nullness is not needed.

Coverity-CID: 198002
Fixes #15777

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-05-02 13:22:09 +03:00
Ravi kumar Veeramally 49cb24a5eb net: ethernet: l2: Add support for VLAN tag strip
If ethernet controller has VLAN tag strip flag enabled
(ETHERNET_HW_VLAN_TAG_STRIP), L2 etherent will not read tag from
the Rx etherent header. Instead it will fetch VLAN tag from
net packet metadata.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2019-04-26 10:46:27 +03:00
Robert Lubos 51a9e6f534 net: openthread: Do not overwrite stored dataset with defaults
This commit prevents a situation when stored and possibly modified
commissioner dataset is overwritten with default configuration during
OpenThread initialization.

It introduces a new function, openthread_start, which verifies if the
dataset is already stored, and if not, depending on configuration,
preloads the default configuration or initiates the join procedure.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2019-04-23 16:43:36 +03:00
Jukka Rissanen 712103d594 net: if: Add access functions for network interface flags
Provide access functions for manipulating network interface flags.
There is no need for the caller of this API to know about the inner
details of the flags.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-04-23 13:11:03 +03:00
Patrik Flykt 3e798dfd88 net: ethernet: Send sender IP address in ARP announce packets
In addition to checking that the ARP entry does not exist as the
implementation is done currently, also check if the ARP packet
is due to IPv4 link local address configuration. In both cases
use the provided IPv4 address instead of the one set for the
interface.

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2019-04-17 10:38:49 -05:00
Patrik Flykt 7e14cff8d7 net: ethernet: Set NET_ETH_PTYPE_ARP for IPv4 link local packet type
IPv4 link local uses ARP to detect conflicting addresses. Properly
set the ethernet packet type to NET_ETH_PTYPE_ARP when probing
for address duplicates.

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2019-04-17 10:38:49 -05:00
Ravi kumar Veeramally 189b22789c net: vlan: Etherent layer missed L2 header
When VLAN is enabled, ethernet l2 layer fills ethernet header
but not added to the network buffer.

Fixes #15346

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2019-04-11 13:20:40 -04:00
Anas Nashif 3ae52624ff license: cleanup: add SPDX Apache-2.0 license identifier
Update the files which contain no license information with the
'Apache-2.0' SPDX license identifier.  Many source files in the tree are
missing licensing information, which makes it harder for compliance
tools to determine the correct license.

By default all files without license information are under the default
license of Zephyr, which is Apache version 2.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-04-07 08:45:22 -04:00
Patrik Flykt 4aa48833d8 subsystems: Rename reserved function names
Rename reserved function names in the subsys/ subdirectory except
for static _mod_pub_set and _mod_unbind functions in bluetooth mesh
cfg_srv.c which clash with the similarly named global functions.

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2019-04-03 17:31:00 -04:00
Patrik Flykt 24d71431e9 all: Add 'U' suffix when using unsigned variables
Add a 'U' suffix to values when computing and comparing against
unsigned variables.

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2019-03-28 17:15:58 -05:00
Jukka Rissanen ac4db1b329 net: gptp: Fix bit shifting in time interval
It is invalid to try to bit shift the same amount of bits as
what is the number of bits in the left expression’s type.

Coverity-CID: 187079
Fixes #8988

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-03-25 13:38:38 -04:00
Tomasz Bursztyka d6d52ce9e5 net/pkt: Remove _new suffix to net_pkt_write functions
Suffix is now useless, as these functions are now the only ones.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-20 10:27:14 -05:00
Tomasz Bursztyka f8a091104e net/pkt: Remove _new suffix to net_pkt_get_data_new function
Now that legacy - and unrelated - function named net_pkt_get_data has
been removed, we can rename net_pkt_get_data_new relevantly.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-20 10:27:14 -05:00
Thomas Stenersen 7516476386 kconfig: Use depend on instead of select to avoid kconfig loop
Remove use of select to "force" enabling other configs in subsys/fs
and subsys/net/l2. The forcing will cause infinite kconfig recursion.

Signed-off-by: Thomas Stenersen <thomas.stenersen@nordicsemi.no>
2019-03-12 19:42:40 +01:00
Andrei Emeltchenko a9090c9538 net: lldp: Move optional End TLV to send function
In a case we have optional TLVs we need to send End TLV in the very
end.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-03-09 16:02:11 -05:00
Andrei Emeltchenko 480f93fbb5 net: lldp: Add optional TLV API
Add possibility to set optional TLVs to LLDP DU.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-03-09 16:02:11 -05:00
Andrei Emeltchenko fba09bffb2 net: lldp: Move LLDP structure definition to lldp
Move duplicated structure definitions to lldp subsystem from
drivers.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-03-09 16:02:11 -05:00
Ulf Magnusson 214ef00db3 kconfig: subsys: net: Remove redundant dependencies
subsys/net/lib/lwm2m/Kconfig.ipso is 'source'd within an 'if LWM2M', in
subsys/net/lib/lwm2m/Kconfig, so the 'depends on LWM2M' is redundant.

The 'depends on NET_IPV4' and 'depends on NET_L2_OPENTHREAD' are within
corresponding 'if's in the same file.

'if FOO' is just shorthand for adding 'depends on FOO' to each item
within the 'if'. Dependencies on menus work similarly. There are no
"conditional includes" in Kconfig, so 'if FOO' has no special meaning
around a source. Conditional includes wouldn't be possible, because an
if condition could include (directly or indirectly) forward references
to symbols not defined yet.

Tip: When adding a symbol, check its dependencies in the menuconfig
('ninja menuconfig', then / to jump to the symbol). The menuconfig also
shows how the file with the symbol got included, so if you see
duplicated dependencies, it's easy to hunt down where they come from.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-09 09:49:59 -05:00
Ulf Magnusson 48753144bd kconfig: ethernet: Remove duplicated dependencies
Some of these are from 'source'ing a file within a menu that has a
'depends on NET_L2_ETHERNET' (in drivers/ethernet/Kconfig) and then
adding another 'depends on NET_L2_ETHERNET' within it.

Similarly, subsys/net/l2/ethernet/Kconfig sources files within an
'if NET_L2_ETHERNET'.

'if FOO' is just shorthand for adding 'depends on FOO' to each item
within the 'if'. Dependencies on menus work similarly. There are no
"conditional includes" in Kconfig, so 'if FOO' has no special meaning
around a source. Conditional includes wouldn't be possible, because an
if condition could include (directly or indirectly) forward references
to symbols not defined yet.

Tip: When adding a symbol, check its dependencies in the menuconfig
('ninja menuconfig', then / to jump to the symbol). The menuconfig also
shows how the file with the symbol got included, so if you see
duplicated dependencies, it's easy to hunt down where they come from.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-08 07:23:02 -05:00
Ulf Magnusson 73efd78432 net: gptp: Remove ref. to undef. CONFIG_NET_GPTP_STACK_SIZE
No Kconfig symbol called NET_GPTP_STACK_SIZE has ever been defined in
the Zephyr repo. Drop the CONFIG_* prefix from the #define.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-05 08:23:22 -05:00
Takumi Ando 1981eef674 net/l2: openthread: Add support for automatic joiner start
We sometimes want to join a device to OpenThread mesh automatically.
This commit adds supports to do by Kconfig.

The default of CONFIG_OPENTHREAD_JOINER_PSKD is based on this page:
https://codelabs.developers.google.com/codelabs/openthread-hardware/

Signed-off-by: Takumi Ando <takumi.ando@atmark-techno.com>
2019-03-04 19:51:10 -05:00
Maksim Masalski b324f35e61 macros: deleted macros SECONDS(), MSEC(), USEC()
Changed everywhere these macros to the K_MSEC(), K_SECONDS()

Signed-off-by: Maksim Masalski <maxxliferobot@gmail.com>
2019-03-04 19:04:21 -05:00
Jukka Rissanen 81e83ba462 net: arp: Update the ARP cache if receiving ARP req
If we receive the ARP request, then check if the ARP cache
contains an entry for this IP address already. If it does,
then update the MAC address in the cache.

Fixes #10188

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-03-02 03:56:48 +01:00
Jukka Rissanen 52dc50dc6b net: lldp: Allow generation of documentation
No need to hide the symbols in the header file if CONFIG_NET_LLDP
is not enabled. This also allows the documentation to be generated
properly.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-03-01 09:45:06 +01:00
Ulf Magnusson 9aab5cef96 kconfig: Remove redundant 'default n' properties
Some more were added since the cleanup pass in June 2018. See e.g.
commit 2d50da70a1 ("drivers: ipm: Kconfig: Remove redundant 'default n'
properties") for a motivation. It also avoids people wondering whether
or not they need to put in 'default n'.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-02-27 09:25:22 +01:00
Tomasz Bursztyka ca7b3b3703 net/ieee802154: Switch fragmentation support to new net_pkt API
- differentiating actual "fragment" to buffer element from a net_pkt
- instead of copying data (and thus allocating buffer) let's just take
the fragment buffer and put it into result packet.
- fixing compilation issue in relevant test

It's more efficient that way, as we use already allocated fragment
buffer instead of reallocating/deallocating after each fragment
reception.

A possible optimization would be to calculate the actual size + header
difference if only the actual size is close to the target size.
It would avoid to get a dry run of the header decompression for each
fragment received. The difficulty being in finding the sweet spot when
it is relevant to calculate the header difference.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-23 07:44:59 -05:00
Tomasz Bursztyka 90ae99274f net/ieee802154: Switch L2 to new net_pkt allocator
Now buffer is allocated at the same time.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-23 07:44:59 -05:00
Tomasz Bursztyka d086f50243 net/l2: Switch OpenThread L2 to new net_pkt allocator
Maybe there is an easier way to fill in the buffer in one call from an
otMessage.

Switch "frag" keyword to "buf", as "frag" is now reserved for actual
packet fragmentation and not buffer.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-21 09:30:20 -05:00
Tomasz Bursztyka 9d68f94d0e net/l2: Switch bluetooth L2 to new net_pkt allocator
Not much changes here as the buffer comes from BT stack already.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-21 09:30:20 -05:00
Krzysztof Chruscinski 3605e48c44 shell: Modify subcommands to use SHELL_STATIC_SUBCMD_SET_CREATE
It is planned to deprecate SHELL_CREATE_STATIC_SUBCMD_SET macro
which is replaced by SHELL_STATIC_SUBCMD_SET_CREATE.

Additionally, removed irrelevant comments about alphabetical
ordering which is no longer needed.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2019-02-20 07:31:35 -05:00
Jukka Rissanen ef7081ee44 net: Fix the function API documentation generation
Make sure that network related functions are always documented.
This means keeping the prototype and possible stub together.

Fixes #12615

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-02-15 16:39:06 -05:00
Carlos Stuart 75f77db432 include: misc: util.h: Rename min/max to MIN/MAX
There are issues using lowercase min and max macros when compiling a C++
application with a third-party toolchain such as GNU ARM Embedded when
using some STL headers i.e. <chrono>.

This is because there are actual C++ functions called min and max
defined in some of the STL headers and these macros interfere with them.
By changing the macros to UPPERCASE, which is consistent with almost all
other pre-processor macros this naming conflict is avoided.

All files that use these macros have been updated.

Signed-off-by: Carlos Stuart <carlosstuart1970@gmail.com>
2019-02-14 22:16:03 -05:00
Tomasz Gorochowik 0604c30a1b net: gptp: Fix pkt allocation with debugs enabled
Commit 44964c735e ("net/gptp: Switch GPTP to new net_pkt API") changed
the callback used for allocation (from net_pkt_get_reserve_tx to
net_pkt_alloc_with_buffer), but for compilation with
CONFIG_NET_DEBUG_NET_PKT_ALLOC enabled, both callbacks are used
(the first pointer was just overwritten, causing MPU FAULT).

This commit removes the extra callback and fixes the fault.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2019-02-14 05:15:25 -06:00
Tomasz Bursztyka a6426620da net/private: Rename net_hexdump_frags to net_pkt_hexdump
And remove the parameter "full" as there is no "ll reserve" distinction
anymore. The parameter was unused since the ll reserve concept removal.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-12 20:24:02 -05:00
Jukka Rissanen 989eeaf96b net: canbus: Set link address type correctly
The link address type should be CANBUS of course.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-02-08 16:01:49 +02:00
Tomasz Bursztyka 499ffd6573 net/ethernet: Remove inserted L2 header buffer
The packet can be referenced somewhere else and letting the newly added
L2 header will generate corrupt packet. If the same packet is being
resent, ethernet will add again its L2 header. Thus the need to remove
such L2 header every time a packet has been sent, successfully or not.

Fixes #12560

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-08 14:24:03 +02:00
Andrei Gansari fea80ca5c1 net: subsys: fixed comments CONFIG_NET*
Fixed stranded comments:
CONFIG_NET_TLS_DEBUG removed
CONFIG_NET_LLDP_MSG_TX_INTERVAL -> CONFIG_NET_LLDP_TX_INTERVAL

Signed-off-by: Andrei Gansari <andrei.gansari@nxp.com>
2019-02-08 13:57:55 +02:00
Jukka Rissanen f610db9453 net: l2: Add CANBUS L2 layer
This is basically a dummy layer that just passes data through.
It is needed so that we can create CANBUS type network interface
to the system.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-02-07 18:08:27 +02:00
Ravi kumar Veeramally 5012223b31 net: l2: ethernet: Handover net packets to driver
If packet family is AF_PACKET and CONFIG_NET_SOCKETS_PACKET
is enabled, just handover the packet to driver for sending.
L2 layer will not touch AF_PACKETs at the moment.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2019-02-07 14:43:30 +02:00
Daniel Glöckner 1e676d654f net: gptp: fix src MAC address
The return value of net_if_get_link_addr points to a struct net_linkaddr
instead of to the raw MAC address. Without this fix the source address
will always end in 06:03 and will most likely be the same for different
boards running the same software.

Signed-off-by: Daniel Glöckner <dg@emlix.com>
2019-02-07 12:58:57 +02:00
Tomasz Bursztyka 89dae2aabd net/lldp: Switch LLDP to new net_pkt API
Minor changes:
- allocator needed to be changed
- and writing the lldp_pdu as well

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-01 14:34:38 +02:00
Tomasz Bursztyka 9a41078c51 net/lldp: Fix where Ethernet PTYPE is set for LLDP message
Since the rework of L2/L3 split, only L2 has access to its header. Thus
up to Ethernet one to set LLDP PTYPE.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-01 14:34:38 +02:00
Tomasz Bursztyka 44964c735e net/gptp: Switch GPTP to new net_pkt API
Allocation and a minor writing logic needed to be changed.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-01 14:34:38 +02:00
Tomasz Bursztyka 970e234965 net/arp: Switch ARP to new net_pkt API
Only the allocators needed to be changed there.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-01 14:34:38 +02:00
Tomasz Bursztyka c14a5c896f drivers/ethernet: Use new net_pkt API for sending and receiving
Use the new API where relevant. Only sam_gmac is left aside for now.

This simplifies a lot the code as the caller should only care about
allocating net_pkt and its buffer once, and thus will not need to mess
with "frags" etc...

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-01 14:34:38 +02:00
Jukka Rissanen d1162600e9 net: app: Remove net-app API files
The net-app API is removed. Users should use the BSD socket API
for application development.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-02-01 12:29:21 +02:00
Daniel Glöckner 5ef825fdf6 net: pkt: fix race condition in packet reference counting
It has been observed that some network drivers, f.ex. the SAM E70 GMAC,
call net_pkt_unref from inside the interrupt that signals the successful
transmission of a packet. This conflicts with the net_pkt_unref call
made by ethernet_send after the packet has been given to the driver.

We fix this by using an atomic_t to hold the reference count as there
might be other, difficult to find cases of net_pkt_(un)ref being used
across threads and interrupts.

The name of the element has been changed from "ref" to "atomic_ref" to
cause a compile error when code still has not been converted to use the
atomic_* functions.

Fixes #12708

Signed-off-by: Daniel Glöckner <dg@emlix.com>
2019-01-29 09:22:14 +02:00
Robert Lubos 43a431e149 net: openthread: Set mesh_local flag in mesh-local OT addresses
Mark automatically and statically configured mesh-local addresses
with mesh_local flag, so that they are not used as a source for
off-mesh destinations.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2019-01-28 21:24:26 -05:00
Robert Lubos c349bafab3 net: openthread: Do not register RLOC and ALOC addresses
In OpenThread RLOC address and ALOC address are used for internal mesh
routing and should not be used by applications as they can change
dynamically during runtime. Therefore prevent registering them on Zephyr
interface.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2019-01-25 10:09:27 +02:00
Loic Poulain 192733c096 net: wifi: Add Access Point mode interface
Add access point mode disable/enable to wifi mgmt/offload.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
2019-01-19 07:20:36 -05:00
Loic Poulain d9365dff92 net: wifi: shell: Add access point commands
Expose access point disable/enable commands.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
2019-01-19 07:20:36 -05:00
Robert Lubos 73ec83a9a5 net: openthread: Increase default stack size when commissioner is on
OpenThread commissioner feature has extra stack requirements, hence
increase it in this configuration.

Fixes #12455

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2019-01-18 15:24:16 +02:00
Robert Lubos 635191ac8c net: ieee802154: Fix ack check
15.4 MHR is no longer set in net_buf pointed by net_pkt, but in a
separate net_buf, hence we need to check that net_buf now to
determine if we need to wait for ACK or not.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2019-01-17 11:16:26 +02:00
Robert Lubos 8f8c6017f4 net: 6lo: Fix ieee802154 fragmentation
Two issues identified with 6lo fragmentation for ieee802154 that broke
the communication:

1) ieee802154_fragment_is_needed function did not take 15.4 FCS size
into account, hence taking wrong decision in some cases.
2) set_up_frag_hdr was writing with wrong offset, which resulted in 6lo
bytes being overwritten by 15.4 header.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2019-01-17 11:16:26 +02:00
Oleg Zhurakivskyy 20ee76ab22 net: ethernet: Clean an obscure ref/unref logic in ethernet_send()
Do not extra ref and then obscurely unref the packet inside
the statistics update function.

Actually, this extra ref/unref isn't needed here at all.

The packet is unreferenced only on a successful send, statistics
updating can be done before the unref in a clean and understandable way.

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2019-01-08 13:39:40 +02:00
Tomasz Bursztyka dc9e408e22 net/ieee802154: Compute ll hdr size before 6lo compression
Or then the IP header access will be bogus afterwards.

Fixes #12154

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-01-08 13:36:14 +02:00
Jukka Rissanen 235ebd0ca0 net: gptp: Track memory allocations better
Try to catch the original caller of setup_gptp_frame() function
in order to see who is allocating buffers.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-01-08 13:29:18 +02:00
Martin Turon 6410a16adb openthread: Update openthread version to latest upstream/master.
Update zephyr integration of openthread to latest api as of 2018-12-17:

2a75d30684

Both echo_server and echo_client compile and are operational.

Signed-off-by: Martin Turon <mturon@google.com>
2018-12-20 12:24:51 +01:00
Tomasz Bursztyka 7f8d92827f net/ethernet: Remove usage of net_pkt_ll() function
This function is planned to be removed, thus avoiding its usage.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-12-14 14:16:37 +01:00
Tomasz Bursztyka 91a9994aaf net/ieee802154: Remove usage of net_pkt_ll() function
This function is planned to be removed, thus avoiding its usage.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-12-14 14:16:37 +01:00
Tomasz Bursztyka e97a543e9b net/pkt: Remove parameters to "reserve" some headroom
Such parameter is not used anymore, it was defaulted to 0 previously.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-12-14 14:16:37 +01:00
Tomasz Bursztyka c8d26f845a net/l2: Finally get rid of reserve concept from L2
Now that net core does not use ll reserve, it can be nuked from L2.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-12-14 14:16:37 +01:00
Tomasz Bursztyka 6ea225e34a net/ieee802154: Finally removing usage of ll_reserve in L2
Moving towards serialized fragmentation, adapting mac command creation
to avoid the need of ll_reserve etc...

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-12-14 14:16:37 +01:00
Tomasz Bursztyka f923d2cb1e net/ieee802154: Serialize packet fragmentation
This will permit to avoid the need for ll_reserve.
It also removes net_buf allocation and deletion, as it works per-frame.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-12-14 14:16:37 +01:00
Tomasz Bursztyka 57a0c55dac net/6lo: Remove fragmentation function parameter on compression
Fragmentation has nothing to do with 6lo. Up to the bearer to do so.

This change is required for futur serialization of 15.4 fragmentation.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-12-14 14:16:37 +01:00
Tomasz Bursztyka bff65b6330 net/ethernet: Let's remove the use for ll reserve
There is no need to reserve any space for each frag, as the l2 will
allocate a frag for the ethernet header, arp will do the same.

This is one step further to removing the concept of ll reserve.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-12-14 14:16:37 +01:00
Jukka Rissanen bafa802657 net: gptp: Calculate the link delay same way as Avnu/gptp
Make sure that the link delay (propagation time) is calculated
same way as how Avnu/gptp is doing it with checks for rate ratio.
This is done like this in order to behave same way as their gptp.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-12-14 13:13:15 +02:00
Jukka Rissanen 11bb406332 net: gptp: Add debug print if a gptp packet cannot be created
This is useful info as otherwise we get no indication to user
if the packet is not created and not sent.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-12-14 13:13:15 +02:00
Jukka Rissanen 5a56900b07 net: gptp: Make sure that neighbor_rate_ratio cannot be 0
Neighbor rate ratio cannot be 0 as that would mean 0 packet
delivery time which is not plausible.
Add also some debugging to print current neighbor propagation
delay value.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-12-14 13:13:15 +02:00
Jukka Rissanen e41fd1ddf9 net: gptp: Update pdelay req lost counter when needed
The pdelay_allowed_lost_resp_exceed_count was updated even if we
had received pdelay response.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-12-11 16:38:12 +02:00
Jukka Rissanen e21d7cc72d net: gptp: Refactor the gPTP header addition
Increase the net_buf length in proper places. So when gPTP
header is added, increase the buf->len properly, and then
when gPTP packet type is added, increase it again properly.
This way the net_buf length is updated in more logical way.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-12-11 13:50:54 +02:00
Jukka Rissanen 2b268f8d3d net: gptp: state2str() func is only available if debugging
The state2str() function should only be used if debugging
is enabled thus add some pre-processor checks there.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-12-07 16:43:59 +02:00
Jukka Rissanen 3af324033e net: gptp: Add more debugging when changing state
Print function and line number when changing state and when
debugging is enabled. Otherwise it is a bit difficult to follow
the program logic and locate the state change operation.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-12-07 16:43:59 +02:00
Jukka Rissanen 83f38b5f2d net: gptp: Remove log_strdup() when printing packet info
As the msg parameter for PRINT_INFO() is always a const string
that is not coming from stack, there is no need to use
log_strdup() here. This helps to avoid the
"<log_strdup alloc failed>" messages.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-12-07 16:43:59 +02:00
Jukka Rissanen ff0483c5af net: gptp: Get the gPTP header properly
If the link layer header is in the separate net_buf,
then skip that one.

Fixes #11827

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-12-07 16:43:59 +02:00
Tomasz Bursztyka 952e494bdd net/ethernet: Let L2 updating common rx/tx statistics
Common statistics should be updated in one centralized place and
ethernet_send is the right place for tx stats, as well as ethernet_recv
for rx stats.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-12-07 14:30:06 +02:00
Jukka Rissanen 86689030e8 net: Clarify logging in networking code
Remove network specific default and max log level setting
and start to use the zephyr logging values for those.

Remove LOG_MODULE_REGISTER() from net_core.h and place the
calls into .c files. This is done in order to avoid weird
compiler errors in some cases and to make the code look similar
as other subsystems.

Fixes #11343
Fixes #11659

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-12-07 12:00:04 +02:00
Jakub Rzeszutko b928b71756 shell: rename shell_help_print function
Function printing help has been renamed to shell_help.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2018-12-05 15:15:44 +01:00
Jakub Rzeszutko e0be6a10b3 shell: printing command's help by shell engine
Removed printing command help from help handler. It is now
realized by the shell engine. This change saves a lot of flash
but still allows to print help in command handler with function
shell_help_print.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2018-12-05 15:15:44 +01:00
Jakub Rzeszutko 5451ff2848 shell: remove "options" concept
Removing help "options" from shell API.

Currently SHELL_OPT macro is not used by users. What is more
commit: a89690d10f ignores possible options created in
command handler by the user. As a result they are not printed
in help message.

Second, currntly implemented "options" in command handlers options are
implemented without SHELL_OPT macro.

And last but not least this change will allow to implement
help handler in a way that user will not need to think about calling
functions printing help in a command handler.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2018-12-05 15:15:44 +01:00
Patrik Flykt b97db52de7 misra-c: Add 'U' to unsigned variable assignments in subsys/
Add 'U' to a value when assigning it to an unsigned variable.
MISRA-C rule 7.2

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2018-12-04 22:51:56 -05:00
Vijay Kumar B 5ff42e038d net: ethernet: Add helper functions to update error stats.
Add missed out helper functions to update the errors.tx and error.rx
in the stats structure.

Signed-off-by: Fadhel Habeeb <fadhel@zilogic.com>
Signed-off-by: Nirav Parmar <niravparmar@zilogic.com>
Signed-off-by: Vijay Kumar B <vijaykumar@zilogic.com>
2018-12-04 09:36:51 -06:00
Andrei Laperie 35a95a9b2f net: gptp: Replace calls to power function with pre-computed values
gPTP subsystem was calling pow(x,y) function with X and Y being
constants; these are replaced with the pre-computed values.

Signed-off-by: Andrei Laperie <andrei.laperie@intel.com>
2018-12-04 15:05:36 +02:00
Tomasz Bursztyka 5fb9a7bc4a net/gptp: Let Ethernet setting up the header
Instead of redoing what Ethernet L2 already does, let just create the
gptp message without any Ethenet header. Which one will be done as
sending phase by Ethernet L2 relevantly.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-11-30 11:12:13 -08:00
Tomasz Bursztyka 2b3046df70 net/bluetooth: Switch to L2 sending path
This is a much more trivial move than in Ethernet or ieee802154 L2s.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-11-30 11:12:13 -08:00
Tomasz Bursztyka ebb40ba338 net/ieee802154: Switch to L2 sending path
As for Ethernet, up to ieee802154 L2's send to actually sent the packet.
It's currently unoptimized as 6lo compression, 15.4 fragmentation and so
on will reallocate net_buf etc... but it's the first step towards
removing ll reserve space and more.

Applying changes to Openthread L2 as well.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-11-30 11:12:13 -08:00
Tomasz Bursztyka 7f2cb02720 net/dummy: Switch to L2 sending path
And adapt loopback and slip drivers relevantly

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-11-30 11:12:13 -08:00
Tomasz Bursztyka 9464ec3343 net/iface: Switch fully to a one-pass sending logic in net_if
Now instead of such path:

net_if_send_data -> L2's send -> net_if tx_queue -> net_if_tx -> driver
net_if's send

It will be:

net_if_send_data -> net_if tx_queue -> net_if_tx -> L2's send -> driver
net_if's send

Only Ethernet is adapted, but 15.4 and bt will follow up.
All Ethernet drivers are made compatible with that new scheme also.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-11-30 11:12:13 -08:00
Tomasz Bursztyka 114521c4bf net/arp: ARP packet can be queued right away
Now that sending is done at last time, in one pass, no need to go
through net_if_send_data here.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-11-30 11:12:13 -08:00
Tomasz Bursztyka 500eca745d net/ethernet: Move sending to a one-pass logic
Currently, first part is done in L2's send, then the next one in
ethernet device driver net_if send function. That last one was already
moved to a L2 based implementation. Let's just move forward and place
the whole logic of the L2's send in that second function.

This is the first step, ethernet centric only, to move towards a
one-pass sending logic in net stack. In future, net_if's send will
disappear.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-11-30 11:12:13 -08:00
Tomasz Bursztyka dcc6eddfef net/ethernet: Centralize where and when header is filled in
Current code generating Ethernet header is scattered all over the place,
sometimes in functions that are supposed to check something (and not
filling the header). Not to say about innefficiency.

Src ll address does not need to be set in L2 as net_if.c handles that
already.

Broadcast dst ll address is the same in ipv4 or ipv6, thus factorizing.
In each case, multicast is filled in only at the relevant place.

This is the first step towards changing L2 sending logic, when L2 send
API function will be the only point of sending. The redirection from
driver to L2 again (which finally uses the right device API function to
send) it a temporary hack.

This simplifies the code but will also enable using statically
allocated net_buf and ethernet header payload buffer afterwards.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-11-30 11:12:13 -08:00
Tomasz Bursztyka 94e89a11b7 net/ethernet: Make ethernet allocating its own frag for the header
This is currently unoptimized, as all frags are allocated with relevant
ll reserve for such header space. However, this is the first step
towards getting rid of that ll reserve concept everywhere.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-11-30 11:12:13 -08:00
Himanshu Jha dbcc5392fe net: openthread: remove unnecessary variable
Remove an unnecessary local variable to store the
return value, instead return directly thereby saving
few bits of memory.

Found using Coccinelle.

Signed-off-by: Himanshu Jha <himanshujha199640@gmail.com>
2018-11-28 11:54:01 -08:00
Ravi kumar Veeramally 3746652f85 net: arp: Drop ARP requests from localhost address
If ARP Request with sender IP address set to localhost then drop
the request.

Fixes #11489

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2018-11-28 10:13:41 +01:00
Ravi kumar Veeramally 6227b12fb4 net: arp: Fix ptype for non arp messages
If network stack found ARP entry for peer address, then it
tries to send pending IP packet. But it always keeps ptype
as ARP only. In this particular scenario it has to be IP
packet.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2018-11-28 10:13:41 +01:00
Ravi kumar Veeramally 0c547f9da9 net: arp: Discard ARP request on special scenario
Discard ARP request if Ethernet address is broadcast and
Source IP address is Multicast address.

REFERENCES:
RFC 826: page 4
RFC 1122: section 3.3.6 {Silently discard link-layer-only b'cast dg's}
RFC 1812: section 3.3.2, page 34

ARP related issues fixed.

Fixes #11329

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2018-11-28 10:13:41 +01:00
Andrei Emeltchenko 1cd95969e3 ieee802154: Remove dead code
Remove unused ieee802154_shell_init()

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-11-15 08:42:52 -05:00
Ravi kumar Veeramally 483378027a net: arp: Check invalid fields in ARP header
If ARP header contains invalid fields then drop the packet.

Fixes #11257
Fixes #11254
Fixes #11253
Fixes #11248

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2018-11-12 15:42:54 +02:00
Krzysztof Chruscinski fa95089b3d net: l2: Fix NET_L2_BT dependency in KConfig
Added NET_IPV6 dependency to NET_L2_BT.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2018-11-10 12:38:29 -05:00
Ravi kumar Veeramally 4b0aa92bba net: arp: Verify incoming packet HW and protocol type
Verify incoming ARP packet hardware and protocol type. Drop
unknown type of packets.

Fixes #11215
Fixes #11217

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2018-11-09 15:21:28 +02:00
Jukka Rissanen 42c180ed5b net: eth: Remove old IPv6 interface identifier address
If we change the ethernet MAC address, then we must also remove
the old IPv6 interface identifier (iid) address from the
interface. Otherwise there might not be enough space in the IPv6
address array for the new iid address and beside the old iid
address is not useful any more after the MAC address is changed.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-11-08 15:23:05 +02:00
Tomasz Bursztyka 3200914ed9 net/ethernet: Remove as many ifdef for CONFIG_NET_VLAN as possible
Most of vlan functions have dummy aliases when it's not enabled, so
let's use this.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-11-06 12:42:06 +02:00
Jukka Rissanen cf063fe85b net: Rename net_is_xxx...() functions to net_xxx_is...()
Unify the function naming for various network checking functions.

For example:
     net_is_ipv6_addr_loopback() -> net_ipv6_is_addr_loopback()
     net_is_my_ipv6_maddr() -> net_ipv6_is_my_maddr()
etc.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-11-02 14:52:33 -04:00
Kumar Gala cabdf5e9dd subsys: Remove board.h include
The subsys code doesn't need anything from board.h so lets remove the
include.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-11-01 13:15:18 +01:00
Jukka Rissanen 7d83543379 net: Properly handle pkt IPv4 broadcast destination address
If we receive an IPv4 that has broadcast destination address, then
properly handle it.
This means that for
  * ICMPv4, if CONFIG_NET_ICMPV4_ACCEPT_BROADCAST is set (this is the
    default value) and we receive echo-request then accept the packet.
    Drop other ICMPv4 packets.
  * TCP, drop the packet
  * UDP, accept the packet if the destination address is the broadcast
    address 255.255.255.255 or the subnet broadcast address.
    Drop the packet if the packets broadcast address is not in our
    configured subnet.

In sending side, make sure that we do not route broadcast address
IPv4 packets back to us. Also set Ethernet MAC destination address
properly if destination IPv4 address is broadcast one.

Fixes #10780

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-10-26 15:37:21 +03:00
Gil Pitney 621ec506e2 net: wifi: Update connect cmd to deal with new shell quoted args
Previously, the wifi shell needed to remove the quotes from the
SSID parameter, passed in by the underlying shell.

The new shell is now able to parse quoted strings as arguments,
so this adjustment can be removed.

Otherwise, it results in a failure to connect to an AP, as the first
character of the SSID name is stripped off.

Signed-off-by: Gil Pitney <gil.pitney@linaro.org>
2018-10-25 20:46:38 +03:00
Jukka Rissanen fb73aee36f net: openthread: Remove remaining SYS_LOG usage
Remove the last SYS_LOG reference from OpenThread code as SYS_LOG is
being deprecated.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-10-22 11:11:35 +03:00
Jukka Rissanen 8f76169190 net: wifi: Make sure shell is valid before trying to print to it
It is possible that connect callback is called when shell is not
yet set. Make sure to check this and fallback to use printk() if
shell_printf() cannot be used.

Fixes #10617

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-10-19 16:16:48 -04:00
Jukka Rissanen 1d72af0393 net: wifi: Fix connect command parameter checks in shell
The connect command parameters were not checked properly if
user decided to supply only mandatory parameters.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-10-19 16:16:48 -04:00
Jukka Rissanen dab9030ab9 net: wifi: Check offloading pointers before accessing them
If the device does not support wifi offloading, then return -ENOTSUP
so that wifi support can be enabled for testing purposes even if
the actual device does not have wifi support. This is happens for
example in qemu which does not support wifi offloading.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-10-19 16:16:48 -04:00