Introduce tap and double tap triggers to the sensor interface.
Change-Id: Ic91d73e4393d643abc4119850d5b02164b1b6843
Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
Document that when passing NULL to k_free, nothing happens.
Jira: ZEP-1475
Change-Id: I0efab2c8c670b0cebfd3e72aa8cd64857798abea
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This patch adds the ARG_UNUSED macros to some function arguments
to avoid compiler warnings.
Change-Id: Iae2cd3018c9442ffa9268fdfd33eb9a21f55087c
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
This commit adds the ARG_UNUSED macro to some function arguments
to avoid compiler warnings when some sections are compiled out.
Change-Id: Ic003c5a6b2757112cbcf9111fceb14c0f8ea352a
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
Use size_t instead of int to avoid the following compiler warning:
warning: comparison between signed and unsigned integer expressions
Change-Id: I1dcd275e685f5c35793bdbf5ba0acc28ae4b181c
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
Use a short name for this option CONFIG_OBJECT_TRACING.
Change-Id: Id27de7ef9ca299492b6b7d2324d9f5bcf8059a31
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Move logging out of misc/ to its own subsystem. Anything related to
logging and any new logging features or backends could be added here
instead of the generic location in misc/ which is overcrowded with
options that are not related to eachother.
Jira: ZEP-1467
Change-Id: If6a3ea625c3a3562a7a61a0ba5fd7e6ca75518ba
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
That module is not used anymore: it was introduced pre-Zephyr to add
some kind of awareness when debugging ARM Cortex-M3 code with GDB but
was never really used by anyone. It has bitrotted, and with the recent
move of the tTCS and tNANO data structures to common _kernel and
k_thread, it does not even compile anymore.
Jira: ZEP-1284, ZEP-951
Change-Id: Ic9afed00f4229324fe5d2aa97dc6f1c935953244
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Minimal frame size is 60 bytes, but IP frame might be smaller than this
size minus the ethernet header. In that case, Ethernet frames are padded
so it does reach this minimal size. In this case, ethernet L2 should
update the buffer list so it remove the padding length from the whole.
Change-Id: Id370cad09ad82bb54febeb60b05f7e430cc8f963
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This patch introduces a k_sem that will block until:
- data is received, or
- the user-provided timeout expires
This change allows us to simplify our previous DNS client
implementation.
This change is related to ZEP-1357 because we are refactoring the
DNS client API removing the continuous update of the net_context_recv
routine that seems to be causing issues after the kernel's update.
Jira: ZEP-1357
Change-Id: If01c9274ac8f096f0095a2872f86be2e007212ee
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
This commit introduces the dns_context structure.
This new structure will reduce stack overhead due to
the simplication of the dns_resolve routine signature.
Furthermore, the timeout parameter is now int32_t
instead of uint32_t.
The dns sample application is also updated.
Change-Id: I5d789656bacbd23c4654edce5d116a88dc42c354
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
TinyDTLS is gone, so in this patch we are removing the tinydtls.h
header.
Change-Id: I7deddc554ac5c2fc952565a2df2e4c46e7cd2f6e
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
RFCOMM channel range is 1 - 30, 0 and 31 shall not be used since
the corresponding DLCIs are reserved in GSM.
Change-Id: I63ff188e06007208b629a3e3bc22681c0bad239b
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
For very constrained systems, like bootloaders.
Only the main thread is available, so a main() function must be
provided. Kernel objects where pending is in play will not behave as
expected, since the main thread cannot pend, it being the only thread in
the system. Usage of objects should be limited to using K_NO_WAIT as the
timeout parameter, effectively polling on the object.
Change-Id: Iae0261daa98bff388dc482797cde69f94e2e95cc
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
nano_cpu_idle/nano_cpu_atomic_idle were not ported to the unified
kernel, and only the old APIs were available. There was no real impact
since, in the unified kernel, only the idle thread should really be
doing power management. However, with a single-threaded kernel, these
functions can be useful again.
The kernel internals now make use of these APIs instead of the legacy
ones.
Change-Id: Ie8a6396ba378d3ddda27b8dd32fa4711bf53eb36
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
Not a functional bug per-se since they resolve to the same thing, but a
conceptual error nonetheless.
Change-Id: Ia11f6bd272cabe8da21d59e3378b8348f034e814
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
Use _INACTIVE instead of hardcoding -1.
_EXPIRED is defined as -2 and will be used for an improvement so that
interrupts are not locked for a non-deterministic amount of time while
handling expired timeouts.
_abort_timeout/_abort_thread_timeout return _INACTIVE instead of -1 if
the timeout has already been disabled.
Change-Id: If99226ff316a62c27b2a2e4e874388c3c44a8aeb
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
The Cortex-M3/4 kernel was reserving priorities 0 and 1 for itself, but
was not registering any exception on priority 0. Only reserve priority 0
and use it for SVC and fault exceptions instead of priority 1.
Change-Id: Iff2405e27fd4bed4e49ab90ec2ae984f2c0a83a6
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
There are now three flags that decide how many priorities are reserved
by the kernel, each one requiring one priority level: Zero Latency
Interrupts, BASEPRI locking (for SVC usage) and faults that are not at
priority -1, so that taking them in an ISR actually triggers the fault
synchronously.
Change-Id: I7f4d760c9110051aeb82dcfd8cd68026a9b74b54
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
This allows using it in _EXC_PRIO() instead of hardcoding 2 and 3.
Change-Id: I3549be54602643e06823ba63beb6a6992f39f776
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
This is a left-over that should have been renamed to the new
net_buf_alloc_debug function name.
Change-Id: Iefcbd2eefab5614b1b80214cb0927f3db77d592e
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
When going into DEEP_SLEEP state, the ARC timer
needs to be restored.
This implements the function to restore the timer
after sleep.
As the time spent during sleep is not currently known,
the timer is expired to reschedule the application task.
Jira: ZEP-1224
Change-Id: I22a30d0fd79f177cf166b9a29dc78d68f7d7fbad
Signed-off-by: Julien Delayen <julien.delayen@intel.com>
Move interrupt initialization for the ARC to its own
device. The init function for the arc will be only
doing platform specific operations
Jira: ZEP-1288
Change-Id: Icb04c3622890021c65cd24cecf6cafee6c37caf9
Signed-off-by: Julien Delayen <julien.delayen@intel.com>
Following commit fc21a76db6
Some more fixes are needed.
Change-Id: I19c2c979d44be5edfd76041d3cf4507860795c78
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Using a LIFO instead of a FIFO has the potential benefit that more
recently in-use buffers may be "cache-hot" and therefore accessed
faster than least recently used (which is what we get with a FIFO).
Change-Id: I59bb083ca2e00d0d404406540f7db216742a27cf
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Since the user data size is now stored in the pool there's very little
value in storing it as well per-buffer.
Change-Id: I17a99123b232423c52a2179b4eccd813728d51b1
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
In order to keep the initialization process light-weight, remove
net_buf_pool_init() and instead perform the initialization of the pool
and buffers in a "lazy" manner. This means storing more information
in the pool, and removing any 'const' members from net_buf. Since
there are no more const members in net_buf the buffer array can be
declared with __noinit, which further reduces initialization overhead.
Change-Id: Ia126af101c2727c130651b697dcba99d159a1c76
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This is only for use with custom destroy callbacks, so that the
application gets isolated away from the details of how exactly the
buffers are managed. This opens up the possibility of switching away
from k_fifo to potentially better solutions, such as k_lifo.
Change-Id: I0d8322fdec3500d8ae060ae471b9448aeaa4572a
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Remove SENSOR_VALUE_TYPE_INT as it is the same as
SENSOR_VALUE_TYPE_INT_PLUS_MICRO with val2 set to 0.
Change-Id: If5a9c579b7267701c27f40fd887acae47d64edc5
Signed-off-by: Bogdan Davidoaia <bogdan.m.davidoaia@intel.com>
Remove SENSOR_VALUE_TYPE_Q16_16 as it is not used by any driver. Future
drivers can use any of the remaining value types.
Change-Id: I984143cc65d6a6fd0477f310ac17c62498cc05b8
Signed-off-by: Bogdan Davidoaia <bogdan.m.davidoaia@intel.com>
Until now it has been necessary to separately define a k_fifo and
an array of buffers when creating net_buf pools. This has been a bit
of an inconvenience as well as blurred the line of what exactly
constitutes the "pool".
This patch removes the NET_BUF_POOL() macro and replaces it with a
NET_BUF_POOL_DEFINE() macro that internally expands into the buffer
array and new net_buf_pool struct with a given name:
NET_BUF_POOL_DEFINE(pool_name, ...);
Having a dedicated context struct for the pool has the added benefit
that we can start moving there net_buf members that have the same
value for all buffers from the same pool. The first such member that
gets moved is the destroy callback, thus shrinking net_buf by four
bytes. Another potential candidate is the user_data_size, however
right not that's left out since it would just leave 2 bytes of padding
in net_buf (i.e. not influence its size). Another common value is
buf->size, however that one is also used by net_buf_simple and can
therefore not be moved.
This patch also splits getting buffers from a FIFO and allocating a
new buffer from a pool into two separate APIs: net_buf_get and
net_buf_alloc, thus simplifying the APIs and their usage. There is no
separate 'reserve_head' parameter anymore when allocating, rather the
user is expected to call net_buf_reserve() afterwards if something
else than 0 headroom is desired.
Change-Id: Id91b1e5c2be2deb1274dde47f5edebfe29af383a
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Last argument for k_stack_init is of time int resulting in UINT_MAX
being converted to negative value. Instead of UINT_MAX use maximum
possible number of entires that won't result in stack->base and
stack->top overflow.
Change-Id: I8470f6dd18abcccc72590e07e0d0efd4ce2208cc
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
Hamming Weight or "popcount" consists in counting the number of bits set
to 1 in a particular word. This commit adds a macro to be able to use
the existing builtin for this purpose with the GCC compiler.
Change-Id: Iec64c19e897de2bc02e981071465bbe230ee9add
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
The ARG_UNUSED macro is added to avoid compiler warnings.
Change-Id: If14c3928a30c8f3156cdcd0fe11e22407a78c088
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
Applications may want to know how much time is left until a delayed
work gets scheduled. To prevent applications from having to track this
themselves simply use the information that's already embedded as part
of the timer that's part of the delayed work struct.
Change-Id: I189df2f3be8b207e68b554a0cbb4f97f1a99de22
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Factor out the code for evaluating the remaining time for _timeout
structs so that it can also be used for other objects besides k_timer
structs (like k_delayed_work, coming in a subsequent patch).
Change-Id: I243a7b29fb2831f06e95086a31f0d3a6c37dad67
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Device_sync_call related APIs and typedef are actually wrappers
for kernel semaphores. These APIs and typedef will be
deprecated. Let's add deprecated attribute to give deprecation
warning.
Jira: ZEP-1411
Change-Id: Ia07557cc81bd9ee8e41f2e17be4607c4bd6d23bd
Signed-off-by: baohong Liu <baohong.liu@intel.com>
Use the SYS_INIT() mechanism to invoke the sys_rand32_init() function
in random drivers that require an initializer. Remove all empty
sys_rand32_init() instances.
The existing explicit sys_rand32_init() function runs immediately after
PRE_KERNEL_2 before stack canaries are initialized. In order to get
equivalent behaviour with sys_rand32_init() we set SYS_INIT() to
initialize the random drivers at the lowest priority of PRE_KERNEL_2.
Change-Id: I4521e44daac806bc4eef01ce7fdf2ba5367e0587
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
There are some corner cases where direct access to the formatter
function is needed. Export _vprintk() so code can use it in a similar
way that _prf() can be directly used.
Change-Id: I9dfb68f87f310e900c662dc8beb320bb4ff7d8b2
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
After some more careful measurements, the worst measured overhead is
288 bytes. Adjust BT_STACK_DEBUG_EXTRA correspondingly to 300 (to give
a bit of playroom still on top of this).
Change-Id: Icdf477b05b40917027314b180c2b69c8c6c759b3
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
BT_STACK_DEBUG_EXTRA was adjusted by commit 047c6eacf7,
however it failed to cover this #ifdef section in log.h.
Change-Id: I1a9cd81dc25e9465daba62f0116b2661ac047362
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This will be used by the user to disconnect or cancel connect dlc.
This also defines an internal close function which will take
appropriate action based on the dlc state.
In case of user initiated disconnection if some pending packets are
there in queue then it has to be sent before sending DISC packet.
< ACL Data TX: Handle 256 flags 0x00 dlen 8
Channel: 64 len 4 [PSM 3 mode 0] {chan 0}
RFCOMM: Disconnect (DISC) (0x43)
Address: 0x2b cr 1 dlci 0x0a
Control: 0x53 poll/final 1
Length: 0
FCS: 0x6d
> ACL Data RX: Handle 256 flags 0x02 dlen 8
Channel: 64 len 4 [PSM 3 mode 0] {chan 0}
RFCOMM: Unnumbered Ack (UA) (0x63)
Address: 0x29 cr 0 dlci 0x0a
Control: 0x73 poll/final 1
Length: 0
FCS: 0x26
Change-Id: Ie4fa3bd8f6b279fee6fb56ddce198d82c5047849
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
Now that printk is the default backend for logging the overhead is not
as bad as with printf. 160 seems to be roughly the worst case amount
of overhead that debug logs now cause.
Change-Id: Ia5937b7318e00cc31c72fa1702c73a57bca0603a
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Instead of %2.2x we should use %02x since printk doesn't (currently)
support the former.
Change-Id: I773972e63071b81c95c65de292f12ab14d7c310b
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
There's now snprintk available that's more light-weight on the stack
than snprintf.
Change-Id: I6b3e4409703ca92fe6b8f4146ff47c490ab826cb
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Applications may want finer control of the NRPA used for
non-connectable beacons, and provide it up-front rather than letting
the stack generate one.
Change-Id: I84d459372cc85ed09a8f9cde16dbb9b98dec2a43
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Expose helpers in hci.h for setting and getting the LE random address
type.
Change-Id: I7c6437051f0b2d1f5f79e19b2616bb643ae6300b
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Having the logging macros arbitrarily mapping to printk or printf
based on selected Kconfig options that the app isn't necessarily aware
of can have unexpeced (bad) side effects. In particular, printf
consumes *a lot* more stack (closer to 512 bytes) than printk, so
enabling a seemingly innocent CONFIG_STDOUT_CONSOLE option could lead
to stack overflows that are hard to debug.
Jira: ZEP-1419
Change-Id: I5fd77a7ed402e9ca67af23857e0f886f96d243bc
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This patch adds the clock_control implementation for the ARM LTD
Beetle platform.
The main features enabled are:
* Clock on and off in ACTIVE, SLEEP and DEEPSLEEP mode.
* PLL support (freq: 12, 36, 48 Mhz).
The integration with the existing drivers will be done in future
patches.
Jira: ZEP-1300
Change-Id: I07cb2325275bd86a036e8e24aeb7bbf2c6176a93
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@linaro.org>
Add the clock driver for the STM32L4 series.
Change-Id: Icdf79061f163d8d00187b382d1564422fb875c5b
Signed-off-by: Fabien Parent <fparent@baylibre.com>
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
These correspond to the libc snprintf and vsnprintf APIs.
Change-Id: If3944972ed95934a4967756593bb2932c3359b72
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Pass a parsing context around, allowing counting the number of
characters written, which is then returned in the return value of
printk(). This makes printk more similar to printf and prepares the
way to extend the implementation to support printing to strings.
Change-Id: Ib28a18a4f36fc58b98b228fd5763b2c05f5af7bc
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Drop the unnecessary trailing whitespace formatting in inline asm.
Change-Id: I351df91b7175fe21d268d325865838b4840def8d
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
Replace the use of a hardwired temporary register in the irq_lock()
implementation with a local variable. This will allow the compiler
more flexibility in register allocation.
Change-Id: Ifbdb52fca1d40404d55934343ac2a8153df7e1a8
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
The cortex-m4 irq_lock() implementation uses a movs instruction, thus
clobbering the condition code, but does not include the clobber in the
asm clobber list. This is a bug in the situation where the compiler
schedules a live condition code over the inline lock instructions.
Since the irq_lock() implementation does not need to kill the CC we
simply switch to mov from movs.
Take the opportunity to drop the unnecessay .n and let the assembler
choose an appropriate encoding.
This fixes a bug found by inspection, it has not actually been
observed in real code.
Change-Id: Id60fa3362df9d4bf05c3d5e23066410ede92d73c
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
Memory accesses could be reordered before an irq_lock() or
after an irq_unlock() without the memory barriers.
See commit 15bc537712 for the
ARM fix for a complete description of the issue and fix.
Change-Id: I1d96fe0088d90150f0888c2893d017155fc0a0a7
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
Memory accesses could be reordered before an irq_lock() or after an
irq_unlock() without the memory barriers.
See commit 15bc537712 for the ARM fix for
a complete description of the issue and fix.
Change-Id: I056afb0406cabe0e1ce2612904e727ccce5f6308
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
Memory accesses could be reordered before an irq_lock() or after an
irq_unlock() without the memory barriers.
See commit 15bc537712 for the ARM fix for
a complete description of the issue and fix.
Change-Id: Ic92a6b33f62a938d2252d68eccc55a5fb07c9114
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
Add the missing memory clobber to irq_unlock() in order to prevent the
compiler reordering memory operations over the unlock.
Change-Id: If1d664079796618ed247ff5b33b8b3f85fb7e680
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
The inline asm definition of irq_lock() on the ARM architecture marks
the ASM as volatile which prevents the compiler from removing the
isntruction but does provide any information to the compiler to
prevent the inline ASM instruction being re-ordered relative to other
instructions. The instruction used in irq_lock() do not touch memory,
however in order to acheive their intended purpose they must be
ordered relative to other memory access instruction. This is acheived
by adding the "memory" clobber.
Instances of the compiler inappropriately re-ordering irq_lock() calls
relative to other instructions without this patch can be observed in
the code generated for k_sleep() on NRF51 target boards.
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
Change-Id: I9d42d54cd9a50e8150c10ce6715af7ca2f5cfe51
Currently it's only possible to configure those GPIOs through
boards.<h/c> files and thus it's not relevant for board that do not
embed cc2520 but might get one wired to it, unlike
quark_se_c1000_devboard which directly embeds one cc2520.
Change-Id: I819bc1d2de707ea12eb70dc60a40b28f92666e51
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This commit adds HTTP message handling support for Zephyr.
So, no network routines are involved at this level.
To add HTTP message handling support for Zephyr, we explored the
following options:
1. Importing an external project and perhaps adapting it to fit our
requirements.
The criteria to pick one codebase among all the available projects
are: licensing, correctness and performance.
2. Writing our own implementation from scratch.
We decided to import an external project instead of implementing our
own parser, mainly due to code maturity and correctness. It could take
more time to obtain a production-ready parser from scratch than adapting
a state-of-art library.
The following is a list of some projects offering similar functionality.
lighttpd (many files)
* License: revised BSD license
* Supported: active
* Comments: this parser can't be integrated to Zephyr due to
dependencies that currently are not satisficed by our SDK.
nginx (src/http/ngx_http_parse.c)
* License: 2-clause BSD-like
* Supported: very active
* Comments: this parser can't be integrated to Zephyr due to
dependencies that currently are not satisficed by our SDK.
wget (src/http-parse.c)
* License: GPL 3.0
* Supported: very active
* Comments: this code can't be included in Zephyr due to
licensing issues
curl (lib/http.c)
* License: MIT/X derivate, see:
https://curl.haxx.se/docs/copyright.html
* Supported: very active
* Comment: it must be forked and adapted to run in Zephyr.
It is not optimized for low-power devices.
nodejs http-parser (http_parser.c)
* License: nginx license (2-clause BSD-like) and MIT license
* Supported: very active
* Comments: optimized with performance in mind.
From https://github.com/nodejs/http-parser: "It does
not make any syscalls nor allocations, it does not buffer data,
it can be interrupted at anytime. It only requires about 40
bytes of data per message stream."
So, nodejs/http-parser looks a very good choice for Zephyr. In this
commit, we integrate nodejs' parser to Zephyr.
Origin: https://github.com/nodejs/http-parser/releases/tag/v2.7.1https://github.com/nodejs/http-parser/archive/v2.7.1.tar.gz
NOTE:
This patch reformats the http_parser files to reduce checkpatch
warnings. Changes made in this refactoring are available at:
Repo: https://gitlab.com/santes/http_parser/commits/refactoring1
Commit: 9ccfaa23f1c8438855211fa902ec8e7236b702b1
Jira: ZEP-346
Jira: ZEP-776
Change-Id: I29b1d47f323a5841cd4d0a2afbc2cc83a0f576f0
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
Create a variable in nbuf metadata area for storing TCP
buf_sent information.
Change-Id: I21a85c58183f1e4997d03d4a93546ddd9b32e977
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Hook up TCP transmission through the net_context_send() API. Queues
packets via a list in the net_buf header, but as of right now simply
transmits the queue synchronously, ignoring the need for retransmit
and the limits of the receive window on the other side.
Requires that the ACK transmission be moved ahead of the net_context
callback invokation. This to work around a glitch in the way ACKs
work with queueing (they depend on current state, but packets are
assembled just once) that will be fixed in a coming patch.
Change-Id: I7490333e4b314e7734fcc03f2a63d76ae89d698a
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
The cc2520 driver RX thread did not like the stack information
collection macros defined in net_core.h. Both the cc2520 TX and
RX got the same variable name which did not compile.
This is now changed so that the first parameter is added to
the variable name to create a unique variable.
Change-Id: Ia41d01a71afd73af2ef31aa5f7a890a3cf0385aa
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
As the native IP stack is now the default, there is no need
for corresponding Kconfig option.
Change-Id: I08e4992f540f928a2b7378e8803e634e38725348
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit removes the legacy Contiki based uIP stack.
The new native IP stack must be used after this commit.
The commit also removes following things:
- legacy cc2520 driver
- legacy ethernet drivers
- legacy IP stack samples
and changes these things:
- disabled tests that only work for legacy IP stack
- select new IP stack by default
- enable random number generator by default as it is needed
by the new IP stack
Change-Id: I1229f9960a4c6654e9ccc6dac14a7efb9394e45d
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This is to be used in net-shell to view currently
available network connections.
Change-Id: Iadb6555ed6db4e8fb0639e6d0dcf1eccd970acca
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
If IP stack offloading is enabled, then call corresponding
L2 driver when corresponding net_context API function is
called. The L2 driver can then do its magic to send/recv
IP packet or do what ever with it.
Change-Id: I26695cee6feb80a41923db0165f22d94477333be
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This code is inspired by a similar feature found in ccan[1],
that enforces that the parameter passed to ARRAY_SIZE() is
always an array and not a generic pointer. This is a slightly modified
version that will work if the macro is expanded outside of a function
body.
The check is performed by comparing if typeof(array) and
typeof(&array[0]) are of a different type. Due to the way arrays
decays to pointers in C, if one passes a pointer, the types won't be
compatible and a compile time assertion will fail.
No bugs have been found with this change, but since there's no runtime
or size overheads, there's no reason to not enable it.
[1] https://github.com/rustyrussell/ccan/blob/master/ccan/array_size/\
array_size.h
Change-Id: I6c321714d0024298e593176be43b2d0b5362cc0d
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
This macro does two things: first, it validates that the pointer is not
NULL. Second, it validates if it's between the first and the last
element in the array.
This is useful for cases where a pool of structures are used, such as
in the network subsystem.
Change-Id: I9d815936e31d87a3b3ff80466eea97bc4ad954b5
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
The macro defines the stack as usual, but if user has
enabled net shell (CONFIG_NET_SHELL), then additional
information about the stack is stored in net_shell
linker section. The information in the net_shell linker
section is then used to print information about the
stacks in the networking sub-system.
Change-Id: Ic6e9f16a73a192b9a59d32a6d0070322382f98bd
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The original version can fail in ARM like this
***** USAGE FAULT *****
Executing thread ID (thread): 0x200027a8
Faulting instruction address: 0x00008080
Unaligned memory access
Fatal fault in thread 0x200027a8! Aborting.
so use UNALIGNED_PUT() and UNALIGNED_GET() instead.
This failure was seen when IPv6 address was
copied to neighbor cache in ipv6.c:nbr_new().
Change-Id: I638424b9a95c451e13314ca9182c39ab8aa71830
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
If CONFIG_INIT_STACKS is not enabled but CONFIG_NET_SHELL is,
then net_analyze_stack_get_values() was not properly compiled
out which caused unknown function call.
Change-Id: I18de5ec0b5d6ab7876e801c83b82c9dd5bf22093
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit adds the MQTT high-level API with Quality-of-Service
support. The following MQTT messages are covered by this commit:
CONNECT (tx), DISCONNECT (tx), PUBACK (tx, rx), PUBCOMP (tx, rx),
PUBREC (tx, rx), PUBREL (tx, rx), PUBLISH (tx), PINGREQ (tx),
SUBSCRIBE (tx), UNSUBSCRIBE (tx), CONNACK (rx), PINGRESP (rx),
SUBACK (rx) and UNSUBACK (rx).
Where 'tx' stands for transmission: routines that create and send
messages. 'rx' stands for reception: routines that receive an RX
buffer from the IP stack and parse the MQTT mesage contained in
that buffer.
Jira: ZEP-365
Jira: ZEP-591
Jira: ZEP-856
Change-Id: Ibee701a298127eb713aa3fde5aaf7d089ecd1b9d
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
Updating the API documentation to use K_NO_WAIT instead of 0.
Change-Id: I10ba31fe116210443f383b343993c3cca830a7c2
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Dropping legacy API. This commit also contains updated
unit tests in order to pass the test.
Change-Id: Ibc7426837e2f4f23bb5f3ed3719635c5c3d0ed0f
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Origin: Original
Based on "IEEE Std 802.3-2008, Section 2" Chapter 22.2.4
Change-Id: I08516dd1c2f74c1324d00d665f221e01af25d7f1
Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
Replace NANOKERNEL by POST_KERNEL in the net stack.
Change-Id: Iaad7cdbe849741bc1cf18b0ccf7264417a9495d6
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The functions that return the start of the UDP and TCP buffers,
did not take the IP extension header length into account.
Change-Id: Ie3e2fbc49365de9176a788b54ab628e6ef37f5ee
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
More logical place for net_ipv4_broadcast_address() is in ipv4.c
instead of net_if.c.
Change-Id: I069f5030963bcb809df34e874054e2b7826ff868
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
More logical place for net_ipv6_unspecified_address() is in ipv6.c
instead of net_if.c. Removing the net_if_ipv6_unspecified_addr()
variant as it is no longer needed.
Change-Id: Ib5b4f6748030a8bf50fb848a87eef2968e2bcbc8
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Add function that returns IPv4 any address (all bits are zero).
Change-Id: I8816f7f264ad3a98fced7089f0b94220603c2291
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Instead of appending the LQI into the buffer, which is an awkward usage.
Change-Id: I2f604cd61ef3b309cdfe304dac0ab1e7a2ca3f6a
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
If net_send_data() returns 0, then the buffer was sent ok
and the sending device driver has already freed the buffer.
If net_send_data() returns <0, then the buffer sending failed
and the caller can either try to fix the issue and re-send the
buffer, or the caller can unref the buffer. Normally caller
should unref the buffer in this case as there is not much that
can be done here.
Change-Id: I39d7b22bbb78a9c16fd037f3a066797e455c31fd
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The pos and len variables were in incorrect order.
The pos is first before the len variable.
Change-Id: I0b078ce2f08923c1673bd918fc03adb2ff09691a
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit adds support for the MQTT protocol v3.1.1.
Specifically, this commit allows a Zephyr application to create
the following MQTT messages:
CONNACK, CONNECT, PUBLISH, PUBACK, PUBREC, PUBREL, PUBCOMP, UNSUBACK,
SUBSCRIBE, SUBACK, UNSUBSCRIBE, PINGREQ, PINGRESP, and DISCONNECT.
Furthermore, the following messages can be parsed by the routines
provided by this commit:
CONNACK, CONNECT, PUBLISH, PUBACK, PUBREC, PUBREL, PUBCOMP, UNSUBACK,
SUBSCRIBE, SUBACK, PINGREQ, PINGRESP and DISCONNECT.
NOTE: client behavior (routines with network access) and QoS will be
integrated in future patches.
The MQTT v3.1.1 specification can be found at:
http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/mqtt-v3.1.1.html
Origin: Original
Jira: ZEP-365
Jira: ZEP-591
Jira: ZEP-856
Change-Id: Ie0c179370cea22f7554564692bc426a8d5c419d2
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
This is needed by net-shell module.
Change-Id: Ic93f806a5882592ff1769b4a14b6ed524ba14912
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Separate the calculation of stack utilization variables and
printing the values from each other so that it is possible
to use separate printing function to print the values.
Change-Id: I3a5827c08edea5017e2a4bc1c5be2fe419cdfcb8
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This function converts a string into an IP address.
Change-Id: If57983a345fe4c18df01e58dbce7d9a50a27b82a
Signed-off-by: Jaakko Hannikainen <jaakko.hannikainen@intel.com>
This creates a `struct net_conn_handle` that's only used as an opaque
pointer. The purpose is to avoid assigning a void* to a void** in
connection registering/unregistering functions, avoiding a
previously-caught bug by issuing an incompatible pointer types warning:
warning: passing argument 7 of 'net_tcp_register' from
incompatible pointer type [-Wincompatible-pointer-types]
Suggested by Andy Ross in 5beec6. This particular commit didn't catch
any bugs, but the one caught in 5beec6 wouldn't exist if this were in
place at the time.
Change-Id: I5c13fb4c5826adce6397feb7b400d36e426c4a87
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
The allocated space for IPv6 string was too short by 10 chars
which meant that full IPv6 address was not printed correctly.
Change-Id: I9c7f3f118f486f88e769aaadf09d100a1d4fd6bc
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Utility function that can add option bits to IPv6 option bitmap.
Change-Id: Ia10d27c201556fb960a736590788b791a7e3c018
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
RPL implementation taken from net/ip/contiki/rpl and
ported to use the new stack.
Origin: Contiki
Change-Id: I479d9dd143b763f90cb7915806fd7e9faea0300c
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Add utilities to return network interface link local and
global IPv6 addresses.
Change-Id: I54d0ec28410b9ad4ad7068a887bfa6706453159c
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Go through the router list and return the default router
where to send the network packet.
Change-Id: I87e5118b03352b7d11e1fde800d1530e5929ebab
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Helper checks if the IPv6 address belongs to one of the subnets
defined for network interfaces.
Change-Id: I0e88ebe5014a514404b589e32cc71590950a39c7
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The other part of the stack can register a handler that is
called after the network packet has been sent. This callback
is used by RPL routing code.
Change-Id: I6b76c5f01d1f6706b0c0a56980ad50e1b85fc427
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This is meant if only one needs reliability when sending non-TCP packets
(as TCP would make is redundant).
Change-Id: I7dc605094b422a750424c3498d18f32d809d23a8
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
For future purpose, let's not occupy a full byte for a unique boolean.
Change-Id: I36f2824cca4806eb90640a71ed3cea37a353b276
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Including net_if.h can makes things looping, as this one will include
net_l2.h, which one might include a technology that will in turn include
net_mgmt.h again.
Change-Id: I514720875937414167f0396edb9147ed29dd6d69
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Up to the part declaring mgmt request to define such handler. This is
meant to avoid such warning:
warning: implicit declaration of function ...
Change-Id: Ide6e9abf886169c26d81fe6b5c7bc280e1ac4e4d
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
net_l2 is the proper name, looked by sanitycheck.
Change-Id: I08548865df21a57c8198fe0a801aa8c2a81b7fb0
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Add support for inserting data into an arbitrary location in fragment.
Change-Id: Iaecdc4e980a73e0f66c208315d342e05762cd6f5
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
Add support for nbuf write to an arbitrary location in fragment.
Change-Id: I686c6d86feb8545603edd7c7a9ef6fde1c909a72
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
net_l2_init sections used to exist in early stage of the native IP stack
but got removed since.
Change-Id: I189d6e6f7aa05a6e5a62a28973c714d0367b0c5a
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This creates initial TCP handling logic but does not yet
enable fully working TCP connection.
Some of the connection logic is taken from FNET TCP
implementation.
Origin: FNET 3.6.1
URL: https://github.com/butok/FNET/blob/master/fnet_stack/stack/fnet_tcp.c
Change-Id: I1e100d9fa9c91437562b933d94d0bd3db1a5885e
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This way we avoid ugly casts in the calling code.
Change-Id: I9c949cf22ecd1603e9247a07240de5759bf85463
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Apparently, a copy-paste error: NET_CONTEXT_TYPE was used instead of
NET_CONTEXT_PROTO. The corresponding "set" function uses the latter,
so it for "get" too.
Change-Id: Ideb5bfaeb548222a6e64d53b782c9a111e3ef33b
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
Current net_nbuf_write() api just appends data to last fragment. And
doesn't write data based on offset. That's why renaming this api.
New net_nbuf_write() apis based on offset will be coming soon.
Change-Id: Ie8e13e5f6091a279b62b6d8b0b3928a5187e75b0
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
Valid case:
1) If the offset is more than current fragment length, adjusts offset
from next relevant fragment and starts reading or skipping.
2) If the read or skip length is more than available data length,
then throw an error.
In case of an error, frag is 'NULL' pos is '0xffff'. Rest of the cases
are successful read and skip.
Change-Id: I88c4b85e14e5821f681966b5148ba9519b91cca4
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
The legacy stack has all the net_context API stuff in
net_socket.h so include it in net/net_context.h file.
This re-works the commit 627feb92d4 which added the
net_context_get_internal_connection() to net_context.h.
Now that function prototype is found in net_socket.h.
Change-Id: If22fa63357f4b2e9503f8c9850e69ffda39c61c7
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit adds support the DNS client API on top of the new
native IP stack. Some features of this implementation are:
- Support for IPv4 and IPv6
- Support for multiple concurrent queries. A net_buf structure is
required per context. See the DNS_RESOLVER_ADDITIONAL_BUF_CTR
configuration variable
Origin: Original
Jira: ZEP-793
Jira: ZEP-855
Jira: ZEP-975
Change-Id: I351a636462a1b78a412c9bce1ef3cd0fa6223a52
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
Enum names are colliding with defines, which is bad.
Change-Id: Ia8c003983ddeb1ebed8a9210e682bcb21abfa687
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Re-ordering fields in struct net_nbuf in order to avoid
holes because of memory alignment.
Change-Id: I5a3ab31a0232003c161fd65848f70d83e07a75c9
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Code is actually meant to identify the part in the layer from which the
events originates. Adding or removing an address is a command.
Change-Id: I42b4823d2585b15851c4fdd91802a13d2a5759c1
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Currently, only address related changes are handled.
Change-Id: I2aa366518dae2725e58cbede4ccbe2ef19cd8b16
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This will be useful when creating request and/or event codes.
Change-Id: Ibc117b476c52d72c77924a245e1f263f583061f6
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
The network interface naming macro is ignoring the
dev_name parameter. This can bring issues if having
more than one network interface in the system.
Change-Id: I7e975be61e82bd04bd865b0c4078607cbdef2230
Signed-off-by: Juan Manuel Cruz <juan.m.cruz.alcaraz@intel.com>
As the function does not modify the IPv6 address,
it can be const.
Change-Id: I2af58a4954d8b6f0d71bc7d0d14ddf0f62f8ca7c
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
While doing some documentation for it, I realized names were not all
good and it missed some stuff:
- what belongs to event should contain "event" in it
- we have a structur as callback so let's type the handler as a handler
- let's add the request handler signature
Change-Id: I18822cbcdc3c10e33600d6db38abab5ca73a228c
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
L2 RAW channel allows to use some functions of IP stack for RAW access
of network drivers. It is hidden from user and is selected by 2520 raw
driver.
Change-Id: I91dd09803052072dfddb7989d9d67c3a5840f89e
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
This adds the capability to raise an event, and for anybody to listen to
it.
Change-Id: I2287b43d678930c29391efa2ddf7b12652cc1bb6
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Define the ground mechanism to interact with the network stack.
Change-Id: Id2af76188967fa66e0f0d755a2c1dc8a85985540
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Two utility functions net_nbuf_read_be16() and net_nbuf_read_be32()
added which return either 16 or 32 bit big endian value.
Change-Id: I3401dde75669b429160c602a820359c800671afb
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit tries to improve inline documentation by refactoring
the original text. Missing information is also added, for example:
function return codes.
Change-Id: I940d4b6fa3e8079323e5e0ec1e5f63407505c9d9
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
The net_ipv6_set_reachable_time() was incorrectly named, the
correct name is net_if_ipv6_set_reachable_time().
The _if_ prefix needs to be there as the function is located
in net_if.c file.
Change-Id: Ic841328bdff92fbb90f51a199ebbee82d7b1c9fd
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Helper functions to read and write data across multiple fragments.
Write function always adds at the end of last fragment. If there is
no space in last fragment new data fragment will be created and added
to input buffer.
Read function start reading from offset of input fragment. If the
required data is located in mutliple fragments it reads from list
of fragments and returns position and fragment where read stopped.
Skip function start skipping from offset of input fragment. If the
required length is across multiple fragments it skip till length and
returns position and fragment where read stopped. This is useful
when reading with unwanted data (reserved or unhandled data).
These functions are quite useful when handling with multiple fragments.
Change-Id: I348b869108724602ae780a1cba4fe17d3af7ffc2
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
No need to store the nbr pool data into a dedicated section
as we have only one nbr pool defined.
Change-Id: I6f2afcce57b5f588878496bf085567b938e32c80
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
If the connection establishment has an error, the accept
callback needs to be able to return that error to user space
so that the application can know about it.
This is especially important in TCP where application needs
to start to listen again if reset is sent during connection
establishment.
Change-Id: I55f36e4f101c7237c1288f09baf6e602b33da2b3
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
So we can easily access TCP buffer that is stored
in net_buf.
Change-Id: I37ae728be45ded2fcc74735592d94897c945afbe
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This will remove given amount of data from the fragment list.
Change-Id: I17d809982af0b941f957205688ee61e5ac3c1f08
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This is needed because if there are more than one network
interfaces configured, then the second interface will point
to wrong address. Only solution to this issue is to align
the net_if to 32 byte boundary. The issue was seen in qemu
and it is not really known if the issue is present in real
hardware.
Change-Id: I2048c8a9a0aab51f84c15539159410b544f6c9b1
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Make sure that the statisitics compilation can be done even
if some sub-statistics module is not compiled, like IPv6 or
IPv4 statistics.
Change-Id: I1a91acd70569f074d9bb3269f74ee9c6a0ea9cf7
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Some of the DEBUG options for the new IP stack still used
the CONFIG_NETWORK_IP_STACK_DEBUG_ prefix.
Change-Id: I8f039ac5e303a7c571a870403ce17d758db540d5
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Implementing the primitives for non-slotted CSMA-CA radio protocol
according to section 5.1.1.4 in the 2011 version of the specification.
Slotted version will come when Beacon frame will be supported, thus
getting PAN coordinator info from its superframe.
Change-Id: I0545ed953a3c48e6b8e9cd4082db01ed66ad098b
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
- new stack options are renamed and placed in their respective menus
- new stack Kconfig gets normalized (tabs vs spaces, etc...)
Change-Id: Ia68f6589fed464bbdd76dc0812775684b2f94a58
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This will be necessary for devices that require to instanciate more than
one network interface.
Change-Id: I01fd4eb220ed63a4fe073614fb2a132cd00c6bc8
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Add socklen_t addrlen parameter to net_context_bind(),
net_context_sendto() and accept callback.
Currently the address length option is not really mandatory
as we can figure out the length from the address family.
But if we are going to support other protocol address families
it might be needed.
Change-Id: I59206465c3259050c469c5b2150221646a9a08d7
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The net_if.h is only meant for new IP stack.
Change-Id: I133d576d7c070dd4a2291544bd0b0401bda942b5
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
If the received IPv6 router advertisement contains prefix
address options, set the validity of the prefix and expire
them when needed.
Change-Id: I7026d2101bd9eca1f90688c14d5c6aaa66e4af5e
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The net_linkaddr_cmp() will compare two link layer addresses
and return true if they are the same.
Change-Id: I13f5ee9e7976a4118e891aefdb6e7c08f098c0b6
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This is the simplest - if not the dumbest - radio protocol we can use
for IEEE 802.15.4 stack. It just transmsits right away (with optional
retry) without taking care of doing any CCA (Clear Channel Assesment).
See IEEE 802.15.4 specification document, part 4.5.4.2
Change-Id: I341ad197aa221bc8f9ec67d0fd523da294a0351b
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
It currently supports the basics for the Data MAC service. A radio
protocol is still necessary to send packets.
Change-Id: I78f974ad7440d258583a5c7c6c7160e904eb54f4
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This new radio API will be provided by 802.15.4 device drivers in order
to fit in the new IEEE 802.15.4 stack within native IP stack.
Change-Id: Ib28e8dd3f25e5c802284568b88c2ea6d5cf58f89
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Allocate the right amount of space for L2's context.
Change-Id: Ia2f4f4162334e9e9c26dc95230abdfde5986e052
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
One might need to find out the proper interface from a given struct
device pointer.
Change-Id: Id480d0a2bdf57f0b2d38379727ea1491dedf213e
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
The dst_ip6 is a parameter, required for future 802.15.4 L2 layer.
At some point such parameter could be changed to a void pointer,
and a utility function would populate it depending on L2 layer,
if such parameter needs someday to be variable and complex (some
specific struct or else).
Also make sure we use ARG_UNUSED() relevantly, and using proper prefix
to functions.
Change-Id: I43297bb4fb48a8f1bb5075c216342db16261cbb8
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
CONFIG_NET_IPV6_ND enables ND packet processing, and we are thus
interested about the packet recv/sent/drop statistics.
Change-Id: Id281c924193bd2b1d71088bf40d47b1601daad5c
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
The send callback in net_context is called after packet has been
successfully sent or dropped. The callback is not called if the
packet is pending and waiting for example IPv6 ND to finish.
Change-Id: I28e77c6333974705a0e31862bb913eedace0b3f9
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The send callback should be called after the packet has been
sent so setup things allowing that.
Change-Id: Icb82f9896667dcb1e400376c0fca6df380509090
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The token is used by net_context.c when sending packet. User
can set the token and get it back when data has been sent.
This can be used to know what specific packet was sent if
there are multiple packets going at the same time.
Change-Id: Iaaf730faaa55a712ae22d903e612e44deb683b8f
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
In order to be consistent with naming, this commit renames
ip_protocol enum that is found in net_ip.h to net_ip_protocol.
Change-Id: Ie6caf059279b819794a13494468de789450e2bd8
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This API provides similar kind of functionality as BSD socket
API. This API does not provide BSD socket API.
Change-Id: I537d0ad2a5213f1d1e11fa7891dd4f4d0f3cc4bb
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
These are need in future commits. The sockaddr struct will hold
the IP address and port number among other things.
Change-Id: I0971c39f0f1cb019aa8610977a245e24548c56ee
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Changing the IP address type to const as the functions do not
modify the IP address.
Change-Id: I176d84af5f05843226a954f91b6bb3bba6596863
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Using network interface index instead of net_if pointer can
save 3 bytes of memory. So these utilities help to convert
pointer to index and vice versa.
Change-Id: I8743a06e0935d48798b19526154058be385550af
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
When checking the IP address from network interface, return
also the used network interface.
Change-Id: If7b8385193da4cb1b469f697e219cfae3b6477dd
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
IPv4/6 functions follows this scheme: net_if_ipv<4/6>_<name>.
Applying that to net_if_set_gw/net_if_set_netmask which are IPv4
functions.
Change-Id: I2dcbb16ce81cfdffbfbb5cae24ad76ddf2b9919a
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Reducing the amount of #if defined(CONFIG_NET_IPV<4/6>) for a clearer
code and to lower compiler's stress.
Change-Id: Iffbfbda4409c6cbf48a3057ea1b9e43309cd84e7
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Utility verifies given address is based on link layer address
or not.
Change-Id: I2b89e498fa2481051ec9a47ada8b4a5e8e38ad7a
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
If the link layer address is short address, create interface ID based on
short address.
Change-Id: I49e150cc20a0bf973880d27f418762f68f2d9139
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
While reusing buffers and passing those parameters might have
already some garbage. So just clear first and create iid.
Change-Id: I5774de157e0c39e7e7b1313a598557c58a4c63b0
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
Using macros does not let the compiler verifying about the type we are
providing, which usually give an error easier to understand.
Also, this will let the compiler deciding how to actually optimize
(inline or not) the code.
Change-Id: Iba49590b620ef0a1bd0ed5621453524fcfea747c
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This make sure we will found all relevant headers in the right location.
Change-Id: I37fe978ed2af09d921c48df6986a8df9041ddc3f
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Debug function that will print individual fragments and their sizes.
Change-Id: I84ce144230fb099bb44ed383075564ebf377998f
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The earlier Kconfig entries for IPv6 DAD and ND were confusing.
This commit will clarify this so DAD is activated by
CONFIG_NET_IPV6_DAD and ND is activated by CONFIG_NET_IPV6_ND.
These are settings are enabled by default.
Change-Id: If6245e3425489bc454a0d75113770c4f797a4017
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Provide an utility function that pushes data down in the fragment
chain which means that there would be some free space before the
first fragment.
Change-Id: I491ac4e8cbf633f86f2351cad48d683e829bda63
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Provide a function that checks if there is any free space
in the individual fragment and remove such slack. If there
are fragments that would become empty, then those fragments
are removed from the fragment list and freed to the fragment
pool.
Change-Id: Ieb1c953a1458622c4552c23ef38e330873cd27c3
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Create a handler for catching UDP network traffic. This commit
is only providing infrastructure for UDP management.
Change-Id: Ia6f8de62773a85f7b637b73bfe3c89197cc2abb1
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Added define for minimum IPv6 MTU value (1280 bytes)
Change-Id: Ia81d8b3df079a2bb9bfb0a05e297d94423ba0fc5
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Changed the net_is_ipv6_addr_unspecified() and
net_is_ipv6_addr_solicited_node() to use const IPv6 address
as those function do not change the address.
Change-Id: I1222bf946c371433a8468fa71054b93346e2ae4e
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
User can set the initial value for time-to-live option in Kconfig.
The TTL option is only used in IPv4.
Change-Id: I57677e65a2adee4aa4dc16d1504f848d1218c6c1
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This function will copy desired amount of bytes from one
fragment list to another. Caller can specify amount of
bytes reserved in front of the new fragment list.
Change-Id: Ie3344b285a47c79f116fbcff500d383a99d28bf9
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
It is possible to turn of IPv6 neighbor discovery if it is
not used in order to save some memory.
Change-Id: I20159dd452b7bac6962532a91e844c33f3da2dfb
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The ARP packet header contained ethernet header. This is very
confusing so separate the link layer header. Fixed also the
unit tests to run properly.
Change-Id: I8b00bde280ad9f49494766370acb2a8e9cade033
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
As the broadcast address is needed in both arp.c and ethernet.c
it is useful to create a utility function for returning that.
Change-Id: I26e75e325f7ee6dcd703a92b3349bd8d388e157e
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Because of commit 7720f6ed1c ("net: buf: Introduce support
for fragmentation") the net_buf should be placed into queue by
calling net_buf_put() when using fragmented data.
Change-Id: I5c3dae92596e9cb0d0ba166bc3de2da9f4fc24b7
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Caller can figure out what is the link layer header size
for a given link layer. There is a callback that can return
a dynamic header size if needed.
Change-Id: I59ea2319eb6cb53a0ba5c6aa9e7eecc4b38c94d3
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
We need to know where the L2 protocol source and destination
addresses are so save that information in nbuf.
Change-Id: I08677a0421effb0c997c6a68cfc02ccfa67e7e1e
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Add helper to check Ethernet broadcast and multicast address.
Change-Id: Icfe5508a4d3ab2364209a50150a4f8fe239ebc93
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The net_arp_init() was not properly declared if IPv4 was
not active.
Change-Id: I479b93f67c4536bcf9a081c36a6bc82dc5605c4c
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Use SYS_LOG instead of directly printing using printk()
Change-Id: I61cff11cf8424f726f24ea00b447f2f4827f2c9c
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The net_core.h accidentally overwrote SYS_LOG_DOMAIN with "net".
This must be done only for network related log domain.
Change-Id: I1050e430e8b649126e527f28c61d191ff34bbf2f
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Setting NET_DEBUG in nbuf.h will confuse the net_core.h
so it should not be done here. The NET_DEBUG can only be
set in .c file.
Change-Id: Ia95996147bf119c4ddf9f45a9fd635f8d2b405cb
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
There is no need to check if the sub-system is initialized
because net_init() is the only place that will call these
functions.
Change-Id: Icd54d2adf2924431cedd7c47124a3410842aeca3
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The network L2 recv handler needs to set the initial value for
IP protocol type (IPv4 or IPv6). Otherwise the recv data check
in net_core.c:process_data() will not work properly if IPv4
is enabled.
Change-Id: I5684cd10e5d79e13a977406729ea68313e689c9b
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This is the framework that neighbor discovery uses. The ND
is coming in later commits.
Change-Id: Iaaa67c80c0b6b8a3adb9217413b906e0a22d3920
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Various utilities for IPv6 address manipulation in network
interface.
Change-Id: I270f0935288abd77d64c0f64f56b549fb6c4feb9
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The IPv4 comparer was a macro but making it now a inline
function.
Change-Id: I315c52d812996e352e9b392627296ba229530ae0
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Adding a variant for net_linkaddr that can actually store
a link layer address. The normal net_linkaddr struct just
uses pointer to a ll address. The storage version is used
when we have a lladdr cache for neighbors.
Change-Id: I57421047f66090caf09595981c81d386144edce3
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
It is then clear what logic to expect once such verdict has been given.
Change-Id: Id64ff00e65ffe2dad45673d1eca4eb76ae3ae1f6
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
As there is a L2 in the middle, there is no need for
net_if to provide such information.
Change-Id: I58a35d4d124cd8a67026f32e71713ef06f43b7c5
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Net core then does not know anything about l2 related logic.
For instance ARP is used in ethernet l2 API and nowhere else.
This will be helpful when adding different technologies altogether.
Currently, only SLIP driver is enabled to use relevant l2 layer.
Change-Id: I03c93326321028d04222733ca4083e3c6b785202
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
net_core.h is the ground brick of the IP stack, and thus should not
include other headers that might include net_core.h also: this would
create circular dependencies.
Change-Id: I70c17b736788528e4e0b4b5b2c478098b049c9b1
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Makes code cleaner so it won't be necessary to access the net_if
internal queue directly.
Change-Id: I119a54e0639843093fa0da6f11e590e8990525d8
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This is meant to stay in 80 chars line length limit.
Change-Id: Ib3b3b1cf5e05fec2407e470ae3600ff5a4c6a505
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
__packed is an alias for __attribute__(packed) and is declared in
toochain's headers.
Change-Id: Ib9d136a1a2dd401194988d6573bf7778f07dbfb6
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
The network device driver can specify what kind of functionality
it supports. Currently there exists one flag that can be used
in ethernet devices that tells if ARP should be enabled or not.
Change-Id: Ieaaefcfc7cdd65f44190248f507ac3cb512a323e
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>