summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/vrrpv2.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/vrrpv2.rs b/src/vrrpv2.rs
index 228c19c..6fc80a3 100644
--- a/src/vrrpv2.rs
+++ b/src/vrrpv2.rs
@@ -83,10 +83,10 @@ fn parse(bytes: &[u8]) -> Result<VRRPv2, VRRPv2Error> {
return Err(VRRPv2Error::ParseError);
};
if (vertype & 0xF) != 1 {
- return Err(VRRPv2Error::InvalidVersion);
+ return Err(VRRPv2Error::InvalidType);
}
if (vertype >> 4) != 2 {
- return Err(VRRPv2Error::InvalidType);
+ return Err(VRRPv2Error::InvalidVersion);
}
let Ok(virtual_router_id) = rdr.read_u8() else {
return Err(VRRPv2Error::ParseError);
@@ -188,7 +188,7 @@ fn test_incomplete_bytes() {
#[test]
fn test_invalid_version() {
let bytes = [
- 0x20, 0x1, 0x2a, 0x0, 0x0, 0x1, 0xb5, 0xfd, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+ 0x31, 0x1, 0x2a, 0x0, 0x0, 0x1, 0xb5, 0xfd, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0,
];
assert_eq!(from_bytes(&bytes), Err(VRRPv2Error::InvalidVersion));
@@ -197,7 +197,7 @@ fn test_invalid_version() {
#[test]
fn test_invalid_type() {
let bytes = [
- 0x31, 0x2a, 0x64, 0x1, 0x0, 0x1, 0xaa, 0x29, 0xc0, 0xa8, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0,
+ 0x20, 0x2a, 0x64, 0x1, 0x0, 0x1, 0xaa, 0x29, 0xc0, 0xa8, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0,
];
assert_eq!(from_bytes(&bytes), Err(VRRPv2Error::InvalidType));