Logging v1 has been removed and log_strdup wrapper function is no
longer needed. Removing the function and its use in the tree.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Files including <zephyr/kernel.h> do not have to include
<zephyr/zephyr.h>, a shim to <zephyr/kernel.h>.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
In order to bring consistency in-tree, migrate all drivers to the new
prefix <zephyr/...>. Note that the conversion has been scripted, refer
to #45388 for more details.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Add a separate macro for registering offloaded sockets implementation,
along with information in the structure whether the implementation is
offloaded or not. This allows to differentiate between native and
offloaded socket implementations, which is critical for binding socket
API with an interface.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Instead of keeping a boolean informing whether a network interface is
offloaded at socket layer or not, keep a pointer to a function which
allows to create an offloaded socket. Native interfaces keep this as
NULL, while for offloaded interfaces it allows to connect an offloaded
socket implementation with an interface.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Check if requested socket family, type and protocol are all supported by
the driver, instead of blindly acknowledging every possible variant.
Reuse switch statements checking valid parameter values that were
already part of simplelink_socket() function, by creating 3 helper
functions for conversion of each parameter (family, type and protocol)
from Zephyr to Simplelink values.
Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
Use NET_SOCKETS_OFFLOAD_PRIORITY instead of
NET_SOCKETS_OFFLOAD_PRIORITY, so that by default offloaded sockets will
be used instead of native sockets.
Addiitonally this allows to select relative priority of offloaded TLS
versus native TLS when used together with NET_SOCKETS_TLS_PRIORITY.
Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
Adding these definitions help ease of porting POSIX applications.
They currently do nothing in the core network stack and will
return an error if used. However, they help port some POSIX
without changing these. In particular, this enables using the
Nim programming language's standard library with Zephyr.
- The values copy Linux amd64, similar to the other SO_OPTIONS
- Add SO_SNDBUF to fix simplelink wifi
- Use compat options in simplelink wifi
Signed-off-by: Jaremy J. Creechley <jaremy.creechley@panthalassa.com>
When creating a socket, all of the registered socket implementation are
processed in a sequence, allowing to find appropriate socket
implementation for specified family/type/protocol. So far however,
the order of processing was not clearly defined, leaving ambiguity if
multiple implmentations supported the same set of parameters.
Fix this, by registering socket priority along with implementation. This
makes the processing order of particular socket implementations
explicit, giving more flexibility to the user, for example when it's
neeed to prioritze one implementation over another if they support the
same set of parameters.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Instead of putting object files inside libzephyr.a,
simply build a separate static library as most other
driver types are doing this already.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Replace all existing deprecated API with the recommended alternative.
Be aware that this does not address architectural errors in the use
of the work API.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Several wifi drivers add some form of zephyr_include_directories(.)
which isn't needed since the headers in the specific driver dir get
included via #include "foo.h". So we can remove any uses of
zephyr_include_directories(.)
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Reimplement getaddrinfo to call SlNetUtil_getAddrInfo from the TI HAL
for a more robust implementation that supports both client and server
modes, and performs better error-checking.
Fixes#11890
Signed-off-by: Vincent Wan <vwan@ti.com>
Now that device_api attribute is unmodified at runtime, as well as all
the other attributes, it is possible to switch all device driver
instance to be constant.
A coccinelle rule is used for this:
@r_const_dev_1
disable optional_qualifier
@
@@
-struct device *
+const struct device *
@r_const_dev_2
disable optional_qualifier
@
@@
-struct device * const
+const struct device *
Fixes#27399
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
PR #27485 introduced new implementations for close() that do not build
correctly. This commit fixes the problem by re-implementing them.
Fixes#27587
Signed-off-by: Vincent Wan <vwan@ti.com>
Do not route close() calls via ioctl() as that is error prone
and quite pointless. Instead create a callback for close() in
fdtable and use it directly.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
When CONFIG_POSIX_API is set in lieu of CONFIG_NET_SOCKETS_POSIX_NAMES,
some macros such as POLLIN, POLLOUT and MSG_PEEK are undefined, and
the appropriate posix headers need to be included to access those.
Signed-off-by: Vincent Wan <vwan@ti.com>
IPv6 support was not fully implemented in the driver and was disabled.
This commit completes the implementation and enables it when
configured.
Signed-off-by: Vincent Wan <vwan@ti.com>
Fix typo in logged Kconfig option name that is missing in used
configuration. This one was mostly problematic for developers wanting to
find such option in source tree using grep - NET_SOCKET_OFFLOAD was not
found in Kconfig files.
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
This change removes references to raw POSIX types and functions,
allowing the drivers to build without NET_SOCKETS_POSIX_NAMES.
After this, the dependency between NET_SOCKETS_OFFLOAD and
NET_SOCKETS_POSIX_NAMES can be removed.
See issue #26033 for additional context
Signed-off-by: Adam Porter <porter.adam@gmail.com>
With the introduction of ZephyrConfig.cmake all parts of CMake code
should rely on the CMake ZEPHYR_BASE variable instead of the environment
setting.
This ensures that after the first CMake invocation, then all subsequent
invocation in same build folder will use same zephyr base.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
By changing the various *NET_DEVICE* macros. It is up to the device
drivers to either set a proper PM function or, if not supported or PM
disabled, to use device_pm_control_nop relevantly.
All existing macro calls are updated. Since no PM support was added so
far, device_pm_control_nop is used as the default everywhere.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Switch to `NET_SOCKET_REGISTER` mechanism over the offloaded API
registration.
Including the following fixes from the review:
* The fd returned by the socket accept call needs to be finalized,
similar to how it is done for socket creation.
* sl_RecvFrom() in TI SimpleLink Host driver does not support NULL
pointers for 'from' address and address length, and sl_SendTo() does
not ignore the destination address when in connection mode, so passing
NULL would cause a failure. These issues have been reported to TI
(CC3X20SDK-1970, CC3X20SDK-1971).
Let's use sl_Recv and sl_Send to implement recvfrom/sendto in the case
of NULL addresses.
* simplelink_poll() should not process negative file descriptors in the
fds array after sl_Selecti() returns. A negative fd value indicates
that the entry is invalid and should be ignored.
Signed-off-by: Vincent Wan <vincent.wan@linaro.org>
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Use this short header style in all Kconfig files:
# <description>
# <copyright>
# <license>
...
Also change all <description>s from
# Kconfig[.extension] - Foo-related options
to just
# Foo-related options
It's clear enough that it's about Kconfig.
The <description> cleanup was done with this command, along with some
manual cleanup (big letter at the start, etc.)
git ls-files '*Kconfig*' | \
xargs sed -i -E '1 s/#\s*Kconfig[\w.-]*\s*-\s*/# /'
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Clean up space errors and use a consistent style throughout the Kconfig
files. This makes reading the Kconfig files more distraction-free, helps
with grepping, and encourages the same style getting copied around
everywhere (meaning another pass hopefully won't be needed).
Go for the most common style:
- Indent properties with a single tab, including for choices.
Properties on choices work exactly the same syntactically as
properties on symbols, so not sure how the no-indentation thing
happened.
- Indent help texts with a tab followed by two spaces
- Put a space between 'config' and the symbol name, not a tab. This
also helps when grepping for definitions.
- Do '# A comment' instead of '#A comment'
I tweaked Kconfiglib a bit to find most of the stuff.
Some help texts were reflowed to 79 columns with 'gq' in Vim as well,
though not all, because I was afraid I'd accidentally mess up
formatting.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Remove unnecessary calls to net_if_ipv4_addr_add() and
net_if_ipv4_set_gw(), to prevent link errors when CONFIG_NET_NATIVE
is set to n.
Signed-off-by: Vincent Wan <vincent.wan@linaro.org>
Due to commit a211afb041, an error on
missing log_strdup() call is seen when running samples for CC32xx
devices that use the Wi-Fi driver. Adding log_strdup() calls to fix
this.
Fixes#18563
Signed-off-by: Vincent Wan <vincent.wan@linaro.org>
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>
Change the SimpleLink wifi driver to use static IP address instead of
DHCP when it is set by NET_CONFIG_MY_IPV4_ADDR. We also support setting
gateway and netmask via NET_CONFIG_MY_IPV4_GW and
NET_CONFIG_MY_IPV4_NETMASK.
This feature is tested out-of-tree against the echo sample after
modifying its prj.conf file to set the static IP address:
CONFIG_NET_CONFIG_MY_IPV4_ADDR="192.168.1.191"
and after commenting out these lines in its board-specific config
file for cc3220sf_launchxl:
so that the NET_CONFIG_SETTINGS are not overridden.
The wifi sample is also verified to run correctly after running the
echo sample.
Fixes#14588
Signed-off-by: Vincent Wan <vincent.wan@linaro.org>
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>
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>
Rename reserved function names in drivers/ subdirectory. Update
function macros concatenatenating function names with '##'. As
there is a conflict between the existing gpio_sch_manage_callback()
and _gpio_sch_manage_callback() names, leave the latter unmodified.
Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
This commit implements fcntl() in the SimpleLink Wifi driver to set and
get the non-blocking mode on a socket.
Fixes#11891.
Signed-off-by: Vincent Wan <vincent.wan@linaro.org>
mqtt_client_tls_connect() calls setsockopt() to set the TLS_PEER_VERIFY
option to require verfication. To enable mqtt, we need to return
success at a minimum when this option is set to 2.
Signed-off-by: Vincent Wan <vincent.wan@linaro.org>
The driver is not returning correct error codes when error occurs.
The error handling function is expecting negative input values, but
that is not true for BSD error codes. So I am taking an approach
where I use a function to convert SimpleLink error codes to BSD
error codes, and call slcb_setErrno() to set the errno independently.
Fixes#12745
Signed-off-by: Vincent Wan <vincent.wan@linaro.org>
These symbols appear within an 'if WIFI' (in drivers/wifi/Kconfig).
'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>
The SimpleLink driver has been defining these macros for its local use.
Given these have been defined in a recent commit in Zephyr
(9c86dbfd8e), we should now avoid
redefining them to prevent build errors.
Signed-off-by: Vincent Wan <vincent.wan@linaro.org>
In the SimpleLink wifi driver, the socket family value needs to be
converted to the SL_* equivalent to be understood by the SimpleLink
API, instead of being passed straight in.
While not strictly necessary, we are doing the same for socket type
and protocol values to future-proof ourselves in case similar changes
happen to the values defined for these in Zephyr header files.
Fixes#13203
Signed-off-by: Vincent Wan <vincent.wan@linaro.org>
Error code SL_ERROR_BSD_ESECUNKNOWNROOTCA is returned from sl_Connect()
when the root CA used is not part of the certificate catalog on the
network processor. We should warn the users about this and continue on,
given the connection is successful.
Signed-off-by: Vincent Wan <vincent.wan@linaro.org>
simplelink_socket() is not returning non-zero socket file descriptors
when it succeeds. This leads to socket() to always return socket fd 0,
even when the network processor returns a non-zero fd.
This commit fixes simplelink_socket() to return the correct socket fd
when it succeeds in getting one from the network processor.
Fixes#12650
Signed-off-by: Vincent Wan <vincent.wan@linaro.org>
The SimpleLink wifi driver enables the Fast Connect method of
WiFi provisioning, which allows the network coprocessor to
reconnect to a previously connected Access Point (AP) on
startup.
Previously, if Fast Connect failed to connect, any network
socket applications would inevitably fail, as there would have
been no wifi connection.
This patch adds a configurable timeout for the Fast Connect
feature, after which timeout, an error is logged informing
the user to manually reconnect to an AP.
Reconnection is typically accomplished by separately running the
wifi sample shell program.
Fixes: #11889
Signed-off-by: Gil Pitney <gil.pitney@linaro.org>