marker: serial-link (WAN) support via data_link_type -> uBridge linktype

Markers now work on serial links (Cisco HDLC / PPP / Frame Relay / ATM), not just Ethernet. A marker carries a data_link_type (default DLT_EN10MB); at the uBridge boundary it becomes the 'mark ... linktype <dlt>' keyword so the BPF compiles and the pcap is written with the matching link-layer.

- MarkerCreate / MarkerDefinitionCreate gain data_link_type (default DLT_EN10MB). Per-link it is create-only; definitions are updatable (a change re-fans-out).
- base_node._marker_linktype() normalizes the GNS3 DLT name (strip DLT_, uppercase, None for EN10MB). Single source is SerialPort.data_link_types, so Cisco PPP -> PPP_SERIAL (50), matching the capture path -- no second mapping table.
- _ubridge_add_marker_filter (generic) and the IOU marker loop append 'linktype <dlt>'.
- Definition fan-out branches on link_type in inherit_marker: Ethernet is always EN10MB; a serial link uses the definition's WAN encapsulation, or is SKIPPED when none was chosen (an EN10MB pcap on serial is undecodable). One definition covers a mixed topology.
- MCP marker_definition exposes data_link_type (None = not forwarded).
- No uBridge rebuild on a data_link_type change -- only that one marker's filter is swapped (delete + re-add), mirroring a BPF change; reset_packet_filters preserves sibling mark filters.

Requires the uBridge build with 'mark ... linktype' support.
This commit is contained in:
YueGuobin committed 2026-08-07 01:53:33 +08:00
1 parent 117f580cfd
commit 3322233658
11 files changed
+231 -29

No files matched your search

+24
View File
@@ -189,6 +189,19 @@ class MarkerCreate(BaseModel):
"Omitted = server auto-picks (first started marker-capable endpoint)."
),
)
data_link_type: str = Field(
"DLT_EN10MB",
description=(
"pcap link-layer type the marker's BPF compiles against and its "
"capture file is written with (a uBridge `linktype` token). Defaults "
"to DLT_EN10MB (Ethernet), which is omitted from the uBridge command. "
"Only meaningful for serial links: set it to the matching serial DLT "
"from the port's data_link_types — DLT_C_HDLC / DLT_PPP_SERIAL / "
"DLT_FRELAY / DLT_ATM_RFC1483 — so the BPF offsets and pcap decode "
"match the encapsulation configured in IOS. Create-only (changing it "
"would invalidate the pcap)."
),
)
@field_validator("direction", mode="before")
@classmethod
@@ -259,6 +272,17 @@ class MarkerDefinitionCreate(BaseModel):
pattern=r"^(tx|rx|both)$",
description="Direction filter: 'tx' = capture node sending only, 'rx' = capture node receiving only, 'both' or null = both directions.",
)
data_link_type: str = Field(
"DLT_EN10MB",
description=(
"pcap link-layer type for inherited markers on serial links (uBridge "
"`linktype`). Defaults to DLT_EN10MB (Ethernet): the definition then "
"applies only to Ethernet links and serial links are skipped. Set a "
"serial DLT — DLT_C_HDLC / DLT_PPP_SERIAL / DLT_FRELAY / "
"DLT_ATM_RFC1483 — to also cover serial links with that encapsulation; "
"Ethernet links stay EN10MB regardless. Changing it re-fans-out."
),
)
@field_validator("direction", mode="before")
@classmethod