Skip to content

feat: add Get-SnmpBridgeNeighbors for L2 edge discovery via forwarding tables (#39) - #56

Merged
jacobyoby merged 2 commits into
mainfrom
feature/bridge-neighbors-39
Sep 9, 2026
Merged

jacobyoby merged 2 commits into
mainfrom
feature/bridge-neighbors-39

Conversation

@jacobyoby

Copy link
Copy Markdown
Owner

Adds BRIDGE-MIB forwarding table walks to discover L2 edges where CDP/LLDP are silent.

New function: Get-SnmpBridgeNeighbors

  • Walks dot1dTpFdbTable (address/port/status) via Invoke-SnmpWalk
  • Filters to status=3 (learned) only, silently discards others
  • Resolves MAC to IP via local ARP table
  • Emits edges with Source=SNMP-FDB, Confidence=L2-FDB
  • No ARP match produces verbose message, not warning

Merge-Edges confidence ranking updated:

  • L2-SNMP (4) > L2-FDB (3) > L2-SNMP-Heuristic (2) > L3-Inferred (1)
  • Order-independent resolution

Tests: 6 new Pester tests covering edge count, status filtering, unresolvable MAC, and three-way confidence ranking in both input orders.

Export: Added to FunctionsToExport in module manifest.

Note: pwsh not available locally so Pester tests not executed, but follow existing test patterns exactly.

Closes #39.

Generated with Qwen Code

…GE-MIB

Walk dot1dTpFdbTable (address/port/status columns) on each eligible node
to discover MAC addresses the switch has learned. Resolves MACs to IPs via
the local ARP table and emits edges with Confidence='L2-FDB' when the IP
matches a topology node. Fills in layer-2 edges that CDP/LLDP miss.

Changes:
- New function Get-SnmpBridgeNeighbors in Public/
  - Reuses Invoke-SnmpWalk for SNMP walks (redaction + injection guards)
  - Status filtering: only status=3 (learned) entries produce edges
  - MAC-to-IP resolution via local ARP table (queried once)
  - No ARP match produces Write-Verbose, not Write-Warning
- Updated Merge-Edges confidence ranking: L2-SNMP > L2-FDB > L2-SNMP-Heuristic > L3-Inferred
- Added Get-SnmpBridgeNeighbors to FunctionsToExport in psd1
- Pester tests:
  - Get-SnmpBridgeNeighbors: edge count, status filtering, unresolvable MAC
  - Merge-Edges: three-way confidence ranking in both input orders
@cursor
cursor Bot force-pushed the feature/bridge-neighbors-39 branch from 7ef5fc7 to 1b28c98 Compare September 9, 2026 13:09
The SNMP mock returned the same FDB table for every eligible node, so
host walks created an extra L2-FDB edge. Empty topology.Edges unwraps
to $null and Merge-Edges then returned @($null); return a real empty
array when nothing survives the merge.

Co-authored-by: Jacobrakai <jacobyoby@users.noreply.github.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.

Switch forwarding tables produce layer 2 edges where CDP and LLDP are silent

2 participants