Commit graph

1260 commits

Author SHA1 Message Date
Jukka Rissanen e0e682eb66 net: Add TX fifo to network interface
Network packets to be sent are placed to correct fifo that
is allocated to certain network interface.

Change-Id: Idd5eded42758c5bed2c18769122c38d9d03dc419
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:00 +02:00
Jukka Rissanen 510ebe255d net: Add IPv6 prefixes to network interface
Change-Id: I34c75eec6068abbd6af1eac2e178e42ce382b128
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:00 +02:00
Jukka Rissanen ad848dcfbf net: Add multicast address to network interface
Change-Id: Ifc09d2e1d3ac44ab0f5980ee17299119fbe2a867
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:00 +02:00
Jukka Rissanen ac479e19b8 net: Add network address information to interface
Change-Id: I14b9257362a1e6f4144900c7acde6a125ecf6a02
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:00 +02:00
Tomasz Bursztyka 2fa38c18f0 net: Add generic network interface header
This will be used by the new network stack to relate a device to actual
network context, and used in the different layers (mac, ip ...).

Change-Id: I30c08fa975314544c36b71636fd9653d562891b3
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:00 +02:00
Jukka Rissanen b9289f176c net: Add ntohl() and related macros
Change-Id: Ia329a63644eab8ca1ce6debb8f7e7b97b8de711d
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:00 +02:00
Jukka Rissanen 9c5a6d17e2 net: Add defines for various IP protocol header lengths
Change-Id: I05dcb7a26f50cd0c8d544c5d829e1154ed3f8119
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:00 +02:00
Jukka Rissanen a3b88f53c4 net: Initial commit for the new IP stack
This is a placeholder that compiles but does nothing else.

Change-Id: I9689fa26eb13bc23d29940938f7b3c11f32b2ff1
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:39:59 +02:00
Luiz Augusto von Dentz 8062f6ea5a net: buf: Add extra logic when debug is enabled
In case of invalid behavior such as error or warnings print caller
function name and line number so it is easier to track back when there
there is a problem.

Change-Id: I3a5f4c7f63e0560fe0cf6f25936b079f127776a8
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-11-28 14:57:44 +00:00
Benjamin Walsh f6ca7de09c kernel/arch: consolidate tTCS and TNANO definitions
There was a lot of duplication between architectures for the definition
of threads and the "nanokernel" guts. These have been consolidated.

Now, a common file kernel/unified/include/kernel_structs.h holds the
common definitions. Architectures provide two files to complement it:
kernel_arch_data.h and kernel_arch_func.h. The first one contains at
least the struct _thread_arch and struct _kernel_arch data structures,
as well as the struct _callee_saved and struct _caller_saved register
layouts. The second file contains anything that needs what is provided
by the common stuff in kernel_structs.h. Those two files are only meant
to be included in kernel_structs.h in very specific locations.

The thread data structure has been separated into three major parts:
common struct _thread_base and struct k_thread, and arch-specific struct
_thread_arch. The first and third ones are included in the second.

The struct s_NANO data structure has been split into two: common struct
_kernel and arch-specific struct _kernel_arch. The latter is included in
the former.

Offsets files have also changed: nano_offsets.h has been renamed
kernel_offsets.h and is still included by the arch-specific offsets.c.
Also, since the thread and kernel data structures are now made of
sub-structures, offsets have to be added to make up the full offset.
Some of these additions have been consolidated in shorter symbols,
available from kernel/unified/include/offsets_short.h, which includes an
arch-specific offsets_arch_short.h. Most of the code include
offsets_short.h now instead of offsets.h.

Change-Id: I084645cb7e6db8db69aeaaf162963fe157045d5a
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-11-12 07:04:52 -05:00
Szymon Janc 2f45faba8c net: buf: Use unified k_fifo API for FIFOs
Only net_receive() is using non-special value for net_buf_get_timeout
so this change is included here. Other users are using special values
which are already correctly handling ticks vs ms change.

Change-Id: Ib12d34ac5a546b36fa7b35615f082c82a256bd07
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-11-11 06:00:17 +00:00
Szymon Janc ccadd4b006 net: Use proper format for printing size_t
size_t should be printed with %zu. This also fix build error on
unified kernel due to ZEP-1133.

Change-Id: I9c5fc7f7de365e47bd0973913b94baa80f7907e3
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-10-27 08:08:27 +00:00
Luiz Augusto von Dentz 76240677d9 net: buf: Make net_buf_frag_add take ownership of the buffer
This simplify buffer handling so that no extra references are needed.

Change-Id: Id99a0a75b39ca8db2216668f76c5a672713075ae
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-10-26 12:48:47 +00:00
Anas Nashif 45616f24e7 Revert "net: fetch valid conn. to determine MSS in data_is_sent_and_acked()"
This reverts commit 627feb92d4.

This patch breaks TCP/IPv4 support in echo_server.

Change-Id: Ia1e2cf8dfa94f845d3a8282c83bba40b36ee782c
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-10-14 07:12:06 +00:00
Rohit Grover 627feb92d4 net: fetch valid conn. to determine MSS in data_is_sent_and_acked()
Packets sent out through net_tx_fiber go through psock_send() where
they wait for data_is_sent_and_acked() to process them.
data_is_sent_and_acked() looks at the underlying connection's
MSS (maximum segment size) before putting them on the wire through
uip_send(). The trouble is that that linkage between the outgoing
buffer and the connection hasn't been established at the point
data_is_sent_and_acked() is called--this normally happens through
a call to uip_set_conn().
So data_is_sent_and_acked() fetches an invalid connection handle
and makes its choice using an arbitrary MSS. In my particular case,
this arbitrary value was 0, and so packets weren't being sent out.

Change-Id: I42e8ae104ac20f8df8780c8aee6964ed37113ba0
Signed-off-by: Rohit Grover <rohit.grover@arm.com>
2016-10-08 21:20:28 +00:00
Johan Hedberg 27fc467e74 net: buf: Allow NULL head pointer when inserting to frag list
To avoid extra logic in code that creates net_buf fragment lists, make
it possible to pass a NULL pointer as the head net_buf when there are
no previous buffers. Before this change the code would look like this:

	if (head) {
		net_buf_frag_add(head, buf);
	} else {
		head = net_buf_ref(buf);
	}

After the patch the code can simply do:

	head = net_buf_frag_add(head, buf);

This will then do the right thing regardless if head is NULL or
non-NULL.

Change-Id: I300394242e2e243ed3839b25629ec816dd98c148
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-09-30 15:07:32 +00:00
Johan Hedberg 8afb6fc229 net: buf: Allow head deletion with net_buf_frag_del()
Extend the net_buf_frag_del() API to be usable for deleting the head
of a fragment chain. This is useful when parsing a stream-based
protocol encoded into a fragment chain, making code such as the
following possible:

	...parse data from 'head' buffer...

	/* If current buffer is empty, move to the next one */
	if (!head->len) {
		head = net_buf_frag_del(NULL, head);
	}

Change-Id: I65794bd7fab4e6dadfd2d6b2fa367f9424fd1bde
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-09-30 15:07:32 +00:00
Ravi kumar Veeramally 69236fd49a net: Fix net_send return value documentation
If net_send() is success, do not unref the buffer. Free the buf
when it returns error.

Change-Id: Ic154879dfb583d52a0b12fd3e8bfc390a24efec9
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-09-12 02:19:57 +00:00
Inaky Perez-Gonzalez 3e63a74514 net/yaip: revert merge
Follow up to TSC decission for further discussion in the networking
WIG.

Change-Id: I148b484dfe308661573e47ed3e60cceed673bddf
Signed-off-by: Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
2016-07-22 04:43:09 +00:00
Johan Hedberg e088b06e44 net: buf: Add API for saving & restoring parsing state
Occasionally it may be useful to pass a buffer to a subroutine and
have the routine do parsing of the buffer. However, since there isn't
necessarily a guarantee of how the subroutine performs the parsing it
may be necessary to restore to a well known state after the routine
returns.

This patch adds a simple struct for storing the parsing state as well
as two new functions to save and restore the state.

Change-Id: If9153ff9997021c76243ea9ebff13dfe94c45faa
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-07-20 14:51:24 +03:00
Johan Hedberg 1de77488ae net: buf: Add net_buf_add_be32 helper
Add helper to add 32-bit big endian data to net_buf and
net_buf_simple.

Change-Id: Ib6359558abcbed824365928327277ad69aa51e99
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-07-19 11:13:08 +03:00
Johan Hedberg 94aa7e6cb0 net: buf: Minor cleanups & fixes to the API documentation
Rename left-over mentions of 'bt_buf' and ensure that all parameter
descriptions end with a period.

Change-Id: Ie63e63920a8bfea2d02806a65306421264c9f89b
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-07-14 05:10:13 +00:00
Johan Hedberg 477fedcf1f net: buf: Add more big endian helpers
Change-Id: I3f8d9a2810359a0cc7b7ce2097f86e03fa35d3bc
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-07-13 14:11:37 +00:00
Johan Hedberg 77dfa93f47 net: buf: Add helpers to use net_buf_simple stack variables
Add a macro to easily define net_buf_simple stack variables, as well
as a helper to initialize them.

Change-Id: I3e4ffc172843a0946e8159618c8f84a87fc682bc
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-07-13 14:11:26 +00:00
Jukka Rissanen d0daa97820 net: yaip: Moved ARP helper macro to arp.h
The helper macro NET_ARP_BUF() needs to be used from other
files so arp.h is proper place for it.

Change-Id: Ief7bbb385d9c180213ecd7cb08023f13999f5270
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-13 14:06:23 +00:00
Tomasz Bursztyka 56a747ead4 net: yaip: Add comment explaining net_core's verdict values
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>
2016-07-13 14:06:23 +00:00
Jukka Rissanen 902912adbb net: yaip: Add NET_ASSERT() macro
Change-Id: Ie98da69fbd1cf277a5d517736217209c85180416
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-13 14:06:22 +00:00
Tomasz Bursztyka 5c64a078f4 net: yaip: Removing capabilities() from net_if api
As there is a L2 in the middle, there is no need for a net_if to provide
such information.

Change-Id: I58a35d4d124cd8a67026f32e71713ef06f43b7c5
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-07-13 14:06:21 +00:00
Tomasz Bursztyka d8f0b9ffed net: yaip: Add an L2 layer
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>
2016-07-13 14:06:20 +00:00
Tomasz Bursztyka bb1fe0c147 net: yaip: Make net_core.h include the least amount of necessary header
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>
2016-07-13 14:06:19 +00:00
Tomasz Bursztyka 1f9f3e138b net: yaip: Add an helper to queue a buffer in a net_if instance
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>
2016-07-13 14:06:19 +00:00
Tomasz Bursztyka bbf7d35001 net: yaip: Shorten IPv4/6 config options
This is meant to stay in 80 chars line length limit.

Change-Id: Ib3b3b1cf5e05fec2407e470ae3600ff5a4c6a505
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-07-13 14:06:18 +00:00
Tomasz Bursztyka 514f184350 net: yaip: Include toolchain related header for aliases
__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>
2016-07-13 14:06:17 +00:00
Ravi kumar Veeramally 4450a41532 net: yaip: Fix __packed attribute, use shorter alias
Change-Id: I5bee3f1a9cf8629151734fc85b2c3e6097232cc0
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-07-13 14:06:15 +00:00
Ravi kumar Veeramally 7789df23d1 net: yaip: Add UDP header
Change-Id: I2f3bba1014cf598bed7606d5d43b3653052b1f7f
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-07-13 14:06:15 +00:00
Ravi kumar Veeramally 2cdbb932df net: yaip: Trivial comment fixes in header files
Change-Id: I2f3bba1014cf598bed7606d5d43b3653052b1f88
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-07-13 14:06:14 +00:00
Ravi kumar Veeramally 3ef38a6e05 net: yaip: Provide separate header file for ethernet
Change-Id: I2f3bba1014cf598cdd7606d5d43b3653052b1f7f
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-07-13 14:06:14 +00:00
Jukka Rissanen 6fd8c1750d net: yaip: Add helper to get pointer to link local header
Change-Id: I079fb35e26499797f14f233b69a152ab1c86f9d0
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-13 14:06:10 +00:00
Jukka Rissanen fabdce2899 net: yaip: Added IPv4 ARP support
Small IPv4 ARP cache that is used in Ethernet networks.

Change-Id: I9ab38ee14a799f8573f4d4e0eade1be107d42f1a
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-13 14:06:07 +00:00
Jukka Rissanen 9de396cfb9 net: yaip: Add capabilities flag to net_if API
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 that ARP should be enabled.

