[+] AuNet::ENetworkAdapterType
[+] AuNet::ENetworkAdapterStatus [+] INetAdapter::ToNetworkType() [+] INetAdapter::ToStatus()
This commit is contained in:
parent
507f418b81
commit
cbcd55ce8e
@ -9,6 +9,9 @@
|
|||||||
|
|
||||||
namespace Aurora::IO::Net
|
namespace Aurora::IO::Net
|
||||||
{
|
{
|
||||||
|
AUE_DEFINE_VA(ENetworkAdapterStatus, eUp, eDown);
|
||||||
|
AUE_DEFINE_VA(ENetworkAdapterType, eUnknown, eOther, eIPGRE, eTunnel, eLoopback, eEthernet, eIEEE80211, eMobileNetwork, eTokenRing);
|
||||||
|
|
||||||
struct INetAdapter
|
struct INetAdapter
|
||||||
{
|
{
|
||||||
virtual const AuString &ToName() = 0;
|
virtual const AuString &ToName() = 0;
|
||||||
@ -16,6 +19,9 @@ namespace Aurora::IO::Net
|
|||||||
|
|
||||||
virtual AuUInt16 GetIndex() = 0;
|
virtual AuUInt16 GetIndex() = 0;
|
||||||
|
|
||||||
|
virtual ENetworkAdapterType ToNetworkType() = 0;
|
||||||
|
virtual ENetworkAdapterStatus ToStatus() = 0;
|
||||||
|
|
||||||
virtual EIPProtocol ToFamily() = 0;
|
virtual EIPProtocol ToFamily() = 0;
|
||||||
|
|
||||||
virtual IPAddress ToAddress() = 0;
|
virtual IPAddress ToAddress() = 0;
|
||||||
|
@ -8,10 +8,10 @@
|
|||||||
#include "Networking.hpp"
|
#include "Networking.hpp"
|
||||||
#include "AuNetAdapter.hpp"
|
#include "AuNetAdapter.hpp"
|
||||||
#include "AuNetEndpoint.hpp"
|
#include "AuNetEndpoint.hpp"
|
||||||
|
|
||||||
#include <asm/types.h>
|
#include <asm/types.h>
|
||||||
#include <linux/netlink.h>
|
#include <linux/netlink.h>
|
||||||
#include <linux/rtnetlink.h>
|
#include <linux/rtnetlink.h>
|
||||||
|
#include <linux/if_arp.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
|
||||||
namespace Aurora::IO::Net
|
namespace Aurora::IO::Net
|
||||||
@ -439,6 +439,43 @@ namespace Aurora::IO::Net
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
adapter.eNetworkStatus = ifa->ifi_flags & IFF_RUNNING ?
|
||||||
|
ENetworkAdapterStatus::eUp :
|
||||||
|
ENetworkAdapterStatus::eDown;
|
||||||
|
|
||||||
|
{
|
||||||
|
switch (ifa->ifi_type)
|
||||||
|
{
|
||||||
|
case ARPHRD_ETHER:
|
||||||
|
case ARPHRD_EETHER:
|
||||||
|
adapter.eNetworkType = ENetworkAdapterType::eEthernet;
|
||||||
|
break;
|
||||||
|
case ARPHRD_IEEE802:
|
||||||
|
case ARPHRD_IEEE802_TR:
|
||||||
|
case ARPHRD_IEEE80211:
|
||||||
|
case ARPHRD_IEEE80211_PRISM:
|
||||||
|
case ARPHRD_IEEE80211_RADIOTAP:
|
||||||
|
case ARPHRD_IEEE802154:
|
||||||
|
case ARPHRD_IEEE802154_MONITOR:
|
||||||
|
define
|
||||||
|
adapter.eNetworkType = ENetworkAdapterType::eIEEE80211;
|
||||||
|
break;
|
||||||
|
case ARPHRD_PRONET:
|
||||||
|
adapter.eNetworkType = ENetworkAdapterType::eTokenRing;
|
||||||
|
break;
|
||||||
|
case ARPHRD_LOOPBACK:
|
||||||
|
adapter.eNetworkType = ENetworkAdapterType::eLoopback;
|
||||||
|
break;
|
||||||
|
case ARPHRD_TUNNEL:
|
||||||
|
case ARPHRD_TUNNEL6:
|
||||||
|
adapter.eNetworkType = ENetworkAdapterType::eTunnel;
|
||||||
|
break;
|
||||||
|
case ARPHRD_IPGRE:
|
||||||
|
adapter.eNetworkType = ENetworkAdapterType::eIPGRE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
auto attr = IFLA_RTA(ifa);
|
auto attr = IFLA_RTA(ifa);
|
||||||
auto attrlen = hdr->nlmsg_len - NLMSG_LENGTH(sizeof(*ifa));
|
auto attrlen = hdr->nlmsg_len - NLMSG_LENGTH(sizeof(*ifa));
|
||||||
|
|
||||||
|
@ -178,6 +178,34 @@ namespace Aurora::IO::Net
|
|||||||
adapter.broadcast = ep.ip;
|
adapter.broadcast = ep.ip;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
switch (pCurrAddresses->IfType)
|
||||||
|
{
|
||||||
|
case IF_TYPE_OTHER:
|
||||||
|
adapter.eNetworkType = ENetworkAdapterType::eOther;
|
||||||
|
break;
|
||||||
|
case IF_TYPE_ETHERNET_CSMACD:
|
||||||
|
adapter.eNetworkType = ENetworkAdapterType::eEthernet;
|
||||||
|
break;
|
||||||
|
case IF_TYPE_IEEE80211:
|
||||||
|
adapter.eNetworkType = ENetworkAdapterType::eIEEE80211;
|
||||||
|
break;
|
||||||
|
case IF_TYPE_ISO88025_TOKENRING:
|
||||||
|
adapter.eNetworkType = ENetworkAdapterType::eTokenRing;
|
||||||
|
break;
|
||||||
|
case IF_TYPE_SOFTWARE_LOOPBACK:
|
||||||
|
adapter.eNetworkType = ENetworkAdapterType::eLoopback;
|
||||||
|
break;
|
||||||
|
case IF_TYPE_TUNNEL:
|
||||||
|
adapter.eNetworkType = ENetworkAdapterType::eTunnel;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
adapter.eNetworkStatus = pCurrAddresses->OperStatus == IfOperStatusUp ?
|
||||||
|
ENetworkAdapterStatus::eUp :
|
||||||
|
ENetworkAdapterStatus::eDown;
|
||||||
|
|
||||||
auto pAnycast = pCurrAddresses->FirstAnycastAddress;
|
auto pAnycast = pCurrAddresses->FirstAnycastAddress;
|
||||||
if (pAnycast)
|
if (pAnycast)
|
||||||
{
|
{
|
||||||
|
@ -38,6 +38,16 @@ namespace Aurora::IO::Net
|
|||||||
return this->device;
|
return this->device;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ENetworkAdapterType NetAdapter::ToNetworkType()
|
||||||
|
{
|
||||||
|
return this->eNetworkType;
|
||||||
|
}
|
||||||
|
|
||||||
|
ENetworkAdapterStatus NetAdapter::ToStatus()
|
||||||
|
{
|
||||||
|
return this->eNetworkStatus;
|
||||||
|
}
|
||||||
|
|
||||||
EIPProtocol NetAdapter::ToFamily()
|
EIPProtocol NetAdapter::ToFamily()
|
||||||
{
|
{
|
||||||
return this->address.ip;
|
return this->address.ip;
|
||||||
|
@ -18,6 +18,9 @@ namespace Aurora::IO::Net
|
|||||||
|
|
||||||
EIPProtocol ToFamily() override;
|
EIPProtocol ToFamily() override;
|
||||||
|
|
||||||
|
ENetworkAdapterType ToNetworkType() override;
|
||||||
|
ENetworkAdapterStatus ToStatus() override;
|
||||||
|
|
||||||
IPAddress ToAddress() override;
|
IPAddress ToAddress() override;
|
||||||
IPAddress ToBroadcastAddress() override;
|
IPAddress ToBroadcastAddress() override;
|
||||||
IPAddress ToAnycastAddress() override;
|
IPAddress ToAnycastAddress() override;
|
||||||
@ -46,6 +49,8 @@ namespace Aurora::IO::Net
|
|||||||
IPAddress anycast;
|
IPAddress anycast;
|
||||||
IPAddress subnet;
|
IPAddress subnet;
|
||||||
IPAddress gateway;
|
IPAddress gateway;
|
||||||
|
ENetworkAdapterType eNetworkType { ENetworkAdapterType::eUnknown };
|
||||||
|
ENetworkAdapterStatus eNetworkStatus { ENetworkAdapterStatus::eUp };
|
||||||
bool dhcp {};
|
bool dhcp {};
|
||||||
AuArray<AuUInt8, 8> mac;
|
AuArray<AuUInt8, 8> mac;
|
||||||
AuUInt32 mtu;
|
AuUInt32 mtu;
|
||||||
|
Loading…
Reference in New Issue
Block a user