Skip to main content

decode

Function decode 

Source
pub fn decode(buf: &[u8]) -> Result<HsrpMessage>
Expand description

Parse a datagram as whichever of the two formats it is.

The two are told apart by their first bytes and cannot be confused: a v1 packet starts with its Version byte, which is 0, while a v2 packet starts with a TLV type, which is never 0. Sniffing rather than trusting a configured version is deliberate — a real segment can carry both at once, and refusing to parse the one the operator did not configure would simply hide a neighbour from the model.