Enable zperf code to support TCP using the native IP stack
when testing the network throughput.
Change-Id: I3e58754cfff65525ad15e63adf57f1ea22e4559d
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Previous commit: 6e6281af96
"net: tcp: Only return -ETIMEDOUT if timeout>0 in connect"
missed that K_FOREVER needs a semaphore taken, but has a
value of -1.
Change the logic here to timeout!=0 to handle this case.
Change-Id: Iae6a784443810130a7de267226483426fbd4f0d4
Signed-off-by: Michael Scott <michael.scott@linaro.org>
When CONFIG_NET_DHCPV4 is selected, ignore the CONFIG_NET_SAMPLES_MY_IPV4_ADDR
setting and instead used DHCPv4.
NOTE: This commit also adds a placeholder for DHCPv6 behavior which is not
yet functional.
Change-Id: Id31fcb99be46e966babf18f94b5dec151920dedc
Signed-off-by: Michael Scott <michael.scott@linaro.org>
When CONFIG_DNS_RESOLVER is active, the PEER config will be ignored and
instead a DNS query for DEFAULT_SERVER will be used.
Change-Id: If2c699944027f3c6a8ae9654f9cda0d7dca387c8
Signed-off-by: Michael Scott <michael.scott@linaro.org>
NOTE: You must set CONFIG_NET_IPV6=n in the project .conf file for
the CONFIG_NET_IPV4 setting to take effect.
Only 1 IP connection is active at a time. And when both are active
CONFIG_NET_IPV6 takes precedence.
Change-Id: I34a75f8d44db986810648d82a65d2ed29fc9a940
Signed-off-by: Michael Scott <michael.scott@linaro.org>
Often IRC messages are split across multiple netbuf fragments.
Let's fix the message processing to account for this.
Change-Id: I3835af6adf337d27c28a0beeb72848dcc838772c
Signed-off-by: Michael Scott <michael.scott@linaro.org>
IRC won't allow 2 users to use the same user name, so let's add
a random number to the end of "zephyrbot" to make it semi-unique.
Change-Id: I56349de21823d8fd2c52646656615b42fc12de5e
Signed-off-by: Michael Scott <michael.scott@linaro.org>
Currently, status can be 0 when a NULL buffer is sent to
on_context_recv() so let's not include status in our check.
And in the future, status parameter may be a non-zero value indicating
an error condition. So modify check to include positive values as well.
NOTE: Also make sure to use NET_ERR in these cases and not NET_INFO.
Change-Id: I8eac9a86d22b3b5624cd7a4e9d99e57afcac035f
Signed-off-by: Michael Scott <michael.scott@linaro.org>
Instead let this be set via the project .conf file
Change-Id: Id8d7b46cc0888b83593b6f82dae619fb42c6ae3f
Signed-off-by: Michael Scott <michael.scott@linaro.org>
chan->irc won't be set after the "JOIN" transmit succeeds.
Change-Id: I935b0a44c94ec3d2c91b73db92bfd2005c27bb7f
Signed-off-by: Michael Scott <michael.scott@linaro.org>
samples/net/irc_bot/src/irc-bot.c:368:36:
warning: 'c' may be used uninitialized in this function
[-Wmaybe-uninitialized]
for (cc = &chan->irc->chans, c = c->irc->chans;
^
As suggested by Leandro Pereira <leandro.pereira@intel.com>
adjusted to:
for (cc = &chan->irc->chans, c = chan->irc->chans;
Change-Id: Icd490059e0b97f95408dd7bad3f1783a215c5edb
Signed-off-by: Michael Scott <michael.scott@linaro.org>
Making a bit more room in these buffers. Some were not big enough
in certain cases, while others needed more room in general.
Change-Id: I47a4bb8c6635305f55dee323f7293b2e4cbed55a
Signed-off-by: Michael Scott <michael.scott@linaro.org>
K_FOREVER timeout in net_context_connect() will wait until
SYNACK has been received and we're ready to proceed with socket
communication.
To make the code as clear as possible, let's remove 2 callback
functions and relocate that code inside zirc_connect().
Change-Id: I6c64852ad5f48b24e1e6a58a741981e7d07bfd40
Signed-off-by: Michael Scott <michael.scott@linaro.org>
Due to code restructuring we should move the following
functions higher in the code (above zirc_connect):
zirc_nick_set()
zirc_user_set()
zirc_chan_join()
Also relocate the function declaration for on_msg_rcvd()
to the top of the code.
Change-Id: I3936fb645b709dcbcfcc4212c127db819974c046
Signed-off-by: Michael Scott <michael.scott@linaro.org>
Users can locate and edit these easier when they are at the
top as a #define.
Change-Id: Iecb53999cef1e70a80a28c7be5664ccde0fe7acf
Signed-off-by: Michael Scott <michael.scott@linaro.org>
By moving panic() function up to the top, other functions can be moved
later and still be able to call it.
Change-Id: I4290d1509cc64fc3f5fc5ec109cc19058090e6dd
Signed-off-by: Michael Scott <michael.scott@linaro.org>
Instead use helper function where necessary.
Change-Id: Idcb47d02966731d7ef18588d1dccc8031a38d9d0
Signed-off-by: Michael Scott <michael.scott@linaro.org>
The aim of this helper function is to remove duplicate code for setting
the parameters of in_addr structures.
Change-Id: Id882a5947c47a9b6f92924ce8fb04023540fbb8d
Signed-off-by: Michael Scott <michael.scott@linaro.org>
This allows for a set app stack and threaded functions to be used later.
Change-Id: I647a3defdf6eb4cca2a4a21192b20641f5bf8d4a
Signed-off-by: Michael Scott <michael.scott@linaro.org>
This is a sample IRC bot program, written using the new IP stack API.
All it does is join an IRC channel, wait for some commands, and react
to them:
!hello will greet whoever sent the command
!random will generate a pseudo-random number and send it back
!led_toggle will toggle an LED in the board [1]
!led_on will turn the LED on regardless of its current state
!led_off will turn the LED off
!rejoin will part the current channel and join again
!disconnect will quit from the IRC server
As far as the IRC protocol goes, it doesn't do much more than this, but
it should be straightforward to add support for other things (such as
notices, CTCP, DCC, etc) if someone is inclined to do so. However,
that's way beyond the scope of this sample, which is to show how to use
the network API to write a TCP client.
Some things are still missing as an example of how to use the APIs,
namely DNS resolution, automatically setting up the network with DHCP,
maybe saving settings on EEPROM. These are good candidates to be added
in the future.
[1] The LED code has been shamelessly stolen from the CoAP sample code.
Change-Id: I7152e97c0726f3559db545579ae8ae8d07bf04cd
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
Signed-off-by: Michael Scott <michael.scott@linaro.org>
The RFC requires we honor the 2MSL TIME_WAIT timeout, support for
which was just removed with the FIN cleanup. Add it back, but make it
optional (proper sequence number and ephemeral port randomization
makes true collisions a birthday problem in a ~80 bit space!).
Change-Id: I176c6250f43bba0c914da1ee7f0136dcb1008046
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
The context may live for a while after the user closes it (c.f. TCP),
and of course the documentation specifies that the user must not use
it after calling net_context_put(). Don't confuse them by invoking
their callbacks on the "closed" connection; it's likely that the user
has destroyed her own tracking data and the user_data pointers would
be garbage.
Change-Id: Iba9cc7025c6ea4a94cc4796903966f8d1b831996
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
The connection close paths were a little tangle. The use of separate
callbacks for "active" and "passive" close obscured the fundamentally
symmetric operation of those modes and made it hard to check sequence
numbers for validation (they didn't). Similarly the use of the
official TCP states missed some details we need, like the distinction
between having "queued" a FIN packet for transmission and the state
reached when it's actually transmitted.
Remove the state-specific callbacks (which actually had very little to
do) and just rely on the existing packet queuing and generic sequence
number handling in tcp_established(). A few new state bits in the
net_tcp struct help us track current state in a way that doesn't fall
over the asymmetry of the TCP state diagram. We can also junk the
FIN-specific timer and just use the same retransmit timer we do for
data packets (though long term we should investigate choosing
different timeouts by state).
Change-Id: I09951b848c63fefefce33962ee6cff6a09b4ca50
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
A FIN packet generated by a net_context_put() must go into the normal
transmit queue and not be sent synchronously. Previously sent data is
expected to be delivered and acknowledged before the connection is
terminated.
An advantage we get with this change is unified timeout and retry
handling for FIN packets.
Note that there remains a misfeature here where the queing of the FIN
results in a synchronous switching of the connection callback to
tcp_active_close(), which will prevent any further data received from
being provided to the user.
Change-Id: I2d41316549da9fee383b4f32af5e8b3adf4cb122
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
The death of a network context was sort of a mess. There was one
function, net_context_put(), which was used both by the user as a way
to "close" the connection and by the internals to delete it and to
"clean up" a TCP connection at the end of its life.
This has led to repeated gotchas where contexts die before you are
ready for them (one example: when a user callback decides the
transation is complete and calls net_context_put() underneath the
receive callback for the EOF, which then returns and tries to inspect
the now-freed memory inside the TCP internals). I've now stepped into
this mess four times now, and it's time to fix the architecture:
Swap the solitary put() call for a more conventional reference
counting implementation. The put() call now is a pure user API (and
maybe should be renamed "close" or "shutdown"). For compatibility,
it still calls unref() where appropriate (i.e. when the context can be
synchronously deleted) and the FIN processing will still do an unref()
when the FIN packets have been both transmitted and acked. The
context will start with a refcount of 1, and all TCP callbacks made on
it will increment the refcount around the callback to prevent
premature deletion.
Note that this gives the user a "destroy" mechanism for an in-progress
connection that doesn't require a network round trip. That might be
useful in some circumstances.
Change-Id: I44cb355e42941605913b2f84eb14d4eb3c134570
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
It will setup IPv4/IPv6 addresses. Telnet is ran in the background,
along with net and kernel shell modules.
See the README.rst for more information how to start and use this
sample.
Change-Id: I3e935014c79b534aab43a6fa8256792b23abb38e
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Allow build-testing zoap-server with support for the CC2520 radio.
Change-Id: I986afd7b15208d477bd79f42a52dd45b217214cb
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
In case the user wants to use BOARD make variable to conveniently use
another board with this sample.
Change-Id: I6dd0656da223218d116dd498c1336c890563b212
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
The old default 2 is too low especially if TCP is enabled.
So in order not to confuse the application developer,
increase the default number of network contexts to 6.
Change-Id: I263bb4b6f31354a11d921d94aa97214abd85ae24
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
net_addr_ntop() will convert IPv4|6 address to string form.
Renamed existing net_sprint_ip_addr_buf() to net_addr_ntop()
and adjusted parameters as per API.
Jira: ZEP-1638
Change-Id: Ia497be6bf876ca63b120529acbadcfd9162a96e3
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
This make sure the link-local address of the destination is added to the
nbr cache as that is accessed when calling net_ipv6_prepare_for_send,
this is needed when following RFC 7668 since link-local addresses are
never registered using nbr discovery.
Change-Id: I2bc578d33d1061726d0cbf46e4464df74d79e992
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
in net_print_statistics for RPL we had:
GET_STAT(rpl.dio..sent)
This wouldn't work or compile, so drop a dot.
Change-Id: Idd6b4dfd5fcae3b90bc977fe3ed301cd813ca87c
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This configuration file allows using the device 802.15.4 radio for
IPv6 networks.
Change-Id: I9b3ee9a64acb71e97e4e8f7aae3e619196ad0462
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
Currently, the function accepts a struct sockaddr * but the code
immediately type casts this to either in_addr or in6_addr. This is
incorrect behavior as the first field in a sockaddr is sa_family_t
and not address data.
So without special knowledge, a developer will use a sockaddr structure
as the parameter and then wonder why the address information isn't being
set correctly.
Let's change this parameter to void * which makes this function similar
to inet_pton().
Jira: ZEP-1616
Change-Id: I1fc9368da999d90feb07c03fac55dcc749d4eba6
Signed-off-by: Michael Scott <michael.scott@linaro.org>
If the user supplied connect callback uses too much time, then
it is possible that the connect_wait semaphore will timeout
even if the TCP connection was established correctly. This issue
can be avoided if connect_cb is called after we have released
the connect_wait semaphore.
Change-Id: I175e80f2ad48de657d0d99a44340c5ee1a17364c
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
It was in the static initializers, but was missing from the object
runtime init functions.
Change-Id: I10d519760eabdbe640a19cc5cfa9241c1356b070
Signed-off-by: Benjamin Walsh <walsh.benj@gmail.com>