Commit graph

1260 commits

Author SHA1 Message Date
Tomasz Bursztyka 7e4bba03b4 net: ieee802154: Optimize context structure usage
For future purpose, let's not occupy a full byte for a unique boolean.

Change-Id: I36f2824cca4806eb90640a71ed3cea37a353b276
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:55 +02:00
Tomasz Bursztyka 62ea188772 net: mgmt: Fix include recursion loop
Including net_if.h can makes things looping, as this one will include
net_l2.h, which one might include a technology that will in turn include
net_mgmt.h again.

Change-Id: I514720875937414167f0396edb9147ed29dd6d69
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:55 +02:00
Tomasz Bursztyka efaa46594f net: mgmt: Define request handlers to avoid build warning
Up to the part declaring mgmt request to define such handler. This is
meant to avoid such warning:

warning: implicit declaration of function ...

Change-Id: Ide6e9abf886169c26d81fe6b5c7bc280e1ac4e4d
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:55 +02:00
Ravi kumar Veeramally f1986a1d1e net: Add IPv4 related events
Change-Id: Ieb26ab96b2b9aa6765ddba21628ab1530a2597ea
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:40:54 +02:00
Ravi kumar Veeramally 889b090ffb net: Implement net_nbuf_insert
Add support for inserting data into an arbitrary location in fragment.

Change-Id: Iaecdc4e980a73e0f66c208315d342e05762cd6f5
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:40:53 +02:00
Ravi kumar Veeramally 9f308ac83c net: Implement net_nbuf_write
Add support for nbuf write to an arbitrary location in fragment.

Change-Id: I686c6d86feb8545603edd7c7a9ef6fde1c909a72
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:40:53 +02:00
Jukka Rissanen ddda50c214 net: tcp: Initial TCP functionality
This creates initial TCP handling logic but does not yet
enable fully working TCP connection.

Some of the connection logic is taken from FNET TCP
implementation.

Origin: FNET 3.6.1
URL: https://github.com/butok/FNET/blob/master/fnet_stack/stack/fnet_tcp.c

Change-Id: I1e100d9fa9c91437562b933d94d0bd3db1a5885e
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:51 +02:00
Ravi kumar Veeramally ed3dbe1cbf net: Fix typos in nbuf apis
Change-Id: Id89d0d7f1d49a275de0f735a6457fdb6fdad31ea
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:40:51 +02:00
Jukka Rissanen 54a500a478 net: Add helpers to get sockaddr pointer
This way we avoid ugly casts in the calling code.

Change-Id: I9c949cf22ecd1603e9247a07240de5759bf85463
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:51 +02:00
Paul Sokolovsky be96b7df62 net: Make net_context_get_ip_proto check correct flag.
Apparently, a copy-paste error: NET_CONTEXT_TYPE was used instead of
NET_CONTEXT_PROTO. The corresponding "set" function uses the latter,
so it for "get" too.

Change-Id: Ideb5bfaeb548222a6e64d53b782c9a111e3ef33b
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2016-12-02 12:40:51 +02:00
Ravi kumar Veeramally c689fd6f1a net: Rename net_nbuf_write to net_nbuf_append
Current net_nbuf_write() api just appends data to last fragment. And
doesn't write data based on offset. That's why renaming this api.

New net_nbuf_write() apis based on offset will be coming soon.

Change-Id: Ie8e13e5f6091a279b62b6d8b0b3928a5187e75b0
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:40:51 +02:00
Luiz Augusto von Dentz 83c9da8af8 net: Add initial Bluetooth support using native IP stack
Initial Kconfig and L2 layer support.

Jira: ZEP-992

Change-Id: Ia60316566ea1e535d9cdb3f372c3c46630d0e9c0
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-12-02 12:40:50 +02:00
Ravi kumar Veeramally ead511ddae net: Fix net_nbuf_read corner cases
Valid case:
 1) If the offset is more than current fragment length, adjusts offset
    from next relevant fragment and starts reading or skipping.
 2) If the read or skip length is more than available data length,
    then throw an error.

In case of an error, frag is 'NULL' pos is '0xffff'. Rest of the cases
are successful read and skip.

Change-Id: I88c4b85e14e5821f681966b5148ba9519b91cca4
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:40:49 +02:00
Jukka Rissanen 962400f9b1 net: uip: Fix the net_context.h content for legacy stack
The legacy stack has all the net_context API stuff in
net_socket.h so include it in net/net_context.h file.

