Commit graph

41120 commits

Author SHA1 Message Date
Tomasz Bursztyka
c72ae15f79 net: Save some bytes on net_if logic
Instead of runtime checks, let's use NET_ASSERT() to verify that net if
API is properly set.

Change-Id: I8e5c769b8383aa9aec5a5e9600c07e05ca96d517
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:06 +02:00
Jukka Rissanen
b6834c2467 net: Add NET_ASSERT() macro
Change-Id: Ie98da69fbd1cf277a5d517736217209c85180416
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:06 +02:00
Tomasz Bursztyka
8d36162929 net: Tiny comment fix
Change-Id: I9fff6651be90f74eaaccdc082b14997b8e55565d
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:06 +02:00
Tomasz Bursztyka
82a6e963f4 net: Removing capabilities from net_if api
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>
2016-12-02 12:40:06 +02:00
Tomasz Bursztyka
4d18de712a net: Re-factor Kconfig and move ARP to a better location
ARP and its related Kconfig options now belong to l2.

Change-Id: Ie21ed3cc39a7c7c76d823587ec33fdd22b439fcd
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:06 +02:00
Tomasz Bursztyka
4090b4c01f net: 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-12-02 12:40:06 +02:00
Tomasz Bursztyka
260d3b95d7 net: 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-12-02 12:40:06 +02:00
Tomasz Bursztyka
d0b382c345 net: Add a 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-12-02 12:40:06 +02:00
Tomasz Bursztyka
b19f26bbbc slip: Fix compiler warnings
2 warnings happens when CONFIG_SLIP_DEBUG is set, thus fixing it.

Change-Id: I032d7481942e86911764da35cdd6f7b8e05cdeaa
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:06 +02:00
Tomasz Bursztyka
249f889782 net: 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-12-02 12:40:06 +02:00
Tomasz Bursztyka
dc0ddca5fd net: The core initialize ARP layer relevantly
Up to the core to initialize what's required to get all things working.
Introducing a NET_ARP configuration option, in future this one will be
set if only some hardware requires it along IPv4.

In order to differentiate ARP and actualy hardware drivers supporting
ethernet frames, adding a NET_ETHERNET config option. Which option, if
enabled along NET_SLIP, will be used later on to fully simulate ethernet
over slip TAP driver. Such option will also be used to unlock ethernet
hardware devices in drivers in future.

Change-Id: I10ed151b96256ea3f265c3926bf9a35e49692e1e
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:06 +02:00
Tomasz Bursztyka
dfe0482f23 net: debug: Indent properly some config options.
Change-Id: I3500081592a983e97e3e5407ac441b4ece58634d
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:06 +02:00
Tomasz Bursztyka
8b6889ea25 net: 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-12-02 12:40:06 +02:00
Tomasz Bursztyka
309ff1b62f net: Use generic wrapper for semaphore give operation
No need to recreate an convenient context wise wrapper since one already
exists.

Change-Id: Ie1bfc0e203281485acb36e0e844b2bad384c2af6
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:06 +02:00
Ravi kumar Veeramally
563835f7ed net: Use shorter alias for __packed attribute
Change-Id: I5bee3f1a9cf8629151734fc85b2c3e6097232cc0
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:40:05 +02:00
Ravi kumar Veeramally
3fe96a52e6 net: Add UDP header definition
Change-Id: I2f3bba1014cf598bed7606d5d43b3653052b1f7f
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:40:05 +02:00
Ravi kumar Veeramally
ada4f17711 net: Fix trivial comment errors in header files
Change-Id: I2f3bba1014cf598bed7606d5d43b3653052b1f88
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:40:05 +02:00
Jukka Rissanen
73b57414a7 net: Setting static IP addresses for echo-server
This allows to test things between qemu and host when
using slip.

Change-Id: I27e17de9f0d8c2c8406f0afdd66c295e827f87a0
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:05 +02:00
Jukka Rissanen
dc5e4c37fc net: Handle ARP messages
Catch ARP messages when processing incoming messages and call
ARP input for parsing.

