Commit graph

346 commits

Author SHA1 Message Date
Kamil Kasperczyk 06bf2ca707 net: openthread: Added config options for NCP vendor hooks.
New config option that can be used to enable vendor hooks
for NCP component.

Signed-off-by: Kamil Kasperczyk <kamil.kasperczyk@nordicsemi.no>
2020-07-23 10:44:19 +02:00
Marek Porwisz 740e0ccc9e net: openthread: Allow use of custom mbedtls
To allow hardware crypto acceleration custom mbedtls library needs to be
prepared. However current implementation forces the default library to
be used.
This patch allows not using the default library and passing custom
mbedtls target to use with openthread.

Signed-off-by: Marek Porwisz <marek.porwisz@nordicsemi.no>
2020-07-22 15:32:30 -05:00
Jukka Rissanen 4746a13324 net: Remove special alignment
The Z_STRUCT_SECTION_ITERABLE() provides an alignment so remove
the 32 byte alignment for net_if and ppp_protocol_handler structs.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-07-20 08:32:46 -07:00
Jukka Rissanen 62580748e5 net: Use section foreach macros
Use system provided Z_STRUCT_SECTION_FOREACH() and
Z_STRUCT_SECTION_ITERABLE() macros instead of manually coding
everything for network sections.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-07-20 08:32:46 -07:00
Marek Porwisz a6c6e7793f net: openthread: Use different kconfig switch for shim and src
Different switch was used for build to allow including all shim body
in zephyr without the need for building openthread from this repo. This
allows developer to include custom OpenThread sources as part of the
application.
This change is needed as Thread is a subject of certification and
sources provided by zephyr may not necesairly pass certification or be
precertified. User is allowed to use certified OpenThread version
this way.

Signed-off-by: Marek Porwisz <marek.porwisz@nordicsemi.no>
2020-07-20 14:42:30 +03:00
Martí Bolívar dfbabb1201 openthread: avoid warning when CONFIG_NET_MGMT_EVENT=n
When this happens, ip6_addr_cb and ipv6_addr_event_handler() both look
unused, since they are passed to macros which discard them.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-07-20 14:28:30 +03:00
Marcin Niestroj 071e8400ad net: l2: ppp: fsm: use packet work object instead of shared one
Single work object for whole fsm was not being able to handle more than
single packet at a time. Because of that we have overwritten already
scheduled packets, resulting in fsm timeout and net_pkt leak.

Use net_pkt work object instead, so we can safely schedule more than a
single packet.

This commit also drops workaround for qemu_x86 unit testing.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-07-20 13:19:28 +03:00
Marcin Niestroj af0bb8835b net: l2: ppp: ipv6cp: remove wrong Configure-Rej handling
Currently there is a single function that handles both Configure-Ack and
Configure-Rej messages. This is obviously wrong for Configure-Rej,
because implementation applies options received in the message.

Remove Configure-Rej callback, so those frames are simply ignored for
the time no valid handling code exists.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-07-09 12:47:12 -04:00
Marcin Niestroj 7996f527d5 net: l2: ppp: ipcp: clear options after protocol goes down
Clear negotiated options in protocol down handler. That way all
addresses are properly requested (by sending 0.0.0.0 in Configure-Req)
in the subsequent option negotiation phases.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-07-09 13:45:18 +02:00
Flavio Ceolin c4f7faea10 random: Include header where it is used
Unit tests were failing to build because random header was included by
kernel_includes.h. The problem is that rand32.h includes a generated
file that is either not generated or not included when building unit
tests. Also, it is better to limit the scope of this file to where it is
used.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2020-07-08 21:05:36 -04:00
Marcin Niestroj 03c774e58c net: l2: ppp: drop ppp_context's is_network_up
There is already a variable 'network_protos_up', which stores number of
network protocols being up. Additionally each network protocol has its
own state represented by is_ip{,v6}cp_up. Use the latter in FSM up() and
down() callbacks.

This fixes a case when both IPCP and IPv6CP protocols are going
down. When using ctx->is_network_up only one of them (the first) was
deinitialized correctly, second stayed always up (at least partially,
e.g. not calling ppp_network_down()).

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-07-06 17:55:44 -04:00
Marcin Niestroj 16542e1642 net: l2: ppp: fix packet length for sending Term-Req and Term-Ack
Each PPP packet sent on wire needs to have at least 4 bytes length. Set
that length for outgoing Term-Req and Term-Ack packets. Also update
length validation to check for at least 4 bytes instead of at least 1
byte.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-07-06 16:50:54 +02:00
Lukasz Maciejonczyk ddb9f290e1 net: l2: openthread: Implement enable API function
It fixes #issues/26220.

openthread_start function is called when L2 enable(iface, true) is
called. openthread_stop is called when L2 enable(iface, false) is
called. openthread_stop makes the device to leave the OpenThread
network.

Signed-off-by: Lukasz Maciejonczyk <lukasz.maciejonczyk@nordicsemi.no>
2020-07-02 08:43:45 -04:00
Markus Becker 350bab6d8c net: openthread: handle non mesh-local IPv6 addresses as DHCPv6
OpenThread BR can assign addresses via DHCPv6 or when acting as an
NCP, addresses can be added manually. Currently, those addresses are
handled in the same way as auto-configured addresses.

This patch maps the newly introduced mAddressOrigin of otNetifAddress to
Zephyr's net_addr_type.

This way an application can register a handler and differentiate by type
of assignment:

```
static void handler(struct net_mgmt_event_callback *cb,
                    u32_t mgmt_event,
                    struct net_if *iface)
{
  if (iface->config.ip.ipv6->unicast[i].addr_type == NET_ADDR_DHCP) {
  }
}
```

Signed-off-by: Markus Becker <markus.becker@tridonic.com>
2020-07-02 08:36:27 -04:00
Marek Porwisz 83f7f81d8d net: openthread: New build options for OpenThread
Some options were available in the options.cmake but were not reflected
in Kconfig.
Added possibility to enable additional configuration options for OT.
Some of the options were left commented out as those options are not
yet supported e.g. require Thread 1.2 or require shim changes.
As openthread has gazillion configuration options that are passed as
define value, created generic option for passing any number of those
values separated with space.

Signed-off-by: Marek Porwisz <marek.porwisz@nordicsemi.no>
2020-06-30 07:48:08 -04:00
Marek Porwisz 81e0a05285 net: openthread: Simplify openthread enabling
Currently user needs to specify quite much additional options to enable
OpenThread support. He also needs to set ip address count,
heap size, etc depending on features enabled.
Nade changes to automatically select/set some of the options on
enabling OpenThread

Signed-off-by: Marek Porwisz <marek.porwisz@nordicsemi.no>
2020-06-30 07:48:08 -04:00
Marcin Niestroj 79a8d0f616 net: l2: ppp: reject unsupported options
Both ASYNC_CTRL_CHAR_MAP and MAGIC_NUMBER are not supported right
now. Send Configure-Reject for them instead of Configure-Nak, as we
don't even propose new values in reply (which should be part of
Configure-Nak).

Send also Configure-Reject for MRU option, as we don't respect it
either.

Drop both count_rej and count_nack, as we can rely solely on nack_idx to
send Configure-Reject or not.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-06-29 08:26:53 -04:00
Jukka Rissanen c7058eba73 net: gptp: The sync receive timer had wrong timeout
The sync receive timeout was using invalid value (nanoseconds
instead of milliseconds). This caused unnecessary state switches
from SLAVE to MASTER and back.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-06-23 18:16:15 +03:00
Jukka Rissanen 0223169f14 net: gptp: Add more debug to PA info state machine
Add debug prints when the port announce information state
machine state changes. This is useful in debugging.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-06-23 18:16:15 +03:00
Jukka Rissanen 2675a11766 net: gptp: Return proper port number for given interface
The port number is stored starting from 0 in Ethernet context.
But in gPTP, it is an index which starts from 1. So increase
the value by 1 for a value returned from Ethernet context.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-06-23 18:16:15 +03:00
Lukasz Maciejonczyk 74b1c617af net: openthread: Add possibility to register ot state changed app cb
It may be useful for the application to register its own callback for
ot state changed event which does not override the current one.

Signed-off-by: Lukasz Maciejonczyk <lukasz.maciejonczyk@nordicsemi.no>
2020-06-22 11:34:18 +03:00
Lukasz Maciejonczyk 4ad78d9249 net: openthread: Make function openthread_start be public
It may be useful to start openthread manually but with default
network settings. For instance when the application wants to register
ot state changed callback which should be done before openthread
starts.

Signed-off-by: Lukasz Maciejonczyk <lukasz.maciejonczyk@nordicsemi.no>
2020-06-22 11:34:18 +03:00
Marek Porwisz 1130f8484e net: lib: openthread: Handle OT transmission in Thread task
OpenThread API is not thread-safe.
Moved creation of otMessage to the Thread task and created api
for passing it properly.
This way it should be less possible for an issue to occure eg.
during message buffer allocation.

Signed-off-by: Marek Porwisz <marek.porwisz@nordicsemi.no>
2020-06-18 19:37:06 +02:00
Jukka Rissanen f7d584a0ce net: ethernet: Check that device has PTP clock before access
Avoid null pointer access by checking that Ethernet device has
PTP clock before trying to get the actual PTP clock device.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-06-15 16:40:36 +03:00
Robert Lubos 7f9b85e8c3 net: openthread: Fix u16_t usage
PR #25936 introduced u16_t type usage and was merged after the type
transition in Zephyr.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-06-10 19:24:20 -04:00
Lukasz Maciejonczyk ff8b864f48 net: openthread: Make OT thread priority class be configurable
It add an option to configure openthread thread priority class
by the application if there is a such need.

Signed-off-by: Lukasz Maciejonczyk <lukasz.maciejonczyk@nordicsemi.no>
2020-06-09 11:00:17 +03:00
Lukasz Maciejonczyk 3fa2fa9a50 net: openthread: Fix the order of adding net pkt in ot_receive_handler
Net pkt is added into the ot net list after queued net pkt into
the net_rx which bases on it. It affects in losting net pkt when for
instance ot thread is preemptive.

Signed-off-by: Lukasz Maciejonczyk <lukasz.maciejonczyk@nordicsemi.no>
2020-06-09 10:57:00 +03:00
Lukasz Majewski 0e32a84bcc net: eth: Add check if passed iface pointer is NULL
The eth_stats_update_errors_rx() implicitly assumes that passed pointer
to struct net_if is not NULL.

This is not true for MCUX's eth_rx() (in eth_mcux.c), where we can
execute eth_stats_update_errors_rx() after net_recv_data() returning
-EINVAL because of passed NULL iface pointer.

This change fixes this problem with adding extra check on iface not
being NULL before it is dereferenced.

Signed-off-by: Lukasz Majewski <lukma@denx.de>
2020-06-09 10:54:29 +03:00
Eduardo Montoya fc1d0635df net: l2: openthread: Add config option to enable OpenThread ref. device
This option enables specific features used by Thread Certification
reference devices.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2020-06-08 21:41:40 +03:00
Marcin Niestroj 747f20720a net: wifi: shell: store shell in context before scan
Right now shell pointer is not assigned before doing a scan, so scan
results are printed using printk(). Save shell instance in context, so
results are printed using shell_fprintf(), thus better aligned in the
console output.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-06-08 21:37:33 +03:00
Markus Becker 2115b575a4 net: ieee802154: Allow to disable auto-start of 802.15.4 interfaces
Some radio drivers need configuration before start-up. Up to now only
the RF2XX drivers allowed this, but other radio drivers need this as
well. In particular for setting EUI64 addresses.

Signed-off-by: Markus Becker <markus.becker@tridonic.com>
2020-06-08 19:55:19 +03:00
Kumar Gala a1b77fd589 zephyr: replace zephyr integer types with C99 types
git grep -l 'u\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/u\(8\|16\|32\|64\)_t/uint\1_t/g"
	git grep -l 's\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/s\(8\|16\|32\|64\)_t/int\1_t/g"

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-06-08 08:23:57 -05:00
Robert Lubos bc5b05f223 modules: mbedtls: Add Kconfig entry for MBEDTLS_MD and MBEDTLS_CIPHER
Due to new checks in mbedTLS config sanitizer, TLS option can no longer
be left enabled, when TLS is not used. OpenThread needs MBEDTLS_MD_C
and MBEDTLS_CIPHER_C even without TLS being used, so we need an option
to enable them manually.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-06-02 15:24:36 +02:00
Eduardo Montoya dd1a71f0c4 net: config: align Kconfig debug levels with OpenThread ones
OpenThread moved from 4 to 5 debug levels and it was not possible
to configure all of them with Kconfig.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2020-05-25 20:41:42 +02:00
Jukka Rissanen d940a813b1 net: lldp: Write LLDPDU data to pkt correctly
Make sure that net_pkt_write() sets the LLDPDU data correctly
in net_pkt.