This re-works the commit 627feb92d4 which added the
net_context_get_internal_connection() to net_context.h.
Now that function prototype is found in net_socket.h.

Change-Id: If22fa63357f4b2e9503f8c9850e69ffda39c61c7
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:49 +02:00
Tomasz Bursztyka 1069d26eae net: Differentiate IPv6 event command and final event
Enum names are colliding with defines, which is bad.

Change-Id: Ia8c003983ddeb1ebed8a9210e682bcb21abfa687
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:48 +02:00
Jukka Rissanen 4bf941ee39 net: Re-order fields in net_nbuf struct
Re-ordering fields in struct net_nbuf in order to avoid
holes because of memory alignment.

Change-Id: I5a3ab31a0232003c161fd65848f70d83e07a75c9
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:48 +02:00
Tomasz Bursztyka 805e475e9d net: events: Fix a mix up between code and command
Code is actually meant to identify the part in the layer from which the
events originates. Adding or removing an address is a command.

Change-Id: I42b4823d2585b15851c4fdd91802a13d2a5759c1
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
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
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
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
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 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
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
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
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 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
Ravi kumar Veeramally 28c82144c2 net: Add DHCPv4 client support
Change-Id: I3a7a9074f68059d69c20c947882a3f6480ace23a
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:40:26 +02:00
Jukka Rissanen c427e9bbd6 net: Context accept cb needs to return failure code
If the connection establishment has an error, the accept
callback needs to be able to return that error to user space
so that the application can know about it.
This is especially important in TCP where application needs
to start to listen again if reset is sent during connection
establishment.

Change-Id: I55f36e4f101c7237c1288f09baf6e602b33da2b3
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:25 +02:00
Jukka Rissanen 73aa1cc72c net: Add TCP buffer access func to nbuf
So we can easily access TCP buffer that is stored
in net_buf.

Change-Id: I37ae728be45ded2fcc74735592d94897c945afbe
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:25 +02:00
Jukka Rissanen 708579eb6b net: Add TCP protocol header definition
Change-Id: I17ab9f21ebbebdfc47e82a11540d8e071d7c46de
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:25 +02:00
Jukka Rissanen 8d9ea90fba net: Add net_nbuf_pull function
This will remove given amount of data from the fragment list.

Change-Id: I17d809982af0b941f957205688ee61e5ac3c1f08
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:25 +02:00
Jukka Rissanen 6ef5fa22b2 net: Align net_if struct to 32-byte boundary
This is needed because if there are more than one network
interfaces configured, then the second interface will point
to wrong address. Only solution to this issue is to align
the net_if to 32 byte boundary. The issue was seen in qemu
and it is not really known if the issue is present in real
hardware.

Change-Id: I2048c8a9a0aab51f84c15539159410b544f6c9b1
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:25 +02:00
Jukka Rissanen 70430795a9 net: Fix the statistics compilation
Make sure that the statisitics compilation can be done even
if some sub-statistics module is not compiled, like IPv6 or
IPv4 statistics.

Change-Id: I1a91acd70569f074d9bb3269f74ee9c6a0ea9cf7
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:25 +02:00
Jukka Rissanen 96e629c877 net: Fix remaining debug option naming issues
Some of the DEBUG options for the new IP stack still used
the CONFIG_NETWORK_IP_STACK_DEBUG_ prefix.

Change-Id: I8f039ac5e303a7c571a870403ce17d758db540d5
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:25 +02:00
Tomasz Bursztyka 7353cf4079 net: ieee802154: Add CSMA-CA non slotted radio protocol support
Implementing the primitives for non-slotted CSMA-CA radio protocol
according to section 5.1.1.4 in the 2011 version of the specification.

Slotted version will come when Beacon frame will be supported, thus
getting PAN coordinator info from its superframe.

Change-Id: I0545ed953a3c48e6b8e9cd4082db01ed66ad098b
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:25 +02:00
Tomasz Bursztyka becf74743b net: Split debug Kconfig options from legacy to new stack
- new stack options are renamed and placed in their respective menus
- new stack Kconfig gets normalized (tabs vs spaces, etc...)

Change-Id: Ia68f6589fed464bbdd76dc0812775684b2f94a58
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:24 +02:00
Tomasz Bursztyka aaf5075372 net: Add a macro to create specific net if instances
This will be necessary for devices that require to instanciate more than
one network interface.

Change-Id: I01fd4eb220ed63a4fe073614fb2a132cd00c6bc8
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:24 +02:00
Jukka Rissanen 58a7ada44c net: Add network address length to user API
Add socklen_t addrlen parameter to net_context_bind(),
net_context_sendto() and accept callback.

Currently the address length option is not really mandatory
as we can figure out the length from the address family.
But if we are going to support other protocol address families
it might be needed.

Change-Id: I59206465c3259050c469c5b2150221646a9a08d7
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:24 +02:00
Johan Hedberg 35c24140f8 net: buf: Fix minor typo in documentation
Change-Id: I19869683c5dde8ef88ddfdfb1e0656a8b824ffdd
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-12-02 12:40:23 +02:00
Jukka Rissanen 5b40f871ff net: Do not try to use net_if.h in legacy uIP stack
The net_if.h is only meant for new IP stack.

Change-Id: I133d576d7c070dd4a2291544bd0b0401bda942b5
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:23 +02:00
Andrei Emeltchenko 295b68d90c net: Fix documentation errors in net_if header file
Change-Id: I66ae70040e7ea65b6b72b9736fe384db02f23581
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-12-02 12:40:23 +02:00
Jukka Rissanen 17d2ab05c8 net: Trickle algorithm implementation
See RFC 6206 for Trickle details.

Change-Id: I709d81eb182f068293cf4b1f1474b2911febc5d4
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:21 +02:00
Jukka Rissanen 181adfdadb net: Add support for IPv6 prefix lifetime
If the received IPv6 router advertisement contains prefix
address options, set the validity of the prefix and expire
them when needed.

Change-Id: I7026d2101bd9eca1f90688c14d5c6aaa66e4af5e
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:20 +02:00
Jukka Rissanen 27d9936bd3 net: Print buffer usage after receiving or sending data
Change-Id: Iae56937f8609b46778bc433ec88c193fe91e6cf4
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:19 +02:00
Jukka Rissanen dfc1e66780 net: Add ll address checker function
The net_linkaddr_cmp() will compare two link layer addresses
and return true if they are the same.

Change-Id: I13f5ee9e7976a4118e891aefdb6e7c08f098c0b6
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:19 +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 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 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
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 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 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 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 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 b055a05ae8 net: Add helpers for getting protocol specific sockaddr
Change-Id: Icdf9dec83856b35228f9e3be24c2beceb37c3178
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:15 +02:00
Jukka Rissanen 0dbe48eb46 net: Add sockaddr struct
These are need in future commits. The sockaddr struct will hold
the IP address and port number among other things.

Change-Id: I0971c39f0f1cb019aa8610977a245e24548c56ee
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:15 +02:00
Jukka Rissanen 6085ff518a net: Making IP address const in utility func
Changing the IP address type to const as the functions do not
modify the IP address.

Change-Id: I176d84af5f05843226a954f91b6bb3bba6596863
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:14 +02:00
Jukka Rissanen 20167bd472 net: Utility to get net_if according to index value
Using network interface index instead of net_if pointer can
save 3 bytes of memory. So these utilities help to convert
pointer to index and vice versa.

Change-Id: I8743a06e0935d48798b19526154058be385550af
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:14 +02:00
Jukka Rissanen 2658ac7a73 net: IP address lookup functions return interface
When checking the IP address from network interface, return
also the used network interface.

Change-Id: If7b8385193da4cb1b469f697e219cfae3b6477dd
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:14 +02:00
Tomasz Bursztyka a1fde2bff8 net: Fix dedicated IPv4 function for net_if
IPv4/6 functions follows this scheme: net_if_ipv<4/6>_<name>.
Applying that to net_if_set_gw/net_if_set_netmask which are IPv4
functions.

Change-Id: I2dcbb16ce81cfdffbfbb5cae24ad76ddf2b9919a
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:14 +02:00
Tomasz Bursztyka 92e592c80d net: Simplify IPV<4/6> config management in net_if
Reducing the amount of #if defined(CONFIG_NET_IPV<4/6>) for a clearer
code and to lower compiler's stress.

