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
parent 268c859fd6
commit 2491e4771e
54 changed files with 1884 additions and 1476 deletions

View file

@ -84,7 +84,7 @@ impl SchemeMut for Rtl8168 {
}
}
fn dup(&mut self, id: usize) -> Result<usize> {
fn dup(&mut self, id: usize, _buf: &[u8]) -> Result<usize> {
Ok(id)
}

View file

@ -85,16 +85,20 @@ fn main() {
let socket_fd = socket.borrow().as_raw_fd();
let socket_packet = socket.clone();
event_queue.add(socket_fd, move |_count: usize| -> Result<Option<usize>> {
let mut packet = Packet::default();
socket_packet.borrow_mut().read(&mut packet)?;
loop {
let mut packet = Packet::default();
if socket_packet.borrow_mut().read(&mut packet)? == 0 {
break;
}
let a = packet.a;
device.borrow_mut().handle(&mut packet);
if packet.a == (-EWOULDBLOCK) as usize {
packet.a = a;
todo.borrow_mut().push(packet);
} else {
socket_packet.borrow_mut().write(&mut packet)?;
let a = packet.a;
device.borrow_mut().handle(&mut packet);
if packet.a == (-EWOULDBLOCK) as usize {
packet.a = a;
todo.borrow_mut().push(packet);
} else {
socket_packet.borrow_mut().write(&mut packet)?;
}
}
let next_read = device.borrow().next_read();
@ -105,10 +109,8 @@ fn main() {
Ok(None)
}).expect("rtl8168d: failed to catch events on IRQ file");
loop {
let event_count = event_queue.run().expect("rtl8168d: failed to handle events");
let event_packet = Packet {
for event_count in event_queue.trigger_all(0).expect("rtl8168d: failed to trigger events") {
socket.borrow_mut().write(&Packet {
id: 0,
pid: 0,
uid: 0,
@ -117,9 +119,22 @@ fn main() {
b: 0,
c: syscall::flag::EVENT_READ,
d: event_count
};
}).expect("rtl8168d: failed to write event");
}
socket.borrow_mut().write(&event_packet).expect("vesad: failed to write display event");
loop {
let event_count = event_queue.run().expect("rtl8168d: failed to handle events");
socket.borrow_mut().write(&Packet {
id: 0,
pid: 0,
uid: 0,
gid: 0,
a: syscall::number::SYS_FEVENT,
b: 0,
c: syscall::flag::EVENT_READ,
d: event_count
}).expect("rtl8168d: failed to write event");
}
}
unsafe { let _ = syscall::physunmap(address); }