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

@ -109,7 +109,7 @@ impl Scheme for Intel8254x {
}
}
fn dup(&self, id: usize) -> Result<usize> {
fn dup(&self, id: usize, _buf: &[u8]) -> Result<usize> {
Ok(id)
}

View file

@ -80,16 +80,20 @@ fn main() {
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.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.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.next_read();
@ -100,10 +104,8 @@ fn main() {
Ok(None)
}).expect("e1000d: failed to catch events on IRQ file");
loop {
let event_count = event_queue.run().expect("e1000d: failed to handle events");
let event_packet = Packet {
for event_count in event_queue.trigger_all(0).expect("e1000d: failed to trigger events") {
socket.borrow_mut().write(&Packet {
id: 0,
pid: 0,
uid: 0,
@ -112,9 +114,22 @@ fn main() {
b: 0,
c: syscall::flag::EVENT_READ,
d: event_count
};
}).expect("e1000d: 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("e1000d: 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("e1000d: failed to write event");
}
}
unsafe { let _ = syscall::physunmap(address); }