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:
Jeremy Soller 2016-10-26 13:19:56 -06:00 • committed by GitHub
commit 2491e4771e

View file

@ -68,21 +68,27 @@ fn main() {
}).expect("ethernetd: failed to listen for network events");
event_queue.add(socket_fd, move |_count: usize| -> Result<Option<()>> {
let mut packet = Packet::default();
socket.borrow_mut().read(&mut packet)?;
loop {
let mut packet = Packet::default();
if socket.borrow_mut().read(&mut packet)? == 0 {
break;
}
let a = packet.a;
scheme.borrow_mut().handle(&mut packet);
if packet.a == (-EWOULDBLOCK) as usize {
packet.a = a;
todo.borrow_mut().push(packet);
} else {
socket.borrow_mut().write(&mut packet)?;
let a = packet.a;
scheme.borrow_mut().handle(&mut packet);
if packet.a == (-EWOULDBLOCK) as usize {
packet.a = a;
todo.borrow_mut().push(packet);
} else {
socket.borrow_mut().write(&mut packet)?;
}
}
Ok(None)
}).expect("ethernetd: failed to listen for scheme events");
event_queue.trigger_all(0).expect("ethernetd: failed to trigger events");
event_queue.run().expect("ethernetd: failed to run event loop");
});
}