Change-Id: Iffbfbda4409c6cbf48a3057ea1b9e43309cd84e7
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:14 +02:00
Ravi kumar Veeramally 3fdaf518da net: Add utility to verify given addr based on ll
Utility verifies given address is based on link layer address
or not.

Change-Id: I2b89e498fa2481051ec9a47ada8b4a5e8e38ad7a
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:40:13 +02:00
Ravi kumar Veeramally a4cb318333 net: Add support for 802.15.4 short address for iid creation
If the link layer address is short address, create interface ID based on
short address.

Change-Id: I49e150cc20a0bf973880d27f418762f68f2d9139
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:40:13 +02:00
Ravi kumar Veeramally 602f1b58bd net: Clear ipv6 addr parameter on create iid
While reusing buffers and passing those parameters might have
already some garbage. So just clear first and create iid.

Change-Id: I5774de157e0c39e7e7b1313a598557c58a4c63b0
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:40:13 +02:00
Tomasz Bursztyka 2c875eb171 net: Fix net_ip.h documentation
Change-Id: I86cd4b607e9d67665e4061b25a459ca8b1d9c2e1
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:13 +02:00
Tomasz Bursztyka 97daa51c80 net: Cleanup net_if's documentation
Change-Id: Idd139ee5f56c8b55119db69582393fe2906eae74
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:13 +02:00
Tomasz Bursztyka b8e3415264 net: Let's use inline function for type checking for net_nbuf
Using macros does not let the compiler verifying about the type we are
providing, which usually give an error easier to understand.
Also, this will let the compiler deciding how to actually optimize
(inline or not) the code.

Change-Id: Iba49590b620ef0a1bd0ed5621453524fcfea747c
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:13 +02:00
Tomasz Bursztyka b70a4f501a net: Moving header files to include/net/yaip
This make sure we will found all relevant headers in the right location.

Change-Id: I37fe978ed2af09d921c48df6986a8df9041ddc3f
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:13 +02:00
Jukka Rissanen 92112c61aa net: Debugging function to print fragment chain information
Debug function that will print individual fragments and their sizes.

Change-Id: I84ce144230fb099bb44ed383075564ebf377998f
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:13 +02:00
Jukka Rissanen 51f48ff377 net: Refactor nbuf.h and nbuf.c
No functionality changes.

Change-Id: I4dc36ee95c46a1311cfa1466e069697df6268854
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:13 +02:00
Jukka Rissanen 482d7c69cc net: Refactored IPv6 DAD and ND activation
The earlier Kconfig entries for IPv6 DAD and ND were confusing.
This commit will clarify this so DAD is activated by
CONFIG_NET_IPV6_DAD and ND is activated by CONFIG_NET_IPV6_ND.
These are settings are enabled by default.

Change-Id: If6245e3425489bc454a0d75113770c4f797a4017
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:12 +02:00
Jukka Rissanen ac390213ff net: Utility that inserts free space to the fragment list
Provide an utility function that pushes data down in the fragment
chain which means that there would be some free space before the
first fragment.

Change-Id: I491ac4e8cbf633f86f2351cad48d683e829bda63
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:12 +02:00
Jukka Rissanen 47d71db2f8 net: Utility function to compact net_buf fragments
Provide a function that checks if there is any free space
in the individual fragment and remove such slack. If there
are fragments that would become empty, then those fragments
are removed from the fragment list and freed to the fragment
pool.

Change-Id: Ieb1c953a1458622c4552c23ef38e330873cd27c3
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:12 +02:00
Jukka Rissanen 4c9c626129 net: Initial UDP support
Create a handler for catching UDP network traffic. This commit
is only providing infrastructure for UDP management.

Change-Id: Ia6f8de62773a85f7b637b73bfe3c89197cc2abb1
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:12 +02:00
Jukka Rissanen 813fdf85ed net: Add IPv6 minimum MTU value
Added define for minimum IPv6 MTU value (1280 bytes)

Change-Id: Ia81d8b3df079a2bb9bfb0a05e297d94423ba0fc5
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:11 +02:00
Jukka Rissanen c30f90a4c4 net: Make some IPv6 utility functions to use const addr
Changed the net_is_ipv6_addr_unspecified() and
net_is_ipv6_addr_solicited_node() to use const IPv6 address
as those function do not change the address.

Change-Id: I1222bf946c371433a8468fa71054b93346e2ae4e
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:11 +02:00
Jukka Rissanen abf82f4150 net: Add TTL IPv4 option
User can set the initial value for time-to-live option in Kconfig.
The TTL option is only used in IPv4.

