Commit graph

1260 commits

Author SHA1 Message Date
Michael Scott ad01c035b8 net: lwm2m: update function prototypes and descriptions
- Several of the functions use "path" as the parameter name for the
  string-based LwM2M path.  Let's clarify by using "pathstr".
- Recent updates to the LwM2M engine now support resource instances
  when parsing the LwM2M path.  Let's update descriptions accordingly.

Signed-off-by: Michael Scott <mike@foundries.io>
2019-08-02 12:00:35 +03:00
Jukka Rissanen c4a692a85f net: ppp: Add proper support to receive Echo-Reply message
Currently only net-shell calls net_ppp_ping() command, so make
it return the amount of time that it took to receive Echo-Reply
so the net-shell can print the round trip time value.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-29 10:24:46 +03:00
Jukka Rissanen 19a09bf553 net: pkt: Add net_pkt_read_le16() helper
We had a big endian helper but little endian one was missing.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-29 10:24:46 +03:00
Jukka Rissanen ddac835ea7 net: pkt: Add net_pkt_write_le16() helper
We had a big endian helper but little endian one was missing.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-29 10:24:46 +03:00
Jukka Rissanen 3e481f9d07 net: ppp: Allow delay of PPP protocol handshakes
By default PPP is started immediately when the network interface
goes up. This can be problematic especially when debugging the beast
so allow user to delay the startup.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-29 10:24:46 +03:00
Jukka Rissanen 4a5543db25 net: shell: Add ppp network interface support
Print point-to-point network information properly.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-29 10:24:46 +03:00
Jukka Rissanen 02239a99a2 net: ppp: Add IPV6CP support
Initial version for PPP IPv6 Control Protocol.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-29 10:24:46 +03:00
Jukka Rissanen f95938da0f net: ppp: Initial support for point-to-point protocol
This implements ppp L2 component, LCP and IPCP modules.

Fixes #14034

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-29 10:24:46 +03:00
Jukka Rissanen 0435dce697 net: Add support for TXTIME socket option
The SO_TXTIME socket option can be used by the application to
tell the network device driver the exact moment when the
network packet should be sent.

This feature is also implemented in Linux.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-24 10:17:16 +03:00
Jukka Rissanen ec2e2f43d8 net: sockets: Add sendmsg() API
Add BSD socket sendmsg() API that can be used to send data to peer
and also pass ancillary data to lower level of the network stack.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-24 10:17:16 +03:00
Jukka Rissanen 390a6cf617 net: context: Add support for net_context_sendmsg()
After this we can implement BSD sendmsg() API.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-24 10:17:16 +03:00
Jukka Rissanen c1d03b24af net: ip: Add iovec and msghdr structs
These are needed in sendmsg implementation. See RFC 3542 for
details of the msghdr struct and the macros that are used
to manipulate it.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-24 10:17:16 +03:00
Markus Fuchs a928b6dc61 net: sntp: add missing __cplusplus check
This patch adds an `extern "C"` linkage directive so sntp.h can be
included by C++ source files.

Signed-off-by: Markus Fuchs <markus.fuchs@de.sauter-bc.com>
2019-07-17 17:51:12 +03:00
Tomasz Bursztyka b2e71a2fa2 net: Add a connection manager preliminary logic
It currently only listens to relevant events about network interface to
decide whether raising connected or disconnected event.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-07-12 12:33:19 +03:00
Jukka Rissanen 3ebe60a3ba net: ip: Helper for getting used network address family as string
This helper can be used in debugging the used network address family.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-12 12:33:19 +03:00
Michael Scott e7155622a2 net: lwm2m: add custom TLS credential load function pointer
Current implementation of LwM2M engine doesn't allow users a way
of overriding TLS credential load with custom function.  This
would be needed by an offloaded TLS stack where we don't want
to use standard Zephyr functions.

Let's add a load_credential function pointer to the LwM2M client
context which will be called when it's available.

Fixes: https://github.com/zephyrproject-rtos/zephyr/issues/17408

Signed-off-by: Michael Scott <mike@foundries.io>
2019-07-11 11:08:05 +03:00
Tomasz Bursztyka c8f7c329a2 net/lldp: Simplify Kconfig file
Let's remove depends on NET_LLDP from all the options. It avoids this:
 # CONFIG_NET_LLDP is not set
 # CONFIG_NET_LLDP_LOG_LEVEL_OFF is not set
 # CONFIG_NET_LLDP_LOG_LEVEL_ERR is not set
 # CONFIG_NET_LLDP_LOG_LEVEL_WRN is not set
 # CONFIG_NET_LLDP_LOG_LEVEL_INF is not set
 # CONFIG_NET_LLDP_LOG_LEVEL_DBG is not set
 CONFIG_NET_LLDP_LOG_LEVEL_DEFAULT=y
 CONFIG_NET_LLDP_LOG_LEVEL=3
 CONFIG_NET_LLDP_CHASSIS_ID="CHASSIS_ID_PLACEHOLDER"
 CONFIG_NET_LLDP_PORT_ID="PORT_ID_PLACEHOLDER"

And instead it will generate this:
 # CONFIG_NET_LLDP is not set

Make the menu as an enablement config option as well.

Adapting lldp header file relevantly.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-07-10 15:24:32 +03:00
Jukka Rissanen 8f92dc4634 net: dns: Send net-mgmt event for DNS server add and del
If DNS server(s) are added or removed e.g., as part of DHCP
processing, send newly defined net-mgmt events so that
a user application may get this information.

