rust-osdev/uefi-rs

RFC: use `core::net` IP address types in `uefi`'s public API

Closed this issue · 2 comments

Currently, we provide the following IP address types:

  • uefi-raw:

  • uefi:

    • struct IpAddress - 16 raw bytes. Compatible with the uefi_raw::IpAddress union, but implemented differently. No way to tell which type of address it is without out-of-band data
  • And these builtin types are in core::net:

The types in uefi-raw correctly match the spec, so there's nothing we need to change there.

In uefi however, I think it might make sense to switch to the core::net types in the public API, and drop our IpAddress. The core::net types are not ABI-compatible with the UEFI types, so internally we'll need to translate between them. This should be a very low-cost operation though.

Using the IpAddr enum provides a better experience than using an untagged enum that requires a separate flag to indicate which type of address it contains. We could define our own enum of course, but using core::net makes it easier to integrate with other Rust code by using a shared type.

This change would be an API break, but it only affects a fairly small part of the library (the SimpleNetwork and pxe::BaseCode protocols).

Yep, sounds good! Thanks for the write-up

At first, I wanted to outline my ideas here. Then I noticed it is simpler to put it into code to see if it works out. My attempt is here: #1645