Change-Id: Ieaaefcfc7cdd65f44190248f507ac3cb512a323e
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-13 14:06:07 +00:00
Jukka Rissanen 892a76745f net: yaip: Add util to check if IPv4 address is part of subnet
Change-Id: I6005861a4c4085b6c17ded03fda38a567a4e504a
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-13 14:06:06 +00:00
Jukka Rissanen 575ad92ffd net: yaip: Add utils to set IPv4 netmask and gateway in net_if
Change-Id: I52bcea3749aa5fb4e12b18fd9fd9a3907842bf01
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-13 14:06:06 +00:00
Jukka Rissanen 554c83f1de net: yaip: Macro to compare two IPv4 addresses
Change-Id: I2af022d8a8df4c174e044d033a23d5912297e495
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-13 14:06:05 +00:00
Jukka Rissanen 630339064c net: yaip: net_ipaddr_copy() macro was too fragile
Making sure we are doing the IP address assignment correctly.

Change-Id: I8bf9233b932321a14df99ce49a39581f1343d004
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-13 14:06:05 +00:00
Jukka Rissanen b826212ed7 net: yaip: Add utility function returning IPv4 broadcast address
Change-Id: Ibe4f5ad530f6a0f50137ef2cd8e64dbc9de6cba1
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-13 14:06:05 +00:00
Johan Hedberg 497268503e net: buf: Add complete net_buf_simple implementation
This just renames the existing net_buf helper APIs to corresponding
net_buf_simple APIs and then defines the old net_buf API names as
macros mapping to the new net_buf_simple helpers.

Change-Id: I3c2b35683c0fde66f5f697be2c34c01172af8e31
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-07-13 14:05:32 +03:00
Johan Hedberg 2d5bfe2f1f net: buf: Introduce net_buf_simple object
The object has the same layout as the last fields of the existing
net_buf. To maintain backwards compatibility net_buf receives a union
so that the old data, len and size members can be accessed as before,
however they are located in the same memory as the actual
net_buf_simple members.

Change-Id: I22d208faba30fe41c5ada17e6d13e641f528729a
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-07-13 09:34:42 +00:00
Johan Hedberg 4e833a6522 net: buf: Group the data, size and len members at the end of net_buf
This is in preparation of introducing a new net_buf_simple object &
API.

Change-Id: I624b86e5d2c9f4e9d3647b2fe21ce8b89750256f
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-07-13 09:34:22 +00:00
Jaakko Hannikainen cf3fe37962 net: Add documentation about yielding
Now that net_send and net_reply yield, this behaviour should be
documented.

Jira: ZEP-469
Jira: ZEP-497

Change-Id: I8c3cf7bda009aa6e89f880447fd3b6a491f5d9ef
Signed-off-by: Jaakko Hannikainen <jaakko.hannikainen@intel.com>
2016-07-13 09:20:11 +00:00
Jukka Rissanen ebfa17eebe net: yaip: Add utility function to return default network interface
Change-Id: Ia64d263831e2842883404d25b7ea429bea80ca1d
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-12 19:20:58 +00:00
Jukka Rissanen 30b07ad70a net: yaip: Process received ICMPv4 messages
Call ICMPv4 handler when receiving such a network packet.
Currently only echo-request is handled.

Change-Id: Ib59c65b38f13c484f1842485118dad32fb6a6f36
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-12 19:20:57 +00:00
Jukka Rissanen 4eb4ee49f5 net: yaip: Network interface needs own TX fiber stack
Each network interface needs its own stack for TX fiber.

Change-Id: I9647c2b945a3d36bc77c00dad11badb0d5f851e5
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-12 19:20:53 +00:00
Jukka Rissanen cada55f5be net: yaip: Add net_send_data() that sends data to network
This function is not meant to be used by applications as it
requires that the IP headers etc. are already in place.

Change-Id: I9099671111a029cdf630d131d7af09b147486f64
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-12 19:20:53 +00:00
Jukka Rissanen de67431a43 net: yaip: Renamed network data receive function
Renamed net_recv() to net_recv_data() so that the more generic
name can be used by applications. The net_recv_data() is only
meant to be used when L2 layer feeds data into L3 (IP) layer.

Change-Id: Iba155d51f81e3b99964fa916fe87a05a8bf8766a
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-12 19:20:52 +00:00
Jukka Rissanen cb2191652e net: yaip: Add ICMP protocol header struct
Add a macro to get and cast the ICMP protocol header.

Change-Id: Ief3f69d1b3dbe9dd55bc0a032b3506c8e0370563
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-12 19:20:51 +00:00
Jukka Rissanen 1b2069c61c net: yaip: Fixed the IP/UDP/ICMP getter macros
The nbuf macros for getting the pointer to start of IP, UDP
and ICMP buffer were incorrect.

Change-Id: I6309bd50cdf2cbf0c6c23b4b349c7c084cfe928d
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-12 19:20:51 +00:00
Jukka Rissanen 7150b0035c net: yaip: Added API documentation to IP address check functions
Some API functions that check IP addresses were not documented
properly.

Change-Id: I0e7361447db55037888c62ada6b55e3cf5f410f7
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-12 19:20:50 +00:00
Jukka Rissanen fbb940d9f0 net: yaip: Receive IPv4 packet
Check if we have received IPv4 packet and call a handler
function to process it.

Change-Id: I9f9e5f0888d2c3b91401c98f4925647ddce09962
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-12 19:20:50 +00:00
Jukka Rissanen d85fa3fe2d net: yaip: IPv6 address utility funcs for network interface
Added more functions to get proper IPv6 address from
a given network interface.

Change-Id: I5aecdb35eb549a0781949134ab4821dcb8ce9e7b
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-12 19:20:49 +00:00
Jukka Rissanen 272c8a62a1 net: yaip: Add IPv4 addresses to network interface
Allow user to assign IPv4 addresses to a network interface.

Change-Id: I77be4ed5eb0231eb12b4ad47cb6076c8f4238124
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-12 19:20:48 +00:00
Jukka Rissanen 208d558f68 net: yaip: Utilities to set and lookup interface IPv6 addresses
The caller is able to add and lookup network interface IPv6
addresses.

Change-Id: I7f43e18bd1fa69c7dcd2f6b46ad33043c28b92e9
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-12 19:20:47 +00:00
Jukka Rissanen a08376cc32 net: yaip: Add utility functions to check IPv6 addresses
IPv6 utility functions that check if a given IPv6 address
belongs to one of host network interfaces, and whether
the address is a given type.

Change-Id: If251534ae0af41963d45e305e7ba505a940d2fdc
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-12 19:20:47 +00:00
Jukka Rissanen 644dc3ba81 net: yaip: Add utility func to return IP address type as a string
This is only used in debugging.

Change-Id: Ie8b1d2540813527131ff489e49975a826b84311c
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-12 19:20:46 +00:00
Jukka Rissanen 3308e95b97 net: yaip: Add extension header and bitmap fields to nbuf
These are needed when parsing IPv6 packet.

