summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSunil Nimmagadda <sunil@nimmagadda.net>2024-01-17 16:41:29 +0530
committerSunil Nimmagadda <sunil@nimmagadda.net>2024-01-17 16:41:29 +0530
commitf2d7b7aa9d8a5f10dca015b7262c4fdd2d6102ac (patch)
tree048bc64a2d835b89523a8617daaa149b6a576e61 /src
parentb8a95026eeabc5acd767dc9940a9cf5aecdeefbe (diff)
Still confused by lsb/msb.
Diffstat (limited to 'src')
-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));