Change-Id: I88ea4699dfb8e7e35d3cecbce32d50aa485c307c
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:05 +02:00
Jukka Rissanen
feaef3626e net: tests: Additional tests for ICMPv4 checksum verification
Change-Id: I21566c9365b8abc5753f6bedba55a3fb494745b9
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:05 +02:00
Jukka Rissanen
03a98571dc net: ICMPv4 checksum calculation fixed
The checksum for IPv4 ICMP was incorrect, the pseudo header
is not to be taken into account here.

Change-Id: I2a2a7e6eace24aba009574bf0021417257c8198a
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:05 +02:00
Jukka Rissanen
962bbe7856 net: IP checksum calculation should ignore ll header
Link layer header was incorrectly taken into account when
calculating the checksum.

Change-Id: If09612145b87ed266998341d380eb6d5ecdde7cf
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:05 +02:00
Jukka Rissanen
9c72b60981 net: Clarified the debug print about packet length
The print about packet length is the data part of the length
and does not include the ll header.

Change-Id: Ia66eb830796a572ffa416df1e6d0badcbe9f9aac
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:05 +02:00
Jukka Rissanen
f6dc86c678 net: tests: Fixed the ARP test
Now uses net_nbuf_ll() to point to link layer header.
Also the ARP req test passes properly.

Change-Id: If649ff19a064490bff33d03b4ce70ef11bfa7cd5
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:05 +02:00
Jukka Rissanen
61cc4e109d net: Use net_nbuf_ll() to get into arp header
This is shorter to write and less error prone.

Change-Id: I67d3b75e0b39f58a4ea655e91530dff6f9fcc6e0
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:05 +02:00
Jukka Rissanen
2f76da194d net: Make echo-server to use documentation IPv4 addresses
Use 192.0.2.0/24 address space that is specified in RFC 5737.

Change-Id: Iff2545f5b0f4817c99813c986d57801e166967a3
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:05 +02:00
Jukka Rissanen
e1cb2ec9bd net: Only accept ARP reply if we requested data
This helps to prevent ARP cache poisoning.

Change-Id: I3cc2adcc3d06520fecfdccc3b415575bb714e27b
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:05 +02:00
Jukka Rissanen
05260f31b4 net: Setting preferred status to manually added IPv4 address
If user is setting the IPv4 address to a given network interface
manually and if lifetime is set to infinite, then set the
state of the address to preferred.

Change-Id: If6e331ac5655d0df0d3b67bb07bcf8cd06351e3d
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:05 +02:00
Jukka Rissanen
d16380457b slip: Support TAP functionality
If CONFIG_SLIP_TAP is defined, then ethernet link layer header is
added before the packet.

Change-Id: I3d266017f85683999d3c67de49b75b60686d7ba7
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:04 +02:00
Jukka Rissanen
7eff526e3b net: tests: Unit tests for the IPv4 ARP code
Change-Id: I607ffdbffc7348fae70272c7add57456fcaf79af
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:04 +02:00
Jukka Rissanen
c46edfa843 net: Added IPv4 ARP support
This implements a small IPv4 ARP cache that is used in
Ethernet networks.

Change-Id: I9ab38ee14a799f8573f4d4e0eade1be107d42f1a
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:04 +02:00
Jukka Rissanen
6e3c12a820 net: tests: Add tests for IPv4 netmask, gateway and subnet compare
Unit tests added for checking network interface netmask, gateway
and IPv4 subnet compare utility functions.

Change-Id: I5b4a07d6a064097ab41ad6552d14181b1631eb53
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:04 +02:00
Jukka Rissanen
667d15de85 net: 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 if ARP should be enabled or not.