Change-Id: I57677e65a2adee4aa4dc16d1504f848d1218c6c1
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:11 +02:00
Jukka Rissanen 38a3253744 net: Add net_nbuf_copy() utility function
This function will copy desired amount of bytes from one
fragment list to another. Caller can specify amount of
bytes reserved in front of the new fragment list.

Change-Id: Ie3344b285a47c79f116fbcff500d383a99d28bf9
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:11 +02:00
Jukka Rissanen 57ab8e0899 net: Make IPv6 ND optional
It is possible to turn of IPv6 neighbor discovery if it is
not used in order to save some memory.

Change-Id: I20159dd452b7bac6962532a91e844c33f3da2dfb
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:11 +02:00
Jukka Rissanen eca55e103e net: Initial router advertisement support
Change-Id: I842a5aeff870da71eeabdc29c8ea730c541eddd0
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:11 +02:00
Jukka Rissanen 66f87c9542 net: Initial router solicitation support
Change-Id: Ic3aee9999656ab435e0965456d94fd5540b4e220
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:11 +02:00
Jukka Rissanen 9b3d8378e5 net: Initial IPv6 neighbor discovery support
Change-Id: I76dc7471c56085a61bbdd9f75ecb49aeb0874dbb
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:11 +02:00
Jukka Rissanen 53caa13652 net: Refactored ARP packet header handling
The ARP packet header contained ethernet header. This is very
confusing so separate the link layer header. Fixed also the
unit tests to run properly.

Change-Id: I8b00bde280ad9f49494766370acb2a8e9cade033
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:10 +02:00
Jukka Rissanen b4b296b888 net: Add utility func to return eth broadcast addr
As the broadcast address is needed in both arp.c and ethernet.c
it is useful to create a utility function for returning that.