Fixes #25184

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-05-11 17:11:23 +02:00
Jukka Rissanen ad9f32a4e9 net: lldp: Sent LLDP packet was missing proper net_pkt type
The LLDP packet was created but its type was not set to LLDP
and was sent as ARP message.

Fixes #25084

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-05-08 11:43:00 +03:00
Robert Lubos 139da50e3c net: openthread: Allow to disable automatic network attachment
Add OpenThread configuration option, which allows to configure and start
OpenThread stack operation manually. This mode should be used in NCP
devices, as well as is needed for certification purposes, where
OpenTread stack have to be configured by the test framework and not
initialize and join the network on its own.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-05-08 10:44:27 +03:00
Robert Lubos 3fa97df43c net: openthread: Update mbedTLS configuration
After the update, CMAC is also required when DTLS is not used.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-05-07 23:27:49 -05:00
Tomasz Bursztyka 38970c07ab net/ieee802154: Validate length on received frames
Frame format was validated, but its length should be also validated
relevantly against the format.

Fixes #24970

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-05-07 13:20:46 +03:00
Alexander Wachter 464f135ce6 canbus: Convert canbus driver and subsys to new timeout API
Convert all canbus related API/samples/tests/subsys
to the new timeout API with k_timeout_t.

Signed-off-by: Alexander Wachter <alexander@wachter.cloud>
2020-05-06 10:19:13 +02:00
Lukasz Maciejonczyk ae68354428 net: l2: openthread: Add function for getting openthread default instance
The new function simplifies use of OpenThread API in Zephyr.

Signed-off-by: Lukasz Maciejonczyk <Lukasz.Maciejonczyk@nordicsemi.no>
2020-05-05 16:30:20 +03:00
Jukka Rissanen 54864d063d net: gptp: Convert to use k_timeout_t
One k_timer_start() was missing k_timeout_t conversion.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-05-01 10:50:03 +03:00
Lukasz Maciejonczyk 3ba7a3c82a net: l2: openthread: Add config option to enable OpenThread CoAP api
There was no way to use Openthread CoAP api in zephyr application so
far. These changes enable the feature. Now you can fully use CoAP
communication in an application working in Thread network.

Signed-off-by: Lukasz Maciejonczyk <Lukasz.Maciejonczyk@nordicsemi.no>
2020-04-17 09:21:41 +03:00
Marek Porwisz ccd74755d5 net: openthread: Pass received frame to the proper thread.
Received frames shall be handled in the OpenThread thread, not in
the receiver thread.
Passed received frame to the function that will handle it in a proper
thread instead of calling otPlatRadioReceiveDone directly.

Signed-off-by: Marek Porwisz <marek.porwisz@nordicsemi.no>
2020-04-09 16:19:20 +03:00
Jukka Rissanen 00a8406d7f net: ieee802154: Fix the scan duration data type
Converting to k_timeout_t

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-04-09 16:07:03 +03:00
Jukka Rissanen fb33da6f81 net: arp: Refactor because of timeout overhaul
Convert minimal parts to support k_timeout_t values.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-04-09 16:07:03 +03:00
Jukka Rissanen ab5aba4f8f net: ppp: Refactor because of timeout overhaul
Use k_timeout_t internally, no change to user API.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-04-09 16:07:03 +03:00
Jukka Rissanen 40f269f033 net: lldp: Refactor because of timeout overhaul
Use k_timeout_t internally, no change to user API.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-04-09 16:07:03 +03:00
Jukka Rissanen f1d886ad29 net: gptp: Refactor because of timeout overhaul
Use k_timeout_t internally, no change to user API.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-04-09 16:07:03 +03:00
Marcin Niestroj 29cb9271ed net: wifi: fix log message printing ssid and psk
The following logs show up when trying to connect:

  uart:~$ wifi connect xxxxxx xxxxxxxxxx
  Connection requested
  <dbg> net_wifi_mgmt.wifi_connect: (0x20000500): xxxxxx 6 255 1 \
                xxxxxxxxxx 10
  <err> log: argument 6 in source net_wifi_mgmt log message \
                "%s: (%p): %s %u %u %u %s %u" missinglog_strdup().
  <err> log: argument 2 in source net_wifi_mgmt log message \
                "%s: (%p): %s %u %u %u %s %u" missinglog_strdup().
  Connected
  uart:~$

Fix that by using LOG_HEXDUMP_DBG() to print SSID and PSK.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-04-07 15:00:55 +03:00