Commit graph

19237 commits

Author SHA1 Message Date
Tomasz Bursztyka
4e7efd4bcb tests: net: Add a IEEE 802.15.4 ACK replies test
- Parsing a proper ACK reply
- Generating a ACK reply from a data packet requesting it, and comparing
  it to a proper one.

Change-Id: I1717fedc899eafa0aa849e1e253f02cd3dc3d4fc
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:18 +02:00
Tomasz Bursztyka
d82d96a93d net: ieee802154: Support ACK replies
If a data packet is received with AR flag set, it will reply
accordingly. This is meaningful when running the stack above hardware
that cannot reply automatically to ACK request.

Change-Id: I7e5be94c4a5b1c889adb67ceb6f44dadd36db3ce
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:18 +02:00
Tomasz Bursztyka
11c9b8dac7 tests: Add grounds for IEEE 802.15.4 stack tests.
First test is a unit test for frame parsing

Change-Id: I080d64a71fe4b6ff00e071a0cdee97ab9cd922d5
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:18 +02:00
Tomasz Bursztyka
79aea80ebf net: Add support for the IEEE 802.15.4 ORFD
Overly Reduced Functionality Device, which is meant only for
testing as well as to mimic legacy stack's behavior. This is
not spec compliant!

Change-Id: I2f98092c85d538b9fbfcef0e812461a80b0d67d3
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:18 +02:00
Tomasz Bursztyka
0624199e1f net: Adding ALOHA radio protocol to IEEE 802.15.4 L2 driver
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>
2016-12-02 12:40:18 +02:00
Tomasz Bursztyka
df9b6f76af net: Add preliminary IEEE 802.15.4 L2 driver
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>
2016-12-02 12:40:18 +02:00
Tomasz Bursztyka
c3ce028d3b net: Add new IEEE 802.15.4 Radio API for device drivers
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>
2016-12-02 12:40:18 +02:00
Tomasz Bursztyka
3560f58293 net: L2 might need private data per-interface
Allocate the right amount of space for L2's context.

Change-Id: Ia2f4f4162334e9e9c26dc95230abdfde5986e052
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:18 +02:00
Tomasz Bursztyka
981da5cb4a net: Fix TX fiber on net_if
API pointer was set twice.

Change-Id: I51d8b72ea3ec5f343589f550dd011d90dc245a9c
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:18 +02:00
Tomasz Bursztyka
f0003c3a25 net: Add a function to lookup for an iface from a device
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>
2016-12-02 12:40:18 +02:00
Tomasz Bursztyka
8565db639c net: Add some debug message on net_if
To track down the initialization of each interface.

Change-Id: Ia52aba0979689ab6ce24433853d1d87ecb693b3d
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:17 +02:00
Tomasz Bursztyka
3501290245 net: Add documentation to net_l2 header file
Change-Id: Ib07406a6d988cd742d2077503b70de230197d390
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:17 +02:00
Tomasz Bursztyka
f7a9b07a84 net: l2 layer reserve size might need extra parameter
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>
2016-12-02 12:40:17 +02:00
Jukka Rissanen
56d3dfdeb9 net: Sent NS was two bytes too long
Change-Id: If330aabd767e0c69d6a2224a6cc72df161cc6123
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:17 +02:00
Jukka Rissanen
08c54ec566 net: Check ICMPv6 options length correctly
The options length check was using fragment length to
verify the correctness of options. This is incorrect
as we need to check against the remaining length of the
packet after we have removed IPv6 and ICMPv6 header lengths.

Change-Id: Ied1b19e3f4b1a88409e81a1974ba5a4bdf022e72
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:17 +02:00
Jukka Rissanen
04a65534e1 net: Change srctree to ZEPHYR_BASE in Makefiles
This is related to changes in commit 7dcbbc39e7
("build: move from srctree to ZEPHYR_BASE for app include paths")

Change-Id: Ie902ed66bb74188ed54aae44e2f4289f954ec351
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:17 +02:00
Tomasz Bursztyka
a4796121a3 net: Add a function to retrieve a neigh from an IPv6 address
This is necessary when an external component tries to relate an address
to an actual neighbour.

