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>
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>
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 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>
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>
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>
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 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>
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>
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>
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>
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>
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>
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>
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>
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>