Expand description
HSRP wire formats, both of them.
HSRPv1 and HSRPv2 are not the same protocol in a different dress — they are two
unrelated encodings that happen to share a name, a port and an election idea. v1 is a
flat 20-byte struct (RFC 2281 §5); v2 is a sequence of TLVs. Nothing about one parses as
the other, and the state numbers differ in a way that silently mis-decodes rather than
failing: code 4 is Speak in v1 and Standby in v2. That collision is the single
most dangerous thing in this file, which is why the enums below never carry a bare integer
across a version boundary — HsrpState is converted through from_v1_code/from_v2_code
and v1_code/v2_code, and there is no as u8 shortcut anywhere.
This module is pure: no sockets, no LLM, no state. mod.rs owns all of that.
Structs§
- Hsrp
Message - One HSRP advertisement, version-independent.
- Md5Auth
- What an HSRPv2 MD5 Authentication TLV said, minus the digest.
Enums§
- Hsrp
State - Where the speaker says it is in the election.
- Hsrp
Version - Which of the two incompatible encodings a message uses.
- Opcode
- What the message asserts. All three are elections moves, not queries.
Constants§
- AUTH_
FIELD_ LEN - Width of the authentication field in both versions.
- DEFAULT_
AUTH_ DATA - The notorious Cisco default. See
CLAUDE.md: this is plaintext on the wire and provides no security whatsoever — it is a misconfiguration guard, not authentication. - V1_LEN
- Exact size of an HSRPv1 datagram (RFC 2281 §5): eight one-byte fields, eight bytes of authentication data, four bytes of virtual IP.
- V1_
VERSION_ BYTE - The value HSRPv1 puts in its
Versionbyte. It is 0, not 1 (RFC 2281 §5: “Currently, this is version 0”). Reading this as “v1 means byte 1” produces a packet no Cisco device accepts, and is the first thing to check if interop ever fails. - V2_
GROUP_ STATE_ LEN - Payload length of the Group State TLV, i.e. the byte after the type. Always 40.
- V2_
GROUP_ STATE_ TOTAL - Total size of a Group State TLV including its two-byte type/length header.
- V2_
MD5_ AUTH_ LEN - Payload length of the MD5 Authentication TLV in the form this parser accepts.
- V2_
TEXT_ AUTH_ LEN - Payload length of the Text Authentication TLV. Always 8, like v1’s inline field.
- V2_
TLV_ GROUP_ STATE - HSRPv2 Group State TLV type.
- V2_
TLV_ INTERFACE_ STATE - HSRPv2 Interface State TLV type. Parsed past, never generated.
- V2_
TLV_ MD5_ AUTH - HSRPv2 MD5 Authentication TLV type. Parsed structurally; see
Md5Auth. - V2_
TLV_ TEXT_ AUTH - HSRPv2 Text Authentication TLV type — the v2 home of the same 8-byte plaintext field v1 carries inline.