Commit graph

1061 commits

Author SHA1 Message Date
Robert Chou c1500fe9a4 net: lwm2m: report resource type / content type at registration
Per LwM2M specification 5.3.1 Register, report "ct=11543" when JSON is
supported. Also, report the resource type as rt="oma.lwm2m" when "ct="
presents.

Signed-off-by: Robert Chou <robert.ch.chou@acer.com>
2017-08-17 21:52:24 +03:00
Robert Chou a64dcbb7bf net: lwm2m: do not report object when object instances available
Per LwM2M specification 5.3.1 Register. When object instances are
available, object ID can be ignored in registration message

Signed-off-by: Robert Chou <robert.ch.chou@acer.com>
2017-08-17 21:52:24 +03:00
Robert Chou c21372eeb8 net: lwm2m: do not expose security object
According to LwM2M specification 5.2.7.3 Bootstrap DISOCVER,
security object is only reported to the bootstrap server.

Correct the behavior to (1) report server object to the server
(2) do not report security object at registration time

Signed-off-by: Robert Chou <robert.ch.chou@acer.com>
2017-08-17 21:52:24 +03:00
Paul Sokolovsky d9af77bfd6 net: sockets: Consistently use "BSD Sockets compatible API" moniker
This is how it's called in the main docs, so use this same phrase in
Kconfig and samples too.

Also, added some articles to docs.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-08-17 12:02:55 -05:00
David B. Kinder 81f7c82625 doc: fix misspellings and missing EOF newlines
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2017-08-16 17:38:41 -05:00
Jukka Rissanen 12017ce761 net: http: Yield after sending response in server
Make sure that a network packet is sent after calling
http_response_send_data(). Othwerwise the packets might be
piling up and not sent in timely manner.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-08-16 14:50:57 -04:00
Michael Scott fe84d4f7dd net: http: allow HTTP_NETWORK_TIMEOUT to be configured
Currently, the HTTP_NETWORK_TIMEOUT setting is hard-coded as 20 seconds.
Not every application may want to wait that long, so let's change this
to a CONFIG option: CONFIG_HTTP_CLIENT_NETWORK_TIMEOUT

NOTE: This also removes HTTP_NETWORK_TIMEOUT from the public http.h
include file.  It was not being used externally to HTTP client sources.

Signed-off-by: Michael Scott <michael.scott@linaro.org>
2017-08-16 12:35:33 +03:00
Michael Scott 8ebaf29927 net: http: dont timeout on HTTP requests w/o body
A TCP FIN message is passed on to user apps as a tcp_received_callback
with a NULL pkt parameter.  This means the connection is closing and
the app should do whatever cleanup it needs as there will be no further
callbacks for the current TCP connection.

Currently, if a HTTP client request doesn't receive a "body" which
the HTTP parser can use to trigger on_message_complete, then the request
will end up timing out and most apps will think an error has occurred.

Instead, let's handle the TCP FIN message and return the waiting
semaphore, leaving the app to deal with whatever has been set in the
current HTTP context response data (IE: http_status).

This fixes using HTTP client to send POST data to servers which
only respond with HTTP_OK status and no body.

Signed-off-by: Michael Scott <michael.scott@linaro.org>
2017-08-15 22:21:15 +03:00
Paul Sokolovsky f9caab42cc net: sockets: Move under "Network Application Support" heading
"Network Application Support" itself is renamed from "Network
Applications" and also includes net_app API.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-08-15 09:20:27 -04:00
Paul Sokolovsky c1a5573c85 net: sockets: Check return value of k_poll()
Mostly to make Coverity happy.

Coverity-CID: 173641

Jira: ZEP-2465

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-08-14 23:46:44 +03:00
Jukka Rissanen f125672c9a net: app: Do not try to set ANY address to interface
If the user has not specified CONFIG_NET_APP_MY_IPV4_ADDR or
CONFIG_NET_APP_MY_IPV6_ADDR, the value is set to "" in this case.
This will be converted to ANY IP address which is not useful
to be set to the network interface. So check this and just
continue the init in this case without setting the IP address.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-08-14 11:06:34 +03:00
Jukka Rissanen 7886336593 net: app: Fix for net_app_get_net_buf()
The documentation says that the API will automatically append the
net_buf fragment to the end of network packet fragment chain.
This was not the case and current only user for this API in
echo-server sample appended the fragment itself. The fix is to
automatically append the fragment to the end of fragment chain.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-08-14 10:04:03 +03:00
Robert Chou 37e21a4152 net: lwm2m: fix registration content format and use plain/text
1. According to the specification 5.3.1, it's a MUST to specify
   (1) content format: app link format (2) supported lwm2m version.
   Also, we should use text/plain instead of LWM2M's (obsolete).
2. Use LWM2M_FORMAT_OMA_TLV as default accept format when accept option
   is not given from the caller for TLV is a MUST have in LwM2M spec and
   it can deals w/ multiple resources read

Signed-off-by: Robert Chou <robert.ch.chou@acer.com>
2017-08-13 20:52:56 +03:00
Robert Chou 87ce5f1935 net: lwm2m: save accept format in observe_node_data
Save in observe_node_data so that later on we can select the correct
content format requested by the caller at the first time

Signed-off-by: Robert Chou <robert.ch.chou@acer.com>
2017-08-11 09:53:47 +03:00
Robert Chou 84106f3cb3 net: lwm2m: fix erroneous TLV write
Function do_write_op_tlv() uses in->inbuf and in->insize as a looping
condition to iterate through items in TLV payload and call
do_write_op_tlv_item() to update the value.

However, do_write_op_tlv_item() will override the value before calling
for fitting the usage of lwm2m_write_handler() function without restore
them. (lwm2m_write_handler() is also called by plain text/json writer
and is expecting in->inbuf is the start of buffer and in->insize as the
length of the buffer)

This will result in errors in do_write_op_tlv().

Signed-off-by: Robert Chou <robert.ch.chou@acer.com>
2017-08-11 09:49:45 +03:00
Michael Scott f18674a320 net: http: fix http client request "Host" header
RFC-7230 "HTTP/1.1 Message Syntax and Routing" Section 5.4
describes the "Host" header formatting.  If Zephyr user
specifies a host string as a part of the HTTP client request
structure, we end up sending an incorrect HTTP header due
to a missing "Host :" text.

Fix this by prepending "Host: " to the header data before
the user supplied host string.

Signed-off-by: Michael Scott <michael.scott@linaro.org>
2017-08-11 09:45:02 +03:00
Aska Wu eb8fd4aacf net: sockets: inet_pton() should return 1 on success
Add zsock_inet_pton() to convert the return value of net_addr_pton()
which returns 0 on success.

Signed-off-by: Aska Wu <aska.wu@linaro.org>
2017-08-10 17:41:47 +03:00
Ricardo Salveti cc3290afc8 net: lwm2m: build sprint_token only when debug is enabled
sprint_token is only used by SYS_LOG_DBG, so only build it when
CONFIG_SYS_LOG_LWM2M_LEVEL > 3.

Signed-off-by: Ricardo Salveti <ricardo.salveti@linaro.org>
2017-08-10 12:42:40 +03:00
Ricardo Salveti 3896930be6 net: lwm2m: engine: add flag for separate response
Separate response can happen when handling block transfer for firmware
updates, and to avoid duplicating the lwm2m_udp_receive function, create
and additional flag to allow handling CoAP separate response messages.
This is required to avoid removing the reply callback, since a new
message (with a valid token) will be received later from the server.

Signed-off-by: Ricardo Salveti <ricardo.salveti@linaro.org>
2017-08-10 12:42:40 +03:00
Ricardo Salveti 36fe07802a net: lwm2m: create common wrapper for net_context_sendto
Simplifly net_context_sendto calls and also allows to easily debug every
send/receive lwm2m call.

Signed-off-by: Ricardo Salveti <ricardo.salveti@linaro.org>
2017-08-10 12:42:40 +03:00
Ricardo Salveti 2c759d180d net: lwm2m: engine: fix typo
Signed-off-by: Ricardo Salveti <ricardo.salveti@linaro.org>
2017-08-10 12:42:40 +03:00
Ricardo Salveti 17b33d3a58 net: lwm2m: rd_client: handle forbidden errors
Stop both bootstrap and registration process if they return forbidden.

