Update smoltcp.

This commit is contained in:
Egor Karavaev
2017-10-25 21:18:24 +03:00
parent b54ead7d77
commit 077673d9e5
9 changed files with 80 additions and 31 deletions
Generated
+10 -10
View File
@@ -13,7 +13,7 @@ dependencies = [
[[package]]
name = "arg_parser"
version = "0.1.0"
source = "git+https://github.com/redox-os/arg-parser.git#288d2fd9ae27ed2c7a3aaf5a77cf07e2b2bd356c"
source = "git+https://github.com/redox-os/arg-parser.git#d16e2d02e87996bbe2bce4a201c66c0df4a1e866"
[[package]]
name = "base64"
@@ -44,13 +44,13 @@ name = "coco"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"either 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"scopeguard 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"either 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "either"
version = "1.2.0"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
@@ -177,7 +177,7 @@ dependencies = [
[[package]]
name = "netutils"
version = "0.1.0"
source = "git+https://github.com/redox-os/netutils.git#29b8efd41d8c56b33c619db78e5b019934dbb7a3"
source = "git+https://github.com/redox-os/netutils.git#2c082a38814922125ca402103a1a50d5531f6330"
dependencies = [
"arg_parser 0.1.0 (git+https://github.com/redox-os/arg-parser.git)",
"extra 0.1.0 (git+https://github.com/redox-os/libextra.git)",
@@ -258,7 +258,7 @@ dependencies = [
[[package]]
name = "redox_event"
version = "0.1.0"
source = "git+https://github.com/redox-os/event.git#42d552e4765efbfb4ec39ce174900d3f48548a70"
source = "git+https://github.com/redox-os/event.git#bb96d9cd6dd01d4118deae84722a522b8328fa9f"
dependencies = [
"redox_syscall 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -308,13 +308,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "scopeguard"
version = "0.3.2"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "smoltcp"
version = "0.4.0"
source = "git+https://github.com/m-labs/smoltcp.git#096ce02ac4c935c4df485a79107fb26b5897065d"
source = "git+https://github.com/m-labs/smoltcp.git#f64a99a4e6d744c3a6f3d9a54a0fb3f94e4b0ec8"
dependencies = [
"byteorder 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -429,7 +429,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0fc10e8cc6b2580fda3f36eb6dc5316657f812a3df879a44a66fc9f0fdbc4855"
"checksum byteorder 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ff81738b726f5d099632ceaffe7fb65b90212e8dce59d518729e7e8634032d3d"
"checksum coco 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c06169f5beb7e31c7c67ebf5540b8b472d23e3eade3b2ec7d1f5b504a85f91bd"
"checksum either 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cbee135e9245416869bf52bd6ccc9b59e2482651510784e089b874272f02a252"
"checksum either 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e311a7479512fbdf858fb54d91ec59f3b9f85bc0113659f46bba12b199d273ce"
"checksum extra 0.1.0 (git+https://github.com/redox-os/libextra.git)" = "<none>"
"checksum fuchsia-zircon 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f6c0581a4e363262e52b87f59ee2afe3415361c6ec35e665924eb08afe8ff159"
"checksum fuchsia-zircon-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "43f3795b4bae048dc6123a6b972cadde2e676f9ded08aef6bb77f5f157684a82"
@@ -461,7 +461,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum ring 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1f2a6dc7fc06a05e6de183c5b97058582e9da2de0c136eafe49609769c507724"
"checksum rustls 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "17727f4b991294da2c84d75a43c003151ff58072212768800f66c56ee46dca43"
"checksum safemem 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e27a8b19b835f7aea908818e871f5cc3a5a186550c30773be987e155e8163d8f"
"checksum scopeguard 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c79eb2c3ac4bc2507cda80e7f3ac5b88bd8eae4c0914d5663e6a8933994be918"
"checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27"
"checksum smoltcp 0.4.0 (git+https://github.com/m-labs/smoltcp.git)" = "<none>"
"checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096"
"checksum time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)" = "d5d788d3aa77bc0ef3e9621256885555368b47bd495c13dd2e7413c89f845520"
+1 -1
View File
@@ -40,4 +40,4 @@ features = ["release_max_level_off"]
[dependencies.smoltcp]
git = "https://github.com/m-labs/smoltcp.git"
default-features = false
features = ["std", "log", "socket-raw", "socket-udp", "socket-tcp"]
features = ["std", "log", "proto-raw", "proto-udp", "proto-tcp"]
+1 -1
View File
@@ -30,7 +30,7 @@ impl ArpCache for LoArpCache {
fn lookup(&mut self, protocol_addr: &IpAddress) -> Option<EthernetAddress> {
//TODO: use IpAddress::is_loopback
if let &IpAddress::Ipv4(ipv4_addr) = protocol_addr {
if let IpAddress::Ipv4(ipv4_addr) = *protocol_addr {
if ipv4_addr.is_loopback() {
return Some(LOOPBACK_HWADDR);
}
+1 -1
View File
@@ -18,7 +18,7 @@ impl Buffer {
pub fn move_out(&mut self) -> Buffer {
Buffer {
buffer: replace(&mut self.buffer, vec![]),
stack: self.stack.clone(),
stack: Rc::clone(&self.stack),
}
}
}
+7
View File
@@ -43,6 +43,13 @@ impl<'a, 'b> SchemeSocket for RawSocket<'a, 'b> {
Ok(0)
}
fn ttl(&self) -> u8 {
0
}
fn set_ttl(&mut self, _ttl: u8) {
}
fn new_socket(
socket_set: &mut SocketSet,
path: &str,
+1 -1
View File
@@ -77,7 +77,7 @@ impl Smolnetd {
Rc::clone(&network_file),
Rc::clone(&input_queue),
hardware_addr,
buffer_pool.clone(),
Rc::clone(&buffer_pool),
);
let arp_cache = LoArpCache::new(protocol_addrs.iter().map(IpCidr::address));
let iface = EthernetInterface::new(
+43 -17
View File
@@ -112,6 +112,9 @@ where
fn can_send(&self) -> bool;
fn can_recv(&self) -> bool;
fn ttl(&self) -> u8;
fn set_ttl(&mut self, u8);
fn get_setting(&SocketFile<Self::DataT>, Self::SettingT, &mut [u8]) -> SyscallResult<usize>;
fn set_setting(&mut SocketFile<Self::DataT>, Self::SettingT, &[u8]) -> SyscallResult<usize>;
@@ -362,24 +365,38 @@ where
}
};
if let Setting::Other(setting) = setting {
SocketT::get_setting(file, setting, buf)
} else {
let timespec = match (setting, file.read_timeout, file.write_timeout) {
(Setting::ReadTimeout, Some(read_timeout), _) => read_timeout,
(Setting::WriteTimeout, _, Some(write_timeout)) => write_timeout,
_ => {
return Ok(0);
match setting {
Setting::Other(setting) => {
SocketT::get_setting(file, setting, buf)
},
Setting::Ttl => {
if let Some(ttl) = buf.get_mut(0) {
let mut socket_set = self.socket_set.borrow_mut();
let socket = socket_set.get::<SocketT>(file.socket_handle);
*ttl = socket.ttl();
Ok(1)
} else {
Err(SyscallError::new(syscall::EIO))
}
};
},
Setting::ReadTimeout |
Setting::WriteTimeout => {
let timespec = match (setting, file.read_timeout, file.write_timeout) {
(Setting::ReadTimeout, Some(read_timeout), _) => read_timeout,
(Setting::WriteTimeout, _, Some(write_timeout)) => write_timeout,
_ => {
return Ok(0);
}
};
if buf.len() < mem::size_of::<TimeSpec>() {
Ok(0)
} else {
let count = timespec.deref().read(buf).map_err(|err| {
SyscallError::new(err.raw_os_error().unwrap_or(syscall::EIO))
})?;
Ok(count)
if buf.len() < mem::size_of::<TimeSpec>() {
Ok(0)
} else {
let count = timespec.deref().read(buf).map_err(|err| {
SyscallError::new(err.raw_os_error().unwrap_or(syscall::EIO))
})?;
Ok(count)
}
}
}
}
@@ -423,7 +440,16 @@ where
};
Ok(count)
}
Setting::Ttl => Ok(0),
Setting::Ttl => {
if let Some(ttl) = buf.get(0) {
let mut socket_set = self.socket_set.borrow_mut();
let mut socket = socket_set.get::<SocketT>(file.socket_handle);
socket.set_ttl(*ttl);
Ok(1)
} else {
Err(SyscallError::new(syscall::EIO))
}
}
Setting::Other(setting) => SocketT::set_setting(file, setting, buf),
}
}
+8
View File
@@ -26,6 +26,14 @@ impl<'a> SchemeSocket for TcpSocket<'a> {
self.can_recv()
}
fn ttl(&self) -> u8 {
self.ttl().unwrap_or(64)
}
fn set_ttl(&mut self, ttl: u8) {
self.set_ttl(Some(ttl));
}
fn get_setting(
_file: &SocketFile<Self::DataT>,
_setting: Self::SettingT,
+8
View File
@@ -28,6 +28,14 @@ impl<'a, 'b> SchemeSocket for UdpSocket<'a, 'b> {
self.can_recv()
}
fn ttl(&self) -> u8 {
self.ttl().unwrap_or(64)
}
fn set_ttl(&mut self, ttl: u8) {
self.set_ttl(Some(ttl));
}
fn get_setting(
_file: &SocketFile<Self::DataT>,
_setting: Self::SettingT,