Redo networking (#22)
* Rewriting network functions * Add buffer to dup Fix non-blocking handling by triggering once on enabling events to read to EOF * Modifications for UDP API * Implement TCP client side * Add active close * Add DMAR parser * Implement basic TCP listening. Need to improve the state machine * Reduce debugging * Fixes for close procedure * Updates to fix path processing in libstd
This commit is contained in:
parent
268c859fd6
commit
2491e4771e
54 changed files with 1884 additions and 1476 deletions
|
@ -61,10 +61,7 @@ impl UserInner {
|
|||
};
|
||||
|
||||
let len = self.todo.send(packet);
|
||||
//TODO: Use O_NONBLOCK and send one notification
|
||||
for _i in 0 .. len {
|
||||
context::event::trigger(ROOT_SCHEME_ID.load(Ordering::SeqCst), self.handle_id, EVENT_READ, mem::size_of::<Packet>());
|
||||
}
|
||||
context::event::trigger(ROOT_SCHEME_ID.load(Ordering::SeqCst), self.handle_id, EVENT_READ, mem::size_of::<Packet>() * len);
|
||||
|
||||
Error::demux(self.done.receive(&id))
|
||||
}
|
||||
|
@ -182,6 +179,14 @@ impl UserInner {
|
|||
|
||||
Ok(i * packet_size)
|
||||
}
|
||||
|
||||
pub fn fevent(&self, _flags: usize) -> Result<usize> {
|
||||
Ok(self.handle_id)
|
||||
}
|
||||
|
||||
pub fn fsync(&self) -> Result<usize> {
|
||||
Ok(0)
|
||||
}
|
||||
}
|
||||
|
||||
/// UserInner has to be wrapped
|
||||
|
@ -230,9 +235,12 @@ impl Scheme for UserScheme {
|
|||
result
|
||||
}
|
||||
|
||||
fn dup(&self, file: usize) -> Result<usize> {
|
||||
fn dup(&self, file: usize, buf: &[u8]) -> Result<usize> {
|
||||
let inner = self.inner.upgrade().ok_or(Error::new(ENODEV))?;
|
||||
inner.call(SYS_DUP, file, 0, 0)
|
||||
let address = inner.capture(buf)?;
|
||||
let result = inner.call(SYS_DUP, file, address, buf.len());
|
||||
let _ = inner.release(address);
|
||||
result
|
||||
}
|
||||
|
||||
fn read(&self, file: usize, buf: &mut [u8]) -> Result<usize> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue