Skip to content

Add BNEP support#57

Merged
colemancda merged 11 commits into
masterfrom
feature/bnep
Jul 18, 2026
Merged

Add BNEP support#57
colemancda merged 11 commits into
masterfrom
feature/bnep

Conversation

@colemancda

Copy link
Copy Markdown
Member

Summary

Adds Personal Area Networking support via the kernel's BNEP module, turning the previously empty BNEP target into a working session-management layer:

  • BNEPSocket — control socket for kernel network encapsulation sessions: addConnection bridges a connected L2CAP socket (PSM 15) into a virtual Ethernet interface and returns the created interface name (e.g. bnep0); removeConnection destroys a session; connections() lists active sessions; supportedFeatures() reads the kernel feature bitmask.
  • Ioctl wrappers for all four operations, following the existing RFCOMM wrapper pattern (the ioctl identifiers already existed in BNEPIO but had no request types). The connection list request embeds a pointer to a caller-allocated array rather than a flexible array member, so the wrapper allocates and wires the buffer internally.
  • C interop structures matching the kernel ABI, with fixed 16-byte interface name buffers and destination addresses in network (Ethernet) byte order.
  • Value typesBNEPRole (PANU, NAP, GN service classes), BNEPConnectionFlag, BNEPConnectionState, and a public BNEPConnection info struct.

Establishing a PAN link end to end additionally requires a classic L2CAP connection to PSM 15 and the setup request/response exchange; classic L2CAP connect conveniences are a natural follow-up (current helpers are LE-only).

Test plan

  • 7 new unit tests using the syscall mocking driver: ioctl request codes asserted against exact kernel values (including sign extension of read-direction requests), struct memory layouts asserted against the C ABI, faked kernel replies for add connection (interface name write-back), connection list, and supported features, and device name encoding round-trips
  • Full test suite passes (57 tests)
  • swift build succeeds with no new warnings
  • Live behavior requires Linux with the kernel BNEP module and CAP_NET_ADMIN (root)

@colemancda
colemancda merged commit ea5cd34 into master Jul 18, 2026
1 check passed
@colemancda
colemancda deleted the feature/bnep branch July 18, 2026 05:55
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.

1 participant