1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
//! IEEE 802.1D / IEEE 802.1w Spanning Tree Protocol (STP / RSTP) BPDU wire frame builder.
//!
//! Synthesizes 35-byte Configuration and Rapid Spanning Tree BPDUs encapsulated inside IEEE 802.3
//! length-framed Ethernet packets addressed to the Bridge Group multicast MAC `01:80:C2:00:00:00`
//! with a 3-byte IEEE 802.2 LLC header (`DSAP = 0x42`, `SSAP = 0x42`, `Control = 0x03`). Encodes
//! Protocol Identifier `0x0000`, Version (`0x00` for STP, `0x02` for RSTP), BPDU Type (`0x00` or
//! `0x02`), Flags, 8-byte Root ID, 4-byte Root Path Cost, 8-byte Bridge ID, 2-byte Port ID, and
//! 1/256-second scaled timers (Message Age, Max Age, Hello Time, Forward Delay).
//!
//! Canonical `.fasm` syntax:
//! `a -> b [STP | RSTP] [ROOT_ID "<str>"] [BRIDGE_ID "<str>"] [PORT_ID <u16>] [COST <u32>] [MAX_AGE <u16>] [HELLO_TIME <u16>] [FORWARD_DELAY <u16>] [FLAGS <u8>]`
use crate*;
use crateWireContext;
use crateCompilerError;
use cratebuild_ethernet_and_l2;
use Vec;
/// Parses a bridge or root identifier string into an 8-byte IEEE 802.1D Bridge ID (`2B Priority + 6B MAC`).
/// Parses a colon- or hyphen-separated 6-octet MAC string.
/// Builds an IEEE 802.1D / 802.1w Spanning Tree Protocol (STP) BPDU wire frame.
///
/// # Errors
/// Returns `CompilerError::BackendError` if construction fails.