The rest of the network (and generally Zephyr subsystem code) use the k_
prefixed variants for memory allocation, which results in data goin in
the _system_heap rather than the stdlib z_malloc_heap.
The code in getaddrinfo use the z_ ones as well apart from the actual
getaddrinfo implementation, which seems like an oversight, change it to
use k_calloc and k_free as well.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Fix the build error when hostapd enterprise is enabled, it should use
new wifi_set_enterprise_credentials API, instead of
wifi_set_enterprise_creds.
Signed-off-by: Maochen Wang <maochen.wang@nxp.com>
This change addresses an alignment problem reported by UBSAN by
using a copy of the address. This avoids the need for extensive
rework to support *_raw variants in the routing layer.
Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
LwM2M engine does not allow strings to be truncated as it would
lead to invalind UTF-8 strings.
However, some content formatters were truncating, so I fixed at least
these
* plain text
* TLV
* SenML CBOR
* SenML JSON
* JSON
* CBOR
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Move it to a separate Kconfig file and move it under the net/lib/shell.
When using menuconfig, it helps to reduce the confusion of network
configuration options.
Signed-off-by: WenBin Zhang <freey7955@gmail.com>
The LwM2M RD client state machine have no knowledge of ongoing
observations or any other CoAP traffic and might trigger
QUEUE_RX_OFF state while engine is still waiting for Ack.
This can happen if CoAP Ack timeout is longer than
CONFIG_LWM2M_QUEUE_MODE_UPTIME and response is lost or taking
longer than QUEUE_MODE_UPTIME.
When observation is lost, CoAP Ack may be send, but socket is not
listening anymore if its closed or not polled while in RX_OFF and this
stops observation.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
The minimum 1 sec timeout for getaddrinfo() call is too long
when executing queries from network tests. So allow test to override
the minimum and set it to very low value.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Allow user to query localhost name and get a localhost address
127.0.0.1 or ::1 back. This is only enabled if loopback driver
is used as the use case does not make much sense otherwise.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Make sure that if user has enabled hostname support, we are
able to query it and get a local IP address back.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
With this changes, device will check if AP support Neighbor Report or
not before trigger roaming. No need to issue 11k command to enable 11k,
if AP supports Neighbor Report, device will trigger 11k roaming with
priority.
Signed-off-by: Hui Bai <hui.bai@nxp.com>
Update the HTTP service API to allow setting per-service configuration,
currently it is only custom socket creation callback,
but in the future it can be extended with other parameter
Signed-off-by: Andrey Dodonov <Andrey.Dodonov@endress.com>
In case of fatal network error (i.e. when the LwM2M client runs out of
retries), call lwm2m_engine_stop() to cleanup any allocated resources
for the client. The engine is dead at that point anyway so the
application needs to recover.
If this isn't done, it is theoretically possible to restart the LwM2M
client (with lwm2m_rd_client_start() which does not report an error in
such case), which in turn could lead to resource leaks (like for
example the observer list is reinitialized) if the application
didn't call lwm2m_rd_client_stop() first. Calling lwm2m_engine_stop()
ensures that all resources are freed even if the application doesn't
call stop before restarting.
Stopping the engine is also needed when the network error occurs when
de-registering - in such case the engine goes straight into the IDLE
state, where it's possible to restart the client and thus reinitialize
the observer lists.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Add tests to make sure that if neighbor cache does not contain
info for neighbor link layer address, we can queue packets
and re-send them when the neighbor cache contains the data.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
If we do not know the neighbor link address, we need to send
neighbor solicitation message to net. While waiting neighbor
advertisement, there might be other packets that we want to
send to that neighbor. Queue those packets so that all of them
can be sent when NA message is received.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
- Added "wifi config" command.
- Add OKC parameter to "wifi config" command.
Set okc to 1 to enable opportunistic key caching.
Signed-off-by: Gang Li <gang.li_1@nxp.com>
Keep-alive probes have seq number set to SND.NXT - 1 and may or may not
contain an octet of data. The latter case was not handled properly
therefore add a special case when validating seq number to response to
keep-alive probes.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Support the case that 11k parameter can be set before wifi connection.
This field should not be cleared by connection.
Neighbor report will be cleared before start_roaming.
So wifi_connect don't need to clear 11k params.
Signed-off-by: Fengming Ye <frank.ye@nxp.com>
Refactor certificate processing code to eliminate duplication and
enable reuse across modules that require enterprise support.
Signed-off-by: Triveni Danda <triveni.danda@nordicsemi.no>
The Tx rate was previously stored as an integer, which caused loss of
precision for rates like 8.6 Mbps or 34.4 Mbps due to integer division.
The change will update data type to float.
Signed-off-by: Kapil Bhatt <kapil.bhatt@nordicsemi.no>
When building with CONFIG_OPENTHREAD_INTERFACE_EARLY_UP enabled,
`is_up` is undefined (since 596844a).
Signed-off-by: Lorenz Clijnen <github@lorc.be>
Signed-off-by: Lorenz Clijnen <l.clijnen@edna.eu>
As lwm2m_notify_observer_path() now reads attributes for the updated
resource, value_conditions_satisfied() does not need to read the
attributes again, it can just reuse the already available data.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
When updating a resource, the LwM2M library verified pmin attribute on
all resources/objects in the observer path list and chose the smallest
value. While this make sense for determining the lower-boundary for the
next notification time, it could lead to unnecessary notifications being
generated too early if the updated resource had a higher pmin value
configured on it.
Therefore, when checking notification criteria for an updated resource,
check the pmin value for that resource path and if set and higher than
the lowest pmin value evaluated for the observer list, use it instead.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Check if there actually is data to copy before calling memcpy() to
prevent potentially calling memcpy() with NULL value pointer.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
* Simplify the logic of the get_number() function to address the corner
cases reported by UBSAN regarding byte-swapping signed integer values.
The existing logic was actually only valid for little-endian systems,
as it expected that the bytes written from the packet buffer will be
stored at the beginning of the int64_t memory, plus the actual
byte-swapping with signed integer casts inside was hard to follow.
Switch to a plain uint8_t buffer for integer readout, and use
dedicated system function to convert the big-endian data in the buffer
into unsigned integer in the system endianness, followed by the final
cast to a signed value.
* Add explicit cast to uint32_t in put_objlnk() to prevent warning about
not-fitting integer after byte shift, and update the result type to
uint32_t as well.
* Switch to buffer with sys_put_be16/32/64 when writing integers due to
similar warnings about byte-swapping signed values.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Verify if the integer value being parsed does not overflow int64_t type
and report an error in such cases.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Verify if the integer value being parsed does not overflow int64_t type
and report an error in such cases.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Check if value pointer is not NULL before passing it to memcmp() inside
lwm2m_engine_set(). As the function actually expects that the value
pointer can be NULL in case resource value is cleared (there is a test
case for such behavior), validate that len value is actually 0 if NULL
value is provided, to avoid unexpected behavior in other parts of the
function.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
As packets need to be forwarded between Wi-Fi/Eth interface and
OpenThread interface, routing support has to be re-enabled and
configurable through prj.conf file.
Signed-off-by: Cristian Bulacu <cristian.bulacu@nxp.com>
Separate CON responses do no have a reply callback registered (as no
response is expected), however are still registered for retransmission
on the pending list. Therefore, we not only need to check for empty
ACKs for such case but for RESET packets as well. However, this cannot
be done before "reply" processing, as some of the reply handlers
(notifications namely) check for RESET replies.
Therefore, add a final check for the RESET response after the existing
"reply" logic. In such case, just remove the pending response packet
from the retransmission queue, and release resources.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
When using a separate response mechanism in LwM2M client, the
acknowledged flag is used to notify the engine that the request has been
acknowledged already with an empty ack and a separate CON response
should be sent. The same flag however is used by the retransmission
mechanism, to check if the CON request sent by the client has been
acknowledged by the peer.
As separate responses use the flag both ways, it has to be cleared
before sending the separate CON reply. Otherwise, the retransmission
logic assumes the reply has already been acknowledged and skips the
retransmission.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
clang reports a warning about a label followed by a variable
declaration:
label followed by a declaration is a C23 extension
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Fix one leftover unaligned access warning generated by clang:
warning: taking address of packed member 'th_seq' of class or
structure 'tcphdr' may result in an unaligned pointer value
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Based on TCP Spec., if the incoming packet seqnum is old but with
new data (seqnum + len > conn->ack), that part of valid data should
be accepted. Now Zephyr doesn't support it.
This patch will add support to such scenario.
Signed-off-by: Shrek Wang <inet_eman@outlook.com>
The alignment value tells the amount of alignment of buffer length
when allocating net_buf data for sending. By default there is no
special alignment. This is needed for example with Nordic Wi-Fi
chip that uses SPI driver that expects 4 byte alignment for the
length of the data that is being sent.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Make the interface interface state array static, ensuring that the array
is zeroed at boot. This enables interfaces which initialise earlier than
the CONN_MGR module to set flags in their init functions.
Signed-off-by: Jordan Yates <jordan@embeint.com>
There are cases, for example when peer is requesting two DNS
addresses, but we can only give one, we should reject the secondary
DNS request first, before sending NAK to acceptable options.
Option parser can reject a parameter by returning -ENOTSUP and when
it wants to NAK the parameter, it returns -EINVAL.
On RFC 1661:
Configure-Reject
If some Configuration Options received in a Configure-Request are
not recognizable or are not acceptable for negotiation (as
configured by a network administrator), then the implementation
MUST transmit a Configure-Reject.
Configure-Nak
If every instance of the received Configuration Options is
recognizable, but some values are not acceptable, then the
implementation MUST transmit a Configure-Nak.
So as stated by RFC, we should start the negotiation by rejecting all
parameters that we cannot configure. I added an example of rejecting
DNS requests, if we don't have those.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
When Kconfig option CONFIG_NET_L2_PPP_OPTION_DNS_USE is enabled,
Zephyr should request two DNS addresses in IPCP negotiation by sending
IPCP ConfReq for DNS otions using 0.0.0.0 as an address.
Remote peer may offer DNS by sending IPCP ConfNak with proper address.
This is explained in RFC 1332 and RFC 1877 (DNS extension).
When no DNS is required, we should only send IPCP ConfReq for IP
address, without having DNS fields in the same request.
However, when PPP is configured to serve a DNS using Kconfig option
CONFIG_NET_L2_PPP_OPTION_SERVE_DNS it should serve the DNS address in the
IPCP ConfNak message and from the ipcp.peer_options structure, not from
the ipcp.my_options.
This might break backward compatibility outside this repository
as DNS addresses used to be served from ipcp.my_options.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Some APIs taken in_addr/in6_addr pointer w/o const qualifier, while they
do not actually intend to modify the provided address. This commit
adds the missing const qualifier where applicable.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>