uefi-rs
uefi-rs copied to clipboard
Model TCP protocol and implement a client
Hi!
Following up on this discussion in UEFIRC, a downstream consumer of uefi-rs
in which I implemented a UEFI TCP client, this PR ports this TCP protocol modelling / client implementation to uefi-rs
proper.
I made a basic effort to triage some things that were directly modelled with no accoutrements into uefi-raw
, but I'm sure more can be moved here. It would be nice to place types such as TCPv4Protocol
in uefi-raw
, but this currently contains 'client business logic' and therefore is placed in uefi
.
Here are some samples on how the client introduced in this PR can be used to communicate over TCP:
- Initialize UEFI TCP stack and connect
- Receive data (this API can certainly be improved)
- Transmit data
Notes
- I believe the
TCPv4*
types introduced by this PR should be renamed toTcpv4
orTcp4
for consistency across the project? -
Ip4RouteTable
(and theIp4IcmpType
,Ip4ModeData
, andIp4ConfigData
types introduced by this PR) should perhaps be renamed toIpv4*
for consistency withIpv4Address
. - I made a fair bit of effort during the development of this code to squash memory leaks, UAFs, and other shenanigans. However, I am not absolutely certain that no issues exist. The code works fine for my use case (mostly receiving, occasional transmitting) and I have not noticed memory leaks.
- The client implementation is incomplete. For example, I have not bothered to implement acting as a TCP server.
- The client code currently contains some 'business logic' that may not be desirable to include in
uefi-rs
, or may not be desirable to include as-is. For example, the client currently internally waits up to 10 seconds for a DHCP-assigned IP. You might wish to just include the protocol definitions inuefi-raw
and omit all the business logic, which would be fine and makes sense.
Thank you for taking the time to get this PR ready for upstream inclusion!
Checklist
- [☑️] Sensible git history (for example, squash "typo" or "fix" commits). See the Rewriting History guide for help.
- [☑️] Update the changelog (if necessary)