Commit graph

41120 commits

Author SHA1 Message Date
Ravi kumar Veeramally
918703cba3 net: tests: Decrease the required buffers count
Buffer leaks are fixed in 6lowpan compression and ieee802154
fragmentation. So lower the count in tests.

Change-Id: Ic9581f898156fedc20a3e445be8b7a466ee15d99
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:40:47 +02:00
Ravi kumar Veeramally
3712eff2cb net: Fix buffer leak in ieee802154 fragmentation
Unref the buffer after net_buf_frag_del() call. net_buf_frag_del()
doesn't unref the buffer.

Change-Id: I06833e059bb46f6d3e63a22b6cce7dce0ccff14d
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:40:47 +02:00
Ravi kumar Veeramally
25feaf196d net: Fix buffer leak in 6lowpan compression
Uncompressed (original) header fragment deleted but not unreffed.
So leaking buffer here.

Change-Id: Iaefef1e8578cf3b290ae5a00141132cae36332a6
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:40:47 +02:00
Flavio Santes
f74f3f8385 net: Fix Kconfig indentation issue
checkpatch warns about some indentation issues found in Kconfig files.
So, this patch fixes those issues. No new information is added by
this commit.

Change-Id: I251add0359be3fd9152df0f6d58c1207488464a6
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2016-12-02 12:40:47 +02:00
Tomasz Bursztyka
18601fedb0 drivers: cc2520: Fix LQI computation and generalize it
LQI is actually not provided as is, but should be computed from an
abstract correlation factor. See Section 20.6.

LQI is provided the same way as Linux does, so it can push it everytime
into the buffer.

Change-Id: I5de318db2c2581d7482cc16e41dc601130753a62
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:47 +02:00
Tomasz Bursztyka
74c30c812b net: ieee802154: End of buffer contains LQI
This avoids bloating the radio API by adding a function to get current
LQI and it optimizes the usage of the fragment as its minimal size is
128. Knowing that 802.15.4 frame cannot be bigger than 127 bytes, it
thus finds a usage for the tail byte.

Change-Id: I213ae226f84527fe7b6d761f738e3924651f81e5
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:47 +02:00
Tomasz Bursztyka
cf9dcd3d5b drivers: cc2520: Fix 80 chars lenght limit
Fixing 80 chars limit by removing length computation:
We can count the FCS as part of the received length, even if AUTOCRC is
on. L2 layer is able to parse this out.

Change-Id: I3c824ed95d177570a07d04784798e14f5979c96b
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:47 +02:00
Tomasz Bursztyka
08b748432b tests: Add network core event tests
A fake network device and interface are setup. Test implies add and
removing an IPv6 address which should trigger the related notification.

Change-Id: I6035cfbfaf80c8f4352b5d31b47ca1445434d926
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:47 +02:00
Tomasz Bursztyka
07217ed772 net: net_if: Notify about IPv6 address related changes
These notifications will be forwarded to any relevant net management
event listener.

CONFIG_NET_MGMT and CONFIG_NET_MGMT_EVENT need to be set.

Change-Id: I5de72aed4db06f1d384effde6cf4f003bead3b31
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:47 +02:00
Tomasz Bursztyka
0bd597348c net: Add network management event code for IPv6
Currently, only address related changes are handled.

Change-Id: I2aa366518dae2725e58cbede4ccbe2ef19cd8b16
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:47 +02:00
Tomasz Bursztyka
1d64c3632d net: mgmt: Add some macro helpers for filling in the bit field
This will be useful when creating request and/or event codes.

Change-Id: Ibc117b476c52d72c77924a245e1f263f583061f6
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:47 +02:00
Ravi kumar Veeramally
aeb6d952f2 net: Adopt net_nbuf_read_u8 to dhcpv4 handlers
Change-Id: I78b5bcf291dcf2941b26dfb6d980ba90b4392f03
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:40:47 +02:00
Juan Manuel Cruz
da5bc59d03 net: Fixes the network interface naming macro
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>
2016-12-02 12:40:46 +02:00
Jukka Rissanen
d46f37fe2d net: Add more nbuf read/write helpers
Add net_nbuf_write_u8(), net_nbuf_write_be16(),
net_nbuf_write_be32() and net_nbuf_read_u8() helpers.

Change-Id: I7129625dab85262885a4e130f6d312860c8d1b31
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:46 +02:00
Jukka Rissanen
76716480d8 net: IPv6 address should be const in net_if_get_ll_reserve
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>
2016-12-02 12:40:46 +02:00
Tomasz Bursztyka
af703e1106 net: Normalizing net_mgmt API names
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>
2016-12-02 12:40:46 +02:00
Jukka Rissanen
146f0e7b87 net: sample: echo-client ported to use the new IP stack
Change-Id: I1666d0634af124fc7a01027187916f427b7c98f8
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:46 +02:00
Jukka Rissanen
35c9098c82 net: sample: Make sure echo-client is compiled by sanitycheck
In some cases the BT header files are missing and the compilation
will fail when done by sanitycheck script.

Change-Id: I484e1f0c23975053e947bc57ff3c9f4042fad71e
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:46 +02:00
Flavio Santes
7e7f72b104 net: Fix tests/net/nbuf/Makefile
Use ?= for the CONF_FILE variable to match the default assignement for
BOARD ?= qemu_x86.

Change-Id: I0b6cf1e967eeb437d99aa7286cf560426d48fbf9
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2016-12-02 12:40:46 +02:00
Andrei Emeltchenko
b41457bc5a ieee802154_cc2520: Fix compiler warning with strict aliasing
Fixes compiler warning with strict-aliasing rules shown below.

 ...
CC drivers/ieee802154/ieee802154_cc2520.o
drivers/ieee802154/ieee802154_cc2520.c: In function 'get_mac':
drivers/ieee802154/ieee802154_cc2520.c:290:42: warning: dereferencing
type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
...

Change-Id: Idb0522e4d2207932c9335db1ca12961a5093b48c
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-12-02 12:40:46 +02:00
Andrei Emeltchenko
3bc58717a1 wpanusb: Export ieee802.14.5 over USB
Export ieee802154 radio over USB to be used in other Operation Systems
like Linux. In this scenario Linux SoftMAC driver would be used
implementing ieee802154 stack inside Linux.

Currently tested to work with Raspberry Pi and addon ieee802154 board.

Change-Id: Iabcbbfcaad8e3935a63faca50a19fb624e78a351
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-12-02 12:40:46 +02:00
Andrei Emeltchenko
7889ebaf5e net: Add L2 RAW channel hidden option
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>
2016-12-02 12:40:46 +02:00
Andrei Emeltchenko
ca2cc81d7a net: Add TI_CC2520 RAW driver
Add TI CC2520 driver allowing RAW access to radio interface similar
way Bluetooth user channel works. This makes possible to handle radio
channel inside external 802.15.4 stacks, for example export it over USB
and handle in Linux.

Change-Id: I61bb4c8b998ff1e47dc65427ac471f04ec8fea63
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-12-02 12:40:46 +02:00
Tomasz Bursztyka
8b1953f740 tests: net: Add net management event sender/receiver tests
It mimics how event could be thrown through a dedicated thrower (a
fiber). The amount and event it can throw is gived through parameters.

Change-Id: I484bc72bdb730a77ce976b0b2998411d9918b7fc
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:46 +02:00
Tomasz Bursztyka
f9fffe32b4 net: Add debugging to network management event part
Change-Id: Ib442dd4a34b30333d1423a9e90367d6626261c37
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:46 +02:00
Tomasz Bursztyka
cce3a7e3d5 net: Add support for event handling on network management API
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>
2016-12-02 12:40:46 +02:00
Tomasz Bursztyka
ec1d2c5a48 tests: net: Add a basic network management API test
Testing if net_mng() works.

Change-Id: I303cffa206859184a503ba8efe392b673b162e43
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:45 +02:00
Tomasz Bursztyka
a73b1c39d1 net: Add network management API
Define the ground mechanism to interact with the network stack.

Change-Id: Id2af76188967fa66e0f0d755a2c1dc8a85985540
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:45 +02:00
Ravi kumar Veeramally
8fc7035cfc net: Adopt net_nbuf_read_be32() api to dhcpv4 handlers
Change-Id: I3103e5f4b1bdbf8dced12ef25edd0b63f45548f6
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:40:45 +02:00
Ravi kumar Veeramally
1ce3550779 net: tests: Add RA message unit tests.
Basic unit tests for Router Advertisement message handler.

Change-Id: Ia99cd160632972a12e2099a3ff6e41e6ea48ff9b
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:40:45 +02:00
Ravi kumar Veeramally
c69b10a3a0 net: Adopt new nbuf API's to RA message handlers.
Add multi fragment parsing support for Router Advertisement
packet.

Change-Id: Ie2730156c96759ee720f406f9d034b350643322e
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:40:45 +02:00
Jukka Rissanen
060362ff14 net: Optimize net_nbuf_write() when handling last frag
Get the last fragment only once instead of searching it for
every byte written.

Change-Id: Iebeed21671b12bc081d7a1291f91d2c897a7a1d6
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:45 +02:00
Jukka Rissanen
d8cb2fb161 net: Make sure buf is correct one in net_nbuf_write()
The buf parameter cannot point to a data fragment in
net_nbuf_write() because we need to use user data inside
that function and the fragments do not have that information.

Change-Id: I45b9c23869df08a0852bd99c0b453210ad2300b5
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:45 +02:00
Jukka Rissanen
25c4f99aee net: Allocate next fragment in net_nbuf_write() if needed
If the caller did not allocate first data fragment, then allocate
it automatically.

Change-Id: Ice0f3bf65b1f9cd838738549ba15117d925b37b7
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:45 +02:00
Jukka Rissanen
127c4f455a net: Make net_nbuf_read() to return NULL if buf is NULL
This way we do not access invalid pointer if user passes NULL
pointer to this function. Also we can avoid extra error checks
when calling net_nbuf_read() function.

Change-Id: Ie124cbe8a7915fa07decedd48c0c274138cfd0aa
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:45 +02:00
Jukka Rissanen
7a4cd852d4 net: Add be16 and be32 read helpers to nbuf.h
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>
2016-12-02 12:40:45 +02:00
Andrei Emeltchenko
d6155e0cf9 ieee802154_cc2520: Correct debug output
Change-Id: I52979eb6661aac62eea875f088972d472f46ef81
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-12-02 12:40:45 +02:00
Andrei Emeltchenko
b85b27eab2 net: Do not source contiki headers always
Source contiki headers only for legacy driver

Change-Id: I356fd65ce9a4ee144c29eed1b51f2f0175315c1c
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-12-02 12:40:45 +02:00
Andrei Emeltchenko
b2a478b935 net: cc2520: Fix setting proper IEEE 802.15.4 address
The bug was introduced by commit ID
a136a2587752cca256950b0efd5567ca29117d11

Which led to write junk as an address into cc2520 and thus made the
chip filtering out all unicast packet (as the incoming address never
matched)

Change-Id: I72009e795039f2059177a5b37a4bcf5d9717d65d
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-12-02 12:40:45 +02:00
Flavio Santes
b29b0995d2 net: Improve net_context_connect documentation
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>
2016-12-02 12:40:45 +02:00
Tomasz Bursztyka
4b7309c751 net: cc2520: Let's provide ll addr in LE already
As it used directly as the ieee addr.

Propre endianess will have to be solved once this stack will be ported
to other arch than x86.

Change-Id: Ie556fabbd99cc5559025c8392d2f699facb007fa
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:28 +02:00
Andrei Emeltchenko
330da1f4c3 net: Fix handling onlink prefix
In a case prefix is valid do not return prematurely.

Change-Id: I4d3a7567787c4bd74a2d66a642b632c32e675be3
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-12-02 12:40:28 +02:00
Andrei Emeltchenko
99a14f9c65 net: Fix handling ra_neighbor
Fix returning without linking laddr to the neighbor, return only when
neighbor is not found.

Change-Id: I284d42bf5b3ffde6487f669be0f95ad40368674a
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-12-02 12:40:28 +02:00
Andrei Emeltchenko
92cfd5127f net: Fix creating neighbour without l2addr
At the moment after receiving Neighbor Solicitation from the peer
a new neighbour is created with unassigned lladr resulting in
error later one below:

...
[net/nbr] [ERR] net_nbr_get_lladdr: {assert: 'idx <
CONFIG_NET_IPV6_MAX_NEIGHBORS' failed} idx 255 >= max 8
...

Change-Id: Ieb218fa5e850f018255b6080cbc0c7764595d40c
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-12-02 12:40:28 +02:00
Andrei Emeltchenko
fcd22382a0 net: Fix link address length calculation
The patch fixes calculation of link address length. In a case of
IEEE802154 link address is 8 bytes long and formula for Source/Target
Link-layer Address calculation gives value 2 * 8 - 2 = 14 bytes.

Change-Id: I27570d4d45d348e53f7f63cb4681a1c8c5150e5e
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-12-02 12:40:28 +02:00
Ravi kumar Veeramally
434f1ed85a net: Remove multiple declarations of net_ipv6_start_rs
Change-Id: Id3da5c9cfebbddd78a2d16220fe32e04b1cd3053
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:40:28 +02:00
Jukka Rissanen
61dc5be389 net: Íncorrectly named function in net_if.c
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>
2016-12-02 12:40:28 +02:00
Ravi kumar Veeramally
722db0baa4 net: Adopt new nbuf API's to dhcpv4 message handlers.
Change-Id: I5f4babef1f183dab5643b9d90dc1631dfd2c6c77
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:40:28 +02:00
Ravi kumar Veeramally
913c1f29ca net: Add unit tests for new nbuf API's
Tests for net_nbuf_read, net_nbuf_write and net_nbuf_skip API's.

Change-Id: I77f702dda8c9df7892120f47ff03a6b256191d31
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:40:28 +02:00
Ravi kumar Veeramally
618879ac6a net: Add nbuf APIs to read/write across multiple fragments
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>
2016-12-02 12:40:28 +02:00