Zeroing-out all bytes from a connection structure when it's
unregistered ensures all state from a previous connection is gone and
can't be mistakenly reused.
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
If either a remote or a local address were supplied to the
net_conn_register() function, the IP stack would proceed to copy
sizeof(struct sockaddr) bytes from the respective remote_addr
or local_addr pointers, regardless of the actual size of the storage
these pointers point to.
Use the proper size depending on the socket address family.
Coverity-ID: 173630
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
If CONFIG_NET_DEBUG_APP was defined, but neither NET_APP_SERVER nor
NET_APP_CLIENT, build failed due to net_app_cb() haven't beeen
defined. So, define it to empty in this case.
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
POSIX requires struct sockaddr's field to be named "sa_family"
(not just "family"):
http://pubs.opengroup.org/onlinepubs/009696699/basedefs/sys/socket.h.html
This change allows to port POSIX apps easier (including writing
portable apps using BSD Sockets compatible API).
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
net_pkt_get_reserve_data ignores the timeout parameter when in isr,
using K_NO_WAIT instead, which can lead to invalid fragment.
Signed-off-by: Ricardo Salveti <ricardo.salveti@linaro.org>
This option enables full debugging output for memory allocations.
As that can produce lot of output and slow down the device under test,
it is disabled by default.
The previous CONFIG_NET_DEBUG_NET_PKT will collect information about
memory allocations but will not print any output. Use "net mem" or
"net allocs" commands in net-shell to see the memory allocation status.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Because the name of the memory pool can be quite long, print
it last so that the columns get aligned nicely.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
If we are not in ESTABLISHED state, then there is no need to
try to resend any pending data packets.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
If the expire send timer expires, then it sends the packet.
If that happens, then we must not try to send the same packet
again if we receive ACK etc. which can cause re-sends to happen.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
If the packet sending is slow then we must NOT increment the ref
count when re-sending it. This is unlikely but can happen if there
are lot of debug prints etc. extra activities that prevent the driver
to actually send the packet fast enough.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Make sure that the sent flag is only set after we have really
sent the packet and the driver has verified that.
If the net_pkt_set_sent() is called while still in tcp.c, then
depending on how fast the device is, it might happen that the
retry timer expires before the packet is actually sent. This was
seen in frdm-k64f with ethernet and various debug prints activated.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
If there is a backlog entry when TCP context is released, then
cancel the ACK timer if one exists.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Some older C libraries do not have errno for EPFNOSUPPORT.
Fixes issues with newlib in some versions of Xtensa XCC compiler.
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
The initial function prototype did not have 'inline' in it,
resulting in a compiler warning with XCC.
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
It's never a good idea to redefine functions as macros if intended
to be unused in some configuration
- "statement with no effect" warnings
- "unused argument" warnings
- No type checking done if the macros are used
These have been redefined as empty inline functions.
Fixes compiler warnings with XCC.
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
The second 'const' is misguided, indicating that the returns pointer
value itself cannot be changed, but since pointers are passed by value
anyway this is not useful and was generating warnings with XCC.
The leading 'const' indicates that the memory pointed to is constant,
which is all we needed.
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
Inline functions declared in header files need to be declared
static. Fixes a compiler warning with XCC compiler.
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This is needed in order to get information which function is
doing the ref. With inline function this was not possible.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Instead of printing [net/net_pkt], print [net/pkt] if debug log
is enabled for network packet allocator. The double net in earlier
print is redundant information.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Instead of always have CONFIG_NET_IPV6_MAX_NEIGHBORS parents,
use CONFIG_NET_RPL_MAX_PARENTS when creating the parent table.
Default value for max parents is the max neighbors so no
functionality changes are introduced here.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Instead of always having CONFIG_NET_IPV6_MAX_NEIGHBORS number
of items in neighbor pool, store the neighbor count in the pool
and use that value when traversing the neighbor table.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Allow user to define what kind of network the RPL should serve.
Currently options will be either ANY or IEEE802154. If there
is only one network interface in the system, then ANY will take
the default network interface and use that. If there are multiple
network interfaces, then one should not use ANY as the default
network interface might not be the expected one.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Print network interface where the DIO, DIS or DAO was sent. This is
useful if we have multiple network interfaces in the system.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
When printing network interface specific data, print also
the type of the network interface (ethernet, bluetooth etc).
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
If the device has multiple network interface, then we must not
blindly use the default one but get the IEEE 802.15.4 network
interface when setting radio parameters in the shell.
Jira: ZEP-2432
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Print route information by groupping them for each network
interface like this:
IPv6 routes for interface 0xa8007140
====================================
IPv6 prefix : 2001:db8::212:4b00:0:3/128
neighbor : 0xa80065e0
link addr : 00:12:4B:00:00:00:00:03
IPv6 prefix : 2001:db8::212:4b00:0:1/128
neighbor : 0xa8006660
link addr : 00:12:4B:00:00:00:00:01
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Add "net rpl" command to net-shell which will return both static
RPL configuration from Kconfig, and dynamic run time configuration
of the nodes and parents.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Create net_rpl_foreach_parent() function that will traverse
through all the parents and return their information via callback.
This is needed by net-shell in later commit.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
If debug level was low but debugging was activated, then some
of the debug variables were left unused.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The net_rpl_repair_root() and net_rpl_set_root_with_version()
functions were static which prevented global repair when using
an instance id. Making those functions global allows RPL network
repairing from shell for example.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The commit b14586c3ca ("net: rpl: RPL route entry was fetched
too late") dropped the DAO packet too early which prevents the
RPL root node functionality. Rework the earlier commit so that
Coverity issues are fixed but the RPL DAO message is also properly
handled.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The API name space for Bluetooth is bt_* and BT_* so it makes sense to
align the Kconfig name space with this. The additional benefit is that
this also makes the names shorter. It is also in line with what Linux
uses for Bluetooth Kconfig entries.
Some Bluetooth-related Networking Kconfig defines are renamed as well
in order to be consistent, such as NET_L2_BLUETOOTH.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Unlikely to happen but make sure parent neighbor exists when
probing it.
Coverity-CID: 173635
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
If there is no parent found with a specific dag, then we have
to check this in order not to access NULL pointer.
Coverity-CID: 173637
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
If the parent is not found when adding DAG, then just return.
We must check the parent pointer as it can be NULL.
Coverity-CID: 173638
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
No need to complex overflow checks that are error prone.
Coverity complained that the original diff check was always
false.
Coverity-CID: 173639
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
There was dead code when handling IPv6 Hop-by-hop option.
The extra option value check can be removed as it is useless.
Coverity-CID: 173642
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Coverity complains about reversed src and dst fields when sending
DAO ack back to originator. This is false positive.
Coverity-CID: 173650
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>