...
 
Commits (3)
This diff is collapsed.
......@@ -15,7 +15,7 @@ name = "redox_netstack"
path = "src/lib/lib.rs"
[dependencies]
netutils = { git = "https://gitlab.redox-os.org/redox-os/netutils.git" }
netutils = { git = "https://gitlab.redox-os.org/redox-os/netutils.git", branch = "redox-unix" }
redox_event = { git = "https://gitlab.redox-os.org/redox-os/event.git" }
redox_syscall = "0.1"
byteorder = { version = "1.0", default-features = false }
......
......@@ -5,7 +5,7 @@ use std::collections::{BTreeMap, BTreeSet};
use std::collections::VecDeque;
use std::collections::btree_map::Entry;
use std::fs::File;
use std::io::{Read, Write};
use std::io::{ErrorKind, Read, Write};
use std::mem;
use std::os::unix::io::RawFd;
use std::str;
......@@ -327,10 +327,19 @@ impl Dnsd {
}
pub fn on_dns_file_event(&mut self) -> Result<Option<()>> {
loop {
let result = loop {
let mut packet = SyscallPacket::default();
if self.dns_file.read(&mut packet)? == 0 {
break;
match self.dns_file.read(&mut packet) {
Ok(0) => {
//TODO: Cleanup must occur
break Some(());
},
Ok(_) => (),
Err(err) => if err.kind() == ErrorKind::WouldBlock {
break None;
} else {
return Err(Error::from(err));
}
}
let a = packet.a;
self.handle(&mut packet);
......@@ -340,8 +349,8 @@ impl Dnsd {
packet.a = a;
self.handle_block(packet)?;
}
}
Ok(None)
};
Ok(result)
}
pub fn on_unknown_fd_event(&mut self, fd: RawFd) -> Result<Option<()>> {
......
......@@ -6,7 +6,7 @@ use smoltcp::wire::{IpAddress, EthernetAddress, IpCidr, Ipv4Address};
use std::cell::RefCell;
use std::collections::BTreeMap;
use std::fs::File;
use std::io::{Read, Write};
use std::io::{ErrorKind, Read, Write};
use std::rc::Rc;
use std::mem;
use std::str::FromStr;
......@@ -18,7 +18,7 @@ use syscall;
use self::nodes::*;
use self::notifier::*;
use redox_netstack::error::Result;
use redox_netstack::error::{Error, Result};
use super::{post_fevent, Interface};
const WRITE_BUFFER_MAX_SIZE: usize = 0xffff;
......@@ -360,16 +360,25 @@ impl NetCfgScheme {
}
pub fn on_scheme_event(&mut self) -> Result<Option<()>> {
loop {
let result = loop {
let mut packet = SyscallPacket::default();
if self.scheme_file.read(&mut packet)? == 0 {
break;
match self.scheme_file.read(&mut packet) {
Ok(0) => {
//TODO: Cleanup must occur
break Some(());
},
Ok(_) => (),
Err(err) => if err.kind() == ErrorKind::WouldBlock {
break None;
} else {
return Err(Error::from(err));
}
}
self.handle(&mut packet);
self.scheme_file.write_all(&packet)?;
}
};
self.notify_scheduled_fds();
Ok(None)
Ok(result)
}
fn notify_scheduled_fds(&mut self) {
......
......@@ -2,7 +2,7 @@ use smoltcp::socket::{AnySocket, SocketHandle};
use std::cell::RefCell;
use std::collections::BTreeMap;
use std::fs::File;
use std::io::{Read, Write};
use std::io::{ErrorKind, Read, Write};
use std::marker::PhantomData;
use std::mem;
use std::ops::Deref;
......@@ -218,10 +218,19 @@ where
}
pub fn on_scheme_event(&mut self) -> Result<Option<()>> {
loop {
let result = loop {
let mut packet = SyscallPacket::default();
if self.scheme_file.read(&mut packet)? == 0 {
break;
match self.scheme_file.read(&mut packet) {
Ok(0) => {
//TODO: Cleanup must occur
break Some(());
},
Ok(_) => (),
Err(err) => if err.kind() == ErrorKind::WouldBlock {
break None;
} else {
return Err(Error::from(err));
}
}
if let Some(a) = self.handle(&mut packet) {
packet.a = a;
......@@ -244,8 +253,8 @@ where
}
}
}
}
Ok(None)
};
Ok(result)
}
pub fn notify_sockets(&mut self) -> Result<()> {
......