Change-Id: I56ab93d45727c57f2d9db47baeb5b5a3725a0c46
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-12 19:20:46 +00:00
Jukka Rissanen e54c565337 net: yaip: Drop received source mcast IPv6 packets
If the source address is multicast, then drop the IPv6 packet.

Change-Id: Ibe733161d67f047469a25a5955c41c335e472945
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-12 19:20:45 +00:00
Jukka Rissanen d9c3552e00 net: yaip: Receive IPv6 packet
Check if we have received IPv6 packet and call a handler
function to process it.

Change-Id: I1226729685ae2a805128b587e2a37e0016d53ecc
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-12 19:20:45 +00:00
Jukka Rissanen 27dcfc3efd net: yaip: Add statistics gathering support
Collect network statistics if CONFIG_NET_STATISTICS is
defined.

Change-Id: Id217daa3e19142c95396dc391ba2dc4123b18b22
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-12 19:20:43 +00:00
Jukka Rissanen c43212d63c net: yaip: Add net_context to compilation
Network context defines network endpoints a.k.a sockets.

Change-Id: Ib1fab03f0862b298a441a79a4f4173f18a8260cb
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-12 19:20:43 +00:00
Jukka Rissanen 5a3834915d net: yaip: Start to receive network packets
Currently all received packets are dropped as this is just
the initial patch enabling the receive support.

Change-Id: Ib06735f498a80edb8c9f7c5ec6f536a5ac1d362a
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-12 19:20:42 +00:00
Johan Hedberg ce88b0528f net: buf: Add basic documentation for net_buf struct
Change-Id: I93404bcafb72c174a216d3e441c5434a7302c128
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-07-12 11:39:23 +00:00
Johan Hedberg 40d83b28e6 net: buf: Fix documentation of fragment related API
Ensure that all parameters and return values are properly documented.

Change-Id: I04b19701355e994ba45cbc98167386c01d0f607b
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-07-12 11:35:49 +00:00
Jukka Rissanen 6bd7430a34 net: yaip: Start to use logging macros from sys_log.h
Instead of directly calling printk/printf, the network printing
macros will use syslog macros defined in sys_log.h

Change-Id: I3f12f81557f50b24ca47a43f345162f9ffbd574c
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-12 07:23:49 +00:00
Jukka Rissanen b133b01d67 net: yaip: Add send() to net_if API
The send() function is called from IP stack and it is used
when the network packet needs to be send via a specific
network interface.

Change-Id: Id6ce86b1748915fee73b62366dee13fcb7cf11a1
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-12 07:23:41 +00:00
Jukka Rissanen 17ddda8721 net: yaip: Add net_if_get_by_link_addr() util function
This will return the network interface that has some specific
link address.

Change-Id: Iaebcf6e769d4f91f3cda6d3a0779324f89603b54
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-12 07:23:24 +00:00
Jukka Rissanen a8aabd8571 net: yaip: Add net_analyze_stack() macro
This macro can be used to check stack usage. It should only
be used when debugging is activated.

Change-Id: I99fe6f9db1f3e955152a91f3a18d031126172cfd
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-12 07:22:48 +00:00
Jukka Rissanen bc24ec86fe net: yaip: Fix compilation error in net_if.h
The NET_IF_INIT() macro used parameter pasting incorrectly.

Change-Id: I40a988ffb06ce135731cd69f18931b7507cd71cc
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-12 07:22:40 +00:00
Jukka Rissanen b7bc53ece9 net: yaip: Add nbuf buffer API
User should use the net_nbuf API that is supporting a concept
of RX, TX and DATA buffers, instead of using directly the net_buf
low level API.

Change-Id: I3b8f5f13cd37d42d2322a58b35573e117d520c54
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-12 07:22:24 +00:00
Jukka Rissanen c630347683 net: yaip: Compile IPv6 and IPv4 address conditionally
Save 12 bytes per IP address if IPv4 is active and IPv6 is not.

Change-Id: Ia01d2feb83e6ba80b2775f9eed3065c956932632
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-12 07:22:14 +00:00
Jukka Rissanen 6c6a3856bc net: yaip: Add function that feeds data to RX fifo
Network drivers should call this when new data has been
received from network.

Change-Id: Ife78fa0683b8c410c38358300a6a18e9325f0ef8
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-12 07:22:05 +00:00
Jukka Rissanen 5a90d28a72 net: yaip: Add TX fifo to network interface
Network packets to be sent are placed to correct fifo that
is allocated to certain network interface.

Change-Id: Idd5eded42758c5bed2c18769122c38d9d03dc419
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-12 07:21:47 +00:00
Jukka Rissanen 61aae6ab27 net: yaip: Add IPv6 prefixes to network interface
Change-Id: I34c75eec6068abbd6af1eac2e178e42ce382b128
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-12 07:21:30 +00:00
Jukka Rissanen daf4871e36 net: yaip: Add multicast address to network interface
Change-Id: Ifc09d2e1d3ac44ab0f5980ee17299119fbe2a867
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-12 07:21:21 +00:00
Jukka Rissanen d4e0025eb7 net: yaip: Add network address information to interface
Change-Id: I14b9257362a1e6f4144900c7acde6a125ecf6a02
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-12 07:21:12 +00:00
Tomasz Bursztyka 5f165e743f net: Add generic network interface header
This will be used by the new network stack to relate a device to actual
network context, and used in the different layers (mac, ip ...).

Change-Id: I30c08fa975314544c36b71636fd9653d562891b3
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-07-12 07:20:51 +00:00
Tomasz Bursztyka 257379d0ff net: Add header file for generic link address
It only describes the structure for now, but will then provide helpers.

Change-Id: I7ac7717a3289086dac50d90e25b2a1ce7d7abc91
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-07-12 07:20:40 +00:00
Jukka Rissanen 8e7007c26f net: yaip: Add ntohl() and related macros
Change-Id: Ia329a63644eab8ca1ce6debb8f7e7b97b8de711d
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-12 07:19:51 +00:00
Jukka Rissanen 7db376cfec net: yaip: Add defines for various IP protocol header lengths
Change-Id: I05dcb7a26f50cd0c8d544c5d829e1154ed3f8119
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-12 07:18:45 +00:00
Jukka Rissanen 75ae39518c net: yaip: Initial commit for new IP stack
This is a placeholder that just compiles but does nothing else.

Change-Id: I9689fa26eb13bc23d29940938f7b3c11f32b2ff1
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-12 07:18:06 +00:00
Jukka Rissanen 83707d5675 net: buf: Calculate amount of bytes in fragments
Utility function net_buf_frags_len() calculates amount of data
stored in the fragments.

Change-Id: I89ebc8dac4f216ff9e77b5c44002082398957f7b
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-11 18:06:24 +00:00
Jukka Rissanen 4605a3771c net: buf: Add fragmentation API support
User can add fragments to the network packet if the data cannot
be placed in one buffer.

Change-Id: I060ef533cc4fdda0f38405fb7dc72015f5cac7fc
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-11 15:37:45 +00:00
Johan Hedberg abc142bdc3 net: buf: Add net_buf_push_u8() helper API
This is similar to the other net_buf_*_u8() helpers that already
exist.

Change-Id: I63fc963877c1946964e675067dd98f748be7cbbc
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-07-09 15:43:31 +03:00
Johan Hedberg 30cb395bbf net: buf: Add big-endian helpers
Add helpers for big-endian 16-bit values, similar to the ones that
already exist for little-endian values.

Change-Id: I63bf4dd7df802669ea6657cd95d6da48e6176487
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-07-09 15:43:31 +03:00
Johan Hedberg 727a2459b1 net: buf: Add net_buf_reserve() API
This API allows initializing the buffer with a given headroom. This
prepares the way for eventually removing the 'reserve_head' parameter
from the net_buf_get APIs, but can already now be useful in some
scenarios where the headroom is desired to be different than some
higher level API sets it to be.

Change-Id: Iffbe5761fdf3d2ad8cb4b8437b1074cf42ea9c6c
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-07-09 15:43:31 +03:00
Johan Hedberg e03151ee3e net: buf: Use precise buffer size given to NET_BUF_POOL
Until now, NET_BUF_POOL() would be opportunistic and allocate a few
more bytes extra for the buffer content if the given size wasn't a
multiple of 4. This is an issue however if the API user really wants
to have a precise size for the buffer so that e.g. net_buf_tailroom
gives meaningful and deterministic results.

This patch removes the opportunistic rounding up, basically leaving it
up to the application to decide if it wants to have unused padding in
the data structure or not.

The crucial thing here is to ensure that locating the user data
section (which is aligned to a 4-byte boundary) doesn't break, since
buf->size is used for that. However, the net_buf_user_data()
implementation already uses ROUND_UP() so the result will still be
the same even if buf->size is not a multiple of 4.

Change-Id: I4bc17139cda19a680180c2d326d417a41ad0d4cd
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-07-09 15:43:31 +03:00
Tomasz Bursztyka 0e0509b67f net: Let's use inline function for type checking for net_buf
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: I17fb1f5a1c1854461fad101bbb40c9be33844c8b
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-06-22 16:43:29 +00:00
Tomasz Bursztyka 06717d3196 net: Fix documentation of buf.h
Make sure all is documented, and the comments properly formated.

Change-Id: I7431535b0f3a409e63ac4b12c421be662098eed1
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-06-22 13:34:46 +00:00
Johan Hedberg 7720f6ed1c net: buf: Introduce support for fragmentation
Introduce support buffer fragment chains that are linked together.
This is done with the help of a flag while the buffer is inside a FIFO
(indicating that the next fragment follows it in the same FIFO) and
with the help of a "next" pointer while the buffer is outside of a
FIFO.

In order to do proper "marshaling" a new net_buf_put() API needs to be
always used when inserting a buffer into a FIFO. Respectively, the
net_buf_get() and net_buf_get_timeout() functions are extended to
support getting buffers from arbitrary FIFOs and reassemble the
fragment chain based on the flags that the received buffers contain.

The insertion of a fragment chain using net_buf_put() into a FIFO is
done atomically with the help of irq_lock/unlock since FIFOs support
multiple writers, however since there's ever only a single reader per
FIFO similar locking is not necessary there.

Change-Id: I0ec579f63ea8d063f50e3f1f4c2e80ec399622d7
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-06-06 08:17:24 +03:00
Johan Hedberg 6e4d2a9e0e net: Add net_buf_get_timeout() API
With this API it's possible for the caller to force specific behavior
when it comes to waiting (or not waiting) on the FIFO.

Change-Id: Ib66e2f767c26c82abf1ba3b80bd15aec2383542e
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-06-02 10:32:20 +00:00
Ravi kumar Veeramally 5e99b14ad4 net: 6lowpan: Fix 6lowpan fragmentation
IP packet passing through 6lowpan compression and 802.15.4
fragmentation has an issue. (RFC 6282 and 4944) RFC4944, 5.3
says "fragment header's datagram_size and datagram_offset
values as the size and offset of the IPv6 datagram before
compression".