Signed-off-by: Ricardo Salveti <ricardo.salveti@linaro.org>
2017-08-10 12:42:40 +03:00
Ricardo Salveti 61961cf737 net: lwm2m: firmware: add Kconfig option for CoAP block size
CoAP block size might be adjusted for a faster firmware download
process.

Signed-off-by: Ricardo Salveti <ricardo.salveti@linaro.org>
2017-08-10 12:42:40 +03:00
Jukka Rissanen 55b8edc88e net: Fix LLVM compiler warnings
Jira: ZEP-2488
Jira: ZEP-2486
Jira: ZEP-2485
Jira: ZEP-2482
Jira: ZEP-2480

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-08-09 12:50:50 -04:00
Robert Chou cd56290dbe net: lwm2m: rename CONFIG_NET_L2_BLUETOOTH to CONFIG_NET_L2_BT
Signed-off-by: Robert Chou <robert.ch.chou@acer.com>
2017-08-09 16:03:02 +03:00
Johan Hedberg 2975ca0754 Bluetooth: Kconfig: Rename CONFIG_BLUETOOTH_* to CONFIG_BT_*
The API name space for Bluetooth is bt_* and BT_* so it makes sense to
align the Kconfig name space with this. The additional benefit is that
this also makes the names shorter. It is also in line with what Linux
uses for Bluetooth Kconfig entries.

Some Bluetooth-related Networking Kconfig defines are renamed as well
in order to be consistent, such as NET_L2_BLUETOOTH.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-08-09 11:14:19 +03:00
Michael Scott ccd4f68da3 net: lwm2m: add SPX Apache-2.0 license tag w/ Linaro copyright
Signed-off-by: Michael Scott <michael.scott@linaro.org>
2017-08-09 10:55:53 +03:00
Michael Scott aef5ee4582 net: lwm2m: add IPSO support w/ temperature sensor object
IPSO Smart Objects are a set of template objects based on the LwM2M
object framework which are designed to represent standard hardware
such as temperature and humidity sensors or light controls.

Let's add a place for these objects to live as well as an initial
temperature sensor object.

Signed-off-by: Michael Scott <michael.scott@linaro.org>
2017-08-09 10:55:53 +03:00
Michael Scott c46c206f8c net: lwm2m: initial library support for LWM2M
Origin: SICS-IoT / Contiki OS
URL: https://github.com/sics-iot/lwm2m-contiki/tree/lwm2m-standalone-dtls
commit: d07b0bcd77ec7e8b93787669507f3d86cfbea64a
Purpose: Introduction of LwM2M client library.
Maintained-by: Zephyr

Lightweight Machine-to-Machine (LwM2M) is a protocol stack extension
of the Constrained Application Protocol (CoAP) which uses UDP
transmission packets.

This library was based on source worked on by Joakim Eriksson,
Niclas Finne and Joel Hoglund which was adopted by Contiki and then
later revamped to work as a stand-alone library.

A VERY high level summary of the changes made:
- [ALL] sources were re-formatted to Zephyr coding standards
- [engine] The engine portion was re-written due to the heavy reliance
  on ER-CoAP APIs which are not compatible to the Zephyr CoAP APIs as
  well as other Zephyr specific needs.
- [engine] All LWM2M/IPSO object data is now abstracted into resource
  data which stores information like the data type, length, callbacks
  to help with read/write.  The engine modifies this data directly (or
  makes callbacks) instead of all of the logic for this living in each
  object's code. (This wasn't scaling well as I was implementing
  changes).
- [engine] Related to the above change, I also added a generic set of
  getter/setter functions that user applications can call to change
  the object data instead of having to add getter/setting methods in
  each object.
- [engine] The original sources shared the engine's context structure
  quite extensively causing a problem with portability. I broke up the
  context into it's individual parts: LWM2M path data, input data and
  output data and pass only the needed data into each set of APIs.
- [content format read/writer] sources were re-organized into single
  .c/h files per content formatter.
- [content format read/writer] sources were re-written where necessary
  to remove the sharing of the lwm2m engine's context and instead only
  requires the path and input or output data specific to it's
  function.
- [LwM2M objects] re-written using the new engine's abstractions

Signed-off-by: Michael Scott <michael.scott@linaro.org>
2017-08-09 10:55:53 +03:00
Michael Scott 911efb0e72 net: zoap: use message id for reply matching
In the 08 Feb 2017 V1.0 LwM2M specification page 80 mentions: in
response to a "Notify" operation for which it is not interested in
any more, the LwM2M Server can send a "Reset Message".

Leshan server sends this CoAP RST response and it does not contain
the originating message token (which is also how the packet flow looks
on page 81 of the LwM2M spec).  Using the current ZoAP sources, the
client has no way of matching back to observation which needs to be
cancelled.

Let's add a match for message ID of a reply where there is no token
to handle this case.

