Skip to content

Add support for raw + af_packet sockets#63

Merged
gasbytes merged 15 commits intowolfSSL:masterfrom
danielinux:rawsockets
Apr 22, 2026
Merged

Add support for raw + af_packet sockets#63
gasbytes merged 15 commits intowolfSSL:masterfrom
danielinux:rawsockets

Conversation

@danielinux
Copy link
Copy Markdown
Member

Add support for raw sockets and packet sockets.

  • Added support for BSD wrapper in posix systems.
  • Added 'raw_ping' and 'packet_ping' examples to craft ICMP echo requests / receive replies using the new sockets
  • Added automated tests to github workflow

Superseeds #10

Copilot AI review requested due to automatic review settings March 3, 2026 17:22
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

Adds raw IP socket and AF_PACKET-style packet socket support to wolfIP, including POSIX preload shim enhancements and new example utilities for pinging via the new socket types.

Changes:

  • Add RAW and PACKET socket types to the wolfIP socket API, including send/recv/bind/connect/poll support.
  • Extend the POSIX LD_PRELOAD BSD socket shim with ioctl() handling for interface/ARP queries needed by packet sockets.
  • Add new raw_ping / packet_ping examples and run them in CI.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
wolfip.h Adds socket constants, socket marks, and sockaddr_ll support plus ARP lookup API.
src/wolfip.c Implements raw sockets + packet sockets, routing/ARP for raw TX, and capture paths for RX.
src/test/unit/unit.c Adds unit tests covering raw/packet socket send/recv behaviors.
src/test/raw_ping.c New raw-socket ping example for CI/manual testing.
src/test/packet_ping.c New AF_PACKET ping example using ioctl-derived interface info.
src/port/posix/bsd_socket.c Adds ioctl() interception and fd bookkeeping for raw/packet sockets.
config.h Enables raw/packet sockets by default and sets default max counts.
Makefile Builds the new ping example binaries.
.github/workflows/linux.yml Runs raw_ping and packet_ping under LD_PRELOAD in CI.
Comments suppressed due to low confidence (2)

src/test/raw_ping.c:55

  • The checksum helper handles odd-length buffers incorrectly: for a trailing byte it should be added as the high-order byte of the final 16-bit word (i.e., byte << 8, zero-padded), not as a low-order byte. This matches how Internet checksums are computed (and how the stack’s checksum helpers handle odd lengths).
    if (len == 1) {
        sum += *(unsigned char *)buf;
    }

src/test/packet_ping.c:99

  • The checksum helper adds the trailing byte for odd-length buffers without shifting it into the high-order position of the final 16-bit word. For correctness with arbitrary payload sizes, treat the last byte as byte << 8 (zero-padded) when len is odd.
    if (len == 1) {
        sum += *(unsigned char *)buf;
    }

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

Comment thread src/wolfip.c Outdated
Comment thread src/port/posix/bsd_socket.c Outdated
Comment thread src/test/unit/unit.c Outdated
Comment thread config.h
Comment thread src/wolfip.c
Comment thread src/wolfip.c Outdated
Comment thread src/wolfip.c Outdated
Comment thread src/test/unit/unit.c Outdated
@danielinux danielinux mentioned this pull request Mar 3, 2026
Copilot AI review requested due to automatic review settings March 3, 2026 18:34
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

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.


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

Comment thread src/port/posix/bsd_socket.c
Comment thread src/wolfip.c
Comment thread src/wolfip.c
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

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


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

Comment thread .github/workflows/linux.yml Outdated
Comment thread Makefile Outdated
Comment thread src/wolfip.c Outdated
Comment thread src/port/posix/bsd_socket.c
Copilot AI review requested due to automatic review settings March 3, 2026 21:53
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

Copilot reviewed 9 out of 9 changed files in this pull request and generated 10 comments.


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

Comment thread src/port/posix/bsd_socket.c
Comment thread src/port/posix/bsd_socket.c
Comment thread src/port/posix/bsd_socket.c
Comment thread src/port/posix/bsd_socket.c
Comment thread src/wolfip.c
Comment thread src/wolfip.c
Comment thread src/wolfip.c
Comment thread src/wolfip.c
Comment thread src/wolfip.c
Comment thread src/wolfip.c
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

Copilot reviewed 11 out of 11 changed files in this pull request and generated 7 comments.


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

Comment thread src/wolfip.c Outdated
Comment thread src/wolfip.c Outdated
Comment thread src/wolfip.c Outdated
Comment thread src/wolfip.c
Comment thread src/wolfip.c
Comment thread wolfip.h
Comment thread src/test/unit/unit.c Outdated
Copilot AI review requested due to automatic review settings April 17, 2026 14:03
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

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


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

Comment thread src/port/posix/bsd_socket.c
Comment thread src/port/posix/bsd_socket.c Outdated
Comment thread src/wolfip.c
Comment thread src/wolfip.c
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

Copilot reviewed 11 out of 11 changed files in this pull request and generated 10 comments.


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

Comment thread src/wolfip.c Outdated
Comment thread src/test/unit/unit_tests_proto.c Outdated
Comment thread src/wolfip.c Outdated
Comment thread src/wolfip.c Outdated
Comment thread src/wolfip.c Outdated
Comment thread src/test/unit/unit_tests_proto.c
Comment thread src/wolfip.c
Comment thread src/wolfip.c Outdated
Comment thread src/wolfip.c Outdated
Comment thread src/port/posix/bsd_socket.c Outdated
Copy link
Copy Markdown

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Choose a reason for hiding this comment

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

Fenrir Automated Review — PR #63

Scan targets checked: wolfip-bugs, wolfip-compliance, wolfip-defaults, wolfip-mutation, wolfip-proptest, wolfip-src

Findings: 4
4 finding(s) posted as inline comments (see file-level comments below)

This review was generated automatically by Fenrir. Findings are non-blocking.

Comment thread src/port/posix/bsd_socket.c
Comment thread src/port/posix/bsd_socket.c
Comment thread src/wolfip.c
Comment thread src/port/posix/bsd_socket.c
@danielinux danielinux requested a review from Copilot April 17, 2026 15:41
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

Copilot reviewed 11 out of 11 changed files in this pull request and generated 8 comments.


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

Comment thread src/port/posix/bsd_socket.c
Comment thread src/port/posix/bsd_socket.c
Comment thread src/wolfip.c
Comment thread src/wolfip.c
Comment thread src/wolfip.c
Comment thread src/wolfip.c
Comment thread src/test/unit/unit_tests_proto.c Outdated
Comment thread src/wolfip.c
Comment thread wolfip.h
@danielinux danielinux requested a review from philljj April 21, 2026 10:00
Comment thread src/wolfip.c Outdated
@danielinux danielinux requested a review from gasbytes April 22, 2026 06:14
@gasbytes gasbytes merged commit 7280c2d into wolfSSL:master Apr 22, 2026
27 of 28 checks passed
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.

5 participants