MXL : Media eXchange Layer
MXL
Loading...
Searching...
No Matches
mxl::lib::fabrics::ofi::RawFabricAddress Class Referencefinal

Wrapper around a libfabric endpoint address. More...

#include <Address.hpp>

Public Member Functions

FabricAddress decode () const
 Decode into a strongly typed FabricAddress.
FabricAddressFormat format () const noexcept
 Return the fabric specific libfaric address format, or FI_FORMAT_UNSPEC if empty.
bool operator== (RawFabricAddress const &other) const noexcept
void const * raw () const noexcept
 Pointer to the raw address data.
void * raw () noexcept
 Pointer to the raw address data.
 RawFabricAddress ()
 Default is an empty fabric address.
std::size_t size () const noexcept
 Byte-length of the raw address data.
std::string toBase64 () const
 Convert the raw fabric address into a base64 encoded string.

Static Public Member Functions

static RawFabricAddress fromBase64 (std::string_view data, FabricAddressFormat addressFormat)
 Parse a fabric address from a base64 encoded string.
static RawFabricAddress fromFid (::fid_t fid, FabricInfoView info)
 Retrieve the fabric address of an endpoint by passing its fid.

Private Member Functions

 RawFabricAddress (std::vector< std::uint8_t > addr, FabricAddressFormat addressFormat)

Static Private Member Functions

static RawFabricAddress retrieveFabricAddress (::fid_t fid, FabricInfoView info)
 Retrieve the fabric address of an endpoint by using its fid.

Private Attributes

FabricAddressFormat _addressFormat
std::vector< std::uint8_t > _inner

Detailed Description

Wrapper around a libfabric endpoint address.

Definition at line 19 of file Address.hpp.

Constructor & Destructor Documentation

◆ RawFabricAddress() [1/2]

mxl::lib::fabrics::ofi::RawFabricAddress::RawFabricAddress ( )

Default is an empty fabric address.

Definition at line 17 of file Address.cpp.

◆ RawFabricAddress() [2/2]

mxl::lib::fabrics::ofi::RawFabricAddress::RawFabricAddress ( std::vector< std::uint8_t > addr,
FabricAddressFormat addressFormat )
explicitprivate

Definition at line 22 of file Address.cpp.

23 : _inner{std::move(addr)}
24 , _addressFormat{addressFormat}
25 {}

Member Function Documentation

◆ decode()

FabricAddress mxl::lib::fabrics::ofi::RawFabricAddress::decode ( ) const
nodiscard

Decode into a strongly typed FabricAddress.

Definition at line 62 of file Address.cpp.

63 {
64 return FabricAddress::decode(_addressFormat, _inner.data(), _inner.size());
65 }
static FabricAddress decode(FabricAddressFormat addrFormat, void const *addr, std::size_t len)
Decode a raw libfabric address buffer of the given addr_format.

◆ format()

FabricAddressFormat mxl::lib::fabrics::ofi::RawFabricAddress::format ( ) const
nodiscardnoexcept

Return the fabric specific libfaric address format, or FI_FORMAT_UNSPEC if empty.

Definition at line 52 of file Address.cpp.

53 {
54 return _addressFormat;
55 }

◆ fromBase64()

RawFabricAddress mxl::lib::fabrics::ofi::RawFabricAddress::fromBase64 ( std::string_view data,
FabricAddressFormat addressFormat )
staticnodiscard

Parse a fabric address from a base64 encoded string.

Parameters
dataBase64 encoded raw binary address
addressFormatA libfabric address format like FI_SOCKADDR_IN, FI_ADDR_EFA, etc..

Definition at line 67 of file Address.cpp.

68 {
70 if (decoded.empty())
71 {
72 throw std::runtime_error("Failed to decode base64 data into FabricAddress.");
73 }
74 return RawFabricAddress{std::move(decoded), addressFormat};
75 }
RawFabricAddress()
Default is an empty fabric address.
Definition Address.cpp:17
OutputBuffer decode_into(std::string_view base64Text)
Definition Base64.hpp:2748

◆ fromFid()

RawFabricAddress mxl::lib::fabrics::ofi::RawFabricAddress::fromFid ( ::fid_t fid,
FabricInfoView info )
staticnodiscard