At the moment datagram size and offset values are after
compression. Due to multiple bearer (15.4 and bluetooth) support
and multiple incoming buffers support functionality is divided
to compression and fragmentation parts. And datagram size and
offset values for BT are after compression. Small packet (which
doesn't need fragmentation) doesn't go through this. So cacheing
compressed and uncompressed header lengths and with hdr difference
preparing fragments as per original buffer (total buf size and offset).

Change-Id: I9d3b0433e64964c68519d7c007cc06ec6035b573
Jira: ZEP-208
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-05-19 14:18:38 +00:00
Jukka Rissanen 3b7208db84 net: Do not wait forever when sending TCP data
If application calls net_send(), set the retry count to some
low number (currently 5) so that we do not wait forever but
eventually we try to send the data properly.

Change-Id: I8103246ac9227a0cf70b56aecab6ed8307877e19
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-05-17 09:57:28 +03:00
Jukka Rissanen 662ce340be net: Add functions to return connection status needed in TCP
These are internal functions needed when initiating a TCP
connection.

Change-Id: Ide5d59ac9854ec8bdea3baa97b3cde3ffa6a5e0f
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-05-17 09:57:28 +03:00
Arkadiusz Lichwa e59773bb48 net: buf: Add net_buf_pull_le32() helper API
The function gets 32bit-wide data from net buffer and converts the
value from little endian to host order.

Change-Id: I2d2454951b3ac39686a25454678ce92d8a1a0f3d
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-05-15 19:39:14 +00:00
Arkadiusz Lichwa fcb6e03021 net: buf: Add net_buf_add_le32() helper API
The function gets 32bits wide data, converts host order to little
endian and then puts the data on protocol stack to be send.

Change-Id: I29e4040b302a16b551a0922133c327ff694fec5d
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-05-13 07:55:39 +00:00
Jukka Rissanen ad2e661569 net: Enable TCP support
User can enable TCP server (listening socket) support in the
IP stack. This commit does not yet have TCP client (connecting
socket) support.

Change-Id: I75dd02a81addc1d1e026463b53631d56378157df
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-04-25 09:40:32 +03:00
Jukka Rissanen bf5d208f25 net: buf: Add helper for catching ref counting errors
Add ip_buf_ref() helper that helps to track the calls to
net_buf refcounting in IP stack.

Change-Id: Ie5f5a5d57b6ffcb20df4fbc9f25c6c73a99589df
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-04-18 12:07:20 +00:00
Vlad Lungu 0667c0fe0e net: contiki: move neighbor_list to struct l2_buf
When using the CSMA MAC driver, a new packet can be queued before
all the fragments of the previous one were sent. The transmit_packet_list()
function will start sending the old fragments with the new net_buf context.

Keep a per-context neighbor_list to avoid that

Change-Id: I9d41a923c48f597cc95a8f8c9f67884c5caac02c
Signed-off-by: Vlad Lungu <vlad.lungu@windriver.com>
2016-03-16 14:20:56 +00:00
Jukka Rissanen cd8d4eb2b7 net: User must provide storage for local IP address
When user creates a socket using net_context_get(), the function
requires local endpoint IP address. This should not be a NULL
pointer because the storage for that IP address was statically
allocated inside the function. Because of this the user needs
to allocate the storage for this and pass that local IP address
to the function. The net_context_get() will fill that local
address to sane value if user passes ANY address (== all bytes
are zeroes) to it.

Change-Id: I88314957f07912d9ecbe517a2402822401d81bd9
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-03-14 11:05:52 +00:00
Tomasz Bursztyka 050ec13556 net: ip: Make sure CONFIG_NETWORKING_WITH_LOGGING is properly handled
If the user unsets CONFIG_NETWORKING_WITH_LOGGING, it will mean he
really doesn't want to get any network stack logging output.

Change-Id: I0629a045adbf8916327a8a9ba69b6e6e9ee2e7d9
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-02-19 12:33:45 +00:00
Johan Hedberg 9d6aaa1cc7 net: buf: Add net_buf_pull_u8() helper API
A helper for the (fairly common) task of decoding individual 8-bit
values.

Change-Id: Id7e97df152232d5dd9861cf1e107877f1b8febaa
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-12 15:10:20 +00:00
Peter Mitsis 61f7a13cfc net doc: Fix parameter names in documentation
Change-Id: I3a58e500d691254a09c922c248beaca0c5569e09
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-02-11 20:11:03 +00:00
Johan Hedberg 754248aedc net: buf: Add convenience API for adding 8-bit integers
There are many situations when encoding data when we need to insert
single bytes to the buffer. With this helper the encoding code stays a
bit more readable.

Change-Id: Ibc0ce43af5ae25a1baa0f1adbc5816ae7c04e3bb
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-11 11:14:20 +02:00
Jukka Rissanen 6d2276e160 net: Print thread pointer in debug prints
This makes it easier to correlate the debug messages
to different fibers.

Change-Id: I6fb2d1265bb39fd27a1d1702e47eaf70e81ee98d
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-10 19:13:00 -05:00
Jukka Rissanen 0cb73a1b9c net: Stack analyze function fixed
The stack analyzer works now same was as the one found in
Bluetooth sub-system.

Change-Id: I75e393882db6ba83f991d37aa2bf81d960b61231
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:25:32 -05:00
Szymon Janc b5c7b1baca net: buf: Fix compilation with newlib libc
newlib is declaring __unused in cdef.h which was conflicting with
__unused member in struct net_buf. Use _unused name instead.

In file included from /work/Zephyr/project/zephyr-project/net/buf.c:27:0:
include/net/buf.h:38:14: error: declaration does not declare anything
    [-Werror]
           int __unused;
               ^
cc1: all warnings being treated as errors

Change-Id: I2df189a4d4aee0f982c2d28d24847052f6168d45
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:31 -05:00
Johan Hedberg 8d98247c8f net: buf: Add net_buf_push_le16 helper function
Change-Id: Icce051392d1523df8ebfeccf76477a6264d3d216
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:28 -05:00
Peter Mitsis a0e4568760 c++: Add extern "C" { } block to header files
Adds extern "C" { } blocks to header files so that they can be
safely used by C++ source files.

Change-Id: Ia4db0c36a5dac5d3de351184a297d2af0df64532
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-02-05 20:25:22 -05:00
Jukka Rissanen d0ac5c7cf0 net: buf: Enable IP and L2 buf debugging properly
The IP and L2 buffer debugging is now activated if one enables
CONFIG_NETWORKING_WITH_LOGGING option.

Change-Id: Idad4978cfd6bd705bdde6e21f1edcd3c7d280c75
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:24:59 -05:00
Jukka Rissanen 31e5fccf30 net: Enable L2 buffers only when 802.15.4 is enabled
Because the L2 buffers are only used by 802.15.4 sub-system,
we must not compile and link them to the kernel.

Change-Id: Iab0352582ac1c57e0dd8f54ca8e757e47e4df3be
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:24:46 -05:00
Jukka Rissanen 2272312b8d net: Refactor code to use new generic net_buf API
Change-Id: Id008bbf43062ca0641a76edaabef47c650287444
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:24:46 -05:00
Johan Hedberg 72050e2352 net: buf: Require destroy callbacks to handle returning to free FIFO
There could be cases where the destroy callback needs more
fine-grained control of step ordering than "1. destroy, 2. put back to
free FIFO". One case could be when the the pool needs to be protected
by a microkernel mutex or semaphore. In such a case the putting back
to the FIFO may need to happen before a custom action in the destroy
callback.

Making the destroy callback responsible for returning to the free FIFO
gives full flexibility regarding the order of the cleanup actions.

Change-Id: Ib9532d1dd70e0a2042af54ebd3e40a853dd42d33
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:44 -05:00
Johan Hedberg c1f007687f net: Add initial generic buffer implementation
We need to have a generic buffer API in order to efficiently transfer
data between different subsystems. The first such case will be the
Networking and Bluetooth subsystems where 6LoWPAN data will be passed
back and forth.

The needed API needs to provide enough flexibility for different
buffer sizes as well as custom protocol-specific context data.

The implementation offered in this patch follows the general design of
the existing Networking and Bluetooth buffer implementations by using
a backing array of buffer which is fed into a "free buffers" FIFO for
management. The main difference is that the API allows specifying
variable sized buffers for each created pool, as well as a minimum
amount of "user data" that's allocated as part of each buffer.

There's also an optional destroy callback that's e.g. useful for HCI
flow control in Bluetooth (for notifying the controller of available
buffers).

Change-Id: I00b7007135a0ff35219f38f48658f31728fbb7ca
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:38 -05:00
Dan Kalowsky 2a57d02400 checkpatch: warning - spacing
Change-Id: Ia63d6c9d8d3c1bd9c540a039263cb8507af82b1e
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
2016-02-05 20:24:35 -05:00
Dan Kalowsky e8563c2f97 checkpatch: error - trailing_whitespace
Change-Id: I819d13f0d7a23e3a61dcda6a3ced18810b192158
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:24:33 -05:00
Dan Kalowsky d8a30896f4 checkpatch: converting from __FUNCTION__ to __func__
Change-Id: I2f28a4dd2b1b372905638cbccdf987396999d7ec
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:24:33 -05:00
Dan Kalowsky da67b29569 checkpatch: warning - block_comment_style
Change-Id: I6da43e41f9c6efee577b70513ec368ae3cce0144
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:24:33 -05:00
Dan Kalowsky 39063598db checkpatch: error - spacing
Change-Id: Ie6e1c43581dd4b0734625b3a4e59a4ca79619e99
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
2016-02-05 20:24:31 -05:00
Javier B Perez Hernandez f7fffae8aa Change BSD-3 licenses to Apache 2
Change all the Intel and Wind River code license from BSD-3 to Apache 2.

Change-Id: Id8be2c1c161a06ea8a0b9f38e17660e11dbb384b
Signed-off-by: Javier B Perez Hernandez <javier.b.perez.hernandez@linux.intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-02-05 20:24:29 -05:00
Jukka Rissanen 4d745b70b0 net: Create separate net_buf pool for RX and TX use
Have a separate network buffer pool for received and transmitted
data. This way incoming packet flood cannot prevent from sending
IP packets out.

Change-Id: I2aae3bcb4ea63f36355f758de44532b167edfdb8
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:15:39 -05:00
Jukka Rissanen 1abb0b5792 net: Enhance debugging of mac net buffer allocations
Print information who allocated or freed mac net buffer.

Change-Id: I106e1703b7f5c3e5363d53d63c599a12b65577cb
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:15:38 -05:00
Jukka Rissanen 792bbbb6d8 net: Refactor the stack analyzer functions
Generalize the stack analyze functions so that they
can be used by other fibers.

Change-Id: If1fae51db45010b75f6ac58cd8d874b31ca336e2
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:15:38 -05:00
Jukka Rissanen c9599d9d9b net: Fix the uip_buf() macro
The macro was incorrectly set and caused in certain case
wrong expansion.

Change-Id: I5198906a5066882d178c0fcff8c6816a5461f37a
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:15:38 -05:00
Jukka Rissanen 6fa1c89b38 net: tinydtls: Include file was missing
The tinydtls.h include file was missing from earlier tinydtls
commits.

Change-Id: I8b8398313c7f598daf81f4fb8c07fd138e22e22d
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:15:24 -05:00
Jukka Rissanen 766eed3461 net: Document udp connection retrieval function as it is needed
Documenting the function that returns the used UDP connection
pointer. This function is needed for example in tinyDTLS
server implementation.

Change-Id: I08aae798dab0749912694d6338de91dcbd13df84
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:15:24 -05:00
Jukka Rissanen 0378a84fef net: Add macros to return IP and UDP info from net_buf
Add NET_BUF_IP() and NET_BUF_UDP() macros that return
correct struct containing either IP or UDP data.

Change-Id: I43b828ef78c1f13ccee41e6a60daa36145a35eba
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:15:23 -05:00
Jukka Rissanen 04dfda8927 net: Fix the documentation of net_release()
Fixed the description of what happens if there is a timeout.

Change-Id: Id19a791193b527a8ee086f069e103f42d2d9b0f4
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:15:22 -05:00
Jukka Rissanen e6d1925a96 net: Make sure Contiki will not remove received packet
We must not touch uip_len(buf) value as Contiki IP stack
will use it to determine what it should do with the
received packet. So after we have received the packet,
we update separate datalen variable in net_buf that will
store the correct length of the packet.

Change-Id: Iab79b741508e95e581d1727645e6b1d1eacded4c
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:15:22 -05:00
Jukka Rissanen e1359ab16b net: Add timeout to net_receive function
Allow caller to specify a timeout in ticks while waiting
network data. The timeout value has following meaning:
  TICKS_UNLIMITED  wait forever
  TICKS_NONE       do not wait
  value > 0        timeout value (only applicaple if
                   CONFIG_NANO_TIMEOUTS is defined)

Change-Id: Icbb33fa0eeb462659d4006dd9d948a04f39a87a9
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:15:22 -05:00
Jukka Rissanen 20aa77ce6f net: Network buffers could be lost when sending packets
When sending data to network, make sure to check the return
code from network driver. The driver should return these codes:
 0 : If packet could not be sent. In this case buf should
     not be released.
 1 : If the packet was sent successfully. In this case the buf
     should be released by either the send() or some other
     lower layer function.
 <0: If there is an error, the buf should not be released by
     send() function.

Fixed the relevant part in Contiki code so that the tcpip_output()
return correct value
  0 = packet was not sent, caller needs to free it
  1 = packet was sent, network driver will free the net_buf
      after sending it to medium

Change-Id: I4380d7747985fc057f5ef73ca97b76f6e9888a55
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:15:22 -05:00
Jukka Rissanen ea970e2ce1 net: Change the remaining doxygen comments to javadoc style
Change-Id: I942558ca9e4c140145de6e4a1bcebf8d9d16f3d2
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:35 -05:00
Jukka Rissanen 3c9fd82c5b net: Add INADDR_ANY for IPv4 connectivity
Change-Id: I027ec85c9e15f0a4aae494f766414faab7f2012b
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:35 -05:00
Jukka Rissanen cc3afa6346 net: Add net_mbuf validation
Add infrastructure and checks to validate the net_mbuf during
its lifecycle.

Change-Id: Id4b638fff991325d2247b1f24152552038888915
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:34 -05:00
Jukka Rissanen 90ca5ff779 net: Validate that net_buf allocation is correct
Add macros that check that we are not trying to use already
freed net_buf and vice versa.

Change-Id: Ifdb6a7e24cd6d7a0de46fa7b991c358ea8828d6f
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:34 -05:00
Jukka Rissanen 73fc66d86a net: Rework the includes so that they are inside include guard
Making sure we do not include anything unless they
are inside include guard.

Change-Id: Ie88cbc0ed6dbbf4033f3c8c310df7d084ab8b126
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:34 -05:00
Jukka Rissanen 54ab6fad20 net: Add net_reply() function
The net_reply() can be used if the application wants to reply
something to peer right after receiving the data. The function
will reverse the source and destination addresses and ports,
and set the uIP internal structures in such a way that the
reply is possible. Using this function saves the application
from allocating a separate net_buf for just sending simple
message back.

Change-Id: Ia960c83b77a8f300222159ee085fed99e2b007c2
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:34 -05:00
Anas Nashif 20764a2e8d doxygen: javadoc style
Change all occurances of /*! to /** to match javadoc
style.

Change-Id: I3a759d34e0e928216f61252682266e64c5b875f8
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:14:32 -05:00
Ravi kumar Veeramally 89c83d0162 net: 6lowpan: Adapt compression functions to net_mbuf buffers
6lowpan HC06 and HC01 compression/uncompression functions are
adapted to net_mbuf buffers. HC06 compression and uncompression
works properly. HC01 adapted to net_mbuf but functionality is
failing due to inproper IPv6 link local addresses. buf pointers
from net_mbuf and couple of net_mbuf calls are removed (which
are not used at the moment and saves memory from net_mbuf).

Change-Id: I2711b71b1b8df2eaac67d69275baf4b62b03f9f6
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:30 -05:00
Jukka Rissanen 5d11691aa6 net: Add source mac address to net_buf
This is needed for enabling RPL and 6lowpan support.

Change-Id: I87f95a08db2cc874bbe841d9b1456803ab16d75d
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:30 -05:00
Ravi kumar Veeramally 56ccfb3785 net: 15.4: Add 802.15.4 driver and 802.15.4 loopback radio driver
Enable 802.15.4 driver that receives the IPv6 packet, does header
compression on it and writes it to the 15.4 stack Tx FIFO.
The 15.4 Tx fiber will pick up the header compressed IPv6
6LoWPAN packet and fragment it into suitable chunks ready
to be sent to the 15.4 hw driver. The 15.4 stack Rx fiber picks
15.4 frames from 15.4 Rx FIFO (which are fed by 15.4 driver)
and reassembles the all fragmented packets and uncompress the
header and writes to the IP Rx FIFO.

The 15.4 loopback radio driver receives the 15.4 frames and
put it back to 15.4 Rx Fifo.

Change-Id: I68d1c7ff6de0e8770616e574206c2091c69a28e6
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:30 -05:00
Ravi kumar Veeramally 575c89eacb net: Update 802.15.4 stack with net_mbuf and split sicslowpan
Move packetbuf from net_buf to net_mbuf, update 802.15.4 stack
with net_mbuf (which is smaller in size, and mostly wrapper for
packetbuf) and split sicslowpan(ipv6/sicslowpan.c|h) functionality
to compression and fragmentataion. This patch contains
null_compression and null_fragmentation which is exactly what
uip_driver.c|h does.

Change-Id: Ifee359e20aa57a50fb00c9ce049d9476b2ac67e3
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:29 -05:00
Patrik Flykt 29a61aff9c net: Add function to receive an IP packet from the driver
After an IP packet has been (reassembled and) received, the driver
submits the IP packet to the IP stack.

Change-Id: Icbd1e7740ce59db16bc1d61002420e86ab101d2d
Signed-off-by: Patrik Flykt <patrik.flykt@linux.intel.com>
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:29 -05:00
Jukka Rissanen 5d3685f85f net: Add separate buffers for MAC layer
We do not need large 1280 bytes long buffers in lower IP stack
layers. After long packet has been fragmented to smaller chunks
it depends on the radio technology how long buffers we need
to use. For 802.15.4 we can use 128 bytes long buffers.

Change-Id: I8cd6085944d78fa26a4aa1a93c58fc436856541b
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:29 -05:00
Jukka Rissanen 2f5b1d1570 net: Add a way to see who is trying to alloc/dealloc a net_buf
Change-Id: Ib7813bc5809f85f27aa4fe06583b64461741466a
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:29 -05:00
Jukka Rissanen 9099884162 net: Allow user application to get the packet data length
The uip_len(buf) cannot be used as the Contiki stack zeroes
the buffer len after sending and after processing received packet.

Thus the application can use uip_appdatalen(buf) macro to get
the application data length.

Change-Id: Iaaa508acb96c28919cfc0188ef46bb2b4a693090
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:28 -05:00
Jukka Rissanen 53fd129094 net: Add max length of the IPv6 address as a string
Change-Id: If7f5f3624cd34b5bff4ebb77c95ae7397e058430
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:24 -05:00
Jukka Rissanen 66fc2795e5 net: Add loopback and any IPv6 address definitions
Create IN6ADDR_ANY_INIT and IN6ADDR_LOOPBACK_INIT address
definitions for applications.

Change-Id: Ic864f559cae90a5f85e45ee90d73127b0ed8fde6
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:24 -05:00
Jukka Rissanen 6b3c739d7d net: Add helper function to set the link local address
Network driver should call this when it knows the device MAC or
EUI-64 address.

Change-Id: Ie03a80fcdb9a10cd1cb15f12037b3802da13bca9
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:24 -05:00
Jukka Rissanen 8ccc4b229a net: Make the union in net_addr anonymous
The network address union that holds IPv4 and IPv6 address
should be anonymous as there is no need to refer the union
separately.

Change-Id: I70bab6b91dcf49dfb5adb405eb2b9c602f932603
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:24 -05:00
Jukka Rissanen 251a45b602 net: Use our network buffers instead of global ones in Contiki
This mega patch changes how Contiki uses buffers. In standard
Contiki there is only couple of static and global buffers.
This makes the stack non-reentrant and only usable in one
thread. This patch replaces the global buffer with buffer
supplied by caller (net_buf.h). The Contiki stack is still not
fully re-entrant after this (packet reassembly needs more TLC)
but it is a good start.

Change-Id: I63abc230b36b14f33f687d3ef64cffb0f3a69f5d
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:20 -05:00
Jukka Rissanen da36c6371c net: Simple socket API introduced
The network context defines a network connection.

Change-Id: I29a186be6c9de9d824f10b6442fa1dfd3711d24d
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:20 -05:00
Jukka Rissanen 4f5723a5d0 net: Network initialization and tx/rx functionality
Functions to receive data from apps and transmit it to network, and
receive from network and pass data to apps.

Change-Id: I1b1b8c041e6c5e20294081d2cd403636e9909cdc
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:20 -05:00