Introduction
AnCH device library provides information about the machine: network interfaces and CPU features.
Prerequisites
anch-uuid: MAC address UUID provider.
Installation
CMake target anch::device:
find_package(Anch REQUIRED)
target_link_libraries(my-app PRIVATE anch::device)
See installation.
Usage
- Network lists network interfaces (
getifaddrs : IPv4, IPv6, MAC address, MTU, ...). Interfaces are loaded once ; reload refreshes them.
- CPU detects CPU features at runtime (
CPUID instruction on x86: AES-NI, MMX, SSE, ...). anch-crypto uses it to select AES-NI.
anch::device::registerMACAddressUUIDProvider registers MAC address based UUID providers in anch-uuid.
Example
#include "device/cpu.hpp"
#include "device/network.hpp"
#include <iostream>
int
main() {
std::cout << name << " " << interface.getIpAddress() << " " << interface.getMacAddress()
<< (interface.isUp() ? " up" : " down") << std::endl;
}
std::cout <<
"AES-NI: " << cpu.
isAES() << std::endl;
return 0;
}