Signed-off-by: Michael Scott <michael.scott@linaro.org>
[ricardo.salveti@linaro.org: Handle both piggybackend and separate
response (id doesn't need to match, only token).]
Signed-off-by: Ricardo Salveti <ricardo.salveti@linaro.org>
2017-08-09 10:55:53 +03:00
Jukka Rissanen 64562e1af2 http: server: Add function to send a chunk of data
The http_response_send_data() can be used to send a chunk of data
to the peer.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-08-08 15:35:18 +03:00
Paul Sokolovsky f80b2ac865 net: sockets: Fix race condition with accept() call
For an accepted socket, we should set our receive callback and start
to queue packets ASAP (in the accept callback itself). Otherwise,
(if done in accept() call like before) we may miss to queue some
packets.

This issue wasn't exposed with slow SLIP and with emulated QEMU, but
easily exposed with Ethernet on a real hardware.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-08-08 12:44:28 +03:00
Jukka Rissanen 509cdfefe2 net: Fix compile warnings
Some compile warnings were shown when using newlib.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-08-08 12:11:04 +03:00
Jukka Rissanen ddc71c139a new: app: Fix compile error if using newlib
We need to define __LINUX_ERRNO_EXTENSIONS__ if newlib is being
used otherwise there is a compile error about ESHUTDOWN errno
value missing.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-08-08 12:11:04 +03:00
Michael Scott 64ead4c6ee net: app: fix IPv6 init for late IP assigment
- Fix typo'd "&&" when checking bit value
- Don't use NET_EVENT_IPV6_ADDR_ADD for checking mask value
  due to combination of bits: _NET_EVENT_IPV6_BASE |
  NET_EVENT_IPV6_CMD_ADDR_ADD
  Instead use NET_EVENT_IPV6_CMD_ADDR_ADD so the check works
  when NET_EVENT_IPV6_ROUTER_ADD is enabled.

Tested fix with echo_server on x86 qemu where it was previously
broken.

Signed-off-by: Michael Scott <michael.scott@linaro.org>
2017-08-08 08:28:54 +03:00
Jukka Rissanen 238c51f6d0 net: sockets: Comment Coverity warning about unchecked values
Coverity complains about non-checked return values here. This is false
positive as the return values do not need checking in this special
case because we are closing the socket.

Coverity-CID: 173646

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-08-07 21:32:03 -04:00
Jukka Rissanen 8c02460a5e net: dns: Check address family when initializing
It is be possible that the local address was not properly
resolved in which case the local_addr variable could be NULL.
This will cause NULL pointer access if the variable is used.

Coverity-CID: 173656

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-08-07 21:32:03 -04:00
Paul Sokolovsky b7e3739043 net: sockets: Manage TCP receive window
As we buffer incoming packets in receive callbacks, we must decrease
receive window to avoid situation that incoming stream for one socket
uses up all buffers in the system and causes deadlock. Once user app
consumes queued data using recv() call, we increase window again.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-08-05 11:40:50 +03:00
Luiz Augusto von Dentz c4f632bd09 net: bt: app: Add NET_APP_BLUETOOTH_NODE option
This enables IPSP node role which requires IPSS GATT service to be
registered.

Jira: ZEP-2451

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2017-08-04 18:18:40 +03:00
Michael Scott 9b3f6362e6 net: app: allow IPv6 interface init to work with late IP assigment
Some network interfaces such as bluetooth 6lowpan can start without
an assigned IP address and then later once the connection is up a
router advertisement broadcast will assign the IP address.

The net_app framework will timeout out during network init if a value
cannot be parsed from CONFIG_NET_APP_MY_IPV6_ADDR.  Let's adjust
the framework to handle a missing value there and fill it in later
when the IPv6 address is added to the interface.

Signed-off-by: Michael Scott <michael.scott@linaro.org>
2017-08-04 17:57:58 +03:00
Paul Sokolovsky 8088e14c74 net: sockets: poll: Use prefixed POLL* constants.
Default examples build with native POSIX aliases enabled, so
unprefixed refs got thru.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-08-04 17:24:22 +03:00
David B. Kinder 62a0cd246d doc: fix uses of back quotes in documentation
ReST defines interpreted text roles where text enclosed by single quotes
can be "intrepreted", for example :ref:`some name` becomes a link to
a label anywhere in the doc set named "some name", :c:func:`funcname()`
becomes a link to the API documentation for "funcname", and
:option:`CONFIG_NAME` becomes a link to, in our case, the documentation
for the generated Kconfig option.

This patch fixes uses of `some name` (without a role) by either adding
an explicit role, or changing to ``some name``, which indicates inline
code block formatting (most likely what was intended).

This is a precursor to changing the default behavior of interpreted
text to treat `some name` as :any:`some name` (as configured in
doc/conf.py), which would attempt to create a link to any available
definition of "some name".

We may not change this default role behavior, but it becomes an option
after the fixes in this patch.  In any case, this patch fixes incorrect
uses of single-quoted text (possibly introduced because GitHub's
markdown language uses single-quoted text for inline code formatting).

Jira: ZEP-2414

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2017-08-03 11:08:23 -04:00
Andrew Boie 507852a4ad kernel: introduce opaque data type for stacks
Historically, stacks were just character buffers and could be treated
as such if the user wanted to look inside the stack data, and also
declared as an array of the desired stack size.

This is no longer the case. Certain architectures will create a memory
region much larger to account for MPU/MMU guard pages. Unfortunately,
the kernel interfaces treat both the declared stack, and the valid
stack buffer within it as the same char * data type, even though these
absolutely cannot be used interchangeably.

We introduce an opaque k_thread_stack_t which gets instantiated by
K_THREAD_STACK_DECLARE(), this is no longer treated by the compiler
as a character pointer, even though it really is.

To access the real stack buffer within, the result of
K_THREAD_STACK_BUFFER() can be used, which will return a char * type.

This should catch a bunch of programming mistakes at build time:

- Declaring a character array outside of K_THREAD_STACK_DECLARE() and
  passing it to K_THREAD_CREATE
- Directly examining the stack created by K_THREAD_STACK_DECLARE()
  which is not actually the memory desired and may trigger a CPU
  exception

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-08-01 16:43:15 -07:00
Jukka Rissanen 95d30430d7 net: app: Add debugging support to get net_app instances
Add API that allows net-shell to get net_app context information
that can be used to debug net_app connections.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-08-01 21:09:59 +03:00
Jukka Rissanen f3f32e872a net: app: Add DTLS support
Allow UDP connections to use DTLS to encrypt the user data.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-08-01 21:09:59 +03:00
Jukka Rissanen 1c07ead104 net: http: Add context net_buf pool support to HTTP client
This commit adds http_client_set_net_pkt_pool() function that allows
caller to define net_buf pool that is used when sending a TCP packet.
This is needed for those technologies like Bluetooth or 802.15.4 which
compress the IPv6 header during send.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-07-31 11:50:25 +03:00
Jukka Rissanen 93214086f9 net: http: Add context net_buf pool support to HTTP server
This commit adds http_server_set_net_pkt_pool() function that allows
caller to define net_buf pool that is used when sending a TCP packet.
This is needed for those technologies like Bluetooth or 802.15.4 which
compress the IPv6 header during send.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-07-31 11:50:25 +03:00
Aska Wu c0b5e55e6d net/mqtt: Enable TLS support
CONFIG_MQTT_LIB_TLS is introduced to enable TLS support.

Also, prj_frdm_k64f_tls.conf is added to demostrate the whole idea.

jira:ZEP-2261

Signed-off-by: Aska Wu <aska.wu@linaro.org>
2017-07-28 11:25:43 +03:00
Aska Wu fb79837862 net/mqtt: Convert mqtt lib to use net app API
Use net app API since we want to enable MQTT with TLS.
mqtt_connect() and mqtt_close() are added to build and close the
connection to the broker. The caller doesn't need to deal with
the net context anymore and the most of network setup code in
mqtt_publisher is removed.

Signed-off-by: Aska Wu <aska.wu@linaro.org>
2017-07-28 11:25:43 +03:00
Ricardo Salveti 696bef58ba net: app: fix build when NET_DEBUG_APP is used with SYS_LOG_NET_LEVEL=1
hr_addr is only available when SYS_LOG_NET_LEVEL is > 1.

Signed-off-by: Ricardo Salveti <ricardo.salveti@linaro.org>
2017-07-27 10:19:13 +03:00
Jukka Rissanen 5e7765ba28 net: app: Setup IEEE 802.15.4 during init
If IEEE 802.15.4 is enabled, then setup the network settings
automatically so that the device is ready for IP configuration.
This is only done if CONFIG_NET_APP_AUTO_INIT is enabled, which
is currently the default.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-07-20 17:09:27 +03:00
Paul Sokolovsky 2c2e8b26b4 net: sockets: Implement poll() operation.
poll() allows to (efficiently) wait for available data on sockets,
and is essential operation for working with non-blocking sockets.

This is initial, very basic implementation, effectively supporting
just POLLIN operation. (POLLOUT implementation is dummy - it's
assumed that socket is always writable, as there's currently no
reasonable way to test that.)

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-07-18 21:46:06 +03:00
Paul Sokolovsky b1a3753669 net: http_server: Properly close network contexts.
Use net_context_put(), not net_context_unref(). This makes sure
that after sending response, connections are properly closed.

Jira: ZEP-2362

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-07-18 08:40:02 +03:00
Robert Chou 33c54ee6fd net: zoap: advance block context by checking M bit from block option
According to RFC7959 page 30, "The end of a block-wise transfer is
governed by the M bits in the Block options, _not_ by exhausting the
size estimates exchanges."

Therefore, we should check the M bit instead of total size (which
is not always available, too)

Signed-off-by: Robert Chou <robert.ch.chou@acer.com>
2017-07-14 11:06:54 +03:00
Jukka Rissanen 7474553543 net: Fix connectivity issues if only UDP or TCP is enabled
If either UDP or TCP is enabled but not both, then connectivity
fails. This was a side effect of commit 3604c391e ("net: udp:
Remove NET_UDP_HDR() macro and direct access to net_buf")

Jira: ZEP-2380

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-07-14 08:49:45 +03:00
Paul Sokolovsky 1abb89f640 net: sockets: Implement non-blocking mode.
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-07-11 14:00:27 +03:00
Jukka Rissanen 98fb2bed63 net: Comment false positives reported by Coverity
Coverity reported false positives, add comment about these in
the code.

Jira: ZEP-2344
Jira: ZEP-2345

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-07-11 13:59:04 +03:00
Andrew Boie 65a9d2a94a kernel: make K_.*_INITIALIZER private to kernel
Upcoming memory protection features will be placing some additional
constraints on kernel objects:

- They need to reside in memory owned by the kernel and not the
application
- Certain kernel object validation schemes will require some run-time
initialization of all kernel objects before they can be used.

Per Ben these initializer macros were never intended to be public. It is
not forbidden to use them, but doing so requires care: the memory being
initialized must reside in kernel space, and extra runtime
initialization steps may need to be peformed before they are fully
usable as kernel objects. In particular, kernel subsystems or drivers
whose objects are already in kernel memory may still need to use these
macros if they define kernel objects as members of a larger data
structure.

It is intended that application developers instead use the
K_<object>_DEFINE macros, which will automatically put the object in the
right memory and add them to a section which can be iterated over at
boot to complete initiailization.

There was no K_WORK_DEFINE() macro for creating struct k_work objects,
this is now added.

k_poll_event and k_poll_signal are intended to be instatiated from
application memory and have not been changed.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-07-10 11:44:56 -07:00
Geoff Gustafson 1405627c37 net: context: Use K_NO_WAIT instead of 0 for timeout
Signed-off-by: Geoff Gustafson <geoff@linux.intel.com>
2017-07-10 10:59:28 +03:00
Robert Chou de3df603fa net: net_app: fix syntax error when accessing remote from default_ctx
Signed-off-by: Robert Chou <robert.ch.chou@acer.com>
2017-07-07 09:42:07 +03:00
Jukka Rissanen 7a31d4b8cb net: app: Fix dual IPv4 and IPv6 support
It was not possible to send IPv4 packets if IPv6 was also
enabled.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-07-06 14:32:37 +03:00
Erwin Rol a0fc5d8229 net: app: prevent setting semaphore limit to 0
When neither IPv4 nor IPv6 are selected the limit that is
passed to k_sem_init will end up being 0, which will trigger
the folowing assertion in k_sem_init;

__ASSERT(limit != 0, "limit cannot be zero");

Fixed by not passing count as initial and limit value but
only as initial value and use UINT_MAX as limit.

Signed-off-by: Erwin Rol <erwin@erwinrol.com>
2017-07-03 20:58:13 -04:00
Erwin Rol f541ba3ca1 net: app: fix typo
Signed-off-by: Erwin Rol <erwin@erwinrol.com>
2017-07-03 20:58:13 -04:00
Jukka Rissanen a1be6a8ba9 net: app: Create support for network application API
The network application API is a higher level API for creating
client and server type applications. Instead of applications
dealing with low level details, the network application API
provides services that most of the applications can use directly.

This commit removes the internal net_sample_*() API and converts
the existing users of it to use the new net_app API.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-06-30 06:13:09 -04:00
Paul Sokolovsky 49eaa2b722 net: sockets: Explicitly flush conn/pkt queue on close()
If a socket is closed without reading all data from peer or accepting
all pending connection, they will be leaked. So, flush queues
explicitly.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-06-28 16:07:55 +03:00
Paul Sokolovsky 6055b6cd6b net: sockets: Implement recv() for DGRAM sockets
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-06-28 16:07:55 +03:00
Paul Sokolovsky 2b4a240859 net: sockets: Implement recv() for STREAM sockets
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-06-28 16:07:55 +03:00
Paul Sokolovsky 41e88ea40c net: sockets: Implement send()
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-06-28 16:07:55 +03:00
Paul Sokolovsky 7567962f3a net: sockets: Implement bind(), connect(), listen(), accept()
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-06-28 16:07:55 +03:00
Paul Sokolovsky 386c5bacd1 net: sockets: Add configurable option to provide raw POSIX API names
With CONFIG_NET_SOCKETS_POSIX_NAMES=y, "raw" POSIX names like
socket(), recv(), close() will be exposed (using macro defines).
The close() is the biggest culprit here, because in POSIX it
applies to any file descriptor, but in this implementation -
only to sockets.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-06-28 16:07:55 +03:00
Paul Sokolovsky 3432ff4fca net: sockets: Bootstrap Sockets API implementation
This adds Kconfig and build infrastructure and implements
zsock_socket() and zsock_close() functions.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-06-28 16:07:55 +03:00
Jukka Rissanen 92fa7ac6ce net: http: Remove mbedtls heap setting from http library
The global mbedtls heap is set automatically now so no need to
set it individually in the http library.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-06-27 16:42:59 +03:00
Robert Chou 7087162385 net: zoap: add missing response code for zoap_header_get_code()
Three response codes are missed in zoap_header_get_code() which will
result in the response code returned from the function being set as
ZOAP_CODE_EMPTY. Check include/net/zoap.h for the missing code
definition.

Signed-off-by: Robert Chou <robert.ch.chou@acer.com>
2017-06-23 16:04:00 -04:00
Jukka Rissanen 35d28fb567 net: http: Connection close fix if old connection is active
If we receive a HTTP request and if the earlier context is still
active and it is not the same as the new one, then close the earlier
one. Otherwise it is possible that the old context will be left into
TCP ESTABLISHED state and would never be released. Example of this
is that we had IPv4 connection active and then IPv6 connection is
established, in this case we will disconnect the IPv4 connection
after this commit.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-06-12 10:23:19 +03:00
Leandro Pereira 87ccb79a7a net: lib: dns: Check return value of net_context_recv()
Given that K_NO_WAIT is passed as a timeout to net_context_recv(), it's
unlikely this function will return any error value.  It's cheap to
check, though, so do it.

Coverity-CID: 170580
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2017-06-12 10:21:38 +03:00
Jukka Rissanen fc125e0e2c net: shell: Add HTTP server connection monitoring
The "net http monitor" command turns on HTTP monitoring,
which means that for each incoming HTTP or HTTPS request,
a information about source and destination address, and
the HTTP request URL is printed.
User can disable the monitoring by "net http" command.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-06-09 13:09:10 +03:00
Jukka Rissanen ab51f67e17 net: http: Collect HTTP server connection information
If CONFIG_NET_DEBUG_HTTP_CONN is enabled, then start to collect
currently active HTTP connections to HTTP server.

This is only useful for debugging the HTTP connections.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-06-09 13:09:10 +03:00
Jukka Rissanen 1b82463dee net: http: Add HTTPS client support
Add HTTPS support into http-client library. The init of the
HTTPS client connection is different compared to HTTP client,
but the actual HTTP request sending is using the same API as
HTTP client.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-06-09 09:56:21 +03:00
Jukka Rissanen 0d43bbfb77 net: http: Move heap init into net/lib/http/http.c
This is done so that both http_client and http_server functionality
can share the same heap.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-06-09 09:56:21 +03:00
Jukka Rissanen 2e2ce3120a net: https: Allow mbedtls debugging for https-server
The mbedtls debugging function was set before the ssl config
struct was initialized. This meant that it was not possible
to activate mbedtls debug prints. This commit sets the debug
print option after the config struct has been initialized.

Fixed also the debug prints which print extra \n which looks
very bad in debugging outputs.

This commit does not enable mbedtls debugging, it just makes it
possible to output mbedtls debug prints. In order to get mbedlts
debug prints one needs to do this:
* set DEBUG_THRESHOLD to >0 in http_server.c
* enable CONFIG_NET_DEBUG_HTTP in project config file
* enable MBEDTLS_DEBUG_C in mbedtls config file (see file pointed
  by CONFIG_MBEDTLS_CFG_FILE option)
* in qemu, one needs to increase the size of the available RAM,
  this setting does the trick, CONFIG_RAM_SIZE=300

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-06-06 09:32:52 +03:00
Jukka Rissanen bd7d1bda20 net: http: Avoid unnecessary net_pkt error print
In some cases the net_pkt can be null when freeing it,
this will print error from net_pkt library. Avoid this by
checking the value of net_pkt before calling net_pkt_unref().

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-06-02 12:43:52 +03:00
Jukka Rissanen c9e6ef5331 net: http: Use random source port when connecting
If we re-connect to same peer server, then we should select a new
source port. Noticed that if the same source port as before is
used for the new connection, the peer might drop the packet. This
was seen when connecting to Linux peer.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-06-02 12:43:52 +03:00
Jukka Rissanen 010b892c8a net: http: Parsing state was not cleared
If we received a bad HTTP request, then subsequent good requests
were also returning 400 error code. The parsing state needs to
be initialized after each received HTTP request.

Jira: ZEP-2181

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-05-31 14:54:06 -04:00
Jukka Rissanen eeaa29666b net: http: Handle HTTPS connection closing gracefully
If the HTTPS connection is closed, then properly handle call to
HTTP parser init in case of error and also remove any pending
data that belong to old connection.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-05-29 23:50:33 +03:00
Jukka Rissanen 4f68e32b8a net: zoap: Remove extra null checks
No need to check attr and path variables for null as they
cannot be null.

Coverity-CID: 157595
Coverity-CID: 157602

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-05-25 18:50:40 +03:00
Jukka Rissanen 3677caa37e tests: net: zoap: Add path uri matching tests
Test the match_path_uri() function that was fixed by previous
commit.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-05-25 18:49:56 +03:00
Jukka Rissanen 7bed585c42 net: zoap: Fix NULL pointer access
The code was setting pointer to null and then access it.

Coverity-CID: 157575

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-05-25 18:49:56 +03:00
Jukka Rissanen 31faeca511 net: http: Add timeout to HTTP server response
Allow the caller to delay the closing of the HTTP connection
for a number of milliseconds. The purpose for this is that
the client can send still some data back to us for a short
period of time.

This is needed for example for Basic authentication so that
server is able to receive authentication values back.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-05-23 18:01:04 +03:00
Jukka Rissanen a174d2eba7 net: http: Add HTTP server library support
This commit creates a HTTP server library. So instead of creating
a complex HTTP server application for serving HTTP requests, the
developer can use the HTTP server API to create HTTP server
insteances. This commit also adds support for creating HTTPS servers.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-05-13 14:30:58 -04:00
Kumar Gala 18e7769431 net: zoap: Cleanup use of C99 types
We introduced some see C99 types, so convert them over to the Zephyr
types.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-05-09 17:06:28 -04:00
Jukka Rissanen 70f334d9f2 http: client: Create a HTTP library
Instead of separate sample application that does everything
related to HTTP client connectivity, create a HTTP client library
that hides nasty details that are related to sending HTTP methods.
After this the sample HTTP client application is very simple and
only shows how to use the client HTTP API.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-05-04 15:58:45 -04:00
Michael Scott 438492843c net/mqtt: return error codes from net_context_send
Instead of returning EIO let's bubble the error from net_context_send
back up to the caller in the following functions:
mqtt_tx_connect()
mqtt_tx_disconnect()
mqtt_tx_pub_msgs()
mqtt_tx_publish()
mqtt_tx_pingreq()
mqtt_tx_subscribe()
mqtt_tx_unsubscribe()

Change-Id: I9bb4396b227b8902ac1195a97bc37eb1959b643e
Signed-off-by: Michael Scott <michael.scott@linaro.org>
2017-04-28 15:01:12 +03:00
Michael Scott 7bce4af81f net/mqtt: cleanup TX function unref handling
With CONFIG_NET_DEBUG_NET_PKT enabled, the log messages are full of
errors regarding NULL parameters passed into net_pkt_unref in almost
every TX function for handling MQTT messages:
mqtt_tx_connect()
mqtt_tx_disconnect()
mqtt_tx_pub_msgs()
mqtt_tx_publish()
mqtt_tx_pingreq()
mqtt_tx_subscribe()
mqtt_tx_unsubscribe()
mqtt_parser()

Let's clean up the unref handling so that our debug log isn't quite
so full of error spam (as opposed to the normal amount of spam from
the net buf log).

Change-Id: Ib49d1192f51abe4329e6dc9da3c51a4a36290082
Signed-off-by: Michael Scott <michael.scott@linaro.org>
2017-04-28 15:01:12 +03:00
Michael Scott fa5503fb44 net/mqtt: use rlen to calculate # of QoS items in SUBACK packet
The data->len of an inbound netbuf can be larger than a single
MQTT packet.  For instance when a PINGRESP is also included
in the same netbuf.  For this reason we should not be using
the data->len to determine how large the rest of the MQTT data is.

Specific Example: we've seen in testing that PINGRESP packets
can be included with a SUBACK packet in the same netbuf. Under
this case the current code uses the data->len incorrectly and
tries to find 3 QoS elements for the SUBACK packet when there
is only 1 (the rest of the data is for PINGRESP).

NOTE: A larger patch to iterate through the netbuf data parsing
individual MQTT packets will be needed to fix the MQTT subsys.
This patch only corrects the SUBACK parsing.

Change-Id: I7f6cebaaed9570b778d466de84331cf8c5060755
Signed-off-by: Michael Scott <michael.scott@linaro.org>
2017-04-28 15:01:12 +03:00
Michael Scott e5f1112b07 net/mqtt: combine mqtt_parser for PUBLISHER and SUBSCRIBER
Currently, app type MQTT_APP_PUBLISHER_SUBSCRIBER is not supported.
mqtt_init() will return EINVAL because the context rcv function is
either mqtt_publisher_parser or mqtt_subscriber_parser (not both).

Let's combine these functions into mqtt_parser and remove the app
type check from mqtt_init().

Change-Id: I60460e011395864706e293c997e9f8a65681b368
Signed-off-by: Michael Scott <michael.scott@linaro.org>
2017-04-28 15:01:12 +03:00
Marti Bolivar 5fab97c9d0 net/mqtt: fix race condition in mqtt_init()
We need to set the mqtt context recv function prior to calling
net_context_recv which installs the mqtt_recv callback.
If not, we risk a race condition where an unprotected reference
to mqtt->rcv(mqtt, buf) is made in mqtt_recv().

Change-Id: If90ee58f4ea6f7879ef7c12b969ba27647426acc
Signed-off-by: Marti Bolivar <marti.bolivar@linaro.org>
2017-04-28 15:01:12 +03:00
Ravi kumar Veeramally d787ccb40a net: zoap: Add block wise support for well-known response
If the ./well-known/core response is bigger than L2 MTU then
response will be sent in multiple fragments. In mesh kind of networks
getting response from farthest node might loose packets. So better to
send response in a block wise fashion. Block size is configurable.

Change-Id: Id421c66597fe448c12a7215f04f63f4a284c14ab
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-04-28 15:01:11 +03:00
Ravi kumar Veeramally 0cdfd75c7f net: zoap: Remove unused struct definition
Change-Id: I1b57972386b0def02eb125b6ae4825f11268f6ce
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-04-28 15:01:11 +03:00
Ravi kumar Veeramally 9d0a484690 net: zoap: Minor comment style fixes
Change-Id: I8f63781a39263e110aec2e6f1e14d72650ce4e30
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-04-28 15:01:11 +03:00
Ravi kumar Veeramally 6740e691e8 net: zoap: Remove magic number
Value 0xFF represents End Of Options marker in CoAP message.
Use #define than magic numbers in code.

Change-Id: I3bef21ea827987f7c2e670447ee20574cb6288ae
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-04-28 15:01:11 +03:00
Ravi kumar Veeramally 38503f8c76 net: zoap: Add timeout while requesting packets
Add timeout for packet and buffer requests. If there are no
buffers available gracefully drop the request.

Change-Id: I56fe2b606556149c83751aadc1c5eee7828a84a8
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-04-28 15:01:10 +03:00
Paul Sokolovsky 25307d5331 net: net_pkt_append: Refactor to return length of data actually added
For stream-based protocols (TCP), adding less data than requested
("short write") is generally not a problem - the rest of data can
be sent in the next packet. So, make net_pkt_append() return length
of written data instead of just bool flag, which makes it closer
to the behavior of POSIX send()/write() calls.

There're many users of older net_pkt_append() in the codebase
however, so net_pkt_append_all() convenience function is added which
keeps returning a boolean flag. All current users were converted to
this function, except for two:

samples/net/http_server/src/ssl_utils.c
samples/net/mbedtls_sslclient/src/tcp.c

Both are related to TLS and implement mbedTLS "tx callback", which
follows POSIX short-write semantics. Both cases also had a code to
workaround previous boolean-only behavior of net_pkt_append() - after
calling it, they measured length of the actual data added (but only
in case of successful return of net_pkt_append(), so that didn't
really help). So, these 2 cases are already improved.

Jira: ZEP-1984

Change-Id: Ibaf7c029b15e91b516d73dab3612eed190ee982b
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-04-28 15:01:09 +03:00
Kumar Gala a509441210 net: convert to using newly introduced integer sized types
Convert code to use u{8,16,32,64}_t and s{8,16,32,64}_t instead of C99
integer types.

Jira: ZEP-2051

Change-Id: I4ec03eb2183d59ef86ea2c20d956e5d272656837
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-04-21 09:30:38 -05:00
Tomasz Bursztyka db11fcd174 net/net_pkt: Fully separate struct net_pkt from struct net_buf
- net_pkt becomes a stand-alone structure with network packet meta
  information.
- network packet data is still managed through net_buf, mostly named
  'frag'.
- net_pkt memory management is done through k_mem_slab
- function got introduced or relevantly renamed to target eithe net_pkt
  or net_buf fragments.
- net_buf's sent_list ends up in net_pkt now, and thus helps to save
  memory when TCP is enabled.

Change-Id: Ibd5c17df4f75891dec79db723a4c9fc704eb843d
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-04-21 14:19:50 +03:00
Tomasz Bursztyka bf964cdd4c net: Renaming net nbuf API to net pkt API
There have been long lasting confusion between net_buf and net_nbuf.
While the first is actually a buffer, the second one is not. It's a
network buffer descriptor. More precisely it provides meta data about a
network packet, and holds the chain of buffer fragments made of net_buf.

Thus renaming net_nbuf to net_pkt and all names around it as well
(function, Kconfig option, ..).

Though net_pkt if the new name, it still inherit its logic from net_buf.
'
This patch is the first of a serie that will separate completely net_pkt
from net_buf.

Change-Id: Iecb32d2a0d8f4647692e5328e54b5c35454194cd
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-04-21 14:19:50 +03:00
Ravi kumar Veeramally 651a0cb269 net: zoap: Prepare and send error response separately
If error occurs while preparing response to .well-known/core request,
do not send partly filled payload by simply changing code part only.
It's better to unref the partly filled reponse and prepare a new error
response and send.

Change-Id: I28013a4e331cfc6f01de873e80af48f765e49494
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-04-21 14:19:49 +03:00
Ravi kumar Veeramally a8ac7af37a net: zoap: Remove unused helper function
Commit "net: zoap: Fix memory overflow issue" fixed and implemented
./well-known/core response in a different way, so this api is not needed
anymore.

Change-Id: I8f945fb5842028be50ecfdef95cbe5da3189a538
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-04-21 14:19:49 +03:00
Ravi kumar Veeramally 79ff5ed5fa net: zoap: Fix memory overflow issue
If CoAP .well-known/core services list is bigger than single fragment
then current helper functions overwrites beyond fragment space. Which
corrupted whole stack. Right now sending response in multiple fragments
but preferred way is send response in block by block. This should
overcome packet loss across mesh scenarios. Recommended feature will
be supported with later patches.

Change-Id: I30ca55bde2516d80b3583731241ad295799c6614
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-04-21 14:19:49 +03:00
Ravi kumar Veeramally 09773f5a5f net: zoap: Refactor zoap utilities
Most of the zoap utilities deal with first fragment of buffer chain.
So accessing of buf->frags directly make less usage of stack than
delcaring another variable for frag and its data. Due to code
refactoring couple of lines removed and in between those lines
coverity complained two issues, which is not valid now.

Coverity-CID: 157597
Coverity-CID: 157598

Change-Id: I3035c0625a131d49a4f0250ff0052875d3382544
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-04-21 14:19:49 +03:00
Kumar Gala 789081673f Introduce new sized integer typedefs
This is a start to move away from the C99 {u}int{8,16,32,64}_t types to
Zephyr defined u{8,16,32,64}_t and s{8,16,32,64}_t.  This allows Zephyr
to define the sized types in a consistent manor across all the
architectures we support and not conflict with what various compilers
and libc might do with regards to the C99 types.

We introduce <zephyr/types.h> as part of this and have it include
<stdint.h> for now until we transition all the code away from the C99
types.

We go with u{8,16,32,64}_t and s{8,16,32,64}_t as there are some
existing variables defined u8 & u16 as well as to be consistent with
Zephyr naming conventions.

Jira: ZEP-2051

Change-Id: I451fed0623b029d65866622e478225dfab2c0ca8
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-04-20 16:07:08 +00:00
David B. Kinder 0ffb648210 spell: fix doxygen comment typos: /subsys
Fix doxygen comment typos used to generate API docs

Change-Id: I3efff6f5fa26f87d1e658d6336fef01ce45f5bb0
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2017-04-19 18:44:06 +00:00
Jukka Rissanen 611ccaaf88 net: dns: Remove dns_client API and sample application
DNS resolving is better done with DNS resolve API so remove
the DNS client API which is quite hard to use.

Change-Id: Ide4973a5be674414ea6e04a35c938195cce40b6a
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-04-13 15:21:45 +03:00
Jukka Rissanen 4bcdf049bb net: dns: Add more debugging about configured servers
Print information about configured DNS servers when starting
in order to ease the debugging.

Change-Id: I3ba71e514e463db790b82913e4c66a67160366dc
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-04-13 15:21:43 +03:00
Jukka Rissanen d31fa5b87c net: dns: Set the address family and address length correctly
We need to set the resolved IP address family and length
before calling the user callback so that callback does not
need to figure out these values itself.

Change-Id: I724909fc1707608ab8728231a0311795b6a313f3
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-04-13 15:21:43 +03:00
Jukka Rissanen 9d74fd71b5 net: dns: Invalid memory access
Do not try to cancel query if the DNS query index is < 0.

Coverity-CID: 166770

Change-Id: I03c1f274453640d0ff80694628b8e8f18e8de900
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-04-13 15:21:41 +03:00
Jukka Rissanen 8dc01261ea net: dns: Initialize DNS resolver if DNS servers are set
If the config file contains DNS server addresses, then
configure the DNS resolver to use them.

Change-Id: Ie7f2bdcf7ac4bb7ee0ecf7fb5b7bd2df3379cdc3
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-03-24 17:31:42 +02:00
Jukka Rissanen 79cd66f40c net: dns: Add resolve API
This commit introduces a generic DNS resolving API that can
be used by applications. Later commits will introduce a system
level DNS support which simplifies the DNS resolving so that
DNS server names can be given from config file.

Change-Id: I60fbc81e2a44928d2ca53d51e703b9cde222b382
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-03-24 17:31:42 +02:00
Ravi kumar Veeramally 72a758fcb6 net: zoap: Fix memory leak
Unref the buffer if net_context_sendto() fails to send.

Change-Id: Iaae81f3044ad7197974493018b873bb76b2c0760
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-03-24 17:31:39 +02:00
Michael Scott 081246737c net/http: let HTTP_SERVER, HTTP_CLIENT and HTTP_PARSER select HTTP
Due to commit 8308b9bd2d ("net/http: Add the HTTP/1.1 API")
every user of CONFIG_HTTP_PARSER would need to add CONFIG_HTTP to
their .conf files.  Which is fine for intree samples/tests as they
have been adjusted, but the rest of world working on Zephyr apps
will need to make this changes as well.

Instead, we should have each of the following select HTTP instead of
depend on it, which will make future use of these configs and their
dependencies more intuitive:
HTTP_SERVER
HTTP_CLIENT
HTTP_PARSER

NOTE: As cleanup, this commit also removes the CONFIG_HTTP added to
samples and test .conf files.

Change-Id: I81cfaa19e37333b1bf98778f8147814780e7f77c
Signed-off-by: Michael Scott <michael.scott@linaro.org>
2017-03-17 10:34:45 +02:00
Flavio Santes 87fc47e1fe net/dns: Fix DNS answer RR computation
- Remove a routine that erroneously computes an answer RR value:
  dns_answer_rdlength.

- Change: dns_unpack_answer_rdlength -> dns_answer_rdlength.

- Change: htonl -> ntohl in the dns_answer_ttl routine.

Change-Id: I8b5a16f63560d3e23dd38cb7339b6e232bb706ea
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2017-03-17 10:34:41 +02:00
Flavio Santes 86e6a5d00a net/dns: Fix wrong name in DNS answer type routine
Use dns_answer_type instead of dns_response_type to reflect that
the routine refers to the DNS answer RR.

Change-Id: I6d01add4a1b090b83a0708326a52b7bb945c8d23
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2017-03-17 10:34:41 +02:00
Flavio Santes b8f8968f70 net/http: Move some statements to the right place
The "null terminator" for the chunked transfer encoding must be
added only if the payload is present.

Change-Id: Id325a660f060b3a3468bcca16a079def11b8c3ef
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2017-03-17 10:34:39 +02:00
Flavio Santes 8308b9bd2d net/http: Add the HTTP/1.1 API
This patch adds the HTTP/1.1 API for Zephyr. This API consists of client
and server context structures enabled via Kconfig variables.
HTTP parser support is enabled via the CONFIG_HTTP_PARSER configuration
variable.

Currently, this API only includes support for writing HTTP requests
(client mode) and HTTP responses (server mode). TLS support is not
considered in this iteration.

Supported HTTP methods:
	GET, HEAD, OPTIONS and POST.

Supported HTTP responses:
	400, 403 404. The http_response routine may be used to write
	any HTTP status code, for example 200 OK.

Jira: ZEP-1701

Change-Id: Ic9ccd4d4578d6d0f3a439976ea332b031644ca7d
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2017-03-09 20:33:49 +02:00
Flavio Santes 1532013f53 net/dns: Fix style issues
Don't break lines after the static keyword.

Change-Id: I46e3a427d819f864c57b142f38b8956d93b6d428
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2017-03-09 20:33:49 +02:00
Flavio Santes f4890e2d87 net/dns: Add the static keyword to the dns_find_null routine
The static keyword is missing in the dns_find_null function definition.

Change-Id: I19c89ca61b6ff550bf7ccb2ca9065a957532ede1
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2017-03-09 20:33:49 +02:00
Flavio Santes e376a68bd1 net/dns: Fix style issues in the DNS high-level API
Don't break the line after the static keyword.

Change-Id: I51343124ae3b3a2f9b4916c5279ba09b8c08fd9a
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2017-03-09 20:33:49 +02:00
Vinicius Costa Gomes 8f409f28b4 lib/zoap: Fix warning about signedness conversion
'query->value' is a 'const uint8_t *' so it should be casted to a
char (signed) array before it is used in places where a 'char *'
is expected, strncmp() is an example.

Jira: ZEP-1810

Change-Id: I94cf780a40ad5fed29607d2302dc7a10387bb86f
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2017-03-09 20:33:40 +02:00
Flavio Santes 6383705e53 net/dns: Improve unaligned memory access
Improve unaligned memory access in some inline routines.

Change-Id: I8065b4ac399a5f9f03997b43d8f8f8d320778ec3
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2017-02-27 08:34:06 +00:00
Vinicius Costa Gomes 8e304ef2e6 iot/zoap: Fix requiring that the buffer is unchanged for retransmit
It is possible that the buffer waiting for retransmission is modified
after it is sent, for example, it can be compacted by 6lo, and our
assumption of where is the message ID is located in the buffer is no
longer valid.

As the message ID is the only information that is necessary for
keeping track of retransmissions, we keep a copy of it in the pending
struct, as well as the destination address of the retransmission.

Change-Id: Id33d54353404628673541225a1a05e27ee08765f
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2017-02-27 10:28:54 +02:00
Flavio Santes 057f31e7e9 net/mqtt: Remove length computations for some msg fields
Currently, for the following MQTT msg fields:

- client_id
- will_topic
- user_name
- topic

their length is computed inside the routine that receives the MQTT msg.

Although this simplifies development, also imposes one restriction:
data must be null-terminated. Sometimes, data is received from other
sources and not generated by the application, so the null-terminated
constraint may be considered problematic for the user.

This patch removes the assumption that string fields are null-terminated.
Current data structures are already prepared to handle this case, so no
API change is required.

Change-Id: I5a147a5b21e0da49541cbe62baac363c8737cd3e
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2017-02-15 12:20:08 +02:00
Flavio Santes 84403077d2 net/mqtt: Add payload size validation
Validate payload size before starting to decodify MQTT messages.

Change-Id: I02653b5e41f930ca75de8f0395b2a7df315e12c5
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2017-02-15 12:20:08 +02:00
Flavio Santes 9c8d2d9fb8 net/mqtt: Use uint32_t for Remaining Length encoding/decoding
This patch updates the Remaining Length field from uint16_t to
uint32_t. The MQTT std specifies that this field must be
unsigned 4 bytes length.

Change-Id: I319d0745c673faece4bbd4db29b1bafad78ac199
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2017-02-15 12:20:08 +02:00
Flavio Santes bed71d0a02 net/mqtt: Fix inline doc for MQTT
Fix inline documentation for the MQTT API.

Jira: ZEP-1669

Change-Id: I90702eae236a9189b58e0f2fb2a6c5a3eeaf959c
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2017-02-14 08:30:34 +02:00
Vinicius Costa Gomes d8d16e81f5 iot/zoap: Add missing const modifier to header file
Makes it cleared that zoap_update_from_block() doesn't modify the
packet.

Change-Id: I35429b153370c50eb5ae9c914b47a3144faf2f04
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2017-02-14 08:30:33 +02:00
Vinicius Costa Gomes e190ffe200 iot/zoap: Fix handling of 16-bytes block-wise transfers
This fixes the case that a request for block number (NUM) 0, using a
16 byte block was considered invalid.

This was because it is encoded as the value 0 (zero), which can be
expressed as the BLOCK1 option present but without any value
associated. The old code considered this the same as the option not
existing.

Change-Id: I0f3912803a88865e9f544a6d0078ed4231775a88
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2017-02-14 08:30:33 +02:00
Luiz Augusto von Dentz 4ab09bdead net: Convert FOR_EACH macro instances to use CONTAINER
Change-Id: I2fbdc8128bef79eac74441c84fbb80e31f6bc261
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2017-02-10 16:16:15 +00:00
Jukka Rissanen bd3908b2a9 net: nbuf: Add timeout to net_buf getters
This commit changes the net_buf getter functions in nbuf.h
by adding a timeout parameter. These function prototypes
are changed to accept a timeout parameter.
	net_nbuf_get_rx()
	net_nbuf_get_tx()
	net_nbuf_get_data()
	net_nbuf_get_reserve_rx()
	net_nbuf_get_reserve_tx()
	net_nbuf_get_reserve_data()
	net_nbuf_copy()
	net_nbuf_copy_all()
	net_nbuf_push()
	net_nbuf_append()
	net_nbuf_write()
	net_nbuf_insert()

Following convinience functions have not been changed
	net_nbuf_append_u8
	net_nbuf_append_be16
	net_nbuf_append_be32
	net_nbuf_insert_u8
	net_nbuf_insert_be16
	net_nbuf_insert_be32
	net_nbuf_write_u8
	net_nbuf_write_be16
	net_nbuf_write_be32
so they call the base function using K_FOREVER. Use the
base function if you want to have a timeout when net_buf
is allocated.

Change-Id: I20bb602ffb73069e5a02668fce60575141586c0f
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-02-08 10:12:35 +02:00
Flavio Santes 362a12200a net/dns: Fix inline documentation
Fix inline documentation for the dns client API.

Jira: ZEP-1669

Change-Id: I9e6ae4e1301f1e4a125b75add1a8bc7331a818b0
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2017-02-07 22:33:47 +00:00
Vinicius Costa Gomes 2d852f47d2 iot/zoap: Fix the return value of zoap_packet_get_payload()
The returning 'len' was always informing the remaining available space
in that net_buf fragment. This not the expected behaviour for
incoming packets, in this case, we really want the size for the
payload already present in the packet.

When this function is called with a packet without a payload, with
will return the available space in the packet, when the payload is
already set, it will return the size of that payload.

Change-Id: Ia4643b8c2a015ad2316bed037e457b186e420b19
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2017-02-03 15:59:19 +02:00
Flavio Santes 32eb764959 net/mqtt: Remove redundant line
Delete redundant line and let the common exit point to release
the buffers.

Change-Id: I97e0ef79803083fabd841fb3d38d67c04ff31f7b
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2017-02-03 15:59:18 +02:00
Flavio Santes 02bd8411dc net/mqtt: Validate null or app level zero-length rx buffers
Don't try to process null or zero-length buffers generated by
the IP stack. Zero-length buffers are valid at the TCP layer but
contain no information for applications.

Change-Id: If66d301527f56ca8e8761789b7fd6931fc37b8e0
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2017-02-03 15:59:18 +02:00
Flavio Santes 9e6a6f3bce net/mqtt: Add the "malformed" callback to the MQTT ctx structure
Add the malformed callback that will be executed when a message
is received and it does not follow the MQTT v3.1.1 spec.

There is another case when this callback may be executed: when
the IP stack reception buffer's size is not enough to hold an
MQTT message.

The publisher and subscriber parser routines are updated to make
use of this callback. Inline documentation is also updated.

Change-Id: Id1d34336c4322673ca85f2db0b8d432db3c9afa8
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2017-02-03 15:59:18 +02:00
Flavio Santes 4a17932d6a net/mqtt: Simplify the MQTT high-level API
1) Remove some variables pointing to user-provided data.
2) Pass the context structure instead of those variables.
3) Homogenize the use of "ctx" for all the callbacks receiving the
   struct mqtt_ctx * pointer.

