[*] INetAdapter refactor: lets not assume all adapters have IP addresses
This commit is contained in:
parent
971b007ab9
commit
528cb01679
@ -24,11 +24,11 @@ namespace Aurora::IO::Net
|
|||||||
|
|
||||||
virtual EIPProtocol GetFamily() = 0;
|
virtual EIPProtocol GetFamily() = 0;
|
||||||
|
|
||||||
virtual const IPAddress &GetAddress() = 0;
|
virtual AuOptional<const IPAddress &> GetAddress() = 0;
|
||||||
virtual const IPAddress &GetBroadcastAddress() = 0;
|
virtual AuOptional<const IPAddress &> GetBroadcastAddress() = 0;
|
||||||
virtual const IPAddress &GetAnycastAddress() = 0;
|
virtual AuOptional<const IPAddress &> GetAnycastAddress() = 0;
|
||||||
virtual const IPAddress &GetSubnetMask() = 0;
|
virtual AuOptional<const IPAddress &> GetSubnetMask() = 0;
|
||||||
virtual const IPAddress &GetGateway() = 0;
|
virtual AuOptional<const IPAddress &> GetGateway() = 0;
|
||||||
|
|
||||||
virtual AuArray<AuUInt8, 8> GetMacAddress() = 0;
|
virtual AuArray<AuUInt8, 8> GetMacAddress() = 0;
|
||||||
|
|
||||||
|
@ -239,7 +239,7 @@ namespace Aurora::IO::Net
|
|||||||
adapter.uReceiveBytesPerSec = pCurrAddresses->ReceiveLinkSpeed / 8;
|
adapter.uReceiveBytesPerSec = pCurrAddresses->ReceiveLinkSpeed / 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (adapter.address.ip == EIPProtocol::eIPProtocolV4)
|
if (adapter.address.Value().ip == EIPProtocol::eIPProtocolV4)
|
||||||
{
|
{
|
||||||
adapter.index = pCurrAddresses->IfIndex;
|
adapter.index = pCurrAddresses->IfIndex;
|
||||||
}
|
}
|
||||||
|
@ -16,11 +16,6 @@ namespace Aurora::IO::Net
|
|||||||
return this->name.empty() ? this->device : this->name;
|
return this->name.empty() ? this->device : this->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
const IPAddress &NetAdapter::GetSubnetMask()
|
|
||||||
{
|
|
||||||
return this->subnet;
|
|
||||||
}
|
|
||||||
|
|
||||||
const AuString &NetAdapter::GetDevice()
|
const AuString &NetAdapter::GetDevice()
|
||||||
{
|
{
|
||||||
return this->device;
|
return this->device;
|
||||||
@ -38,7 +33,7 @@ namespace Aurora::IO::Net
|
|||||||
|
|
||||||
EIPProtocol NetAdapter::GetFamily()
|
EIPProtocol NetAdapter::GetFamily()
|
||||||
{
|
{
|
||||||
return this->address.ip;
|
return this->address.ValueOr(IPAddress {}).ip;
|
||||||
}
|
}
|
||||||
|
|
||||||
AuUInt16 NetAdapter::GetIndex()
|
AuUInt16 NetAdapter::GetIndex()
|
||||||
@ -46,24 +41,39 @@ namespace Aurora::IO::Net
|
|||||||
return this->index;
|
return this->index;
|
||||||
}
|
}
|
||||||
|
|
||||||
const IPAddress &NetAdapter::GetAddress()
|
AuOptional<const IPAddress &> NetAdapter::GetAddress()
|
||||||
{
|
{
|
||||||
return this->address;
|
return this->address ?
|
||||||
|
this->address.Value() :
|
||||||
|
AuOptional<const IPAddress &> {};
|
||||||
}
|
}
|
||||||
|
|
||||||
const IPAddress &NetAdapter::GetBroadcastAddress()
|
AuOptional<const IPAddress &> NetAdapter::GetBroadcastAddress()
|
||||||
{
|
{
|
||||||
return this->broadcast;
|
return this->broadcast ?
|
||||||
|
this->broadcast.Value() :
|
||||||
|
AuOptional<const IPAddress &> {};
|
||||||
}
|
}
|
||||||
|
|
||||||
const IPAddress &NetAdapter::GetAnycastAddress()
|
AuOptional<const IPAddress &> NetAdapter::GetAnycastAddress()
|
||||||
{
|
{
|
||||||
return this->anycast;
|
return this->anycast ?
|
||||||
|
this->anycast.Value() :
|
||||||
|
AuOptional<const IPAddress &> {};
|
||||||
}
|
}
|
||||||
|
|
||||||
const IPAddress &NetAdapter::GetGateway()
|
AuOptional<const IPAddress &> NetAdapter::GetGateway()
|
||||||
{
|
{
|
||||||
return this->gateway;
|
return this->gateway ?
|
||||||
|
this->gateway.Value() :
|
||||||
|
AuOptional<const IPAddress &> {};
|
||||||
|
}
|
||||||
|
|
||||||
|
AuOptional<const IPAddress &> NetAdapter::GetSubnetMask()
|
||||||
|
{
|
||||||
|
return this->subnet ?
|
||||||
|
this->subnet.Value() :
|
||||||
|
AuOptional<const IPAddress &> {};
|
||||||
}
|
}
|
||||||
|
|
||||||
const AuList<IPAddress> &NetAdapter::GetDNS()
|
const AuList<IPAddress> &NetAdapter::GetDNS()
|
||||||
|
@ -21,11 +21,11 @@ namespace Aurora::IO::Net
|
|||||||
EAdapterType GetAdapterType() override;
|
EAdapterType GetAdapterType() override;
|
||||||
EAdapterStatus GetAdapterStatus() override;
|
EAdapterStatus GetAdapterStatus() override;
|
||||||
|
|
||||||
const IPAddress &GetAddress() override;
|
AuOptional<const IPAddress &> GetAddress() override;
|
||||||
const IPAddress &GetBroadcastAddress() override;
|
AuOptional<const IPAddress &> GetBroadcastAddress() override;
|
||||||
const IPAddress &GetAnycastAddress() override;
|
AuOptional<const IPAddress &> GetAnycastAddress() override;
|
||||||
const IPAddress &GetSubnetMask() override;
|
AuOptional<const IPAddress &> GetSubnetMask() override;
|
||||||
const IPAddress &GetGateway() override;
|
AuOptional<const IPAddress &> GetGateway() override;
|
||||||
|
|
||||||
const AuList<IPAddress> &GetDNS() override;
|
const AuList<IPAddress> &GetDNS() override;
|
||||||
|
|
||||||
@ -46,11 +46,11 @@ namespace Aurora::IO::Net
|
|||||||
|
|
||||||
AuString name;
|
AuString name;
|
||||||
AuString device;
|
AuString device;
|
||||||
IPAddress address;
|
AuOptional<IPAddress> address;
|
||||||
IPAddress broadcast;
|
AuOptional<IPAddress> broadcast;
|
||||||
IPAddress anycast;
|
AuOptional<IPAddress> anycast;
|
||||||
IPAddress subnet;
|
AuOptional<IPAddress> subnet;
|
||||||
IPAddress gateway;
|
AuOptional<IPAddress> gateway;
|
||||||
EAdapterType eNetworkType { EAdapterType::eUnknown };
|
EAdapterType eNetworkType { EAdapterType::eUnknown };
|
||||||
EAdapterStatus eNetworkStatus { EAdapterStatus::eUp };
|
EAdapterStatus eNetworkStatus { EAdapterStatus::eUp };
|
||||||
bool dhcp {};
|
bool dhcp {};
|
||||||
|
Loading…
Reference in New Issue
Block a user