Skip to content

Added relevant POSIX headers for networking.#120

Merged
SebastianSchildt merged 2 commits intoCOVESA:mainfrom
nayakned:fix/zephyr_posix_headers
Apr 17, 2026
Merged

Added relevant POSIX headers for networking.#120
SebastianSchildt merged 2 commits intoCOVESA:mainfrom
nayakned:fix/zephyr_posix_headers

Conversation

@nayakned
Copy link
Copy Markdown
Collaborator

Due to a change in Zephyr structure, we need to now specifically add headers for POSIX utilities. See zephyrproject-rtos/zephyr@ac859d0 for the corresponding Zephyr commit.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates Zephyr example code to accommodate Zephyr’s header reorganization by switching socket-related includes to the new POSIX header locations, aligning with the referenced upstream Zephyr change.

Changes:

  • Replace #include <zephyr/net/socket.h> with #include <zephyr/posix/sys/socket.h> in shared/example code paths.
  • Remove redundant Zephyr socket header include(s) where the header is now expected to come from elsewhere.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
examples/common/common.h Switch Zephyr socket include to POSIX sys/socket header.
examples/common/common.c Remove Zephyr-specific socket include from the source include list.
examples/acf-can/zephyr/acf-can-bridge.c Switch Zephyr socket include to POSIX sys/socket header and remove duplicate include.
examples/acf-can/acf-can-common.c Switch Zephyr socket include to POSIX sys/socket header.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread examples/common/common.c
Comment thread examples/common/common.h
#include <netinet/in.h>
#elif defined(__ZEPHYR__)
#include <zephyr/net/socket.h>
#include <zephyr/posix/sys/socket.h>
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On Zephyr, common.h now only includes <zephyr/posix/sys/socket.h> (and ethernet). The code in common.c uses struct sockaddr_in/struct in_addr fields and htons/htonl/INADDR_ANY, which typically come from the inet/netinet headers rather than sys/socket.h. To avoid relying on transitive includes that may change across Zephyr versions, consider also including the appropriate POSIX inet/netinet header(s) in the __ZEPHYR__ branch here.

Suggested change
#include <zephyr/posix/sys/socket.h>
#include <zephyr/posix/sys/socket.h>
#include <zephyr/posix/netinet/in.h>
#include <zephyr/posix/arpa/inet.h>

Copilot uses AI. Check for mistakes.
Due to a change in Zephyr structure, we need to now specifically add headers for POSIX utilities.
See zephyrproject-rtos/zephyr@ac859d0 for the corresponding Zephyr commit.

Signed-off-by: Naresh Nayak <naresh.nayak@de.bosch.com>
@nayakned nayakned force-pushed the fix/zephyr_posix_headers branch from afba478 to 86b9f2b Compare April 15, 2026 14:55
Signed-off-by: Naresh Nayak <naresh.nayak@de.bosch.com>
Copy link
Copy Markdown
Collaborator

@SebastianSchildt SebastianSchildt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me 🌵

@SebastianSchildt SebastianSchildt merged commit 4f25e9c into COVESA:main Apr 17, 2026
5 checks passed
@nayakned nayakned deleted the fix/zephyr_posix_headers branch April 17, 2026 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants