native_tap only queued TX timestamp callbacks for gPTP packets, which
left PTP SO_TIMESTAMPING socket traffic without TX timestamps.
Add host-clock packet timestamp updates in native_tap TX/RX paths, queue
TX timestamp callbacks when net_pkt_is_tx_timestamping() is set (while
preserving gPTP behavior without double-queueing), and propagate
SO_TIMESTAMPING TX/RX flags for AF_PACKET packets in net_context.
Signed-off-by: Philipp Steiner <philipp.steiner1987@gmail.com>
Add Layer-2 (EtherType 0x88F7) transport support and the PTP stack
updates needed for L2 operation.
Use recvmsg() RX timestamping on IEEE 802.3 sockets and fall back to
recvfrom() when ancillary timestamp data is unavailable, retrying
recvmsg() later so L2 reception keeps working across runtime and driver
limitations. Register Delay_Req TX timestamp handling for both UDP and
L2 paths and suppress expected UDP parse warnings while L2 is enabled.
Also wake the PTP worker when pollfd or state-decision changes require
it, and clear pending Sync, Delay_Req, and foreign clock state when a
port is disabled so stale state is not carried across reopen or link
transitions.
Signed-off-by: Philipp Steiner <philipp.steiner1987@gmail.com>
Timestamp callbacks can unregister themselves or other callbacks while
net_if_call_timestamp_cb() is iterating the callback list. That path
runs under the timestamp callback lock, so immediate unregister can
re-enter the same lock and stall the TX timestamp thread.
Handle unregister requests from the dispatch thread by marking callbacks
inactive, skip inactive entries during iteration, and prune them after
dispatch completes.
Signed-off-by: Philipp Steiner <philipp.steiner1987@gmail.com>
Use NET_CMSG_SPACE() when checking ancillary buffer capacity and
account for aligned cmsg storage in msg_controllen.
This keeps recvmsg() control-data handling consistent with cmsghdr
layout and avoids under-reporting consumed control-buffer space.
Signed-off-by: Philipp Steiner <philipp.steiner1987@gmail.com>
Implement AF_PACKET recvmsg() support and deliver ancillary
SO_TIMESTAMPING data to packet socket users.
Signed-off-by: Philipp Steiner <philipp.steiner1987@gmail.com>
Store the first foreign Announce and compare it against the previous entry.
Fix the BTCA receiver-port tie-break to avoid false role decisions.
Signed-off-by: Philipp Steiner <philipp.steiner1987@gmail.com>
Moved the TCP header validation in tcp_recv() before the connection
lookup to prevent processing malformed packets and improve efficiency.
Signed-off-by: Nikhil Namjoshi <nikhilnamjoshi@google.com>
Inverted the condition in tcp_input() to correctly process
valid packets and drop invalid ones.
Signed-off-by: Nikhil Namjoshi <nikhilnamjoshi@google.com>
Add an optional function to connectivity bindings that communicates
whether the binding has the configuration it needs in order to attempt
a connection. This is then used by the connectivity API for
non-persistent interfaces to determine whether it makes sense for the
interface to be powered up.
Signed-off-by: Jordan Yates <jordan@embeint.com>
Move header for IEEE 802.15.4-2020 constants from subsystem
location to common for usage by 15.4 radio device drivers.
Signed-off-by: David Boullie <David.Boullie@silabs.com>
For P2P connect set frequency default value as 0.
Let wpa_supplicant choose channel. User can override with -f option.
Signed-off-by: Kapil Bhatt <kapil.bhatt@nordicsemi.no>
Add input validation for PSK and SAE password length in wifi_ap_enable().
Invalid lengths could trigger driver-side assertions during AP startup.
Return -EINVAL when parameters are out of range instead of letting the
AP enable flow proceed.
Signed-off-by: Maochen Wang <maochen.wang@nxp.com>
In the http client, the body of 5xx was skipped, leading to a parse error
in the http parser when it reaches the body.
Signed-off-by: Arthur Gay <arthur.gay@marshmallow.kids>
Avoid accessing the packet after sending it, as the driver may
have already unreferenced or freed it. Use iface argument instead
of calling net_pkt_iface() on a potentially freed packet when
updating packet statistics.
Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
Avoid accessing the packet after sending it, as the driver may
have already unreferenced or freed it. Store the iface before
sending instead of calling net_pkt_iface() on a potentially
freed packet when updating packet statistics.
Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
Avoid accessing the packet after sending it, as the driver may
have already unreferenced or freed it. Store the iface before
sending instead of calling net_pkt_iface() on a potentially
freed packet when updating packet statistics.
Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
Avoid accessing the packet after sending it, as the driver may
have already unreferenced or freed it. Store the iface before
sending instead of calling net_pkt_iface() on a potentially
freed packet when updating packet statistics.
Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
Avoid accessing the packet after sending it, as the driver may
have already unreferenced or freed it. Store the iface before
sending instead of calling net_pkt_iface() on a potentially
freed packet when updating packet statistics.
Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
encode_be32() is only used in some configurations.
Let's mark it as possibly unused so the compiler does not warn us about
it
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Commit b9d3344fd4 introduced this static
helper function that is effectively unused and makes clang unhappy.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Turn the hardcoded TLS_SETTINGS_PREFIX into a Kconfig symbol
CONFIG_NET_SOCKETS_TLS_SESSION_CACHE_PERSISTENT_PREFIX so users
can choose a different settings key prefix if needed.
Signed-off-by: Rithic Chellaram Hariharan <gr8rithic@gmail.com>
Add persistent TLS/DTLS session cache support using the settings
subsystem. Sessions are saved after each successful handshake and
restored during tls_init(), enabling session resumption across
device reboots without a full handshake.
Backend-agnostic: works with any settings backend (NVS, ZMS, FCB,
filesystem).
Signed-off-by: Rithic Chellaram Hariharan <gr8rithic@gmail.com>
Added support for TLSv1.3 to the OCPP subsystem by enabling
TLS secure sockets. This allows secure WebSocket
connections over TLSv1.3 during OCPP communication.
Signed-off-by: Sanjay Vallimanalan <sanjay@linumiz.com>
Instead of waiting the full socket poll period, calculate the next timeout
to resend messages.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
Clear the request slot if we cancel them. release_internal_request is
wrong for cancel: Its purpose is to keep token/MID data so late responses
can be matched. But handle_response just silently drops responses for
released slots anyway.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
Add support for getting the number of bytes queued for TCP TX
that have not yet been acknowledged. Follows FreeBSD's API.
Signed-off-by: Egill Sigurdur <egill@egill.xyz>
There some more instances of net_pkt_acknowledge_data
API whose return code is not being checked.
Signed-off-by: Nikhil Namjoshi <nikhilnamjoshi@google.com>
In IEEE 1588 standard, there was actually no GRAND_MASTER port state.
We should treat GRAND_MASTER as same as MASTER state (TIME_TRANSMITTER)
in code.
So, added the case PTP_PS_GRAND_MASTER handling same with
PTP_PS_TIME_TRANSMITTER. Otherwise port entering PTP_PS_GRAND_MASTER
won't go out of the state. Also removed switching PTP_PS_TIME_TRANSMITTER
to PTP_PS_GRAND_MASTER which was useless.
Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
net_tcp_foreach() drops tcp_lock before the callback and re-acquires
it afterwards. A concurrent tcp_conn_release() can free the next
node cached by SYS_SLIST_FOR_EACH_CONTAINER_SAFE during this window,
causing the iterator to follow a dangling pointer on the next
iteration.
Move context teardown in tcp_conn_release() inside the tcp_lock
critical section and keep tcp_lock held across the callback in
net_tcp_foreach(). No current callback acquires tcp_lock.
Signed-off-by: Ofir Shemesh <ofirshemesh777@gmail.com>
Add HTTP client shell commands under the 'net http' subcommand group.
Supports GET, POST, PUT, and DELETE methods.
Commands:
net http get <url>
net http post <url> <body>
net http put <url> <body>
net http delete <url>
Signed-off-by: Muhammad Waleed Badar <walid.badar@gmail.com>
Add CoAP over TCP/TLS framing, parsing, and client support as
specified in RFC 8323. This includes:
- TCP message framing with variable-length header encoding
- CSM (Capabilities and Settings Message) exchange
- Signaling codes: Ping/Pong, Release, Abort
- CoAP TCP client with blockwise transfer support
- New Kconfig options under CONFIG_COAP_OVER_RELIABLE_TRANSPORT
- Documentation update for CoAP client API
Signed-off-by: Marcus Penate <marcus.penate@ellenbytech.com>
In case socket is closed during an async TCP handshake, the TCP context
should be closed immediately, otherwise the connection could be
established after the socket was closed, causing TCP context leak.
To avoid race between socket close and resend timer (i.e. socket being
closed at the same time as the retransmission limit is reached), add
extra state checks before attempting to close the TCP context.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
body_frag_len was computed using a raw buffer offset formula:
body_frag_len = data_len - (body_frag_start - recv_buf)
This is correct for Content-Length responses: the recv buffer contains
only decoded body bytes after the headers, so the offset arithmetic
gives the exact body byte count.
It is broken for Transfer-Encoding: chunked. RFC 7230 §3.3.2 makes
the two mutually exclusive, so chunked TE never comes with a
Content-Length. With chunked TE, the recv buffer contains both the
decoded body bytes and the chunk framing bytes (chunk-size line, CRLF
body-terminator, terminal chunk "0\r\n\r\n") side by side. The
formula counts everything from body_frag_start to the end of the
buffer fill, so it includes the framing bytes that follow the body,
causing body_frag_len to overcount.
http_parser already knows the exact decoded body byte count: it passes
it as the length argument to on_body(). Use that instead.
Add a regression test that sends a single chunked 206 response from a
raw loopback TCP server in one write, so the chunk terminator and
terminal chunk land in the same recv buffer as the body. The test
asserts body_frag_len equals the decoded body size, not body size + 7
framing bytes.
Signed-off-by: Vytautas Virvičius <vytautas@virvicius.dev>
This PR enables the DNS packet forwarding without taking into account
the return value of `dns_validate_msg` function.
This is to accomodate scenarios like where ANCOUNT is set to 0, or other
cases in which internal DNS implementation will not validate the
message.
Signed-off-by: Cristian Bulacu <cristian.bulacu@nxp.com>
Replace the hardcoded WAMP RPC type values used when encoding OCPP
messages with their corresponding symbolic constants.
- Replace '2' with OCP_WAMP_RPC_REQ
- replace '3' with OCP_WAMP_RPC_RESP
This removes magic numbers and improves human readability.
Signed-off-by: David J. Leach, Jr. <tasmar@gmail.com>
Static analysis has a difficult time tracing whether a call to
ocpp_send_to_server() needs to initialize sndlock and rspsig because
the message type is set very much earlier in the program logic flow.
Note that coverity is creating a single issue for sndlock and for rspsig
in each function that calls ocpp_send_to_server() without initializing
them.
Adding a NULL test will prevent future static analysis false positives.
Fixes#100026Fixes#100025Fixes#100024Fixes#100017Fixes#100015Fixes#100013Fixes#100011Fixes#100010Fixes#100008Fixes#100006
Signed-off-by: David J. Leach, Jr. <tasmar@gmail.com>
Drop the unnecessary _ri_ptr NULL check, as multi-instance resources
always provide a valid instance array when _ri_count > 0. This
simplifies the initialization logic and prevents compile time warrning
messages/noice.
Signed-off-by: Zafer SEN <zafersn93@gmail.com>
ethernet_update_tx_stats checks the multicast address first and then the
broadcast which causes the broadcast address to be treated as multicast
and not counted correctly.Fix this by checking broadcast address first,
followed by the multicast address.
Signed-off-by: Taha Benderli <taha.benderli@analog.com>
There are several areas in the networking stack where this is missing.
So make sure we add it.
Signed-off-by: Nikhil Namjoshi <nikhilnamjoshi@google.com>
`net_calc_chksum` is designed to return uint16_t checksum.
Its current behavior is to return 0 checksum on error
(or on an empty payload) and a valid non zero checksum for non empty
payloads. 0 could be a valid checksum for empty payload.
So update the `net_calc_chksum` and its wrapper's definition to
return error codes.
Signed-off-by: Nikhil Namjoshi <nikhilnamjoshi@google.com>
tcp_options_len calculation in tcp_data_len can underflow
if th_off(th) is less than 5. This can lead to a huge
tcp_options_len value and subsequently a wrong data length calculation.
Add the checks in tcp_recv() which is a top API, so that the checks
are covered at the entry point.
Fixes https://github.com/zephyrproject-rtos/zephyr/issues/106657
Signed-off-by: Nikhil Namjoshi <nikhilnamjoshi@google.com>