Now users must use the CONTAINER_OF macro to access data required
by the MQTT callbacks.

Change-Id: I871c0bd8601a67b39187683215579f9ed0087cf9
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2017-02-03 15:59:18 +02:00
Flavio Santes db6fda8835 net/mqtt: Move upwards buffer size validation
Although the buffer size validation works as it is inside the
mqtt_linearize_buffer routine, let's move it before getting a
data buffer from the buffer poll.

Change-Id: Id80af8a1e188929769463b04deaef3956b63cd00
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2017-02-03 15:59:18 +02:00
Jorge Ramirez-Ortiz 8b9212d57d net/mqtt: Check function return value
Change-Id: I4a4df19d50b9422f3e72d6386c0c726b6d9b82f2
Signed-off-by: Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org>
2017-02-03 15:59:14 +02:00
Vinicius Costa Gomes d27cc52f37 iot/zoap: Add a helper to find an observer by address
In some situations, for example, when the remote side sends a RESET
message indicating that it is no longer interested in observing a
resource, it is helpful to have a way to obtain the obverser
representation.

Change-Id: Ifbf627f9170be844fd525c557dda8cb722ac7aff
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2017-01-20 16:23:19 +02:00
Vinicius Costa Gomes 13fc795b3e iot/zoap: Fix wrong byte-order when retrieving integer options
When retrieving options that represent an integer, the order of the
bytes being considered was inverted, resulting in invalid values being
returned.

Change-Id: I8ba84f77e3402066632c0ba650939266c87a8ea2
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2017-01-20 16:23:19 +02:00
Vinicius Costa Gomes 4534046ad9 iot/zoap: Ignore non-request packets in zoap_handle_request
For example, when a RESET packet is passed to zoap_handle_request(),
there's nothing it can do, and it's not an error, so it returns
success silently.

Change-Id: I025bb44733521d6132999c219aaa292a3de302d7
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2017-01-20 16:23:19 +02:00
David B. Kinder ac74d8b652 license: Replace Apache boilerplate with SPDX tag
Replace the existing Apache 2.0 boilerplate header with an SPDX tag
throughout the zephyr code tree. This patch was generated via a
script run over the master branch.

Also updated doc/porting/application.rst that had a dependency on
line numbers in a literal include.

Manually updated subsys/logging/sys_log.c that had a malformed
header in the original file.  Also cleanup several cases that already
had a SPDX tag and we either got a duplicate or missed updating.

Jira: ZEP-1457

Change-Id: I6131a1d4ee0e58f5b938300c2d2fc77d2e69572c
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-01-19 03:50:58 +00:00
Flavio Santes e86b6c23af net/dns: Introduce the qname_copy routine
When a CNAME is part of the DNS answer RR, sometimes a label with
a pointer is found. The CNAME must be reused to create a new DNS
query and that CNAME will become the new DNS Query QNAME. This new
QNAME must not include pointers.

