Newly added security types are missing from the help. Also, now that we
have two variants of PSK, use the prefix to disambiguate.
Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
While printing SSID in wifi status command, If the
length is maximum(32 character). It leads to buffer
overflow. It required one character for null
terminator ‘\0’. Changing the Format Specifiers to
print proper SSID.
Signed-off-by: Kapil Bhatt <kapil.bhatt@nordicsemi.no>
This fix addresses wrong announce message length warning message.
TLV is a variable length (4+8N) based on the 802.1AS-2011 (table 10-8). In
Zephyr TLV is fixed to 12 bytes. TLV type and length are already taken
into account in the announcement message length.
Signed-off-by: Mario Paja <mario.paja@zal.aero>
The Zephyr's core ethernet code had to be adjusted to support setting T1S
PLCA parameters from user Zephyr programs.
Such approach allows more flexibility, as T1S network configuration;
especially PLCA node numbers, can be assigned not only via device tree
at compile time. For example user can read them from EEPROM and then
configure the network accordingly.
For now - the union in struct ethernet_t1s_param only consists of plca
structure. This can change in the future, when other T1S OA parameters -
like Receive/Transmit Cut-Through Enable (bits RXCTE/TXCTE in OA_CONFIG0
register) are made adjustable from user program.
Signed-off-by: Lukasz Majewski <lukma@denx.de>
Regular OpenThread upmerge to commit `75694d2`.
Move CONFIG_OPENTHREAD_PLATFORM_KEY_REFERENCES_ENABLE
from header file to Kconfig.
Signed-off-by: Maciej Baczmanski <maciej.baczmanski@nordicsemi.no>
Do not enable subsystem/driver shell modules by default and stop abusing
CONFIG_SHELL_MINIMAL, which is internal to the shell subsystem, to decide
when to enable a driver shell.
The list of shell modules has grown considerably through the
years. Enabling CONFIG_SHELL for doing e.g. an interactive debug session
leads to a large number of shell modules also being enabled unless
explicitly disabled, which again leads to non-negligible increases in
RAM/ROM usage.
This commit attempts to establish a policy of subsystem/driver shell
modules being disabled by default, requiring the user/application to
explicitly enable only those needed.
Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
A recent iface lock removal in ed17320c3d
exposed issues with concurrent access on TX to drivers that are not
re-entrant.
Reverting that commit does not really solve the problem, as it would
still exist if multiple Traffic Class queues are in use.
Therefore, introduce a separate mutex for TX data path, protecting the
L2/driver from concurrent transfers from several threads.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The enum is mainly to print output of band, so, the default value is 0
which means 2.4GHz, which is not correct when using it to configure like
in connect.
Fix the default value to unknown i.e., no user preference. This way we
can use same enum for both set and get.
Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
Move the syscall_handler.h header, used internally only to a dedicated
internal folder that should not be used outside of Zephyr.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
The warning which became error looks like this
error: type qualifiers ignored on function return type
[-Werror=ignored-qualifiers]
219 | const char * const wifi_ps_txt(enum wifi_ps ps_name);
It is pointless to add a const qualifier to a return value.
So remove the const pointer to avoid this warning.
Fixes#64197
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
The stack size was previously hardcoded in the source code, making it
difficult to change when enabling options that require a larger stack.
Signed-off-by: Ambroise Vincent <ambroise.vincent@arm.com>
According to IEEE Std 802.1AS-2011 11.3.3, gPTP messages are not
VLAN-tagged.
Remove the use of VLAN headers for gPTP messages on the TX path.
The RX path is handled by the drivers. The network drivers in Zephyr
might need to be updated as well in order to accept receiving
non-VLAN-tagged gPTP messages when the CONFIG_NET_VLAN option is
selected.
Continue sending gPTP packets with VLAN tags when CONFIG_NET_GPTP_VLAN
is enabled. Specify that this option is for testing purposes.
Signed-off-by: Ambroise Vincent <ambroise.vincent@arm.com>
The previous implementation was setting priority 3 (Critical
applications) for Sync, Pdelay and Pdelay_Resp messages; and priority 6
(Internetwork control) for the other PTP messages. This might have been
done under the incorrect understanding that "Critical applications" was
the highest priority.
This resulted in the Pdelay_Resp_Follow_Up getting sent before the
Pdelay_Resp message when enough TC_TX queues were being used
(NET_TC_TX_COUNT >= 2), which is an inversion compared to the intended
order.
Invert the priority of the outgoing PTP packets so that the PTP event
messages are sent with higher priority, as was originally intended.
Signed-off-by: Ambroise Vincent <ambroise.vincent@arm.com>
rand32.h does not make much sense, since the random subsystem
provides more APIs than just getting a random 32 bits value.
Rename it to random.h and get consistently with other
subsystems.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
The mode command operation has to be set to WIFI_MGMT_GET when the
option -g is provided. It was mistakenly set to true. Correcting the
same
This PR fixes#63424 and sets the proper value for the get command
Signed-off-by: Vivekananda Uppunda <vivekananda.uppunda@nordicsemi.no>
This commit adds a check to prevent attempting to reestablish
the PPP session if the carrier is down. Without this check,
the PPP FSM attempts and fails to establish a PPP session
twice before giving up. The behavior is not breaking anything,
but it is not desired.
Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
As we already log fragmented packets there's no need to log them again
unless they have been fully assembled and the result is to be logged.
We also want to log the final packet in all cases (after mangling LL
address) for the non-fragmented case.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
It is the general rule in Zephyr's network stack that methods that
return NET_OK are expected to have "consumed" the packet, i.e. it should
not be referenced any more.
This change applies this rule to the methods in ieee802154_mgmt.* for
improved consistency with the remainder of the network stack.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The experimental status of the PPP L2 is long overdue so
it can be removed as the component is working fine.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Re-add the `WIFI_MGMT_FORCED_PASSIVE_SCAN` option removed in #62751.
Now that `struct wifi_scan_params` is a reasonable size, we can enforce
the passive scan request even when no parameter struct is supplied by
the user.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Instead of providing a comma seperated list of SSIDs, provide the SSIDs
individually. This substantially simplifies the implementation.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Hides types used in the IEEE 802.15.4 L2 sub-API and L2-internal APIs
that are of no public interest and improves documentation of the
remainder.
The changes are mostly minor as the API documentation had already been
improved and clarified in previous changes. Also includes non-visible
documentation to the subsystem-internal Frame API by adding references
to the specification.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The CONFIG_NET_L2_WIFI_SHELL isn't always enabled.
But these functions might still be used, so need to
move functions into mgmt.
Signed-off-by: Kapil Bhatt <kapil.bhatt@nordicsemi.no>
Replaces the previous approach to define bands via hardware capabilities
by the standard conforming concept of channel pages.
In the short term this allows us to correctly calculate the PHY specific
symbol rate and several parameters that directly depend from the symbol
rate and were previously not being correctly calculated for some of the
drivers whose channel pages could not be represented previously:
* We now support sub-nanosecond precision symbol rates for UWB. Rounding
errors are being minimized by switching from a divide-then-multiply
approach to a multiply-then-divide approach.
* UWB HRP: symbol rate depends on channel page specific preamble symbol
rate which again requires the pulse repetition value to be known
* Several MAC timings are being corrected based on the now correctly
calculated symbol rates, namely aTurnaroundTime, aUnitBackoffPeriod,
aBaseSuperframeDuration.
In the long term, this change unlocks such highly promising functional
areas as UWB ranging and SUN-PHY channel hopping in the SubG area (plus
of course any other PHY specific feature).
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
We must send the packet without queueing it. The pkt has already
been queued for sending, once by net_if and second time in the ARP
queue. We must not queue it twice in net_if so that the statistics
of the pkt are not counted twice and the packet filter callbacks
are only called once.
Fixes#62483
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Turn the nested arrays of `scan_params->chan` into a single array.
This adds the requirement to specify the band for each channel, but
eliminates the large amount of dead memory for unused bands. Overall,
this saves 50% of the RAM space for this variable.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Make the maximum number of channels that can be manually scanned
configurable by the application. The previous value of 233 was vastly
overallocating memory as the largest band only contains 60 allocated
channels.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
The header file contains mixture of functions and static arrays.
Replacing static arrays to functions.
Initialize functions in C file.
Signed-off-by: Kapil Bhatt <kapil.bhatt@nordicsemi.no>
Remove the wifi_mgmt interface overriding default values with values
from kconfig. The defaults were only applied when a `params` struct was
provided by the application.
This is the case when the application is explicitly setting the options
it wants, why is the mgmt API changing these. When `params` is NULL and
thus modem defaults are requested, these defaults aren't applied. This
is the opposite behaviour from what seems reasonable.
In addition, these options are:
* Undocumented
* Using non-trivial string parsing functions (strtok)
* Adding complexity to the API implementation by forcing support for
ROM versions of command line arguments.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
All WiFi channel numbers fit within a 8 bit number, as the maximum
allocated channel is 233. This halves the memory requirement.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
This patch amends the existing L2CAP accept callbacks to use the new
accept signature that includes a pointer to the L2CAP server structure.
Signed-off-by: Donatien Garnier <donatien.garnier@blecon.net>
This change brings in support for setting various Wi-Fi modes and
enables a specific Wi-Fi interface to be also placed into a sniffer
operation via monitor mode and promiscuous mode. A raw TX- packet
Injection mode is also introduced
Signed-off-by: Vivekananda Uppunda <vivekananda.uppunda@nordicsemi.no>
wifi_utils_parse_scan_ssids could cause a crash if a constant string is
passed to it. Fix this by duplicating the input string parameter before
parsing it with strtok_r.
Also limit the range of the CONFIG_WIFI_SCAN_SSID_FILT_MAX parameter
from 1 to 4 to avoid stack overflow due to users specifying a large
value for this parameter.
Signed-off-by: Sachin D Kulkarni <sachin.kulkarni@nordicsemi.no>
wifi_utils_parse_scan_bands could cause a crash if a constant string is
passed to it. Fix this by duplicating the input string parameter before
parsing it with strtok_r.
Signed-off-by: Sachin D Kulkarni <sachin.kulkarni@nordicsemi.no>
In the IEEE 802.15.4 area certain settings must be set before
net_if_up() may be called (e.g. the channel).
Also net_if_up() may not be called if
CONFIG_IEEE802154_NET_IF_NO_AUTO_START=y.
This fixes the set-up order and handling of
CONFIG_IEEE802154_NET_IF_NO_AUTO_START.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The twt and ps helper functions were not namespaced (were missing
wifi_ prefix).
Also change wifi_get_twt_... to more logical wifi_twt_get...
like the other twt prefixed functions and wifi_get_ps... to
wifi_ps_get... like the other ps prefixed functions.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Changed Add to Enable in help text to convey the intended use of the
Kconfig NET_L2_WIFI_MGMT.
Signed-off-by: Sachin D Kulkarni <sachin.kulkarni@nordicsemi.no>
Add a scan command option to print the help text for the scan command.
This is to facilitate ease of using the command (since now there are
many different options added to the scan command).
Signed-off-by: Sachin D Kulkarni <sachin.kulkarni@nordicsemi.no>
Add scan extension to allow limiting the scanning to specific channels.
Only 20 MHz channel specifications are allowed presently.
Signed-off-by: Sachin D Kulkarni <sachin.kulkarni@nordicsemi.no>
Add scan extension to allow limiting the scan results to a user defined
maximum number. This parameter is intended to return results with the
best RSSI. It cannot be counted upon to limit the scan times since the
Wi-Fi chips might have to scan all the channels to find APs with the
best RSSI values across all channels.
Signed-off-by: Sachin D Kulkarni <sachin.kulkarni@nordicsemi.no>
Add scan extension to control scanning time spent on channels where
passive scanning is used.
Signed-off-by: Sachin D Kulkarni <sachin.kulkarni@nordicsemi.no>
Added scan extension to support scanning individual Wi-Fi bands or
combinations thereof.
Signed-off-by: Sachin D Kulkarni <sachin.kulkarni@nordicsemi.no>
Modify the way the scan type option is passed to the wifi scan command.
This makes it flexible to add more scan options.
Signed-off-by: Sachin D Kulkarni <sachin.kulkarni@nordicsemi.no>
This fixes 3 issues that came within PR #59124 for ppp uart usage.
Earlier start/stop of ppp was done at enable() but that
was removed in PR #59124. Now putting enable/disable() back and
putting start/stop there.
Additionally, there was a double ppp carrier ON when NET_EVENT_IF_DOWN.
For that net_if_carrier_on/off is set in uart ppp.c driver.
Also, maybe worth to be mentioned that after PR #59124 there is no
ppp carrier off when lcp is disconnected, for workaround that change,
application should use ppp dead/running events.
Signed-off-by: Jani Hirsimäki <jani.hirsimaki@nordicsemi.no>
The PPP TX thread handles the transmission of packets at PPP layer.
Make it's priority configurable, so it's priority can be configured higher
then higher protocol layers.
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
When parsing user input for "wifi connect" and "wifi ap enable"
commands, the SSID and PSK lengths were not verified. It's better to
detect invalid connect/AP enable parameters early, so that help text can
be printed, instead of letting wifi_mgmt command to fail.
For WIFI_SECURITY_TYPE_SAE, follow the Linux convention of limiting the
size to 128 bytes.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The `attr_get` method is added to the ieee802154_radio to allow
reading of driver specific attributes of given device.
The enum `ieee802154_attr` provides common extension pattern
allowing to extend the attribute set.
Accessor function `ieee802154_radio_attr_get` is provided.
Signed-off-by: Andrzej Kuroś <andrzej.kuros@nordicsemi.no>
Associate command handler did not validate the provided address length.
In result, if provided address string was longer than the expected
extended address size, strncpy() would not NULL terminate the buffer,
which could lead to unexpected behavior in parse_extended_address(), as
it expects NULL terminated string.
Fix this by validating the length of the provided address string before
parsing.
Additionally, make parse_extended_address() return the parsing result,
so that it can be detected when provided extended address has incorrect
format.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Linuxptp report UTC offset is 9472 seconds, is a byte order issue,
The right value is 37. Also fixed offset_scaled_log_var byte order.
Signed-off-by: Chen Caidy <chen@caidy.cc>
According to IEEE802.1AS Table 11-6 and 10.6.2.2.9,
802.1AS using peer-to-peer delay mechanism, two-step clock,
Grand master clock should keep this correction_field as zero.
Signed-off-by: Chen Caidy <chen@caidy.cc>
According to IEEE802.1AS 11.4.4.2.1, we need fill
preciseOriginTimestamp as syncEventEgressTimestamp.
In this follow_up message, prec_orig_ts need to filled
from net_pkt_timestamp(sync) for best accuracy. state machine
is software trigger with insufficient precision.
After this change, a grand master endpoint sync accuracy
increase from 3.5ms to 580ns with mimxrt1050_evk board.
Signed-off-by: Chen Caidy <chen@caidy.cc>
Use the macro to print to handle for cases where shell context is NULL,
this is possible because in this net management event handler shell
context is not passed.
Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
Check if a network interface is managed by a network manager before
falling back to offload API.
Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
This introduces support for Wi-Fi network managers in Zephyr. The
motivation is for the Wi-Fi management layer to work with both
Network managers and offloaded Wi-Fi drivers. The device driver
decides which one to use.
network manager : Apps -> Wi-Fi Mgmt -> Network Manager -> Wi-Fi
interface
offloaded : Apps -> Wi-Fi Mgmt -> Wi-Fi offloaded interface
Support for multiple network managers has been added, each device can
choose its own network manager and there can be mix and match:
wlan0 - Offloaded
wlan1 - Network manager 1
wlan2 - Network manager 2
Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
Decouple interface and Wi-Fi APIs, Wi-Fi APIs are common independent of
Wi-Fi offload or implemented natively (This is preparation for
introducing Native Wi-Fi).
Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
Removes redundant ACK state from `struct ieee802154_context` and
simplifies the ACK procedure.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
This change introduces test coverage for association request and
response. Based on this coverage, several closely related issues were
found in the association process which cannot be split into separate
changes without breaking the build.
Most notably did the associate and disassociate net_mgmt commands send
already encoded IEEE 802.15.4 MPDUs to L3 rather than L2. L3 treated
them as payload and made L2 wrap them with another LL header/footer
which produced invalid packets.
The tests also enforce better aligment of the association process with
the IEEE 802.15.4-2020 standard:
* Association requests now ask for ACK as required by the standard. The
fake driver was enhanced to produce ACK packages when requested.
* macPanId and macCoordinator* MAC PIB attributes are set in the right
order for improved filtering of association responses.
* The coordinator may decide not to assign a short address to the end
device even when associated. This is now supported.
* The coordinator may or may not use a short address. Coordinators
choosing not to support short addresses are now supported.
* Updating the association will now remove any previously added short
address from the hardware filter.
* The short address may no longer be changed by the user while
associated to a PAN. Only the coordinator is allowed to allocate short
addresses.
* Validation of outgoing and incoming association request/response
packets is improved.
All changes are documented by pointers into the spec.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
Fixes an off-by-one bug in the parsing routine of the coordinator
address when associating via shell command.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
Input validation of some of the IEEE 802.15.4 net_mgmt commands was
incomplete and/or inconsistent. This change introduces a consistent
approach to input validation that is easier to follow.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
Calculates macResponseWaitTime and applies it to the association
process.
As the timing calculation re-uses symbol period calculations and other
PHY timing constants previously introduced, these are now shared as
utility functions.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The IEEE 802.15.4 stack defines radio API helpers that provide
simplified and encapsulated access to radio API features.
These helpers were missing the `_radio_` infix. This infix is introduced
to clearly distinguish between MAC and PHY concerns. While PHY features
may be shared between L2 implementations (including the functions
concerned here), this is not true for MAC features.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The IEEE 802.15.4-2020 standard introduces an association type field to
support fast association, see sections 6.4.3 and 7.5.2. We do not yet
implement fast association but we introduce the flag to make this
obvious.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
Minor simplification in the definition of IEEE 802.15.4 Kconfig packet
fragmentation configuration.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
parse_number() helper function accepts long * pointer or the output,
however in several places, an address of a variable of incompatible
type was passed to the function (for example an address of a bool
variable was cast to (long *) and provided to the function). This
could cause memory overwrites or other unexpected behaviour.
Fix this, by defining a helper variable of type long, and use it with
the parse_number() function. Only after successful parsing, the value is
then assigned to the proper destination.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This change replaces one letter variable names with considerable
variable spans by much more readable alternatives that ease code
maintenance and help human reviewers to catch semantic errors.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The f_ctx variable renamed in this change has a considerable variable
span. This makes the code hard to read as the variable name is neither
defined in the IEEE 802.15.4 standard nor can it be deduced from the
variable name.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The 'ar' abbreviation has a well defined meaning in IEEE 802.15.4 which
is NOT the meaning of the local "ar" variable being renamed in this
change (see the comparison to the actual MHR ar field in this change
set).
To avoid confusion, a non-abbreviated variable name is introduced
instead.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The 'af' abbreviation is nowhere standardized in IEEE 802.15.4 and makes
the source code unnecessarily hard to read. It is replaced by a readable
long name.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
Several distinct naming conventions existed within the IEEE 802.15.4
stack wrt header length. This change converges to a single naming
convention, the one that is less ambiguous and already most used.
The change also makes the distinction between L2 (link layer/LL) header
length and 6LoWPAN fragmentation header length to avoid confusion.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
This change is in preparation for the newer frame version's more
complex compression algorithm that may compress both, the source
and the destination PAN independently.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
This change renames buf to pkt_buf in one very specific instance to
distinguish the packet buffer from the frame buffer which is kept in the
same local scope. In all other instances the meaning of "buf" should be
obvious from context, not so here, though
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
Default scan mode is Active. User can force the scan mode to passive
through Kconfig option or using 'passive' option from shell.
Using either of this option will override regulatory settings and
forces all scan channels to be passive only.
Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
Most AP's are not sending proper HE triggers or stopping triggers after
sometime, so, change the default to non-triggered based TWT.
Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
Switch the driver to the soft CSMA/CA algorithm as an intermediate
compromise for improved standard compliance (namely expontential
backoff) until true hardware support can be implemented by chaining
radio commands.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The PAN ID in IEEE 802.15.4 frames is little endian while in the
IEEE 802.15.4 context it is kept in CPU byte order.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The ACK procedure had the following issues:
- MAC commands were not acknowledged.
- When the package is a broadcast package the package must not be
acknowledged.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
Acknowledgment is mandatory if legitimately requested by the package's
"ACK requested" flag. The L2 layer will have to ensure that compliant
ACK packages will always be sent out automatically as required by the
standard.
For IEEE 802.15.4 compliance, the NET_L2_IEEE802154_ACK_REPLY option is
therefore being deprecated.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The existing calls to ieee802154_radio_send() and soft MAC ACK handling
were inconsistent and/or not properly integrated with more recent
radio driver capabilities as CSMA/CA and ACK in hardware.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The method ieee802154_radio_handle_ack() does not belong to the
PHY/radio layer but to the L2 layer. It is a callback called from the
radio layer into the L2 layer and to be implemented by all L2 stacks.
This is the same pattern as is used for ieee802154_init(). The
'_radio_' infix in this function is therefore confusing and
conceptually wrong.
This change fixes the naming inconsistency and extensively documents
its rationale.
It is assumed that the change can be made without prior deprecation of the
existing method as in the rare cases where users have implemented custom
radio drivers these will break in obvious ways and can easily be fixed.
Nevertheless such a rename would not be justified on its own if it were
not for an important conceptual reason:
The renamed function represents a generic "inversion-of-control" pattern
which will become important in the TSCH context: It allows for clean
separation of concerns between the PHY/radio driver layer and the
MAC/L2 layer even in situations where the radio driver needs to be
involved for performance or deterministic timing reasons. This
"inversion-of-control" pattern can be applied to negotiate timing
sensitive reception and transmission windows, it let's the L2 layer
deterministically timestamp information elements just-in-time with
internal radio timer counter values, etc.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The IEEE 802.15.4 standard clearly separates clear channel assessment
from retransmission. This separation of concern was not represented in
the current channel access vs. retransmission implementation which
resulted in considerable duplication of code and logic.
This change removes the duplication of logic and encapsulates the
resulting functions in a private API that may only be used from within
Zephyr's native L2 layer.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The CSMA/CA algorithm had multiple issues:
- Timing of backoff periods depends on the PHY's symbol rate and other
PHY-specific settings. We introduce a preliminary solution that works
with current drivers. A fully standard-compliant long-term solution
has already been conceptualized but requires further pre-conditions,
see #50336 (issuecomment-1251122582).
- We enforce the condition defined in the standard that macMinBe must be
less than or equal macMaxBe.
- According to the standard a CSMA/CA failure should lead to immediate
abortion of the transmission attempt, no matter how many
retransmissions have been configured.
- The number of retransmissions was off by one. It is now used as
defined in the standard algorithm.
- Retransmissions are only allowed when acknowledgement is requested in
the packet.
- prepare_for_ack() has side effects and must be called before each
retransmission.
We also replace variables by constants where possible.
The function was renamed as it represents unslotted CSMA/CA and does not
support other CSMA/CA modes. These may be introduced in the future.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The ALOHA algorithm had two minor implementation errors:
- The number of retransmissions was off by one.
- Retransmissions are only allowed when acknowledgement is requested
otherwise it is to be assumed that the transmission was successful.
- prepare_for_ack() has side effects and must be called before each
retransmission.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The allowable ranges of several CSMA/CA-related settings were not
conforming to the standard, see IEEE 802.15.4-2020, section
8.4.3.1, table 8-94 (MAC PIB attributes). This change fixes the ranges.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
This adds a few line use zephyr_syscall_header() to include
headers containing syscall function prototypes.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
If a user tries to enable TWT too early in the connection, then we might
enter TWT sleep even before DHCP is completed, this can result in packet
loss as when we wakeup we cannot receive traffic and completing DHCP
itself can take multiple intervals. Though static ip address can be
assigned too. Reject TWT till Wi-Fi interface has
a valid IP address.
Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
This commit replaces the workarounds spread around the
drivers and subsystems with the updated PPP L2
interface.
Signed-off-by: Bjarki Arge Andreasen <baa@trackunit.com>
Currently, the L2 PPP subsystem is not using the network
interface subsystem appropriately. Here are the issues:
1. net_if_up hidden away internally in net L2 PPP
2. net_if_down not used at all...
3. net_if_carrier_on / off is not used, a workaround is
used instead, which results in duplicated code
4. L2 PPP does not listen for network events, instead
it needs the workaround callbacks from drivers.
5. The carrier_on workaround is delegated to a complex
and broken sys work queue item.
This commit fixes all above issues. net_if_up/down and
net_if_carrier_on/off now work as expected. workaround
for carrier_on/off has been removed.
Signed-off-by: Bjarki Arge Andreasen <baa@trackunit.com>
Fix for not getting expected event information at application.
net_mgmt_event_notify_with_info() expects the address
not the value as pointer.
Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
A bug was introduced in one of my earlier commits: The shell does no
longer print the full extended address. Fixes the issue.
Fixes: #59125
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
As since commit bff6a5c, params.dst.ext_addr is no longer assigned with
the ctx->coord_ext_addr pointer, but a endianness swap is included, it
should be assigned with a proper buffer before the memcpy.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
For IEEE 802.15.4 compliance, the NET_L2_IEEE802154_ACK_REPLY option must
automatically be active if the radio driver does not AUTOACK and inactive
otherwise. No user interaction is required.
Future changes will deprecate this option and replace it by a standard
compliant automatic mechanism.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The IEEE 802.15.4 standard does not specify a "Sub-GHz" option.
Therefore this option will be deprecated in the foreseeable future.
Rationale: Selecting PHYs and frequency bands is abstracted by the
concept of channel pages (see IEEE 802.15.4-2020, 10.1.3).
Radio drivers may expose additional configuration options that
specify the low level frequency band, operating mode and other
PHY-specific parameters. Such parameters should be exposed on a driver
instance level, e.g. via devicetree or as runtime options of the driver.
PHY-specific attributes derived from driver settings (e.g. available
channels) can then be announced to L2 w/o the user having to be aware of
any implementation details of the specific PHY.
Future changes will introduce the necessary infrastructure to define
channel pages and other PHY-specific configuration options to
replace this option. New drivers should therefore not rely on this
option.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
Variable declarations are moved to the beginning of the block in
which they are visible to ensure consistency with the remainder
of the code base.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The encryption-only security level has been removed from the
spec, see IEEE 802.15.4-2020, 9.4.2.2 Security Level field.
The standard provides the following explanation (ibid):
"This security level is deprecated and shall not be used in
implementation compliant with this standard. Devices that
receive frames with security level 4 shall discard them, as
described in 9.2.4. The counter mode encryption and cipher
block chaining message authentication code (CCM) used allows
trivial changes to the underlaying encrypted data unless
data authenticity is provided, thus using data confidentiality
only is not useful. In the case of TSCH mode, security level 4
allows higher security level frames to be downgraded to
security level 4 frames."
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
See IEEE 802.15.4-2020, 7.2.2.11 Source Addressing Mode field and
7.2.2.9 Destination Addressing Mode field, table 7-3: The
previously deprecated "Simple addressing mode" was removed
from the spec.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
Currently the insertion of an authentication tag requires a memcpy() call
and breaks encapsulation.
This change removes the need for memcpy() and improves the encapsulation
by calculating and reserving the required headspace early on while
keeping insertion where it belongs in the outgoing security procedure.
This is also a preparation for improved standard compliance of the
outgoing security procedure which is scheduled for a later commit.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The naming of variables and arguments containing the authentication
tag length was inconsistent:
* Naming inconsistency between header "length" vs. authtag "size"
in the same API calls
* "Tag" rather than "Auth[orization ]Tag" in external API calls
which is too generic from a compliance and readability viewpoint.
This is in preparation to zero-copy authentication support.
Almost all call sites will be subject to required structural changes
later on so no relevant git blame noise/history loss will be introduced
by this naming change in the long run.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
Over time, some non-standard concepts and extensions were introduced
into the stack (in KConfig, in drivers, in the internal API and into the
implementation) which makes introduction of additional standard-
compliant extensions like TSCH (and others) unnecessarily difficult.
To introduce extensions like TSCH it is required for the IEEE 802.15.4
stack to become more structurally aligned with the standard again which
will be the focus of some of the upcoming preparatory changes.
One way to check and prove standard compliance is to reference the
standard from within the source code. This change therefore introduces
inline references to the IEEE 802.15.4-2020 standard wherever possible.
Deviations from the standard are documented with TODO or deprecation
labels to be addressed in future changes.
In the future, new code introduced to the IEEE 802.15.4 stack should
be documented and reviewed for standard-compliance to avoid further
divergence. Most importantly:
* MAC/PHY configuration (via net mgmt, radio API, devicetree or
KConfig) should always be directly linked to well-defined MAC/PHY
PIB attributes if visible to the MAC API or the end user.
* Net management/shell/radio API commands should have a documented
reference to the corresponding MLME action from the standard.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The current implicit MAC payload length algorithm (based on
an otherwise irrelevant footer pointer) produces invalid
(non-standard) values for beacon and command frames.
This change produces standard-conforming MAC payload length
values and simplifies access to payload length.
It would have been possible to fix the current footer pointer
based approach but there are arguments in favor of the new
approach:
- The footer pointer is used nowhere in the current code
base and makes length calculations rather non-obvious.
- The new approach does not use more memory and is easier
to understand and use.
- This change is a first step to support of IEEE 802.15.4
information element (IE) support. At a later stage the
distinction between MAC payload length and frame payload
length will be introduced and become relevant to
distinguish between header and payload IEs. At that point
the current implicit length calculation algorithm will
break down anyways.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The current IEEE 802.15.4 stack would not accept beacons
unless hardware filtering was active.
This change fixes the bug.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The shell command calling the IEEE 802.15.4 scanning procedure
did not properly release its net management event callback.
This change fixes the memory leak.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
Active and passive scanning requires the channel and PAN to
be set temporarily.
This change ensures that the temporary configuration will
be reverted even when the scan is aborted due to an error.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
Beacon and command frames are consumed by the IEEE 802.15.4
stack internally and should therefore be released before
returning control to the generic net stack.
This change fixes the resource leak.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
Until now iterable sections APIs have been part of the toolchain
(common) headers. They are not strictly related to a toolchain, they
just rely on linker providing support for sections. Most files relied on
indirect includes to access the API, now, it is included as needed.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This change splits the IEEE 802.15.4 test into two separate
test profiles, one with and one without sockets enabled to ensure
that both configurations work correctly.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The current IEEE 802.15.4 stack assumes that drivers will
not provide more than one fragment in incoming packages.
This change exposes and enforces the pre-existing assumption
made by the implementation.
So far this is not a limiting restriction as MPDUs with more
than 127 bytes are not supported yet. It will probably have to
be changed as soon as larger payloads (as allowed by PHYs
introduced more recently into the spec) might want to allocate
smaller fragments.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
When changing IEEE 802.15.4 security settings or setting security
to 'none' then the previous session must be cleaned up to avoid
resource leaks.
This change introduces proper clean-up of the security session.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
This is needed for applications that rely on WPA supplicant being
in disconnected state before issue subsequent commands (e.g., issue scan
immediately after disconnect fails, until disconnect is completed).
Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
Add a trailing _ to the section iterable name. This is useful, for
example, to implement numeric sorting like this:
SORT(.z_device_LEVEL_?_)
SORT(.z_device_LEVEL_??_)
Without the trailing _ it would not be possible to use the ?? wildcard
without triggering into trigraphs issues, because linker-defs.h header
is included in C files as well.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Provide an extra struct net_if * iface parameter to
net_if_ipv*_maddr_join/leave functions, so that the corresponding
interface context, the mcast address belong to, can be locked for the
operation.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
LLDP start timer is executed when iface is up
at startup, then once more when iface up event
is received.
When iface is up before net_lldp_init call, then multiple
entries are added to the lldp_ifaces related to the
same iface.
That leads to continuous loop execution within
lldp_tx_timeout.
This commit checks if lldp tx_timer_start is set and
doesn't append new entry into the slist.
The tx_timer_start is set at startup and reset on
down event.
Signed-off-by: Georgij Cernysiov <geo.cgv@gmail.com>
'ps_wakeup_mode' is used to set the wake up interval
to either 'dtim or 'listen_interval'. By default the
sta wakes up every dtim interval.
With 'ps_wakeup_mode' set to 'listen_interval' sta
will wake up for every listen interval period configured.
Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
listen interval is the time periods the STAs may be in idle
without listening beacons.
By default STA wakes up for every DTIM period.
If listen interval based power save is used
STA uses configured listen interval period(default 10
beacon intervals) to wake up.
Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
As we are using a generic validation function for limits, due to data
type mismatch the check for TWT interval overflow and fails.
Fix the data type and accordingly the maximum value in the help.
Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
TFM is not the only provider for PSA API, which means
the PSA config shouldn't depend only on it.
Signed-off-by: Piotr Jasiński <piotr.jasinski@nordicsemi.no>
OpenThread networks do not use ND or MLD as they have their own set of
protocols to cover this functionality. So far, the use of OpenThread
with Zephyr relied on disabling those protocols support statically with
Kconfig, which prevented OT interfaces from being used along with other
IPv6 interfaces.
With the new network interface flags, it's now possible to disable ND
and MLD on individual interfaces, therefore disable them for OT
specifically.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>