Fixes #16924

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-09 17:04:55 +03:00
Jukka Rissanen 4b06ae323c net: mgmt: Add L4 layer and related events
These events are used by connection management patches following
this one.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-09 17:04:55 +03:00
Tomasz Bursztyka d80d181d04 net/iface: Add IPv4 route find and add
Removing an IPv4 router was missing, as well as finding the default
router for an IPv4 address.

Note howevere that IPv4 router features are not used anywhere yet. But
at least the API is there and is a 1:1 to IPv6, if that matters.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-07-09 14:54:23 +03:00
Tomasz Bursztyka eccc268d0a net/iface: Rework how routers are handled
- router lifetime is always a u16_t so fixing
net_if_ipv6_router_update_lifetime() signature.
- Coalescing router timers into one: this reduces the net_if_router
structure by 22 bytes
- refactor IPv6 and IPv4 router code so it's handled in generic
functions, to avoid duplicating 90% of the code for each family. This
also fixes the lifetime support for IPv4 which was missing.

Note however that IPv4 routing support seems to be missing as none of
the relevant functions are used anywhere yet.

Fixes #8728

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-07-09 14:54:23 +03:00
Tomasz Bursztyka b2d95840a5 net/ipv4: Add a net mgmt event for IPv4 router deletion
There will probably be at some point a way to remove IPv4 router, and
thus it will require such event.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-07-09 14:54:23 +03:00
Tomasz Bursztyka b5bcd25398 net/iface: Coalesce all RS timers through one
This reduces the size of struct net_if_ipv6 by 24 bytes by moving
the k_delayed_work attribute into net_if core code.
Then each net_if_ipv6 can be added to the timer handler via a slist.

This does not make much gain if the system has only 1 network interface
It starts to be interesting if it has 2+ network interfaces then.

Fixes #8728

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-07-09 14:54:23 +03:00
Tomasz Bursztyka 09e7262be8 net/iface: Coalesce all DAD timers through one
This reduces the size of struct net_if_addr by 24 bytes by moving
the k_delayed_work attribute into net_if core code.
Then each net_if_addr can be added to the timer handler via a slist.

This does not make much gain if the system has only 1 unicast IPv6
address. It's a nice memory improvment once it has 2+ unicast IPv6
address. Note that having IPv4 enabled along with IPv6 will also see
memory improvements since both IPv6 and IPv4 use the same struct
net_if_addr.

Fixes #8728

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-07-09 14:54:23 +03:00
Tomasz Bursztyka ca5d24d2cd net/iface: Remove useless attributes in net_if_ipv6 structure
DAD use dad_count attribute in struct net_if_addr, since DAD is ran on
each and every ipv6 unicast address.

Fixes #8728

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-07-09 14:54:23 +03:00
Tomasz Bursztyka 6a513e4394 net/iface: Reduce ifdef usage on various options
Offload, DAD, RS and IPv4 autoconf.

Fixes #8728

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-07-09 14:54:23 +03:00
Nicolas Pitre d19a5f9119 net: socket: mgmt: use uintptr_t for the nm_pid field
This may contain a pointer so make sure it is sufficiently wide
on 64-bit targets.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2019-07-05 10:06:23 -04:00
Nicolas Pitre 66045b5db0 net/socket: use the iterable section object constructor/iterator
The handcrafted allocation falls victim of misaligned structures due to
toolchain padding which crashes the socket test code on 64-bit targets.
Let's move it to the iterable section utility where those issues are
already taken care of.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2019-07-04 11:36:52 +03:00
Jukka Rissanen a18bd3a2e7 net: mgmt: Remove L1 layer as that is useless
The network interface events should be in L2 layer so there
is no one that would emit L1 events so no need for it.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-03 14:40:03 +03:00
Jukka Rissanen eef7625660 net: socket: Add SO_TIMESTAMPING socket option
This can be used to activate the network packet statistics
collection. Note that we do not have resources to calculate
each network packet transit times but we collect average times
instead.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-03 09:42:45 +03:00
Jukka Rissanen e809b95c51 net: Collect network packet TX send time
Finalize the CONFIG_NET_CONTEXT_TIMESTAMP support that was started
earlier but never properly finished. We collect network statistics for
TX packet network stack throughput time from when the net_context_send
is called and when the net_pkt was sent out successfully by the network
device driver.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-03 09:42:45 +03:00
Jukka Rissanen 7c65db4e31 net: socket: mgmt: Add setsockopt() and getsockopt() support
Currently only setting and getting of Ethernet Qav options are
supported via this interface.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-01 13:50:08 -07:00
Jukka Rissanen 6f32f17cda net: socket: Add userspace support to getsockopt()
Allow userspace application to call getsockopt() without crashing.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-01 13:50:08 -07:00
Jukka Rissanen ee849826e3 net: socket: Add userspace support to setsockopt()
Allow userspace application to call setsockopt() without crashing.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-01 13:50:08 -07:00
Jukka Rissanen 5d13df9c3b net: utils: Add userspace support to net_addr_ntop/pton()
Allow userspace application call net_addr_ntop() and
net_addr_pton() functions.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-01 13:50:08 -07:00
Jukka Rissanen c0d6831bc0 net: sockets: mgmt: Add AF_NET_MGMT address family support
Allow application to listen network management events using
BSD socket API. Application needs to create the socket using
AF_NET_MGMT address family. At this point we only support
receiving network management events that the network subsystem
is sending.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-01 13:50:08 -07:00
Jukka Rissanen 02b3826fa0 net: mgmt: Add info length to event wait API
The info parameter is difficult to use if the caller does not
get information how long the info struct is. So add info_length
parameter to net_mgmt_event_wait_on_iface() and
net_mgmt_event_wait() APIs.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-01 13:50:08 -07:00
Jukka Rissanen 766ad9f96c net: if: Make gateway address in net_if_ipv4_set_gw() const
As the function does not modify the parameter, we can make it const.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-01 15:34:11 +03:00
Jukka Rissanen 7063921e87 net: if: Add userspace support to IPv4 gateway set function
Allow application to call net_if_ipv4_set_gw_by_index()
and set the gateway if enabled by configuration.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-01 15:34:11 +03:00
Jukka Rissanen 813ae63f6b net: if: Add userspace support to IPv4 netmask set function
Allow application to call net_if_ipv4_set_netmask_by_index()
and set the netmask if enabled by configuration.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-01 15:34:11 +03:00
Jukka Rissanen 10189332cd net: if: Make IPv4 address const in removal function
As the function does not touch IPv4 address in removal, we
can mark it const.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-01 15:34:11 +03:00
Jukka Rissanen 041cd5f18f net: if: Add syscall interface to IP address add and rm
Make IPv4 and IPv6 address addition and removal possible from
userspace app. But allow this only if CONFIG_NET_IF_USERSPACE_ACCESS
By default these operations are not allowed from userspace app.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-01 15:34:11 +03:00
Justin Brzozoski ffe25df82a mqtt: Allow client to override keepalive
This change will allow an MQTT client to override the compile-time
keepalive if desired.  The change is structured such that the
compile-time default will still be setup by calling mqtt_client_init,
but can be changed by the application before calling mqtt_connect if
desired.