Retrieve the fabric address of an endpoint by passing its fid.

Parameters
fidlibfabric address object
addressFormatA libfabric address format like FI_SOCKADDR_IN, FI_ADDR_EFA, etc..

Definition at line 27 of file Address.cpp.

28 {
29 return retrieveFabricAddress(fid, info);
30 }
static RawFabricAddress retrieveFabricAddress(::fid_t fid, FabricInfoView info)
Retrieve the fabric address of an endpoint by using its fid.
Definition Address.cpp:77

◆ operator==()

bool mxl::lib::fabrics::ofi::RawFabricAddress::operator== ( RawFabricAddress const & other) const
noexcept

Definition at line 57 of file Address.cpp.

58 {
59 return (_inner == other._inner) && (_addressFormat == other._addressFormat);
60 }

◆ raw() [1/2]

void const * mxl::lib::fabrics::ofi::RawFabricAddress::raw ( ) const
nodiscardnoexcept

Pointer to the raw address data.

Definition at line 42 of file Address.cpp.

43 {
44 return _inner.data();
45 }

◆ raw() [2/2]

void * mxl::lib::fabrics::ofi::RawFabricAddress::raw ( )
nodiscardnoexcept

Pointer to the raw address data.

Definition at line 37 of file Address.cpp.

38 {
39 return _inner.data();
40 }

◆ retrieveFabricAddress()

RawFabricAddress mxl::lib::fabrics::ofi::RawFabricAddress::retrieveFabricAddress ( ::fid_t fid,
FabricInfoView info )
staticnodiscardprivate

Retrieve the fabric address of an endpoint by using its fid.

Definition at line 77 of file Address.cpp.

78 {
79 auto const format = mustConvertAddressFormat(info->addr_format);
80
81 // First obtain the address length
82 std::size_t addrlen = 0;
83 auto ret = fi_getname(fid, nullptr, &addrlen);
84 if (ret != -FI_ETOOSMALL)
85 {
86 throw FabricException("Failed to get address length from endpoint.", MXL_ERR_UNKNOWN, ret);
87 }
88
89 // Now that we have the address length, allocate a receiving buffer and call fi_getname again to retrieve the actual address
90 auto addr = std::vector<std::uint8_t>(addrlen);
91 fiCall(fi_getname, "Failed to retrieve endpoint's local address.", fid, addr.data(), &addrlen);
92
93 return RawFabricAddress{std::move(addr), format};
94 }
FabricAddressFormat format() const noexcept
Return the fabric specific libfaric address format, or FI_FORMAT_UNSPEC if empty.
Definition Address.cpp:52
@ MXL_ERR_UNKNOWN
Definition mxl.h:27
int fiCall(F &&fun, std::string_view msg, T &&... args)
Call a libfabric function and check its return code.
FabricAddressFormat mustConvertAddressFormat(std::uint32_t fiAddrFormat)
Convert from libfabric address format value to FabricAddressFormat Never returns FabricAddressFormat:...

◆ size()

std::size_t mxl::lib::fabrics::ofi::RawFabricAddress::size ( ) const
nodiscardnoexcept

Byte-length of the raw address data.

Definition at line 47 of file Address.cpp.

48 {
49 return _inner.size();
50 }

◆ toBase64()

std::string mxl::lib::fabrics::ofi::RawFabricAddress::toBase64 ( ) const
nodiscard

Convert the raw fabric address into a base64 encoded string.

Definition at line 32 of file Address.cpp.

33 {
34 return base64::encode_into<std::string>(_inner.cbegin(), _inner.cend());
35 }
OutputBuffer encode_into(InputIterator begin, InputIterator end)
Definition Base64.hpp:2676

Member Data Documentation

◆ _addressFormat

FabricAddressFormat mxl::lib::fabrics::ofi::RawFabricAddress::_addressFormat
private

Definition at line 91 of file Address.hpp.

◆ _inner

std::vector<std::uint8_t> mxl::lib::fabrics::ofi::RawFabricAddress::_inner
private

libfabric address represented as a buffer of bytes

Definition at line 90 of file Address.hpp.


The documentation for this class was generated from the following files: