Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: smoltcp-rs/smoltcp
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 3335b698b43a
Choose a base ref
...
head repository: smoltcp-rs/smoltcp
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 5259855c7cd4
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Dec 20, 2016

  1. Copy the full SHA
    49c0f4a View commit details
  2. Copy the full SHA
    5259855 View commit details
Showing with 7 additions and 2 deletions.
  1. +1 −1 examples/smoltcpserver.rs
  2. +6 −1 src/wire/ip.rs
2 changes: 1 addition & 1 deletion examples/smoltcpserver.rs
Original file line number Diff line number Diff line change
@@ -38,7 +38,7 @@ fn main() {
let udp_socket = iface.sockets()[0].as_socket();
let client = match udp_socket.recv() {
Ok((endpoint, data)) => {
println!("data {:?} from {}", &data[..8], endpoint);
println!("data {:?} from {}", data, endpoint);
Some(endpoint)
}
Err(Error::Exhausted) => {
7 changes: 6 additions & 1 deletion src/wire/ip.rs
Original file line number Diff line number Diff line change
@@ -107,7 +107,12 @@ pub mod checksum {
pub fn data(data: &[u8]) -> u16 {
let mut accum: u32 = 0;
for i in (0..data.len()).step_by(2) {
let word = NetworkEndian::read_u16(&data[i..i + 2]) as u32;
let word;
if i + 2 <= data.len() {
word = NetworkEndian::read_u16(&data[i..i + 2]) as u32
} else {
word = (data[i] as u32) << 8
}
accum += word;
}
(((accum >> 16) as u16) + (accum as u16))