This patch introduces the qname_copy routine that "linearizes" a
given QNAME (perhaps with pointers).

The dns_read routine is also updated to reflect these changes.

Change-Id: I8e8f64e85e2cbf494fd589e2b7a67d470d34604b
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2017-01-06 09:11:45 +01:00
Flavio Santes e8eb62b87b net/mqtt: Allow an MQTT subscriber app to receive msgs
This patch adds the mqtt_subscriber_parser routine and modifies the
mqtt_init routine to allow an MQTT subscriber app to receive MQTT msgs.

Change-Id: Ie54ab892dacbc4386acab78a8991eba1850d8171
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2017-01-06 09:11:45 +01:00
Flavio Santes 76e479974a net/mqtt: Allow an MQTT publisher app to receive msgs
Changes applied by this patch:

- Add the mqtt_publisher_parser routine
- Add the MQTT_PACKET_TYPE macro to get the MQTT msg packet type
  (required by mqtt_publisher_parser)
- Add the mqtt_linearize_buffer (required by mqtt_publisher_parser)
- Add the mqtt_recv callback for reception
- Modify the mqtt_init routine to install the reception callback

The mqtt_publisher_parser routine is a callback used internally
to execute the appropriate mqtt_rx routine. Only the following
messages are handled by this routine:

MQTT_CONNACK, MQTT_PUBACK, MQTT_PUBREC, MQTT_PUBCOMP and MQTT_PINGRESP.