Change-Id: Ic1b40032300e9fa06e029017098c16b6260c3a41
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:17 +02:00
Tomasz Bursztyka
a0daca0c6a net: Fix IPv6 NS packet size check
Source link-layer address option might not be present, if the IP source
address is unspecified.

Change-Id: I1c9e89cce39588c6c8735e59cf894f6d278d52bb
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:17 +02:00
Tomasz Bursztyka
72df406cb8 net: Add IPv6 ND statistics when relevant
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>
2016-12-02 12:40:17 +02:00
Jukka Rissanen
1619279553 net: RX fiber needs bigger stack
Current stack consumption as reported by analyzer

  RX fiber stack real size 1200 unused 84 usage 1072/1156 (92 %)

so increase the stack to 1200 bytes.

Change-Id: Ibf2b27a6fb25cfb6be6d95e77c2e882526128a0a
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:17 +02:00
Jukka Rissanen
86a3edffd0 net: Return NET_CONTINUE in L2 ethernet driver in send()
If the packet is not sent yet, then return NET_CONTINUE so that
the caller can avoid processing the packet yet. The packet might
not be sent yet if for example IPv6 ND is being done.

Change-Id: I242ffcafb3e68f63d9dca06367e075a143a7bbe6
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:17 +02:00
Jukka Rissanen
fe7cc6d2d2 net: Ethernet driver needs to set ll address
Instead of swapping the ll address set the source and
destination addresses if they are not set.

Change-Id: Icdded06df2edb27f71894e29e9bc22a8f0313fae
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:17 +02:00
Jukka Rissanen
ad4fe09c48 net: IPv6 neighbor was not properly added to cache
The IPv6 and ll address of the neighbor was not properly updated
and set in the neighbor cache. Symptoms were that packets were
discarded even thou the cache contained proper ll address.

Change-Id: I2acfb1b03d2eb69eddcf7ad5e25e8a7ce2ce3bb5
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:17 +02:00
Jukka Rissanen
43acda57b8 net: No need to swap ll address in IPv6 module
The L2 layer sender should actually set the link layer addresses
properly.

Change-Id: I9dd2f9ca269384dff0bef12e570317173f6a5f02
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:17 +02:00
Jukka Rissanen
dd3b93d3f3 net: Update UDP sent packet statistics
Change-Id: Ia012f1b1d2cd9e975e3e1744a2f6fce09ccc0987
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:17 +02:00
Jukka Rissanen
5754b64611 net: nbuf variables needs clearing when allocating nbuf
Initial value for nbuf variables need to be set as they
might contain garbage from previous allocation.

Change-Id: I1d16e72387dbda86355ac01aabc1ba617bba0d50
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:16 +02:00
Jukka Rissanen
d873ba5fbc net: Check packet sending status correctly in arp.c
The packet sending function returns either NET_OK or NET_DROP
instead of <0 value. Make sure we check the value correctly.

Change-Id: Iab5b5c07ca548e9c2ccb31542a7633ecc0de2bc9
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:16 +02:00
Jukka Rissanen
1eb1c0f4f3 net: Call net_context send callback when packet is sent
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>
2016-12-02 12:40:16 +02:00
Jukka Rissanen
e2908b1a6b net: Call send callback in net_context properly
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>
2016-12-02 12:40:16 +02:00
Jukka Rissanen
e04fbc04e1 net: Add token to nbuf
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>
2016-12-02 12:40:16 +02:00
Jukka Rissanen
63d14c33e3 net: Check IPv6 NS, NA and RA messages for corruption
Additional checks to make sure the received IPv6 neighbor
solicitation, neighbor advertisement and router advertisement
messages are not corrupted.

Change-Id: Ic34a92eaac14dc9e2e6ed305fc7b2b6dcab9c29c
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:16 +02:00
Jukka Rissanen
11e111d494 net: Rename ip_protocol to net_ip_protocol
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>
2016-12-02 12:40:16 +02:00
Jukka Rissanen
84edd8f2f1 net: apps: Fix echo-server to use the new user API
Echo-server no longer reverses the data as doing it
when we have a fragment chain is quite challenging.

Change-Id: I298669f3ddba67000672320e7b3b14f72e9f12d4
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:16 +02:00
Jukka Rissanen
7ec784f102 net: Set reserve, context and iface properly in nbuf
Invalid values were used when filling reserve, context and
network interface in nbuf private data area.

