The tcphdr->offset was not set when tcp options were added.
Change-Id: I19fe97983ce81948a9a84893183e5c9000f12767
Signed-off-by: june li <junelizh@foxmail.com>
There are no users of net_tcp_set_state() left outside of
subsys/net/ip/tcp.c.
And the naming of this function is confusing -- it could easily
be mistaken for net_tcp_change_state() which contains additional
logic for certain tcp states.
Let's remove it entirely and fix the remaining uses to set
tcp->state directly.
Change-Id: I92855ad180e8682780fcff11e50af06adcbc177c
Signed-off-by: Michael Scott <michael.scott@linaro.org>
In net_tcp_release() when a TCP connection is being closed, we
should call net_tcp_change_state instead of net_tcp_set_state.
net_tcp_change_state() will call into net_tcp_set_state() but
also contains logic specific to NET_TCP_CLOSED which unregisters
the context's conn_handler and sends an accept callback (if
present) with -ENETRESET error for user code to handle.
This fixes an EISCONN error returned by net_context_bind() when
a TCP-based net_context was reused. Due to the conn_handler
not being cleaned up in the TCP code.
Change-Id: I8439a028a1c7ae5fd2a50d11caa9947a0ac6c7d4
Signed-off-by: Michael Scott <michael.scott@linaro.org>
GET and DEL requests may not have payloads, so it's not correct to
return with an error in those cases.
This was only noticed now that zoap_packet_get_payload() returns the
correct value for all situations.
Jira: ZEP-1754
Change-Id: Ie533041aa7a66855582ff4c5c937d943304bad84
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
These were flagged by icx compiler.
Jira: ZEP-1811 , ZEP-1809
Change-Id: I0dff800ce2bb440b39dceb08b145e085be4c8caf
Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
The parsing of IPv6 extension headers was skipping bytes
in certain cases.
Change-Id: I80612144aed55aa2dcf9eaab1f4408e10ef9ca31
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Compress bit calculation was wrong. It should be moved
to 4 bits left to cache it properly.
Change-Id: Ib011874881a69032795c2ecfd9a615b6cf559c69
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
Max 6lowpan contexts are 16 as per RFC 6775 4.2 6LoWPAN Context Option.
Range is 0 - F. So context id '0' is valid.
Change-Id: I8468a805e0145b64921139a587cdaeeb9d6871b8
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
If hoplimit bit is unset then values are inlined as
per RFC 6282 3.1.1 HLIM: Hop Limit.
Change-Id: I5821fdf1a4a65b252362277cc604ae913203f80e
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
Hop limit compression should be after next header compression as
per RFC 6282 3.1.1.
Change-Id: I0eaf3428bf835fe73831a7fe6fb708b73c8f5d12
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
The enc28j60's reception routine requires a timeout
for a buffer assignation. The timeout is configurable
to allow a per application fine tuning.
The effect that K_NO_WAIT currently has is that there are frames
lost everytime that a buffer is required and there are none
available.
Jira: ZEP-1169
Change-Id: Ia18736fd85daee51fe1c2304977209cc7f0038b5
Signed-off-by: Juan Manuel Cruz <juan.m.cruz.alcaraz@intel.com>
net_nbuf_ll_src(buf)->addr and net_nbuf_ll_dst(buf)->addr should be
pointing to ctxt area not actual net_nbuf_ll region since the payload
over Bluetooth does not carry any ll addresses.
Change-Id: I87828d74abf2402fdf2a5e34aa8db93aa7c50d08
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Bluetooth consumes buffer when transmitting them therefore any protocol
that need to retain them, like TCP, needs to have its own pool to copy
the buffers as they may need to be resent in case they are not acked.
Change-Id: I483c5a3eb4d54fae6b5b2902c69b67e8c2e0be5e
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
If the packet contains IPv6 header + Extra header + ICMPv6 headers,
last header does not contain 'next header and length' fields. So
while parsing header we should first check next header and continue
parsing. Otherwise we parse 2 bytes extra and set invalid ext hdr len
and handover to other layers. So everything goes wrong after that.
Also simplified next header parsing to minimal.
Change-Id: I5d8235c5a57c8b77adf6a07eb8eb74350a3e4dc6
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
If the buffer contains IPv6 header, set header length only once.
Need not to set it in different scenarios.
Change-Id: I54ab9a4259851c9230db240f6091e3190d25b6cb
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
If RPL is not enabled do not handle RPL options in IPv6 extra header.
Issues will arise if we skip reading those bytes and continue further.
E.g. Upper layer protocol like ICMPv6 echo request does not prepare
proper echo reply if we skip like this. It doesn't know what options
need to be updated in reply header.
Change-Id: I250672a54d4c7f60727313f6e7f8fe902685d0c5
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
Verdict not assgined to its proper value and return NULL in case
of read error. Also simplified error handling.
Change-Id: Idf4c5e242066dfd03e1519271dc1ba38ec43e6ce
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
Verdict NET_DROP returned even though it handled properly.
Change-Id: I61e04b12f971b39585e983aa9a1007c63acd8b4e
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
Debugging code snippet inside handle_echo_reply() does not look nice,
just provided inline functions and simplified it.
Change-Id: Idc3a9284153aaa04d0431a9dd705c4f1c51b817d
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
Earlier net_nbuf_copy_all() mangled the original buffer. So cacheing
src and dst address and other values was necessary. Now original
buffer does not get affected by net_nbuf_copy_all() call. Cacheing
is not required.
Change-Id: I8a8534f7ec299853b9b296d85e8aacecd3768c8e
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
Variable len is not used in net_icmpv6_input() and if required
it can be obtained from 'buf'.
Change-Id: I4b0710e1cf16cff9837173ad9d6908ec54ebafae
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
TCP support is already implemented so it can be removed from
TODO file.
Change-Id: I27690120959ffa1e15891e3210bbcc38a3898359
Signed-off-by: Jesus Sanchez-Palencia <jesus.sanchez-palencia@intel.com>
If a UDP context had net_context_recv() called before
net_context_bind(), then it will have a stale connection handle
associated with initial (random) port number, while will be "bound"
to a new port as specified in net_context_bind(). So, it silently
won't behave as a user expects. net_context_bind() should really
update (or destroy/recreate) conn_handle in this case, but until
it's implemented, apply stopgap measure of at lease reporting error
back to user in this case.
Jira: ZEP-1644
Change-Id: I22ad55f94eaac487a4d5091ccbb24f973ec71553
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
NATS is a publisher/subscriber protocol implemented on top of TCP. It
is specified in [1], and this is a sample implementation for Zephyr
using the new IP stack. The API is loosely based off of [2].
With this sample, it's possible to subscribe/unsubscribe to a given
subject, and be notified of changes asynchronously. In order to
conserve resources, the implementation does not keep its own track of
subscribed subjects; that must be performed by the application itself,
so it ignore unknown/undesired subjects.
TLS is not supported yet, although basic auth is. The client will
indicate if it supports username/password if a certain callback is set
in the struct nats. This callback will then be called, and the user
must copy the username/password to the supplied user/pass buffers.
Content might be also published for a given subject.
The sample application lets one observe the subject "led0", and turn it
"on", "off", or "toggle" its value. Changing the value will, if
supported, act on a status LED on the development board. The new
status will be published.
Also worth noting is that most of the networking and GPIO boilerplate
has been shamelessly copied from the IRC bot example. (Curiously, both
protocols are similar.)
[1] http://nats.io/documentation/internals/nats-protocol/
[2] https://github.com/nats-io/go-nats
Jira: ZEP-1012
Change-Id: I204adc61c4c533661eacfb8c28c1c08870debd91
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
This is a minimal JSON parser (and string encoder helper). This has
been originally written for the NATS client sample project, but since
it's a generic bit of code, it's also being provided as a library
outside the NATS application source.
It's limited (no support for arrays, nested objects, only integer
numbers, etc), but it is sufficient for the NATS protocol to work.
Jira: ZEP-1012
Change-Id: Ibfe64aa1884e8763576ec5862f77e81b4fd54b69
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
Fix the following error:
Calling "transmit(irc->conn, pong, ret)" without checking return value.
It wraps a library function that may fail and return an error code.
Coverity-CID: 163115
Change-Id: I525e1059e6a2ae3896f68760f1a8a6c68ecfc074
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
Print information who freed the net_buf last time if this
can be figured out. This info is not fully accurate if there
is lot of allocations going on but could give some indicatation
who was using the net_buf previously.
Change-Id: I3d4463c54a9b944847a532d951fb6d2303fc06cf
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Run both TCP and UDP to run at the same time. This requires two
extra threads in echo-client sample application.
Change-Id: I450a26d7ab1472150ea8f1309a43897a30bd4d90
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
If we could not allocate a buffer while unfragmenting, make sure
that all the created temporary net_buf artifacts are freed and
we do not have a memory leak.
Change-Id: Ib98ae32eb4a0f9b5f92c51e9713fd8e6d78b10da
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
It is possible that the cached buf is NULL so avoid nasty
error print by not trying to free NULL pointer.
Change-Id: Iec53164f6ffab4b830aba63a1f351ca2349a43ff
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
If net_nbuf_read() or net_nbuf_write() offset adjustment fails,
print the offset value in order to make debugging easier.
Change-Id: I899998bdcbc91a25ed7d71a599a5052a6fa4ee36
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Show only what would be freed when debugging the allocations.
Let the net_buf_unref() to delete the individual fragments.
Change-Id: I1a39a553f12d73b78c4ba08be0e8e8252b666c8e
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The "net stacks" command will also print main and interrupt
handler stack sizes.
Change-Id: I1b867be81ac8b4f6d9446f484ebb8b1d852b98b0
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Create net_nbuf_frag_del() so that we can track net_buf frees.
If CONFIG_NET_DEBUG_NET_BUF is not defined, then this new function
will call net_buf_frag_del() directly, and if not, then it will
track memory usage.
Change-Id: I5f382436cebc71fdaf12baf7bf964fb63bee7aca
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit adds "net allocs" command that can be used to
track net_buf allocations that are done by net_nbuf_get*()
and net_nbuf_unref().
Change-Id: If3dc2ecf5552f8008138ee9733458a19f9764c13
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
User can track memory allocations and deallocations.
This is enabled by CONFIG_NET_DEBUG_NET_BUF option.
Change-Id: I9d83b9b63fb2b141c9a283887f1770bb4232f61c
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
No need to set the buf to NULL as it will get its value
from net_buf_alloc() call anyway.
Change-Id: Ib3a32b6e4cb4b446761b6a97a88c20fc52d3d683
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Add description what happens if NET_DROP is returned from
L2 send function.
Change-Id: I371de725b710041bb26a141f9860c0062fb1ef5d
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
There is no user for the reserve variable inside struct net_nbuf
so remove it.
Change-Id: I45750215cefa2227002eb2de57f080823e7013ce
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Instead of always calling net_nbuf_get_reserve_tx() with zero
ll_reserve (first parameter) and then setting the link layer
reserve separately, pass the reserve to that function which can
then set the ll_reserve in buf itself.
Change-Id: I21c14cb7e2e6c36d170c09998bca0207ecf65c75
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The ll_reserve parameter is useless in net_ipv{4|6}_create_raw()
function as the reserve information is already stored in buf.
Change-Id: I7815a78c001e3da532478c04b3dac9b37bbc723c
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The code used net_nbuf_get_reserve_{rx|tx}_data() function to
allocate a fragment. Instead of that low level function, use
net_nbuf_get_frag() instead. There are few places this is not
possible or is too big change like in few test programs.
Change-Id: Ied7e2b7db352de998b200ffa6ff82471bfa5ebe3
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The net_buf pool address is not very useful so print the
user friendly name of the pool instead.
Change-Id: I1c64621c816832d2459819490ec5609f5c39f9f1
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The columns were not aligned properly.
Change-Id: I551d04182c2877a29bb02a9da5400d74a080a1c9
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
If we receive lot of packets, it might happen that we exhaust
all the DATA buffers in the system. This would prevent from
us sending anything to the network.
Change this by splitting the DATA buffer pool into RX and TX
parts. This way RX flooding cannot consume all DATA buffers
that needs to be sent.
Change-Id: I8e8934c6d5fdd47b579ffa6268721b5eb3d64b6d
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>