src/vrrpv2.rs
changeset 22 809a5a9e5dd9
parent 21 17afb5ba9c2b
child 23 1bfa6fd5b5f9
equal deleted inserted replaced
21:17afb5ba9c2b 22:809a5a9e5dd9
   161         return Err(VRRPv2Error::InvalidChecksum);
   161         return Err(VRRPv2Error::InvalidChecksum);
   162     }
   162     }
   163     Ok(vrrpv2)
   163     Ok(vrrpv2)
   164 }
   164 }
   165 
   165 
       
   166 /// TODO: as_chunks is nicer but not stabilised yet.
   166 fn checksum(bytes: &[u8]) -> u16 {
   167 fn checksum(bytes: &[u8]) -> u16 {
   167     let mut sum: u32 = 0;
   168     let mut sum: u32 = 0;
   168     for chunk in bytes.chunks(2) {
   169     for chunk in bytes.chunks(2) {
   169         // Left over byte if any
   170         // Left over byte if any
   170         if chunk.len() == 1 {
   171         if chunk.len() == 1 {