Change-Id: Id063fa3a415cd281d50148c10e7b838d56878894
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:16 +02:00
Jukka Rissanen
2420452c28 net: Add more debugging to nbuf
Change-Id: Id23bc69d1566d50cbee4f9ae6def51f5f79b7dfe
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:16 +02:00
Jukka Rissanen
d4aa154e70 net: Use proper ll header length when sending IPv6 NS
We must use the link layer header length derived from the
actual interface when sending IPv6 neighbor solicitation msg.

Change-Id: I1836743ffed50254c89341fbdade039741e62f33
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:16 +02:00
Jukka Rissanen
a91fbc7e3f net: Resolve LL address for IPv6 packet in ethernet L2 driver
If we do not know link layer address when sending ethernet frame,
then initiate IPv6 neighbor discovery process.

Change-Id: Id9c55646895a12ea3693cdca330e730bc80d83dc
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:16 +02:00
Jukka Rissanen
14dc085830 net: Do IPv6 ND if LL address is not known when sending
Resolve the ll address so that IPv6 packet can be sent.
This means that the IPv6 neighbor discovery needs to be done.
The original packet will be sent after neighbor advertisement
is received.

Change-Id: If54cdbd1468ca802f59e206996ea3addab16d5b8
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:16 +02:00
Jukka Rissanen
2ea5bc52b2 net: Neighbor cache entry was not properly init
Pending variable needs to be init so that we do not use
some old value when cache entry is reused.

Change-Id: Id6af61981d4fc7628992b4a018d84a4e5c8a16f6
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:16 +02:00
Jukka Rissanen
7d97b7d10e net: Fix debug prints in net conn manager
The IP address was not printed properly when registering a handler.

Change-Id: Iadb02997a43f1440932d224e0113b6f45c4f0aed
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:15 +02:00
Jukka Rissanen
9d5b0d651c slip: Do not send ethernet header if MTU is large enough
No need to partition the data if MTU is large enough and
data can be sent in one frame.

Change-Id: I8ba0f5030ed1e2c1341c7e2dd409ba636b1a9a4c
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:15 +02:00
Jukka Rissanen
755c96fddf net: Set the protocol family and interface for net_buf
When allocating net_buf via a net_context, set the network
interface and protocol family to net_nbuf.

Change-Id: I0df876e0c8ba66bac42f3aa7fd17c5bf9a935985
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:15 +02:00
Jukka Rissanen
498f9e04de net: tests: Unit tests for user space socket API
Change-Id: Ifd149e4f4313abde4cead135f7533f26dec6bdf7
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:15 +02:00
Jukka Rissanen
c0e4781346 net: Create IPv4, IPv6 and UDP packets when needed
The sending functions net_context_send() and net_context_sendto()
will need to send data.

Change-Id: I5372cb9dede2a996276c30241f28689c4f902dff
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:15 +02:00
Jukka Rissanen
b481908c71 net: Utility function to append UDP packet into net_buf
Change-Id: I7008b7cddb08525c2f549715a46cae608bb865d4
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:15 +02:00
Jukka Rissanen
41670f78c2 net: Add helper to create IPv4 packet
Change-Id: I51a19878f3e21cfcff5b92fec413d172cc025dd6
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:15 +02:00
Jukka Rissanen
961a32ad95 net: Add helper to create IPv6 packet
Change-Id: I5bf6e29f450d13add1ca78ee090e2107e7fee45f
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:15 +02:00
Jukka Rissanen
13733f7894 net: Add user space API to net_context
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>
2016-12-02 12:40:15 +02:00
Jukka Rissanen
7702e0384c net: Increasing the default IPv6 unicast addr count
The earlier default 1 was too low, a more usable 2 is now
the default. User can set the limit to 1 if needed.

Change-Id: Ib30a1ceb95c42f69197298f672daaeab6b41890b
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:15 +02:00
Jukka Rissanen
9331b2bc7b net: Add net_conn pointer to callback
When a UDP packet has been received and if a watcher match
is found, then a callback is called. It is useful to have
a pointer to net_conn when calling the callback.

Change-Id: Ifa97b37c22b1fc9cac7eadfba23aa68dfd473fda
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:15 +02:00