equal
deleted
inserted
replaced
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 { |