summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/vrrpv2.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/vrrpv2.rs b/src/vrrpv2.rs
index c830899..a6321ea 100644
--- a/src/vrrpv2.rs
+++ b/src/vrrpv2.rs
@@ -110,15 +110,20 @@ impl VRRPv2 {
self.count_ip_addrs,
self.auth_type as u8,
self.advertisement_interval,
+ 0x0, // checksum bits
+ 0x0, // checksum bits
]
.as_ref(),
)?;
- wr.write_all(self.checksum.to_be_bytes().as_ref())?;
for ip in self.ip_addrs.iter() {
wr.write_all(&ip.to_bits().to_be_bytes())?;
}
wr.write_all([0; 8].as_ref())?; // Authentication Data
- Ok(wr.into_inner())
+ let mut bytes = wr.into_inner();
+ // Calculate the checksum and set the respective bits
+ let sum = checksum(&bytes);
+ [bytes[6], bytes[7]] = sum.to_be_bytes();
+ Ok(bytes)
}
}