Skip to content

Add routed device addressing for Python bindings - #2

Open
acedrew wants to merge 3 commits into
feature/bvll-router-discoveryfrom
feature/routed-device-addressing
Open

Add routed device addressing for Python bindings#2
acedrew wants to merge 3 commits into
feature/bvll-router-discoveryfrom
feature/routed-device-addressing

Conversation

@acedrew

@acedrew acedrew commented Mar 21, 2026

Copy link
Copy Markdown

Summary

  • Adds RequestTarget enum (Direct, Routed, ImplicitRouted) to bacnet-client, allowing all service methods to accept routed addresses via impl Into<RequestTarget> — fully backwards compatible
  • Adds ClientRouterTable auto-populated from I-Am-Router-To-Network messages, with resolve_router() for automatic router discovery when using implicit routed addresses
  • Adds parse_target() in Python bindings supporting "network:mac" address format (e.g. "1001:10.1.0.10:47808" for IP, "1001:0a" for MS/TP)
  • Adds router: Optional[str] = None keyword-only parameter to all 32 address-taking Python methods and .pyi type stubs

Address formats

Format Example Meaning
Direct IPv4 "192.168.1.100:47808" Direct MAC
Implicit routed "1001:10.1.0.10:47808" Auto-discover router for network 1001
Explicit routed "1001:10.1.0.10:47808" + router="192.168.1.254:47808" Use specified router
MS/TP routed "1001:0a" Network 1001, 1-byte MAC 0x0a

Test plan

  • cargo check passes across full workspace
  • cargo test — all 1706 tests pass (includes new unit tests for parse_target and ClientRouterTable)
  • cargo check -p rusty-bacnet --tests confirms Python bindings compile
  • Container integration test on campus network with actual routed devices

🤖 Generated with Claude Code

acedrew and others added 3 commits March 20, 2026 19:30
Introduces RequestTarget enum (Direct/Routed/ImplicitRouted) so all
client service methods accept routed addresses via `impl Into<RequestTarget>`.
Adds ClientRouterTable auto-populated from I-Am-Router-To-Network, with
resolve_router() for automatic router discovery. Python bindings gain
parse_target() supporting "network:mac" address format and a `router`
keyword-only param on all 32 address-taking methods. Includes unit tests
for parse_target and ClientRouterTable.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Two issues caused routed confirmed requests to time out:

1. The NPDU destination filter in layer.rs (line 143) discarded all
   non-broadcast messages with a DNET, including legitimate application-
   layer responses to our routed requests. Since network-layer messages
   are already handled earlier in the dispatch loop, the remaining
   messages are all APDUs — which should be accepted regardless of
   DNET, as a non-router can be the destination of a routed reply.

2. The non-BBMD FORWARDED_NPDU handler in bip.rs used the UDP sender
   address as source_mac instead of the originating IP from the BVLL
   header. When a response came through a BBMD relay, the source_mac
   wouldn't match the router_mac registered in the TSM, causing a
   correlation failure. Now uses originating_ip consistently with the
   BBMD code path.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add routed_test.rs: 8-test integration binary for campus simulator
  (router discovery, direct reads, routed reads to multiple networks,
  error round-trip, and implicit routing via auto-discovery)
- Auto-resolve ImplicitRouted targets in confirmed_request() and
  unconfirmed_request() instead of requiring callers to pre-resolve

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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