Fix build break when enabling CONFIG_HTTPS w/o CONFIG_NET_APP_SERVER
This error can be seen when building sample/net/http_client like so:
$ cd samples/net/http_client
$ mkdir build && cd build
$ cmake -DBOARD=qemu_x86 -DCONF_FILE=prj_tls.conf ..
$ make run
In file included from
/home/<user>/zephyr/include/net/http.h:11:0,
from /home/<user>/zephyr/samples/net/http_client/src/main.c:19:
/home/<user>/zephyr/include/net/http_app.h:643:11: error: unknown type
name ‘net_app_cert_cb_t’
net_app_cert_cb_t cert_cb,
^~~~~~~~~~~~~~~~~
CMakeFiles/app.dir/build.make:302: recipe for target
'CMakeFiles/app.dir/src/main.c.obj' failed
Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
Of these, only struct net_ipv6_nbr_data::send_ns is a descriptive
change:
send_ns is used for timing Neighbor Solicitations in general, not
just for DAD.
The rest are typo/grammar fixes.
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
- Add needed settings for DTLS support to the lwm2m_ctx structure.
- Add initialization of MBEDTLS to the LwM2M lib based on the
user application settings in lwm2m_ctx.
Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
This will avoid exposing IEEE 802.15.4 Zephyr's L2 private context data
to unrelevant places.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
L2 specific data and IEEE 802154 net mgmt interface are not related.
Plus, application may use the net mgmt part, not the L2 one. So let's
split the content in relevant headers.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
IPv6 mcast addr to MAC mcast conversion was factored out to
subsys/net/ip/l2/ethernet.c for reuse by other drivers.
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
Compute the length of the TX payload that is transported in one
IPv4 or IPv6 datagram taking into account UDP, ICMP or TCP
headers in addition to any IPv6 extension headers added by RPL.
The TCP implementation in Zephyr is known to currently carry at
maximum 8 bytes of options. If the protocol is not known to the
stack, assume that the application handles any protocol headers
as well as the data. Also, if the net_pkt does not have a
context associated, length check on the data is omitted when
appending.
Although payload length is calculated also for TCP, the TCP MSS
value is used as before.
Define IPv4 minimum MTU as 576 octets, See RFC 791, Sections 3.1.
and 3.2.
Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
- Renaming NET_L2_RAW_CHANNEL to NET_RAW_MODE
- Create a generic IEEE 802.15.4 raw mode for drivers
- Modify the IEEE 802.15.4 drivers so it passes the packet unmodified,
up to code using that mode to apply the necessary changes on the
received net_pkt according to their needs
- Modify wpanusb/wpan_serial relevantly
Fixes#5004
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Add in6addr_any and in6addr_loopback which are defined in RFC2553 Basic
Socket Interface Extensions for IPv6.
Signed-off-by: Aska Wu <aska.wu@linaro.org>
In http_request() a CRLF is added to the header information after
the protocol is added. 2 CRLF in a row means the header information
is done, so following header information will be ignored.
Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
Add status error string when sending a error message from
HTTP server to client as described in RFC 2616 ch 6.1.
Previously only error code was sent except for 400 (Bad Request).
This also fixes uninitialized memory access in error message.
Coverity-CID: 178792
Fixes#4782
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
When sending a packet with AR flag set, the ACK frame that should be
replied to it must holp the same sequence number, so let's verify this
properly.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
The old HTTP server and client library code is deprecated. The
new HTTP library will be based on net-app API code which requires
changes to function names and parameters that are not compatible
with old library.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Create http library that uses net-app instead of net_context
directly. The old HTTP API is deprecated.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Now that net_buf has "native" support for sys_slist_t in the form of
the sys_snode_t member, there's a danger people will forget to clear
out buf->frags when getting buffers from a list directly with
sys_slist_get(). This is analogous to the reason why we have
net_buf_get/put APIs instead of using k_fifo_get/put.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Rename net_pkt_get_src_addr() to net_pkt_get_addr() and make it able to
handle source or destination address.
Signed-off-by: Aska Wu <aska.wu@linaro.org>
Add a net_buf_id() API which translates a buffer into a zero-based
index, based on its placement in the buffer pool. This can be useful
if you want to associate an external array of meta-data contexts with
the buffers of a pool.
The added value of this API is slightly limited at the moment, since
the net_buf API allows custom user-data sizes for each pool (i.e. the
user data can be used instead of a separately allocated meta-data
array). However, there's some refactoring coming soon which will unify
all net_buf structs to have the same fixed (and typically small)
amount of user data. In such cases it may be desirable to have
external user data in order not to inflate all buffers in the system
because of a single pool needing the extra memory.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The client TLS code did not handle server issued close properly.
Now the connection is terminated properly and TLS thread is left up to
wait more requests from the user.
This commits adds new boolean field to net_app context. Because there
are already multiple boolean flags there, convert them all to bitfields
to save space.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
As the TLS handshake might take long time before connection is ready,
check this before trying to send user data.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Previously, post_write and execute callbacks returned 1 when handled
and 0 for error condition. However, this wasn't detailed enough and
the engine can't propagate any sort of error back to users -- so it
doesn't even check the return values in many cases!
Let's adjust the resource callback functions of all objects and the
lwm2m_client sample to return 0 for success or a valid error code.
Signed-off-by: Michael Scott <michael.scott@linaro.org>
With the change to support multi-fragement buffers in the LwM2M subsys,
the OPAQUE data type was direct write methods were broken.
Let's fix OPAQUE handling by using the newly introduced getter methods
which can use multiple user callbacks (depending on the size of the
user provided buffer). Let's also add public methods for users to set
/ get OPAQUE data in resources for future use with DTLS key data.
Signed-off-by: Michael Scott <michael.scott@linaro.org>
Describe details and usecase for using this function. This follows
earlier updates for macros used to define buffers used by this
function (in 09b967366).
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
This patch moves from the ZoAP API in subsys/net/lib/zoap to
the CoAP API in subsys/net/lib/coap which handles multiple
fragments for sending / receiving data.
NOTE: This patch moves the LwM2M library over to the CoAP APIs
but there will be a follow-up patch which re-writes the content
formatter reader / writers to use net_pkt APIs for parsing
across multiple net buffers. The current implementation assumes
all of the data will land in 1 buffer.
Samples using the library still need a fairly large NET_BUF_DATA_SIZE
setting. (Example: CONFIG_NET_BUF_DATA_SIZE=384)
Signed-off-by: Michael Scott <michael.scott@linaro.org>
The net_tcp_get/set_hdr() and net_udp_get/set_hdr() documentation
was not clear in corresponding header file. Clarify how the return
value of the function is supposed to be used.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Previously net_pkt.h, defined macros NET_PKT_TX_SLAB_DEFINE,
NET_PKT_DATA_POOL_DEFINE, but advertised them as intended for
"user specified data". However, net_pkt.c effectively used the
same parameters for slabs/pools, but this wasn't obvious due
to extra config param redirection. So, make following changes:
1. Rename NET_PKT_TX_SLAB_DEFINE() to NET_PKT_SLAB_DEFINE()
as nothing in its definition is TX-specific.
2. Remove extra indirection for config params, and use
NET_PKT_SLAB_DEFINE and NET_PKT_DATA_POOL_DEFINE to define
system pools.
3. Update docstrings for NET_PKT_SLAB_DEFINE and
NET_PKT_DATA_POOL_DEFINE.
Overall, this change removes vail of magic in the definition of
system pkt slabs/pools, making obvious the fact that any packet
slabs/pools - whether default system or additional, custom - are
defined in exactly the same manner (and thus work in the same manner
too).
Fixes#4327
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
We should not close the TLS connection immediately if the TLS
data is not yet sent. So if user calls net_app_close() and we
still have data pending, then send the TLS data and only after
that close the connection.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
As there can be multiple listening network contexts, it should
be possible to close one of them.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The server is able to listen and serve multiple incoming
connections. This commit does not add support for multiple
incoming TLS connections.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Applications may want to be notified when various events
happen in the LwM2M rd client. Let's implement an event
callback which sends: connect, disconnect and update events.
Signed-off-by: Michael Scott <michael.scott@linaro.org>
1. Add handling block1 option in handle_request(). The basic idea is
to declare structure block_context at compiled time and use "token"
as a key to pick up the on-going block cotext. It should be able to
support multiple blockwise transfer concurrently
2. Use write callback implemented in lwm2m_obj_firmware to deal w/ the
update state transition and than call the callback registered by the
application
3. move default_block_size to lwm2m_engine.c to share between
lwm2m_engine and lwm2m_obj_firmware_pull
Signed-off-by: Robert Chou <robert.ch.chou@acer.com>
[michael.scott@linaro.org: rebased on LwM2M net_app changes.]
Signed-off-by: Michael Scott <michael.scott@linaro.org>
1. Parse firmware pull URI
2. Add lwm2m_firmware_get/set_update_cb() for application to register
callback. This is because we want to check the update_state before
we pass to the application
3. Add lwm2m_firmware_get/set_update_result() and
lwm2m_firmware_get/set_update_stat() to manage the state transition
as well as the sanity check
Signed-off-by: Robert Chou <robert.ch.chou@acer.com>
[michael.scott@linaro.org: rebased on net_app framework and
lwm2m_message refactoring.]
Signed-off-by: Michael Scott <michael.scott@linaro.org>
Currently this is defined as a k_thread_stack_t pointer.
However this isn't correct, stacks are defined as arrays. Extern
references to k_thread_stack_t doesn't work properly as the compiler
treats it as a pointer to the stack array and not the array itself.
Declaring as an unsized array of k_thread_stack_t doesn't work
well either. The least amount of confusion is to leave out the
pointer/array status completely, use pointers for function prototypes,
and define K_THREAD_STACK_EXTERN() to properly create an extern
reference.
The definitions for all functions and struct that use
k_thread_stack_t need to be updated, but code that uses them should
be unchanged.
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
Make sure the multicast MAC address checker checks also
IPv4 multicast MAC address and accepts it.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
User can configure hostname of the device in Kconfig. This can
be used by mDNS responder to answer <hostname>.local queries.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
With the introduction of CoAP and other protocols, URL parsing is
be needed when HTTP_PARSER is not. Let's split out the existing
functionality of URL parsing into it's own CONFIG and let
HTTP_PARSER use it by automatically selecting HTTP_PARSER_URL when
HTTP_PARSER is enabled.
Signed-off-by: Michael Scott <michael.scott@linaro.org>
Some chips are smart enough to handle the ACK request flag on
transmitted frames, so it's unneccessary for the L2 to wait for it.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This is both required in L2's radio part as well as it might be useful
on some ieee802154 radio drivers.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Finally removing set_ieee_addr, set_short_addr and set_pan_id which have
been replaced by set_filter.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This will replace the current mandatory set_ieee_addr, set_short_addr
and set_pan_id functions, which are only valid if the hardware is
supporting filtering. Which is not the case on some chips.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This will be useful to know various generic hardware aspects that can be
used relevantly by the L2 layer.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Now that lqi and rssi are embedded into net_pkt, there is no need for
that function.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Instead of having dedicated function on the radio api level for 15.4,
let's just add the relevant values to the net_pkt structure (if only
IEEE802154 is enabled). It's simpler and make the values relevantly
tied to the received packet.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Adding net_mgmt_event_notify_with_info() which lets the event notifier
to pass dedicated data along with the event. The size of data that can
be passed must be limited to the biggest data passed (which will be
currently IPv6 + prefix).
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>