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>
Make sure that we define and declare the _net_app_register() and
_net_app_unregister() functions properly if net_app logging level
is set to debug.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Adding spaces around "=" when definining Kconfig template so
that is more consistent with overall style of these template
variables.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
As the debugging print calls are async, all the strings that might
be overwritten must use log_strdup() which will create a copy
of the printable string.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The code was trying to print peer IP address string but that
pointer could contain garbage. There is actually no need to print
anything in this case, the error code return is enough.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The return of memset is never checked. This patch explicitly ignore
the return to avoid MISRA-C violations.
The only directory excluded directory was ext/* since it contains
only imported code.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
The result of both printk and vprintk are not used in any place.
MISRA-C says that the return of every non void function must be
checked.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
The peers were not informed about DTLS connection close because
we removed DTLS context. The fix is to notify peers before we
remove the DTLS connection.
Fixes#8605
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
If a disconnection callback was registered, it is not called
as the check done in net_app is reversed. The disconnection callback
is not called if there are any inactive contexts.
The check should be on any active context.
Signed-off-by: Philémon Jaermann <p.jaermann@gmail.com>
Bool symbols implicitly default to 'n'.
A 'default n' can make sense e.g. in a Kconfig.defconfig file, if you
want to override a 'default y' on the base definition of the symbol. It
isn't used like that on any of these symbols though.
Remove some 'default ""' properties on string symbols too.
Also make definitions more consistent by converting some
config FOO
<type>
prompt "foo"
definitions to a shorter form:
config FOO
<type> "foo"
This shorthand works for int/hex/string symbols too, not just for bool
symbols.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Due to the fact that cmake doesn't allow to build empty "library"
(which would be the case when neither CONFIG_NET_APP_SERVER nor
CONFIG_NET_APP_CLIENT is defined).
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
net_app library consisted of 2 disjoint parts: a) library to
setup/configure networking on the application startup; b) library
to setup client and server connections.
As the configuration library is universally useful and is a generic
Zephyr networking component, split it out to a seperate top-level
networking library under net/lib/config/.
Fixes: #7658
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
The code was using MSEC() macro in few places instead of more
proper K_MSEC(). The MSEC() takes seconds as a parameter and
K_MSEC() takes milliseconds.
Fixes#7657
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Currently, the client_addr parameter is only used to check the
sa_family at various points during the init process. Both the
IP address and the port are ignored. Let's set the local client's
port based on the port value of the passed in client_addr if one
is supplied.
Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
The port parameter passed to _net_app_set_local_addr() is converted
from host byte-order to network byte-order. Here we are passing
a port value which has already been translated to network byte-order.
Let's translate the local port to host byte-order when passing it
to _net_app_set_local_addr() to fix this issue.
Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
Instead of selecting the first IPv4 address from the network
interface, use destination address to select the proper local IPv4
address.
Fixes#7500
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Fix a build warning when compiling a net_app sample with
CONFIG_NET_APP_DTLS enabled by changing the print formatter from %zu
to %d. It references the var hdr_len which is defined as an int:
In file included from include/net/net_core.h:78:0,
from subsys/net/lib/app/net_app.c:27:
subsys/net/lib/app/net_app.c: In function ‘_net_app_ssl_mainloop’:
include/logging/sys_log.h:96:20: warning: format ‘%zu’ expects
...
subsys/net/lib/app/net_app.c:2132:6: note: in expansion of macro
‘NET_ERR’
NET_ERR("could not skip %zu bytes",
^~~~~~~
Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
If we have multiple network interface (like in VLAN), then we need
to select the proper local interface based on destination address.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Without that, if ipv4 is configured via DHCPv4, server will not be
accessible. It looks like it won't properly bind addresses.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
- Removed OT_PLAT_RADIO_DEVICE_NAME
- Changed OpenThread binding to use NET_AP_IEEE802154_DEV_NAME
- Modified Kconfig chain to ensure NET_AP_IEEE802154_DEV_NAME
is enabled for both native 802.15.4 and OpenThread configurations
- Changed default setting of NET_L2_IEEE802154 in defconfig for mkw41z4.
- Fixed OpenThread api support code to use the state of mIsCcaEnabled
in the transmit frame to conditionally invoke radio_api->cc() on
transmits.
Signed-off-by: David Leach <david.leach@nxp.com>
We returned too early when creating listeners which meant that
IPv4 listener was not created if IPv6 one was created successfully.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Instead of always allocating both IPv6 and IPv4 address information
to every network interface, allow more fine grained address
configuration. So it is possible to have IPv6 or IPv4 only network
interfaces.
This commit introduces two new config options:
CONFIG_NET_IF_MAX_IPV4_COUNT and CONFIG_NET_IF_MAX_IPV6_COUNT
which tell how many IP address information structs are allocated
statically. At runtime when network interface is setup, it is then
possible to attach this IP address info struct to a specific
network interface. This can save considerable amount of memory
as the IP address information struct can be quite large (depends
on how many IP addresses user configures in the system).
Note that the value of CONFIG_NET_IF_MAX_IPV4_COUNT and
CONFIG_NET_IF_MAX_IPV6_COUNT should reflect the estimated number of
network interfaces in the system. So if if CONFIG_NET_IF_MAX_IPV6_COUNT
is set to 1 and there are two network interfaces that need IPv6
addresses, then the system will not be able to setup IPv6 addresses to
the second network interface in this case. This scenario might be
just fine if the second network interface is IPv4 only. The net_if.c
will print a warning during startup if mismatch about the counts and
the actual number of network interface is detected.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Move IP address settings from net_if to separate structs.
This is needed for VLAN support.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
We need to check the debug level to be INFO or higher, otherwise
the some of the variables in net app init.c will give unused
warning. Also the sys_log.h needs to be included _after_ we have
set the logging level, this is done by net_core.h so we should
not include the syslog header file here.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Assertions should only be used to check invariants. Things that may
change value in runtime are better left to proper checks.
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
mbedTLS log level is obviously a mbedTLS config setting. It makes
sense to have it defined in mbedTLS Kconfig, and different parts
of Zephyr to reuse as needed (e.g. net-app vs upcoming TLS wrapper
for sockets).
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
When IPv6 and IPv4 both are enabled and net_app acting as a client,
configuring local context has one glitch.
After selection of IPv6 context as a default context function
should return immediately, otherwise it continue to select IPv4
context as default context.
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
In case of TCP and node acting as a APP_SERVER it can have multiple
concurrent connections. Calling close callback when there are still
active connections exists, causing an issue.
e.g. When a node acting as a HTTP server and can support multiple
TCP connections. Let's say one of the connection is in closing
state and the rest are still in active state. net_app_ctx is
calling close (http_closed) callback of registered upper layers.
HTTP assumes all the connections are closed and unref all the
connection related stuff.
Call the close callback only when there are no active connections.
Patch has also moved TCP stuff under one #ifdef.
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
In net_app_init_client(), the remote port is set after an initial
set of checks based on the remote_addr's assigned family.
However, if the peer_addr_str is a host name which needs to be
resolved via DNS, the family won't be set yet, and the port is
left as 0.
To fix this behavior let's move the port assignment after the
DNS lookup section to be sure that the remote sa_family is set.
Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
Added a new API to get net pkt based on dst address. Destination
address will be used to find correct net_context.
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
When net_app_ctx has multiple net_contexts, selecting net_context
based on dst address has some glitches.
E.g. One net_app_ctx and two net_contexts (net_ctx1, net_ctx2).
Both net_contexts are mapped to net_app_ctx.
When a caller looking for net_ctx (e.g. net_ctx2) with
matching dst address. Loop goes through net_ctx1 and dst
doesn't match. But another if condition checks does this
net_context mapped to net_app_ctx, yes it matches.
So return net_ctx1, which is wrong.
So first go through all elements in array of net_contexts for
matching dst address, if it fails to find then go for matching
net_app_ctx.
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
The meaning of this address type is the same as NET_ADDR_MANUAL,
but with a provision that DHCP can override such an address.
It's intended for the usecase when there's a default static
configuration for when DHCP is not available, but DHCP should
override it.
Before going to add another address type, there was an attempt
to repurpose TENTATIVE address state, but it doesn't work as
expected, as indeed, all existing address types/states already
have clearly semantics, and it makes sense to just another
address type to avoid confusion and unexpected behavior.
Fixes: #5696
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
The idea is that static config is used unless/until DHCP values
arrive. This allows to have the same network configuration values
for both a case of direct board - workstation connection (where
DHCP is usually not available), and a case where both a board and
workstation connect to a router (which serves DHCP).
The changes in this commit however take care of netmask and gateway
settings, but not about IP address itself. This is addressed in the
next patch.
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
This reverts commit 3599d793c2.
Setting a packet's data_len here doesn't fix the fact that we shouldn't
be using it at all on RX packets. Fix belongs in net_pkt_append().
Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
When testing TLS connections on production web server, it was noticed
that the TLS mainloop was getting "hung" after a connection was made
via HTTPS and then closed by the server. The TLS mainloop was never
being notified that the connection was closed and was stuck waiting
for more data.
The next time that connection was used, TLS would fail to start.
Let's force trigger a closure of the TLS process when the net-app layer
is notified of the connection closure. This allows the connection to
be successfully reused later.
Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
This fixes a bug when calling net_pkt_append[_all] which uses
pkt->data_len as part of the maximum packet length calculation
when the net_context is set.
Without this change the maximum packet length is calculated as 0
(the value of pkt->data_len) and an ENOMEM error is returned.
Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
Do not reset net_context information in net_app_close. In case of
TCP behind the curtains connection might wait for some timers to
expire and send some messages (e.g. ACK). If we set source port to
'0', unexpected behaviour might happen with peer connection.
Only reset net_app context related information on net_app_close.
Let net_context_put will take care of proper connection closure.
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
Of these, only struct net_ipv6_nbr_data::send_ns is a descriptive
change:
send_ns is used for timing Neighbor Solicitations in general, not
just for DAD.
The rest are typo/grammar fixes.
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
L2 specific data and IEEE 802154 net mgmt interface are not related.
Plus, application may use the net mgmt part, not the L2 one. So let's
split the content in relevant headers.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
- Renaming NET_L2_RAW_CHANNEL to NET_RAW_MODE
- Create a generic IEEE 802.15.4 raw mode for drivers
- Modify the IEEE 802.15.4 drivers so it passes the packet unmodified,
up to code using that mode to apply the necessary changes on the
received net_pkt according to their needs
- Modify wpanusb/wpan_serial relevantly
Fixes#5004
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Introducing CMake is an important step in a larger effort to make
Zephyr easy to use for application developers working on different
platforms with different development environment needs.
Simplified, this change retains Kconfig as-is, and replaces all
Makefiles with CMakeLists.txt. The DSL-like Make language that KBuild
offers is replaced by a set of CMake extentions. These extentions have
either provided simple one-to-one translations of KBuild features or
introduced new concepts that replace KBuild concepts.
This is a breaking change for existing test infrastructure and build
scripts that are maintained out-of-tree. But for FW itself, no porting
should be necessary.
For users that just want to continue their work with minimal
disruption the following should suffice:
Install CMake 3.8.2+
Port any out-of-tree Makefiles to CMake.
Learn the absolute minimum about the new command line interface:
$ cd samples/hello_world
$ mkdir build && cd build
$ cmake -DBOARD=nrf52_pca10040 ..
$ cd build
$ make
PR: zephyrproject-rtos#4692
docs: http://docs.zephyrproject.org/getting_started/getting_started.html
Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>