Change-Id: I26e75e325f7ee6dcd703a92b3349bd8d388e157e
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:10 +02:00
Jukka Rissanen 4352795436 net: Calling net_buf_put() instead of nano_fifo_put()
Because of commit 7720f6ed1c ("net: buf: Introduce support
for fragmentation") the net_buf should be placed into queue by
calling net_buf_put() when using fragmented data.

Change-Id: I5c3dae92596e9cb0d0ba166bc3de2da9f4fc24b7
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:09 +02:00
Jukka Rissanen 79fc041407 net: Add link layer reserve information to l2 driver
Caller can figure out what is the link layer header size
for a given link layer. There is a callback that can return
a dynamic header size if needed.

Change-Id: I59ea2319eb6cb53a0ba5c6aa9e7eecc4b38c94d3
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:09 +02:00
Jukka Rissanen 60752bd08d net: Set the l2 src/dst addresses in nbuf
We need to know where the L2 protocol source and destination
addresses are so save that information in nbuf.

Change-Id: I08677a0421effb0c997c6a68cfc02ccfa67e7e1e
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:09 +02:00
Jukka Rissanen 068f0bf092 net: Add ethernet address helpers
Add helper to check Ethernet broadcast and multicast address.

Change-Id: Icfe5508a4d3ab2364209a50150a4f8fe239ebc93
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:09 +02:00
Ravi kumar Veeramally 5a15b9070c net: Add utility to remove ipv4 address from iface
Change-Id: Ic1366f575ac476b25a240be99df3b82594df2891
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:40:09 +02:00
Jukka Rissanen c13ffd3433 net: Fix arp.h so that net_arp_init() is found
The net_arp_init() was not properly declared if IPv4 was
not active.

Change-Id: I479b93f67c4536bcf9a081c36a6bc82dc5605c4c
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:08 +02:00
Jukka Rissanen 01423a8467 net: Network stack analyzer uses now the SYS_LOG sub-system
Use SYS_LOG instead of directly printing using printk()

Change-Id: I61cff11cf8424f726f24ea00b447f2f4827f2c9c
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:08 +02:00
Jukka Rissanen 41f584ee51 net: Do not overwrite SYS_LOG_DOMAIN
The net_core.h accidentally overwrote SYS_LOG_DOMAIN with "net".
This must be done only for network related log domain.

Change-Id: I1050e430e8b649126e527f28c61d191ff34bbf2f
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:08 +02:00
Jukka Rissanen 45afd1b0a7 net: The NET_DEBUG must not be set in header file
Setting NET_DEBUG in nbuf.h will confuse the net_core.h
so it should not be done here. The NET_DEBUG can only be
set in .c file.

Change-Id: Ia95996147bf119c4ddf9f45a9fd635f8d2b405cb
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:08 +02:00
Jukka Rissanen 4f193e5baf net: Refactor various network init functions
There is no need to check if the sub-system is initialized
because net_init() is the only place that will call these
functions.

Change-Id: Icd54d2adf2924431cedd7c47124a3410842aeca3
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:08 +02:00
Jukka Rissanen 7a88cee800 net: The IP protocol type needs to be set in L2 layer
The network L2 recv handler needs to set the initial value for
IP protocol type (IPv4 or IPv6). Otherwise the recv data check
in net_core.c:process_data() will not work properly if IPv4
is enabled.

Change-Id: I5684cd10e5d79e13a977406729ea68313e689c9b
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:07 +02:00
Jukka Rissanen fa15fe3de6 net: Add IPv6 address network interface utils
Various utilities for IPv6 address manipulation in network
interface.

Change-Id: I270f0935288abd77d64c0f64f56b549fb6c4feb9
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:07 +02:00
Jukka Rissanen e42774ce42 net: Add IPv6 utils for address manipulation
Change-Id: Iea5a0c81c5d35080b0206e33b4f279100fd0c80b
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:07 +02:00
Jukka Rissanen ec689c32f9 net: Changing IPv4 address compare to a function
The IPv4 comparer was a macro but making it now a inline
function.

Change-Id: I315c52d812996e352e9b392627296ba229530ae0
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:07 +02:00
Jukka Rissanen 518eedf1a2 net: Use const for static and pre-defined IPv6 addresses
Change-Id: Ia1ed07e6bd93d2102c6c25ab8cb1ccdc9cf80d17
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:07 +02:00
Jukka Rissanen 301feea5b4 net: Add struct to store link layer address
Adding a variant for net_linkaddr that can actually store
a link layer address. The normal net_linkaddr struct just
uses pointer to a ll address. The storage version is used
when we have a lladdr cache for neighbors.

Change-Id: I57421047f66090caf09595981c81d386144edce3
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:07 +02:00
Tomasz Bursztyka b81ece31e4 net: 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-12-02 12:40:07 +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 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 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 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 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
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 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 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 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
Jukka Rissanen d7e2897370 net: 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-12-02 12:40:03 +02:00
Jukka Rissanen 5729d1c461 net: 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-12-02 12:40:03 +02:00
Jukka Rissanen 6e803a9c6d net: 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-12-02 12:40:03 +02:00
Jukka Rissanen 6e8fdd34fe net: 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-12-02 12:40:03 +02:00
Jukka Rissanen d24f673248 net: 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-12-02 12:40:02 +02:00
Jukka Rissanen 93f129060d net: 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-12-02 12:40:02 +02:00
Jukka Rissanen cf5c1db262 net: 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-12-02 12:40:02 +02:00
Jukka Rissanen 09d317ccd0 net: 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-12-02 12:40:02 +02:00
Jukka Rissanen f49de47f42 net: 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-12-02 12:40:02 +02:00
Jukka Rissanen 6646597a86 net: 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-12-02 12:40:02 +02:00
Jukka Rissanen cce1854b58 net: 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-12-02 12:40:02 +02:00
Jukka Rissanen c44c229660 net: 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-12-02 12:40:02 +02:00
Jukka Rissanen 7047e00f85 net: 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-12-02 12:40:01 +02:00
Jukka Rissanen 8c8052497d net: 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-12-02 12:40:01 +02:00
Jukka Rissanen f75d8a86bb net: 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-12-02 12:40:01 +02:00
Jukka Rissanen 71f2a78316 net: 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-12-02 12:40:01 +02:00
Jukka Rissanen b33d8d6591 net: 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-12-02 12:40:01 +02:00
Jukka Rissanen 3e1aef117a net: 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-12-02 12:40:01 +02:00
Jukka Rissanen 14cdced965 net: 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-12-02 12:40:01 +02:00
Jukka Rissanen 81298abfb4 net: 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-12-02 12:40:00 +02:00
Jukka Rissanen 920a5f5e38 net: 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-12-02 12:40:00 +02:00
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