Signed-off-by: Justin Brzozoski <justin.brzozoski@signal-fire.com>
2019-06-28 09:54:16 -04:00
Anas Nashif efb8df5366 cleanup: include/: move misc/stack.h to debug/stack.h
move misc/stack.h to debug/stack.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif a2fd7d70ec cleanup: include/: move misc/util.h to sys/util.h
move misc/util.h to sys/util.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif 536dd5a71f cleanup: include/: move misc/slist.h to sys/slist.h
move misc/slist.h to sys/slist.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif 0c9e280547 cleanup: include/: move misc/mutex.h to sys/mutex.h
move misc/mutex.h to sys/mutex.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif 5d001f3e41 cleanup: include/: move misc/byteorder.h to sys/byteorder.h
move misc/byteorder.h to sys/byteorder.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif 5eb90ec169 cleanup: include/: move misc/__assert.h to sys/__assert.h
move misc/__assert.h to sys/__assert.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif c0c9396d44 cleanup: include/: move can.h to drivers/can.h
move can.h to drivers/can.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif e1e05a2eac cleanup: include/: move atomic.h to sys/atomic.h
move atomic.h to sys/atomic.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Nicolas Pitre 659fa0d57d lifo/fifo: first word is not always first 4 bytes
The first word is used as a pointer, meaning it is 64 bits on 64-bit
systems. To reserve it, it has to be either a pointer, a long, or an
intptr_t. Not an int nor an u32_t.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2019-06-26 09:08:42 -04:00
David B. Kinder 8de9cc7079 doc: use @rst/@endrst for ReST in headers
Folks found the use of @rststar/@endrststar non-intuitive (wanted to use
@rststart).  The "star" was there indicating the doxygen comment lines
had a leading asterisk that needed to be stripped, but since our
commenting convention is to use the leading asterisk on continuation
lines, the leading asterisk is always there.  So, change the doxygen
alias to the more expected @rst/@endrst.

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2019-06-25 23:33:55 -04:00
Jukka Rissanen 95e8498c27 net: ptp: Add usermode support to net_eth_get_ptp_clock_by_index()
Make net_eth_get_ptp_clock_by_index() clock API to work with user space.
Create also unit test for testing this user mode support.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-06-25 15:22:51 +03:00
Jukka Rissanen 11b06fab76 net: ethernet: Add net_eth_get_ptp_clock_by_index() function
This can be used to get the PTP clock if only network interface
index is known.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-06-25 15:22:51 +03:00
Jukka Rissanen def6b14aa7 net: ptp: clock: Create a dummy inline func for net_eth_get_ptp_clock()
Follow the style in other similar functions in this file.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-06-25 15:22:51 +03:00
Håkon Øye Amundsen 05cd3420ac net: mqtt: add mqtt_readall_publish_payload()
This function uses mqtt_read_publish_payload_blocking to perform a
blocking read of the specified number of bytes.

When reading out a payload, the normal use case is to read the
entire payload. This function facilitates that use case.

