[+] INetAdapter::ToMacAddress
[+] INetAdapter::HasDHCP [+] INetAdapter::GetMTU
This commit is contained in:
parent
9092f9268c
commit
ec8f3b3f23
@ -24,6 +24,12 @@ namespace Aurora::IO::Net
|
||||
virtual IPAddress ToSubnetMask() = 0;
|
||||
virtual IPAddress ToGateway() = 0;
|
||||
|
||||
virtual AuArray<AuUInt8, 8> ToMacAddress() = 0;
|
||||
|
||||
virtual bool HasDHCP() = 0;
|
||||
|
||||
virtual AuUInt32 GetMTU() = 0;
|
||||
|
||||
virtual AuList<IPAddress> GetDNS() = 0;
|
||||
};
|
||||
};
|
@ -446,14 +446,23 @@ namespace Aurora::IO::Net
|
||||
|
||||
size_t dstlen = RTA_PAYLOAD(attr);
|
||||
|
||||
const size_t addrlen = (family == AF_INET) ? sizeof(struct in_addr) : sizeof(struct in6_addr);
|
||||
|
||||
if (attr->rta_type == IFLA_IFNAME)
|
||||
{
|
||||
adapter.device = (const char *)RTA_DATA(attr);
|
||||
}
|
||||
|
||||
// TODO: we can pull MTU and other stats from here.
|
||||
if (attr->rta_type == IFLA_MTU)
|
||||
{
|
||||
adapter.mtu = *(unsigned int *)RTA_DATA(attr);
|
||||
}
|
||||
|
||||
if (attr->rta_type == IFLA_ADDRESS)
|
||||
{
|
||||
if (dstlen <= adapter.mac.size())
|
||||
{
|
||||
AuMemcpy(adapter.mac.begin(), (const char *)RTA_DATA(attr), dstlen);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -148,6 +148,10 @@ namespace Aurora::IO::Net
|
||||
adapter.device = pCurrAddresses->AdapterName;
|
||||
adapter.name = AuLocale::ConvertFromWChar(pCurrAddresses->FriendlyName);
|
||||
|
||||
AuMemcpy(adapter.mac.begin(), pCurrAddresses->PhysicalAddress, pCurrAddresses->PhysicalAddressLength);
|
||||
|
||||
adapter.mtu = pCurrAddresses->Mtu;
|
||||
|
||||
auto pUnicast = pCurrAddresses->FirstUnicastAddress;
|
||||
if (pUnicast)
|
||||
{
|
||||
@ -201,6 +205,8 @@ namespace Aurora::IO::Net
|
||||
|
||||
adapter.gateway = ep.ip;
|
||||
}
|
||||
|
||||
adapter.dhcp = pCurrAddresses->Dhcpv4Enabled;
|
||||
}
|
||||
|
||||
if (adapter.address.ip == EIPProtocol::eIPProtocolV4)
|
||||
@ -269,6 +275,9 @@ namespace Aurora::IO::Net
|
||||
for (auto &pAdapter : gIpv4Adapters)
|
||||
{
|
||||
auto pAdapterEx = AuStaticCast<NetAdapter>(pAdapter);
|
||||
|
||||
pAdapterEx->dhcp = pIPAddrTable->DhcpEnabled;
|
||||
|
||||
if (pAdapterEx->device == AuString(pIPAddrTable->AdapterName))
|
||||
{
|
||||
pAdapterEx->gateway = IPAddress(pIPAddrTable->GatewayList.IpAddress.String);
|
||||
|
@ -60,4 +60,19 @@ namespace Aurora::IO::Net
|
||||
{
|
||||
return this->dns;
|
||||
}
|
||||
|
||||
AuArray<AuUInt8, 8> NetAdapter::ToMacAddress()
|
||||
{
|
||||
return this->mac;
|
||||
}
|
||||
|
||||
bool NetAdapter::HasDHCP()
|
||||
{
|
||||
return this->dhcp;
|
||||
}
|
||||
|
||||
AuUInt32 NetAdapter::GetMTU()
|
||||
{
|
||||
return this->mtu;
|
||||
}
|
||||
}
|
@ -26,6 +26,12 @@ namespace Aurora::IO::Net
|
||||
|
||||
AuList<IPAddress> GetDNS() override;
|
||||
|
||||
AuArray<AuUInt8, 8> ToMacAddress() override;
|
||||
|
||||
bool HasDHCP() override;
|
||||
|
||||
AuUInt32 GetMTU() override;
|
||||
|
||||
// FriendlyName
|
||||
|
||||
static AuString GetHostname();
|
||||
@ -40,6 +46,9 @@ namespace Aurora::IO::Net
|
||||
IPAddress anycast;
|
||||
IPAddress subnet;
|
||||
IPAddress gateway;
|
||||
bool dhcp {};
|
||||
AuArray<AuUInt8, 8> mac;
|
||||
AuUInt32 mtu;
|
||||
AuList<IPAddress> dns;
|
||||
|
||||
AuUInt16 index {};
|
||||
|
Loading…
Reference in New Issue
Block a user