use smoltcp as networking stack
Created by: little-dude
Hi @jackpot51,
Here is my take at replacing the existing network stack by smoltcp.
Rationale
Benefits from using a third-party network stack:
- Less code to maintain:
smoltcp
is currenlty written and maintained by @whitequark. - If
smoltcp
get adopted by many project, we can reasonably expect it to grow in terms of features, code quality, and performance. For instance it might get IPv6 soon.
Benefits from using smoltcp
:
- It's built in such a way that it is theoritically possible for the whole network stack not to allocate any memory. This could be highly desirable, to run redox on systems with very little memory, or simly to offer a network stack with a very low latency.
- The code is easy to read and well documented. As a beginner in system programming I learnt a lot by reading the code and the various blog posts about smoltcp implementation.
Disclaimer
I'm a newbie in system programming, and this is my first contribution to Redox. I did my best to make the code as correct as possible but there may be obvious mistakes.
The implementation is not complete yet but I'm making this PR to get early feedback. Basically, am I in the right direction? Are there any fundamental design flaws?
Implementation details
- I removed
ipd
,udpd
andtcpd
. Everything is contained inethernetd
- TCP sockets are not yet implemented.
- I introduced to new scheme methods:
sockrecv
andsocksend
, because I could not find a way to implement UDP sockets with onlyread
andwrite
. The problem is that thestd::net::UdpSocket::recv_from()
andstd::net::UdpSocket::send_to()
semantics requires an extra endpoint argument to be passed to the method that read/write to/from the socket. Basically, I needed something similar tosendto
andrecvfrom
on Linux. - As said previously, the implementation is incomplete.