Signed-off-by: Håkon Øye Amundsen <haakon.amundsen@nordicsemi.no>
2019-06-20 13:06:08 +03:00
Anas Nashif f2cb20c772 docs: fix misspelling across the tree
Found a few annoying typos and figured I better run script and
fix anything it can find, here are the results...

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-19 15:34:13 -05:00
Jukka Rissanen 06b500b6bd net: sockets: can: Close the socket cleanly
If the socket is closed, then do CAN detach if that is needed.
This way the CAN interrupts are not received if there are no
CAN sockets listening the data.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-06-18 17:58:00 +03:00
Nicolas Pitre a946b2cc7a net: make __net_buf_align 64-bit compatible
Structures to which this applies contain pointers. So the alignment
should depend on pointer width. On 32-bit builds this remains the same.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2019-06-12 09:18:08 +03:00
David B. Kinder 00c41ea893 doc: fix doxygen comments with embedded reST
Doxygen comments can include doxygen-specific markup tags.  If other
markup tags are used (e.g., restructuredText) we need to indicate that
in the doxygen comments (via @rststar/@endrststar tags).

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2019-06-10 18:16:12 -04:00
Jukka Rissanen c3bb0a6af9 net: socket: Add SO_PRIORITY support to setsockopt
Allow user to set the socket priority using setsockopt() call.
The priority value is used to order the networking queues so
that packets with a higher priority may be processed first.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-06-09 12:54:05 +03:00
Loic Poulain 3653e688f3 net: ethernet: Fix build issue with C++
When compiling with CPP, compiler complains about implicit type
conversions. Fix them.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
2019-06-06 17:15:10 +08:00
Tomasz Bursztyka 79a25a6fff net/pkt: Redefine the necessary fifo attribute
commit 79672d16 was missing the fact socket layer is putting net_pkt
into a k_fifo. However, it's on receiving side only: at this point the
k_fifo_put is using the k_work area which is then useless at this
point Thus why it did not break anything, as k_fifo only needs 4 bytes
while the k_work attribute takes 12 bytes.

Thus adding a union on the k_work attribute with another new attribute
that describes the behavior.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-05-24 14:09:11 +03:00
Tomasz Bursztyka 79672d1647 net/pkt: Remove useless _reserved attribute
This attribute was used when net_pkt where queued into a fifo. However,
since the cove to k_work queues (due to the introduction of TC), such
attribute has been totally useless.

Removing it gains 4 bytes in net_pkt structure.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-05-23 22:22:16 +03:00
Tomasz Bursztyka 426764ebcf net/iface: Add a function to get IPv4 global address
As for IPv6, let's create the same function on IPv4 side.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-05-21 15:37:53 +03:00
Tomasz Bursztyka 979aedfab4 net/iface: Modify function to get IPv6 global address
Let's filter out on a state parameter.

There is no impact as this function is not used anywhere yet.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-05-21 15:37:53 +03:00
Tomasz Gorochowik c0b30355fb net: sockets: implement getsockname function
From POSIX.1-2017:

The getsockname() function shall retrieve the locally-bound name of the
specified socket, store this address in the sockaddr structure pointed
to by the address argument, and store the length of this address in the
object pointed to by the address_len argument.

The address_len argument points to a socklen_t object which on input
specifies the length of the supplied sockaddr structure, and on output
specifies the length of the stored address. If the actual length of the
address is greater than the length of the supplied sockaddr structure,
the stored address shall be truncated.

If the socket has not been bound to a local name, the value stored in
the object pointed to by address is unspecified.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2019-05-17 22:49:32 +03:00
Jukka Rissanen 89bf1578d9 net: sockets: Add a way to register a socket family handler
Allow automatic handling of registered socket families.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-05-10 22:43:27 +03:00
Paul Sokolovsky 22f1a29185 net: sntp: Add convenience API for one-shot SNTP query
sntp_simple() function queries the server (passed as "addr[:port]"
string). It wraps calls to a number of other functions, and may be
useful to write simple, concise apps needing the absolute time.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2019-05-10 13:44:32 +03:00
Paul Sokolovsky 426f3fa1ac net: socketutils: Add utils to manipulate network address strings
Two utils to manipulate addresses in format "addr[:port]". I.e.,
network address (domain name or numeric), optionally followed by
port number:

* net_addr_str_find_port(), to return pointer to port number
substring (or NULL if not present).
* net_getaddrinfo_addr_str(), which is effectively getaddrinfo()
wrapper taking a "addr[:port]" string as a parameter.

The header file is named socketutils.h to emphasize that these
utility functions are implemented on top of BSD Sockets API
(and other POSIX/ANSI C functions), and thus portable to other
POSIX systems (e.g., Linux), so can be used in apps testing
POSIX compatibility. More utility functions (beyond address
manipulation) can be added later.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2019-05-10 13:44:32 +03:00
Paul Sokolovsky 9ca9e077aa net: socket: Define NI_MAXHOST for compatibility
Not in POSIX. Linux man getnameinfo says about it:

"In order to assist the programmer in choosing reasonable sizes for
the supplied buffers, <netdb.h> defines the constants

           #define NI_MAXHOST      1025
           #define NI_MAXSERV      32

Since glibc 2.8, these definitions are exposed only if suitable
feature test macros are defined, namely: _GNU_SOURCE, _DEFAULT_SOURCE
(since glibc 2.19), or (in glibc versions up to and including 2.19)
_BSD_SOURCE or _SVID_SOURCE."

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2019-05-10 13:44:32 +03:00
Robert Lubos b8494d9a51 net: lib: mqtt: Enable blocking PUBLISH payload readout
It is convenient to have a blocking version of
`mqtt_read_publish_payload` function, for cases when it is called from
the event handler. Therefore, extend the 'mqtt_read_publish_payload'
argument list with information whether the call should block or not.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2019-05-07 22:08:30 -04:00
Tomasz Bursztyka 622f4abdf2 net/ip: Make struct net_addr holding uninon of ipv6/4 unconditionally
It will help to use IS_ENABLED in place of #ifdef in relevant place.

Only struct net_if uses this structure.
In case only IPv4 is used, it will bloat up this struct by 12 bytes.

There are few reasons why this is "ok" in this case:

- On limited rom/ram system it will be unlikely to find a lot of
network interfaces so it should not harm much to raise the size of
struct net_addr.
- If IPv4 is the only enabled IP version, it gains a good amount of
rom/ram to discard IPv6 support so it is fine to steal a bit of this
gain to bloat up a bit struct net_addr.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-05-07 15:40:33 +03:00
Tomasz Bursztyka b17664b1b0 net/offload: Add dummy functions when offloading is disabled
Thit will help removing usage of #if defined(CONFIG_NET_OFFLOAD) in
relevant places.

Note that static inlines are used instead of #define foo(...), to keep
the parameter check at build time.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-05-07 15:40:33 +03:00
Robert Lubos c5b0a99640 drivers: ieee802154: New API for ACK configuration
Introduce new API function for ieee802154 driver configuration.
Currently this function is used for ACK configuration.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2019-05-01 20:40:30 +03:00
Ravi kumar Veeramally 686830bbda drivers: native_posix: Add VLAN tag strip feature
This is mainly testing purpose from native_posize ethernet
driver. Enable CONFIG_ETH_NATIVE_POSIX_VLAN_TAG_STRIP to have
VLAN tag strip feature on ethernet Rx frames.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2019-04-26 10:46:27 +03:00
Ravi kumar Veeramally 08d24e428e net: ethernet: Add VLAN tag stripping capability flag
Some ethenet controllers want to strip the VLAN tag from
ethernet Rx frames and feed the packet into proper interface
queue based on the tag. Add this flag to get_capabilities()
to provide VLAN tag stripping feature to the controller.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2019-04-26 10:46:27 +03:00
Paul Sokolovsky f65727a193 net: sntp: Add sntp_query() function with fractional precision
Existing sntp_request() function has a coarse integer seconds
precision,  discarding fractional part as returned by SNTP.
Deprecate it, and instead introduce sntp_query() function which
returns both integer and fractional seconds as a newly introduced
structure sntp_tstamp.

Fixes: #15596

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2019-04-24 12:53:09 +03:00
Paul Sokolovsky e8e814c631 net: sntp: Handle case of request timeout
Previously, a case when poll() call timed out wasn't handled, and
recv() was called unconditionally. In the case of timeout, recv()
itself would hang indefinitely.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2019-04-24 12:50:12 +03:00
Jukka Rissanen 3633951652 net: if: Only start the network interface during init if needed
If the NET_IF_NO_AUTO_START network interface flag is set, then
do not take network interface up during the initialization of the
network interface. The network device driver can set the flag in its
network interface initialization function if needed.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-04-23 13:11:03 +03:00
Jukka Rissanen 712103d594 net: if: Add access functions for network interface flags
Provide access functions for manipulating network interface flags.
There is no need for the caller of this API to know about the inner
details of the flags.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-04-23 13:11:03 +03:00
Johan Hedberg f0c98527a4 net: buf: Remove wrong alignment annotation from NET_BUF_SIMPLE()
The code (net_buf_simple_init in particular) expects the data buffer
to immediately follow the net_buf_simple struct, so it's wrong to
request any specific alignment for this buffer. In practice this
doesn't make any difference since the net_buf_simple struct itself is
4-bytes aligned and a multiple of 4 bytes, however the extra
__net_buf_align makes it look like its location in memory doesn't need
to immediately follow the net_buf_simple struct.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-04-18 17:53:36 -04:00
Brett Witherspoon 88a1fd7dd9 net: fix errno returned without promiscuous mode support
If promiscuous mode support is disabled in Kconfig and promiscuous.h is
included the build will fail. The returned errno should be ENOTSUP.

Signed-off-by: Brett Witherspoon <spoonb@cdspooner.com>
2019-04-17 15:39:04 +03:00
Andrew Boie ce6b80470d net: add missing syscall for gethostname()
We need all the socket APIs to work from user mode.
tests/net/socket/misc now runs in userspace.

