Printing values as <integer_part>.<fractional_part> gives undesired
results for negative numbers, so print the values converted to floating
point to avoid this.
Change-Id: I871b8461f2d643a2adce67df064e9f5e6d506319
Signed-off-by: Bogdan Davidoaia <bogdan.davidoaia@linaro.org>
Main changes:
- TCP fixes
- ZoAP server sample application
- Fixes to issues reported by Coverity
----------------------------------------------------------------
Anas Nashif (1):
net: in newlib, ESHUTDOWN is considered an extension
Andrei Emeltchenko (1):
wpan_serial: Fix possible NULL pointer dereference
Andy Ross (2):
net: tcp: Pass correct user_data pointers
net: tcp: Destroy net_tcp struct at the same time as the context
Flavio Santes (3):
samples/net: Remove redundant configuration variable
drivers/ethernet: Update default GPIO pin for the ENC28J60 module
samples/net: Remove legacy configuation variables
Jukka Rissanen (11):
net: Fix possible null pointer dereference in nbuf
net: icmpv6: Removing dead code
net: tcp: Allocate space for TCP header
net: ipv6: Check neighbor pointer in NS reply timeout
net: ipv6: Fix IPv6 prefix comparision
net: nbuf: Check possible null pointer access
net: buf: Use TCP sent_list variable only if needed
net: nbuf: Fix debug prints in memory pool init and unref
net: context: Add status to connect callback
net: echo-server: Use net_buf_frag_del() return parameter
net: echo-server: Discard 0 byte received packets
Leandro Pereira (7):
net: slip: Do not remove fragments when sending data
net: tcp: Ensure all timers are disposed of when releasing context
net: tcp: Use an uint8_t for retry timeout instead of an uin32_t
net: tcp: Remove unused `recv_ack` field from TCP context
net: tcp: Get rid of `recv_mss` field from TCP struct
net: tcp: Reduce size of `state` member from 32 to 4 bits
net: tcp: When retransmitting, hold an extra, temporary reference
Luiz Augusto von Dentz (2):
net: zoap-client: Add bluetooth support
net: zperf: Add bluetooth support
Michael Scott (13):
net: linkaddr: calculate linkaddr storage addr size via config
net: linkaddr: introduce net_linkaddr_set function
net: ipv6: fix NULL reference in handle_ra_neighbor
net: route: remove extra variable use in net_route_add()
net: tcp: remove unused semaphore tcp_lock
net: tcp: in tcp_establish save TCP flags for post-processing use
net: tcp: handle TCP_FIN after processing any data in the buffer
net: tcp: don't assume TCP_FIN buffers are NET_DROP
net: tcp: if buffer is TCP_FIN increment send_ack by 1
net: tcp: fix buffer leak in tcp_synack_received
net: net_context: correct description of recv_data_wait in net_context
net: tcp: move accept_cb from net_context to net_tcp
net: tcp: add timeout wait in net_context_connect
Ravi kumar Veeramally (6):
samples: net: Fix DHCPv4 config options and run on its own thread
net: 6lo: Handle destination address uncompression properly
net: 6lo: Fix dereferencing null pointer
net: dhcpv4: Remove dead code
net: samples: Add ENC28J60 pin numbers to documentation
net: samples: Print assigned address from DHCPv4 server
Tomasz Bursztyka (4):
net: shell: Use lighter printk() instead of printf()
samples: net: Fix a format issues in echo_client
samples: net: Enable buffer warning and errors in echo apps on qemu
net: tcp: Fix TCP states swap when accepted an incoming connection
Vinicius Costa Gomes (14):
samples/zoap_server: Add support for the '/separate' resource
samples/zoap_server: Add support for blockwise GET tests
iot/zoap: Add response code for Continue status
samples/zoap_server: Add resouce for TD_COAP_BLOCK_03
iot/zoap: Ignore non-request packets in zoap_handle_request
iot/zoap: Fix wrong byte-order when retrieving integer options
iot/zoap: Clarify the return value of zoap_register_observer()
iot/zoap: Add a helper to find an observer by address
samples/zoap_server: Fix responding messages with the wrong type
samples/zoap_server: Add support for messages with token
samples/zoap_server: Add Content-Format options to GET responses
samples/zoap_server: Include a path for the "created" resource
samples/zoap-server: Add support for the "location-query" resource
samples/zoap_server: Do not error if there's no payload or queries
drivers/ethernet/Kconfig.enc28j60 | 2 +-
drivers/slip/slip.c | 5 +-
include/net/buf.h | 2 +
include/net/net_context.h | 24 +-
include/net/net_ip.h | 21 +-
include/net/net_linkaddr.h | 55 ++-
include/net/zoap.h | 9 +
samples/net/dhcpv4_client/prj_arduino_101.conf | 2 -
samples/net/dhcpv4_client/prj_frdm_k64f.conf | 12 +-
samples/net/dhcpv4_client/prj_qemu_x86.conf | 29 +-
samples/net/dhcpv4_client/src/Makefile | 1 +
samples/net/dhcpv4_client/src/main.c | 52 ++-
samples/net/dns_client/README.rst | 22 +-
samples/net/dns_client/prj_arduino_101.conf | 5 -
samples/net/echo_client/prj_arduino_101.conf | 4 +-
samples/net/echo_client/prj_qemu_x86.conf | 3 +
samples/net/echo_client/src/echo-client.c | 2 +-
samples/net/echo_server/prj_arduino_101.conf | 4 +-
samples/net/echo_server/prj_qemu_x86.conf | 3 +
samples/net/echo_server/src/echo-server.c | 16 +-
.../net/mbedtls_dtlsclient/prj_arduino_101.conf | 2 -
samples/net/wpan_serial/src/main.c | 6 +-
samples/net/zoap_client/Makefile | 7 +-
samples/net/zoap_client/prj_bt.conf | 21 +
samples/net/zoap_client/src/Makefile | 5 +
samples/net/zoap_client/src/zoap-client.c | 38 +-
samples/net/zoap_client/testcase.ini | 5 +
samples/net/zoap_server/src/zoap-server.c | 476 ++++++++++++++++++++-
samples/net/zperf/Makefile | 7 +-
samples/net/zperf/prj_bt.conf | 32 ++
samples/net/zperf/src/Makefile | 5 +
samples/net/zperf/src/zperf_shell.c | 12 +
subsys/net/ip/6lo.c | 16 +-
subsys/net/ip/Makefile | 1 +
subsys/net/ip/dhcpv4.c | 9 +-
subsys/net/ip/icmpv6.c | 4 -
subsys/net/ip/ipv6.c | 26 +-
subsys/net/ip/nbr.c | 6 +-
subsys/net/ip/nbuf.c | 40 +-
subsys/net/ip/net_context.c | 126 +++---
subsys/net/ip/net_shell.c | 217 +++++-----
subsys/net/ip/route.c | 6 +-
subsys/net/ip/tcp.c | 140 +++---
subsys/net/ip/tcp.h | 67 ++-
subsys/net/lib/zoap/zoap.c | 86 +++-
tests/net/context/src/main.c | 3 +-
tests/net/ipv6/src/main.c | 66 +++
tests/net/rpl/src/main.c | 8 +-
48 files changed, 1278 insertions(+), 432 deletions(-)
create mode 100644 samples/net/zoap_client/prj_bt.conf
create mode 100644 samples/net/zperf/prj_bt.conf
Change-Id: Id27ce34fccfaf2b7d5f3112b9a8b47c60f695f3e
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
If we receive 0 byte packets from the network, we need to
ignore those as otherwise it is possible to leak network
buffers.
Change-Id: Id4b5b0d03c0b6d1e16634ff2d1960ea4728c8aa1
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Because net_buf_frag_del() returns the next fragment in the list,
we can use the return value which makes the code nicer looking.
Change-Id: Ic3d0155417b52a34bfbaa918570ff9af95aee468
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Return and clean buffer when fragment can not be allocated.
Coverity-CID: 157590
Change-Id: Ic8844609da4049623a6cf0c2ae037b2b777542e9
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
TCP states are swaped between "server" context and the new connection
context. But in any case the "server" context should loose the
information that makes it able to accept other new connections.
The swap was badly made, as the "server" context was loosing the
accept_cb (!) and the user data pointer. Instead the new connection
context was unrelevantly inheriting those.
Change-Id: Icc877449e1d4c4e59553dcbfd41718c5006edca0
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
It is useful that the user API can know whether the connection
was established properly or not. So this commit adds status
parameter to connect callback in net_context API.
The call to connect callback needs to be set properly in TCP
code. This commit does not fix the connect callback call which
is not properly done right now in net_context.c.
Change-Id: I284a60ddd658ceef9e65022e96591f467a936a09
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Print assigned address and other information if client receives
anything from server. E.g. subnet, lease time and router.
Change-Id: I759d59522930401766452eb1fb3d57d1a8295a67
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
ENC28J60 has numbers on the board. Documentation has information about
signals only. Wiring will be easy with pin numbers.
Change-Id: I0afd6058a9417b679ef6358304737bf256aa3522
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
Wrong pool pointer was used when printing pool information during
the unref in nbuf.c. During nbuf init, wrong pool pointer was used
when printing memory pool sizes.
Change-Id: I9ed08cf7afa3c841c97ea981b97fff37aa40a984
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
If the parameter "timeout" is set in net_context_connect(), the
assumption by the user is that the function would wait for SYNACK
to be received before returning to the caller.
Currently this is not the case. The timeout parameter is handed
off to net_l2_offload_ip_connect() if CONFIG_NET_L2_OFFLOAD_IP is
defined but never handled in a normal call.
To implement the timeout, let's use a semaphore to wait for
tcp_synack_received() to get a SYNACK before returning from
net_context_connect().
Change-Id: I7565550ed5545e6410b2d99c429367c1fb539970
Signed-off-by: Michael Scott <michael.scott@linaro.org>
net_context is used for more than just TCP contexts. However,
the accept_cb field is only used for TCP. Let's move it from
the generic net_context structure to the TCP specific net_tcp
structure.
Change-Id: If923c7aba1355cf5f91c07a7e7e469d385c7c365
Signed-off-by: Michael Scott <michael.scott@linaro.org>
The recv_data_wait field in struct net_context is described as a "Mutex"
when in fact it's a semaphore signal.
Change-Id: I3bef8d1a07ceb3da5894ae4cdc8f1fe3c61c5dbe
Signed-off-by: Michael Scott <michael.scott@linaro.org>
When SYNACK is received we dont hand off the netbuf to anything
which will call net_nbuf_unref, so let's not mark it NET_OK.
Instead let the code path fall through to mark it NET_DROP.
Change-Id: I1f883e1a13c53c930bf50c07ff701e3db6f02d8a
Signed-off-by: Michael Scott <michael.scott@linaro.org>
Now that the TCP_FIN block is after a potential packet_received()
tcp->send_ack should be appropriately set to the last sequence
processed.
In the case of a TCP_FIN buffer, we should advance it by 1 or else
the destination will continue to retry to send the last block.
Change-Id: I9c97d35a87ad6cc1a50f928b237780bff4cd2877
Signed-off-by: Michael Scott <michael.scott@linaro.org>
Since we default to a return value of NET_DROP, we
can remove the automatic NET_DROP in the TCP_FIN block.
The return value will be set to NET_OK by packet_received()
if appropriate data is found which needs to be sent to
the callback.
Change-Id: Ib2634ba34440ca7053a4e98bf80f12cf6fbbd361
Signed-off-by: Michael Scott <michael.scott@linaro.org>
Buffers marked TCP_FIN may still have data attached to them
which needs to be processed and handed back to the callback.
Let's move the TCP_FIN handling to after the data processing
section now that we have a copy of the TCP flags to do this.
Change-Id: I90f53b10e393024ebffebe1837b8866764b8a7ac
Signed-off-by: Michael Scott <michael.scott@linaro.org>
buffer TCP flags can be cleared during packet_received so let's
save a copy of them for later.
Change-Id: I401e99c1ed2723dac4e86da58635b548a5645c13
Signed-off-by: Michael Scott <michael.scott@linaro.org>
Allow building the IP stack with newlib by enabling linux extensions.
Jira: ZEP-1592
Change-Id: I6714b73c7666a6f56c5203e2754ce1d7d94af0f1
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
If TCP is not enabled, then compile out the TCP retransmit
list variable that is part of net_buf struct.
Change-Id: I07e188454d9be76ac93fe96405f00a89b967668a
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
These logs are mandatory to spot buffer leaks. Unfortunately, they are
still not detailed enough to spot the actual place where the leak
happen.
Change-Id: If36dfa7a54aa1546fb268301f369b5ecd046e276
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
CONFIG_STDOUT_CONSOLE is anyway disabled by default so printf() will not
output anything without it.
Change-Id: I8013e4efa5cb760215316e9413734281fb576f4d
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
In case of a GET request do not error if there's no payload or queries
parameters.
Change-Id: I29b2225700c83a8a2dad166146288dd55bd8f3de
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
This resource verify the capability of the server to send a response to
a POST including a Location-Query option.
Change-Id: I4b663e813eb713d7e93a3c2f8cfd58c335b24cde
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
The CoAP test suite expects a specific path included in the
Location-Path option in the response.
Change-Id: Ib7616f9ad318fa93dc862f686429edb5084306e3
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
The Californium tests expects that all GET responses include the
Content-Format information of the response. In our case, all responses
are of type plain-text.
Change-Id: I08844825f31ed8f4c54020a41b9172cef5da6d70
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
So the sample zoap server application is more conformant, include the
token from the request, if any, in the response.
Change-Id: I5aacc1a3f81ebeaf473d327163c952b829489b01
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
The Californium test suite considers an error responding a NON_CON
request with a ACK response, even if the spec says it is valid, so add
support for using the correct type of response according to the
request.
Change-Id: I211c8a135b8db83af442a1d645b7ea0826dbbdec
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
In some situations, for example, when the remote side sends a RESET
message indicating that it is no longer interested in observing a
resource, it is helpful to have a way to obtain the obverser
representation.
Change-Id: Ifbf627f9170be844fd525c557dda8cb722ac7aff
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
When retrieving options that represent an integer, the order of the
bytes being considered was inverted, resulting in invalid values being
returned.
Change-Id: I8ba84f77e3402066632c0ba650939266c87a8ea2
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
For example, when a RESET packet is passed to zoap_handle_request(),
there's nothing it can do, and it's not an error, so it returns
success silently.
Change-Id: I025bb44733521d6132999c219aaa292a3de302d7
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
This allows to verify that the CoAP server is able to handle a
blockwise PUT request.
Change-Id: I801e353a27b10a5266748591d023bcb607db6bb4
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
This status is used when a blockwise transfer should continue with the
next block.
Change-Id: If68c32aea8c0b63efcd929cdff57f0ff235b2792
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
This adds support for TD_COAP_BLOCK_01 and TD_COAP_BLOCK_02 tests,
which test that the CoAP server is able to handle GET requests with
blockwise tranfers.
Change-Id: Id0d1703adcf5d4e76dd1bc489c8bcc94a3fd90bc
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
This resource is used to verify that the CoAP server is able to send
responses in two steps: 1. only acknowledge that the request was
received and is going to be handled; 2. The actual response, with the
payload.
Change-Id: Ia77cc0ee9805e6cc120c57f4598c68ad364882a0
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
When parser encouter DHCPV4_OPTIONS_END, it immediately returns NET_OK.
No need to maintain end variable here.
Coverity-CID: 157584
Change-Id: I4c8b91f37ae882845c280dab1a8204966aaac00a
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
Pointer udp will be NULL when (!(CIPHC[0] & NET_6LO_IPHC_NH_1))
condition is true.
Coverity-CID: 157588
Change-Id: I8aa1eb2e4d4aee8039631d76ad0ecc345247d6b5
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
When contex information provided and DAC bit is not set and vice versa
are invalid cases.
Coverity-CID: 157569
Change-Id: I1b798703cbbb6155a7bdf734d0fcde9ce48c409c
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
In net_nbuf_get(), check that context pointer value is not
null before accessing data via it.
Coverity-CID: 157600
Change-Id: I7e7ea19a85f6fbef129e9ce699ea740d3be84cb8
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
If the prefix length % 8 is not 0, then the remaining
bit length was calculated incorrectly and the prefixes
were claimed to match even though they might not be the
same.
Adding a test cases for testing this properly.
Coverity-CID: 157591
Change-Id: I9cb5a73d5cc211ec183176400fa5e2dfd209e2da
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
If neighbor is not found, then ignore the timeout.
Coverity-CID: 157583
Change-Id: Ia2199970bd862e43901f5717025271c11c74af5e
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
We need to allocate separate fragment to store the IP
protocol headers.
Coverity-CID: 157582
Change-Id: Ib0dd5d28cd6876a0cf2de3b063c030ef64da998c
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Callback cannot be null so no need to check its value.
Coverity-CID: 157572
Change-Id: I26e4b24c41d30aa9007b78895975035e6bf8807f
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The context parameter might be NULL so we need to check
its value before accessing its content.
Coverity-CID: 157571
Change-Id: I7f75323d9d261a77421688f37a40bb44ff3ca2bd
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The link layer dereferences a buffer right after it is transmitted.
If this extra reference is not held, the second time a buffer is
retransmitted, the reference that TCP holds when keeping the buffer in
the `sent_list` will be taken, and retransmission won't happen reliably
anymore.
As soon as the TCP fragment is acknowledged by the peer, the
`sent_list` reference is taken, and the buffer is freed.
Change-Id: Ie50f9acf02c1dff74248a5dfbec3785a91ff90f7
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>