Change-Id: Ieaaefcfc7cdd65f44190248f507ac3cb512a323e
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:04 +02:00
Jukka Rissanen
702ea43621 net: Add util to check if IPv4 address is part of a subnet
Change-Id: I6005861a4c4085b6c17ded03fda38a567a4e504a
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:04 +02:00
Jukka Rissanen
79fa53e17d net: Add utils to set IPv4 netmask and gateway to net_if
Change-Id: I52bcea3749aa5fb4e12b18fd9fd9a3907842bf01
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:04 +02:00
Jukka Rissanen
2593796d04 net: Add macro to compare two IPv4 addresses
Change-Id: I2af022d8a8df4c174e044d033a23d5912297e495
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:04 +02:00
Jukka Rissanen
2b552fcc66 net: net_ipaddr_copy() macro was too fragile
Now making sure we are doing the IP address assignment correctly.

Change-Id: I8bf9233b932321a14df99ce49a39581f1343d004
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:04 +02:00
Jukka Rissanen
af685962b6 net: Add utility function returning IPv4 broadcast address
Change-Id: Ibe4f5ad530f6a0f50137ef2cd8e64dbc9de6cba1
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:04 +02:00
Jukka Rissanen
9d0de92f59 net: Do not remove fragments if main buffer is not removed
The fix prevents the net_nbuf_unref() from removing fragment
list if the top level net_buf is not removed.

Change-Id: Ice580c25bd74f3239c01321f2b9d61cc8c0c9c1d
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:04 +02:00
Jukka Rissanen
1bf6a529a1 net: tests: Tweak the IP address test to use new net_if API
Instead of using hard coded net_if, get the default network
interface using net_if_get_default() function.

Change-Id: I6248555ce57ae5196adea7baa9db325660a71255
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:04 +02:00
Jukka Rissanen
94ba84426c net: Add utility function to return default network interface
Change-Id: Ia64d263831e2842883404d25b7ea429bea80ca1d
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:04 +02:00
Jukka Rissanen
b6a7648569 net: Process received ICMPv4 messages
Call ICMPv4 handler when receiving ICMP v4 packet.
Currently only echo-request msg is handled.

Change-Id: Ib59c65b38f13c484f1842485118dad32fb6a6f36
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:04 +02:00
Jukka Rissanen
0cd6742f00 net: Process received ICMPv6 messages
Call ICMPv6 handler when receiving such a network packet.

Change-Id: I2ebe612bd4a4615e8cd1c8b323507c6a03f6008d
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:03 +02:00
Jukka Rissanen
5580cdcc54 net: Add unit tests for ICMPv6 handler
Change-Id: Ibdbe82ed56f110e2e0c6443700863632ee1ef56b
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:03 +02:00
Jukka Rissanen
7c78925050 net: Add ICMPv6 handler
The host will be able to respond to ICMPv6 messages.
An echo-request handler is implemented and it will send
echo-reply when needed.

Change-Id: I08f4703bab5cf3e95d3ae722ebc7a386d22fe17e
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:03 +02:00
Jukka Rissanen
4445e53f1e net: tests: Unit tests for network utilities
Right now there are tests for IP packet checksum calculation.

Change-Id: I1e9e72d01d4690728269c4484f8628350cf95729
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:03 +02:00
Jukka Rissanen
0d5e829da6 net: Add debugging option for network utilities
Various network utility routines can debug print after this.
The Kconfig option is called CONFIG_NETWORK_IP_STACK_DEBUG_UTILS

Change-Id: I8384f974bd3c4965a6ef401bff8060389fab51ad
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:03 +02:00
Jukka Rissanen
1a9421886e net: Add IP packet checksum calculation utilities
Added function that is used when calculating various IP
protocol checksums. The function works with fragmented
net_buf data.

Change-Id: Icaef707ba15ac2729608929e52e235e6e8a154dc
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:03 +02:00
Jukka Rissanen
eba768aba0 net: Add net_hexdump() utility to print network data
Only usable if network debugging is activated.

Change-Id: Id7d70d88b5ddca772603e5d2c567b8df23cf084e
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:03 +02:00
Jukka Rissanen
402996e374 net: 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-12-02 12:40:03 +02:00