On error, it executes the ctx->malformed cb, if defined.

This commit also introduces the mqtt_linearize_buffer routine that
will be used to linearize an IP stack fragmented buffer. This patch
makes use of the net_nbuf_linear_copy routine to linearize the
incoming buffer. mqtt_rx_xxxx routines are also updated to handle
linear buffers (no fragmentation).

Currently, all the network protocol routines assume that the input
buffer is not fragmented. Future versions will remove that assumption
and the mqtt_linearize_buffer routine will be removed as well.

Public MQTT API is not affected by this patch.

Change-Id: I02fece67052ffbc7cb393d5ca545c503da463c4b
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2017-01-06 09:11:45 +01:00
Flavio Santes 8619d9d625 net/mqtt: Improve error handling in mqtt_rx_connack routine
Avoid undesired behaviors by exiting once an error is detected.

Change-Id: Id8e6accd6cd096274fe1c40a615d290967f1d4b9
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2017-01-06 09:11:45 +01:00
Flavio Santes e4e74be208 net/mqtt: Improve buffer error handling in mqtt_tx routines
This commit improves the buffer error handling in the mqtt_tx
routines.

Change-Id: Ic8e5761d927fe881b2376b6ac948a412e3b1168a
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2017-01-06 09:11:45 +01:00
Flavio Santes d490ff27ad net/mqtt: Add the mqtt_rx_publish routine
The mqtt_rx_publish is used to process incoming MQTT PUBLISH
messages. This routine performes the following steps:

- take ownership of the rx buffer containing the MQTT PUBLISH msg,
- call the MQTT parser routine, and
- determine, based on the incoming message's MQTT QoS,
  the next action.

Change-Id: I3cc011cf0c280205161d0484f12a2cfa79fdf44a
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2017-01-06 09:11:45 +01:00
Flavio Santes edfaeba73d net/mqtt: Use the right data type
Use the appropriate data type for some variables:

- const input arguments
- int32_t instead of uint32_t for timeout
- uint8_t instead of int for variables that take just a few
  possitive values.

Change-Id: Id7d762b400fa17e6751829ac401cd7c13aabb7b2
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2017-01-06 09:11:44 +01:00
Flavio Santes 4cfd7f7fe2 net/mqtt: Improve indentation
Replace tabs by spaces to improve code alignment in mqtt_pkt.c.

Change-Id: If586b91ba67b8075ddc7e0203dc538420e96b49a
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2017-01-06 09:11:44 +01:00
Flavio Santes 51a48d2d07 net/mqtt: Make input arguments const
This commit changes some function signatures found at the private
MQTT Packet Lib. Input arguments representing arrays can be considered
'const', avoiding compiler warnings when passing "const arrays" in
MQTT applications.

Change-Id: I3ebaa9c7ff5fba74324bf79c55027cdd82669eaa
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2017-01-06 09:11:44 +01:00
Flavio Santes c015c0e2c8 net/nbuf: Introduce the net_nbuf_linear_copy routine
This commit adds one routine previously found at the DNS resolver
library. The net_nbuf_linear_copy routine allows to "linearize"
an IP stack network buffer. This routine is required by functions
that must jump between big chunks of data that in this case may
lie between many fragments. Tracking fragments may be a tedious
task, so getting a linear copy of the buffer will reduce code
complexity altough it increases memory consumption.

The DNS client library is updated to reflect these changes.

Change-Id: Iae321f99fa9b05fae7e722b6d41baac427d82d7e
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2017-01-06 09:11:44 +01:00
Flavio Santes a46548ec31 net/protocols: Remove unnecessary assignement in Makefiles
Change-Id: Ifea85ebdaf5f1ac6b17abddc0311306c31c36b37
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2017-01-06 09:11:44 +01:00
Flavio Santes ac7300611c net: Restructure network protocols
This commit restructures the network protocols. Changes applied are:

- Move lib/iot/ to subsys/net/lib
- Move network protocol headers to include/net
- Move lib/iot/zoap/link-format.h to include/net/zoap_link_format.h
  and link-format.c to zoap_link_format.c
- Move tests/iot/ to tests/net/lib/
- Adapt sample code
- Adapt build system
- Modify doxygen paths

Change-Id: I37085fa4cc76a8a8e19a499ecb4e87b451120349
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2017-01-02 10:03:19 +01:00