Fixes: #15227

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-04-06 14:30:42 -04:00
Paul Sokolovsky bd10c72bc4 net: sockets: Add docstrings for BSD Sockets API
The current idea is that we document zsock_* prefixed symbols, refer
to Open Group POSIX website
(http://pubs.opengroup.org/onlinepubs/9699919799/) for normative
descriptions, and explicitly mention bare POSIX name of a function
too (so e.g. users could find it via search).

Fixes: #13397

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2019-04-04 17:30:28 +08:00
Andrew Boie 7e3a34f84f mqtt: use sys_mutex instead of k_mutex
Allows the mqtt_client data structure to exist in user memory.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-04-03 13:47:45 -04:00
Patrik Flykt 24d71431e9 all: Add 'U' suffix when using unsigned variables
Add a 'U' suffix to values when computing and comparing against
unsigned variables.

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2019-03-28 17:15:58 -05:00
David B. Kinder 5d8e367efe doc: fix misspelling in docs and API comments
Fix misspellings missed during regular reviews.

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2019-03-27 15:59:09 -04:00
Jukka Rissanen c3cf543452 net: ethernet: lldp: Use short types for ints
Instead of uint16_t and uint8_t, use u16_t and u8_t types.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-03-27 10:13:16 -05:00
Jukka Rissanen 0888b9f85c doc: net: Fix LLDP documentation
The LLDP documentation was missing descriptions for enums
and structs.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-03-27 10:13:16 -05:00
Paul Sokolovsky 85e64097e3 net: socket: Define flags for getaddrinfo()
Add various AI_* flags, similar to previously added flags for
getnameinfo(). All flags specified by POSIX are defined (with
values compatible with Linux), to allow to build existing
software which may refer to them. They can be implemented
gradually, as usecases arrive.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2019-03-26 14:29:48 -04:00
Robert Lubos 1e0c7e4811 net: tls: Add credential type documentation
Add a brief description of available credential types.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2019-03-26 07:30:57 -05:00
Jukka Rissanen 295dc41c61 net: gptp: Rename z_gptp_pow2() to gptp_pow2()
The earlier removal of _ prefix went and renamed this func
and added z_ prefix. This is useless as the relevant macro
is called GPTP_POW2() so call the helper function as gptp_pow2().

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-03-25 14:43:23 -04:00
Tomasz Bursztyka a96d066038 net/pkt: Switch function internal notes to doxygen details
Replace "Note:" to actual @details so it appears properly formated in
generated documentation.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-25 13:50:55 -04:00
Tomasz Bursztyka 632e3fb1ae net/pkt: Improve net_pkt_skip documentation.
Its behavior varies whether overwrite bit is set or not, so detailing
this more carefully.

Fixes #14093

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-25 13:50:55 -04:00
Tomasz Bursztyka 874b164df5 net/context: Fix net_context_send_cb documentation
status parameter documentation was outdated.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-25 13:50:55 -04:00
Vincent Wan 3609e261bb net: sockets: move fcntl back to socket_offload.c
We are reverting the changes in commit
55b3f05932 given build errors are seen
when fcntl.h is included, as it declares fcntl() as a non-static
function. The same function cannot be declared as both static and
non-static.

Instead, we avoid redefining fcntl() in lib/os/fdtable.c specifically
for case of the SimpleLink family, til we have support for the new
socket_op_vtable.

Signed-off-by: Vincent Wan <vincent.wan@linaro.org>
2019-03-20 11:36:18 -05:00
Tomasz Bursztyka ebb3ca9430 net/pkt: Remove now useless attribute data_len
This reduces net_pkt structure size.
Moving sent_list attribute for better alignment.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-20 10:27:14 -05:00
Tomasz Bursztyka 84909970a0 net/pkt: Remove unused legacy net_pkt allocator
Now, only net_pkt_alloc and variants are used.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-20 10:27:14 -05:00
Tomasz Bursztyka a57e218965 net/offload: Remove useless token parameter
This parameter was removed from net_context already thus applying the
change also on net_offload API.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-20 10:27:14 -05:00
Tomasz Bursztyka 730b5de6d9 net/pkt: Remove superfluous total_pkt_len attribute
This attribute, in case CONFIG_NET_STATISTICS is enabled, made sense
when L2's send() function did not return the length of the sent packet.
But now, it's a superflous optimization as is it used only to set the
stats on recv or send, where net_pkt_get_len() can be used directly.

This helps to save 2 bytes from struct net_pkt.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-20 10:27:14 -05:00
Tomasz Bursztyka 03bfc5dd0f net/context: Remove token parameter from net_context_send/sendto
And also to the relevant callbacks.

That parameter is not used anywhere so it is useless.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-20 10:27:14 -05:00
Tomasz Bursztyka 7d97a1871a net/pkt: Remove unused token attribute
Seems like a useless attribute. Since net_context is not being used by
the user directly (socket is the unique interface now) and since no core
parts uses the token parameter of net_context API: let's remove the
attribute.

This helps to save 4 bytes from struct net_pkt.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-20 10:27:14 -05:00
Tomasz Bursztyka 39504c2560 net/pkt: Remove legacy net_frag_linear_copy function
This function is now superseded by net_pkt_read() and is no longer
used.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-20 10:27:14 -05:00
Tomasz Bursztyka ec3fe5560b net/pkt: Remove legacy net_pkt_append functions
These were based on the former allocation scheme and are no longer used.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-20 10:27:14 -05:00
Tomasz Bursztyka 23b753feed net/pkt: Remove legacy net_frag_read/skip/get_pos functions
These were based on the former allocation scheme and are no longer used.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-20 10:27:14 -05:00
Tomasz Bursztyka d6d52ce9e5 net/pkt: Remove _new suffix to net_pkt_write functions
Suffix is now useless, as these functions are now the only ones.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-20 10:27:14 -05:00
Tomasz Bursztyka a15654980e net/pkt: Remove legacy net_pkt_insert functions
These were based on the former allocation scheme and are no longer used.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-20 10:27:14 -05:00
Tomasz Bursztyka ea518af5dd net/pkt: Remove legacy net_pkt_write functions
These were based on the former allocation scheme and are no longer used.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-20 10:27:14 -05:00
Tomasz Bursztyka a25f054cbd net/pkt: Remove _new suffix to net_pkt_read functions
Suffix is now useless, as these functions are now the only ones.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-20 10:27:14 -05:00
Tomasz Bursztyka f8a091104e net/pkt: Remove _new suffix to net_pkt_get_data_new function
Now that legacy - and unrelated - function named net_pkt_get_data has
been removed, we can rename net_pkt_get_data_new relevantly.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-20 10:27:14 -05:00
Tomasz Bursztyka 2022aa3484 net/pkt: Remove now useless net_pkt_get_data()
That function was responsible for allocating new buffer element, but it
is now unused and can be removed safely. Buffer allocation is now done
via net_pkt_alloc_buffer().

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-20 10:27:14 -05:00
Tomasz Bursztyka 172fe5a87b net/context: Remove _new suffix on net_context_send/sendto functions
Now that legacy functions are removew, let's rename the new functions by
removing the _new suffix.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-20 10:27:14 -05:00
Tomasz Bursztyka 62ab954251 net/pkt: Remove appdata/appdatalen attributes and related functions
There is no need for these anymore: all is dictated by the position of
the net_pkt's cursor now

- actual cursor position is like the former appdata attribute
- net_pkt_remaining_data() is like the former appdatalen attribute

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-20 10:27:14 -05:00
Tomasz Bursztyka 0b173e3b77 net/context: Remove legacy API
Former net_context_send/sendto and net_context_create_ipv4/ipv6 are now
unused and can be removed.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-20 10:27:14 -05:00
Paul Sokolovsky f79965f77b net: pkt: Clarify docstring of the new API
Make descriptions a bit more clear, emphasizing the primary
operation, and de-emphsizing (but still describing) prerequisites
and side effects.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2019-03-18 11:23:23 -05:00
Paul Sokolovsky 193d6c60df net: sockets: Implement gai_strerror()
To save binary size, currently just returns textual name of error
code, e.g. EAI_FAIL -> "EAI_FAIL". Based on real usecases, can be
replaced with user-friendly message later. (Current usecase is to
allow/help to elaborate sockets API by proof-of-concept porting
existing socket apps).

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2019-03-15 07:13:15 -05:00
Andrei Emeltchenko 99403c5b13 net: ethernet: Define and use Ethernet frame and datagram size
Remove magic numbers from Ethernet drivers and tests by defining
NET_ETH_MAX_DATAGRAM_SIZE and NET_ETH_MAX_FRAME_SIZE.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-03-15 06:44:13 -05:00
Paul Sokolovsky 8658e3fe79 net: socket: Split select-related declaration to separate header
select() is a rather peculiar construct, defining/depending on many
types and symbols. Making that to coexist with POSIX subsystem is
an ongoing challange. To facilitate that, let's split those
definitions to a separate header (which e.g. can be included without
including all the rest of socket defines).

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2019-03-14 12:05:02 +01:00
Jukka Rissanen 6346cc1a9e doc: net: Add SNTP API documentation
Documentation for Simple Network Time Protocol library was
missing.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-03-13 15:37:02 -07:00
Tomasz Bursztyka 4508e94b4e net/pkt: Enable allocating from external slab and data pool on new API
This is meant for very particular use case as only logging uses that.
Where it makes entirely sense for it to send the logs through its own
slab/pool in order to not drain the core slabs/pools.

So enabling the new API to manage that. That has to be used with
net_context for the buffer pool. So one has to first allocate the
net_pkt from external slab, set the context and then (and only then)
allocate buffer. Basically, only net_context will uses that scheme
anyway.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-11 20:56:44 -07:00
Tomasz Bursztyka c10d780e90 include/net: Fix net_pkt.h indentation issue
Tiny macro parameter identation issue fixed.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-11 20:56:44 -07:00
Patrik Flykt 4344e27c26 all: Update reserved function names
Update reserved function names starting with one underscore, replacing
them as follows:
   '_k_' with 'z_'
   '_K_' with 'Z_'
   '_handler_' with 'z_handl_'
   '_Cstart' with 'z_cstart'
   '_Swap' with 'z_swap'

This renaming is done on both global and those static function names
in kernel/include and include/. Other static function names in kernel/
are renamed by removing the leading underscore. Other function names
not starting with any prefix listed above are renamed starting with
a 'z_' or 'Z_' prefix.

Function names starting with two or three leading underscores are not
automatcally renamed since these names will collide with the variants
with two or three leading underscores.

Various generator scripts have also been updated as well as perf,
linker and usb files. These are
   drivers/serial/uart_handlers.c
   include/linker/kobject-text.ld
   kernel/include/syscall_handler.h
   scripts/gen_kobject_list.py
   scripts/gen_syscall_header.py

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2019-03-11 13:48:42 -04:00
Andrei Emeltchenko a9090c9538 net: lldp: Move optional End TLV to send function
In a case we have optional TLVs we need to send End TLV in the very
end.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-03-09 16:02:11 -05:00
Andrei Emeltchenko 480f93fbb5 net: lldp: Add optional TLV API
Add possibility to set optional TLVs to LLDP DU.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-03-09 16:02:11 -05:00
Andrei Emeltchenko fba09bffb2 net: lldp: Move LLDP structure definition to lldp
Move duplicated structure definitions to lldp subsystem from
drivers.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-03-09 16:02:11 -05:00
Tomasz Bursztyka dd01e9997f net/context: Add an option so set/unset packet timestamping
Though core system is able to manage packet timestamping internaly (gptp
requires it for instance), it might be necessary to enable/disable
packet timestamping from net context directly.

Currently this will be only used by the tx timestamp test. So this
support is disabled by default. (And gptp does not require it anyway).

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-09 10:09:33 -05:00
Tomasz Bursztyka 6c18a27c30 net/pkt: Allow having NULL as iface
That can be useful on some tests which will not have any interface but
still allocate net_pkt. Also, one may allocate a packet with buffer not
knowing yet the interface it will be send through.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-09 10:09:33 -05:00
Loic Poulain 10bdc2aa38 net: context: Explicit net_sock_type enum conversion
When compiling with C++ support, a build error occur:

net_context.h: In function ‘net_sock_type net_context_get_type(net_context*)’:
net_context.h:402:75: error: invalid conversion from ‘long unsigned int’ to ‘net_sock_type’ [-fpermissive]
  enum net_sock_type t = ((context->flags & NET_CONTEXT_TYPE) >> 6);

Let's fix that using a cast.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
2019-03-08 08:44:46 -05:00
Vincent Wan 55b3f05932 include: net: Move fcntl implementation into socket_offload.h
This is done to conform with how the rest of the socket APIs are
implemented during socket offload. Otherwise link error would
result due to the symbol being redefined in lib/os/fdtable.c.

Signed-off-by: Vincent Wan <vincent.wan@linaro.org>
2019-03-05 11:37:10 -05:00
Michael Scott b56035c940 doc: net: lwm2m: add LwM2M high-level API documentation
The LwM2M public APIs were never well documented.  Let's fix
that by adding the needed information to include/net/lwm2m.h

Fixes: https://github.com/zephyrproject-rtos/zephyr/issues/12958

Signed-off-by: Michael Scott <mike@foundries.io>
2019-03-05 08:10:06 -05:00
Jukka Rissanen 81e83ba462 net: arp: Update the ARP cache if receiving ARP req
If we receive the ARP request, then check if the ARP cache
contains an entry for this IP address already. If it does,
then update the MAC address in the cache.

Fixes #10188

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-03-02 03:56:48 +01:00
Jukka Rissanen 6e2501dd25 net: buf: Doxygen comment additions and fixes
Following changes done:

* While looking through generated net_buf HTML documentation
  I noticed that some of the macros were not documented.
* Removed extern variable declarations from generated
  documentation (because those variables were not documented).
* Replaced "/** @brief xxx" by "/**\n * @brief xxx" as
  checkpatch complained about them (@brief being in the same
  line as the start of the block comment).
* Went through all the block comments and made them look similar
  and removed extra space character.
* Removed duplicate lines from function documentations. So
  if the @brief text is the same as the detailed one, then the
  generated output was looking funny.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-03-01 13:02:01 +01:00
Paul Sokolovsky 9c86dbfd8e net: socket: Define a few well-known socket options
Values based on Linux values, which are in turn likely based on
well-known BSD values.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2019-03-01 09:52:15 +01:00
Paul Sokolovsky 4e36a05c89 net: ip: Add defines for IPPROTO_IP and IPPROTO_IPV6
These can be used as getsockopt/getsockopt params and required for
compatibility with existing socket applications.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2019-03-01 09:52:15 +01:00
Jukka Rissanen 52dc50dc6b net: lldp: Allow generation of documentation
No need to hide the symbols in the header file if CONFIG_NET_LLDP
is not enabled. This also allows the documentation to be generated
properly.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-03-01 09:45:06 +01:00
David B. Kinder e731bdc81a doc: fix docs, include, and Kconfig misspellings
Fix misspellings missed during regular reviews

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2019-02-28 09:32:12 +01:00
Jukka Rissanen c74d3b06d5 net: doc: Add missing doxygen comments to structs
The doxygen comment for ieee802154_radio_api, net_l2 and
net_pkt structs was missing, which meant that no documentation
was generated for them.

Also add comment to "enum net_l2_flags" as that looks better in
the generated html file.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-02-27 08:34:39 -06:00
Paul Sokolovsky 9744985af1 net: context: Fix send function documentation
Newly added net_context_send_new()/net_context_sendto_new() take
void *buf, size_t len params but in docstring, refer to "network
buffer", which is apperently copy-paste artifact.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2019-02-27 08:33:52 -06:00
Robert Lubos d26963fceb net: socket: Add doxygen descriptions for socket offloading
Add brief doxygen documentation for socket offloading API.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2019-02-26 17:26:48 -08:00
Jukka Rissanen 429b6ed68e net: stats: Wrong Kconfig options were used for statistics
The net-shell was using wrong config options for statistics
support. Also net_stats.h had wrong config used for IPv6 MLD
statistics.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-02-26 02:25:45 +01:00
Jukka Rissanen b04ea677e7 net: ethernet: Place MII defines into separate doxygen group
The Ethernet documentation will look better if we place
the MII defines into a separate ethernet_mii doxygen group.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-02-26 02:07:36 +01:00
Jukka Rissanen 907ea83b1e net: ethernet: Fix doxygen documentation
Ethernet hw capability was not in generated documentation.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-02-26 02:07:36 +01:00
Tomasz Bursztyka 6435553dea net/context: Add a way to set/get ttl/hop_limit from net_context
Since net_context_sendto_new() does not take a net_pkt anymore, the only
way to set net_pkt's ttl/hop_limit is to pass it through net_context.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-26 01:50:59 +01:00
Jukka Rissanen 898973be8a net: ip: Add more documentation to net_ip.h
No functionality changes, just doxygen additions and some
things are hidden from document generation.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-02-22 13:54:14 -05:00
Jukka Rissanen 82616a62d6 net: offload: Remove CONFIG_NET_OFFLOAD from header file
The extra check for CONFIG_NET_OFFLOAD is not needed as it
prevents documentation generation for this API.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-02-22 10:48:14 -05:00
Jukka Rissanen c478b5bb6e can: Rename can_msg and can_msg_filter structs
In order to follow the naming from Linux, change the name of
can_msg to zcan_frame, and can_msg_filter to zcan_filter.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-02-22 08:07:03 -05:00
Jukka Rissanen efff3c68fe net: stats: Add missing doxygen comments
Various net_stats structs were missing doxygen comments.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-02-21 16:37:56 -05:00
Jukka Rissanen db45ed716f doc: net: Hide UDP API documentation
The UDP API functions are for Zephyr internal use only so do
not generate documentation for them.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-02-21 16:37:43 -05:00