Skip to content

Conversation

@jweyrich
Copy link
Owner

@jweyrich jweyrich commented Oct 21, 2025

This PR adds Windows support, hopefully without breaking anything!

TL;DR

  • Windows packet capture
  • Cross-platform compatibility layers
  • Adapted BPF filters to work cross-platform

Long story

The Windows implementation uses a raw socket and includes proper privilege handling for raw socket access.

I created abstraction layers for the main platform differences (networking headers, time functions, string operations, etc) so the core logic stays clean.

The BPF filters now automatically adjust when they're dealing with Ethernet frames (Linux and BSD) or raw IP packets (Windows). This was the trickiest part since Windows raw sockets work differently.

I also added CMake configs for Visual Studio and MinGW, besides the documentation for building on Windows.

The filters work seamlessly, with the exception of Layer 2 protocols that don't work on Windows without an extra driver, which we're not writing at the moment.

It still has 0 external dependencies!

This PR closes #7.

- Add datalink_type_t enum to distinguish between Ethernet and raw IP packets
- Implement auto-detection of datalink type from packet structure
- Add *_ex() variants of filter functions with explicit datalink parameter
- Refactor filter creation to use dynamic offset calculation
- Support both Ethernet frames (Linux/BSD) and raw IP (Windows) formats
- Fix protocol and port filtering for Windows raw socket packets

This enables babysniff to work correctly on Windows where raw sockets
provide packets without Ethernet headers, while maintaining compatibility
with existing Linux/BSD Ethernet-based packet capture.
@jweyrich jweyrich merged commit ca568fd into master Oct 21, 2025
4 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.

Add support for Windows

2 participants