AnCH Framework 0.2
Another C++ Hack: C++23 utility libraries
Loading...
Searching...
No Matches
AnCH device library documentation

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() {
for(const auto& [name, interface] : anch::device::Network::getInterfaces()) {
std::cout << name << " " << interface.getIpAddress() << " " << interface.getMacAddress()
<< (interface.isUp() ? " up" : " down") << std::endl;
}
std::cout << "AES-NI: " << cpu.isAES() << std::endl;
return 0;
}