2022-12-14 20:08:52 +00:00
|
|
|
/***
|
|
|
|
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
|
|
|
|
File: AuNetAdapter.cpp
|
|
|
|
Date: 2022-11-14
|
|
|
|
Author: Reece
|
|
|
|
***/
|
|
|
|
#include "Networking.hpp"
|
|
|
|
#include "AuNetAdapter.hpp"
|
|
|
|
#include "AuNetAdapter.hpp"
|
|
|
|
|
|
|
|
namespace Aurora::IO::Net
|
|
|
|
{
|
2023-12-10 15:42:04 +00:00
|
|
|
const AuString &NetAdapter::GetName()
|
2022-12-14 20:08:52 +00:00
|
|
|
{
|
|
|
|
return this->name.empty() ? this->device : this->name;
|
|
|
|
}
|
|
|
|
|
2023-12-10 15:42:04 +00:00
|
|
|
const AuString &NetAdapter::GetDevice()
|
2022-12-14 20:08:52 +00:00
|
|
|
{
|
|
|
|
return this->device;
|
|
|
|
}
|
|
|
|
|
2024-04-01 05:41:51 +00:00
|
|
|
EAdapterType NetAdapter::GetAdapterType()
|
2023-12-01 12:11:54 +00:00
|
|
|
{
|
|
|
|
return this->eNetworkType;
|
|
|
|
}
|
|
|
|
|
2024-04-01 05:41:51 +00:00
|
|
|
EAdapterStatus NetAdapter::GetAdapterStatus()
|
2023-12-01 12:11:54 +00:00
|
|
|
{
|
|
|
|
return this->eNetworkStatus;
|
|
|
|
}
|
|
|
|
|
2023-12-10 15:42:04 +00:00
|
|
|
EIPProtocol NetAdapter::GetFamily()
|
2022-12-14 20:08:52 +00:00
|
|
|
{
|
2024-04-14 19:11:08 +00:00
|
|
|
return this->address.ValueOr(IPAddress {}).ip;
|
2022-12-14 20:08:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
AuUInt16 NetAdapter::GetIndex()
|
|
|
|
{
|
|
|
|
return this->index;
|
|
|
|
}
|
|
|
|
|
2024-04-14 19:11:08 +00:00
|
|
|
AuOptional<const IPAddress &> NetAdapter::GetAddress()
|
|
|
|
{
|
|
|
|
return this->address ?
|
|
|
|
this->address.Value() :
|
|
|
|
AuOptional<const IPAddress &> {};
|
|
|
|
}
|
|
|
|
|
|
|
|
AuOptional<const IPAddress &> NetAdapter::GetBroadcastAddress()
|
2024-04-01 05:05:30 +00:00
|
|
|
{
|
2024-04-14 19:11:08 +00:00
|
|
|
return this->broadcast ?
|
|
|
|
this->broadcast.Value() :
|
|
|
|
AuOptional<const IPAddress &> {};
|
2024-04-01 05:05:30 +00:00
|
|
|
}
|
|
|
|
|
2024-04-14 19:11:08 +00:00
|
|
|
AuOptional<const IPAddress &> NetAdapter::GetAnycastAddress()
|
2024-04-01 05:05:30 +00:00
|
|
|
{
|
2024-04-14 19:11:08 +00:00
|
|
|
return this->anycast ?
|
|
|
|
this->anycast.Value() :
|
|
|
|
AuOptional<const IPAddress &> {};
|
2024-04-01 05:05:30 +00:00
|
|
|
}
|
|
|
|
|
2024-04-14 19:11:08 +00:00
|
|
|
AuOptional<const IPAddress &> NetAdapter::GetGateway()
|
2022-12-14 20:08:52 +00:00
|
|
|
{
|
2024-04-14 19:11:08 +00:00
|
|
|
return this->gateway ?
|
|
|
|
this->gateway.Value() :
|
|
|
|
AuOptional<const IPAddress &> {};
|
2022-12-14 20:08:52 +00:00
|
|
|
}
|
|
|
|
|
2024-04-14 19:11:08 +00:00
|
|
|
AuOptional<const IPAddress &> NetAdapter::GetSubnetMask()
|
2022-12-14 20:08:52 +00:00
|
|
|
{
|
2024-04-14 19:11:08 +00:00
|
|
|
return this->subnet ?
|
|
|
|
this->subnet.Value() :
|
|
|
|
AuOptional<const IPAddress &> {};
|
2022-12-14 20:08:52 +00:00
|
|
|
}
|
|
|
|
|
2024-04-01 05:44:20 +00:00
|
|
|
const AuList<IPAddress> &NetAdapter::GetDNS()
|
2022-12-14 20:08:52 +00:00
|
|
|
{
|
|
|
|
return this->dns;
|
|
|
|
}
|
2023-10-24 18:12:47 +00:00
|
|
|
|
2023-12-10 15:42:04 +00:00
|
|
|
AuArray<AuUInt8, 8> NetAdapter::GetMacAddress()
|
2023-10-24 18:12:47 +00:00
|
|
|
{
|
|
|
|
return this->mac;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool NetAdapter::HasDHCP()
|
|
|
|
{
|
|
|
|
return this->dhcp;
|
|
|
|
}
|
|
|
|
|
|
|
|
AuUInt32 NetAdapter::GetMTU()
|
|
|
|
{
|
|
|
|
return this->mtu;
|
|
|
|
}
|
2023-12-01 13:22:44 +00:00
|
|
|
|
|
|
|
AuUInt64 NetAdapter::GetTransmitBytesPerSec()
|
|
|
|
{
|
|
|
|
return this->uTransmitBytesPerSec;
|
|
|
|
}
|
|
|
|
|
|
|
|
AuUInt64 NetAdapter::GetReceiveBytesPerSec()
|
|
|
|
{
|
|
|
|
return this->uReceiveBytesPerSec;
|
|
|
|
}
|
2022-12-14 20:08:52 +00:00
|
|
|
}
|