1/* @ajax/mesh-abi-host-nics: NIC records (NI_*) and the virtual interfaces left out of the total.
2 *
3 * Part of alpha-c-mesh, a C port of alpha-rust-mesh (README.md says from where). */
4#ifndef MESH_ABI_HOST_NICS_H
5#define MESH_ABI_HOST_NICS_H
67#include <stdbool.h>
8#include <stddef.h>
9#include <stdint.h>
10#include "mesh/abi/fields.h"
1112/* NIC records (S_NICS, S_NET_TOTAL). */
13#define MESH_S_NICS 0xb00
14#define MESH_NIC_BYTES 0x60
15#define MESH_MAX_NICS 8
16#define MESH_NI_NAME 0x00 /* 16 bytes NUL padded */
17#define MESH_NI_RX_BYTES 0x10 /* u64 each, cumulative (the OS's counters, extended past wraps and resets) */
18#define MESH_NI_TX_BYTES 0x18
19#define MESH_NI_RX_PACKETS 0x20
20#define MESH_NI_TX_PACKETS 0x28
21#define MESH_NI_RX_ERRS 0x30
22#define MESH_NI_TX_ERRS 0x38
23#define MESH_NI_RX_DROP 0x40
24#define MESH_NI_TX_DROP 0x48
25#define MESH_NI_LINKS 0x50 /* u32 bit k: the link to system k is on it */
26#define MESH_NI_COUNT 0x54 /* u32 interfaces summed (1; the total: how many) */
27/* Interface name prefixes left out of the total: loopback, container and VM
28 * bridges and veths, overlays and tunnels. */
29#define MESH_NET_VIRTUAL_LEN 16
30extern const char *const MESH_NET_VIRTUAL[16];
31#define MESH_NIC_FIELDS_LEN 11
32extern const mesh_field MESH_NIC_FIELDS[11];
3334/* NIC record i. */
35static inline size_t mesh_nic(size_t i) { return MESH_S_NICS + MESH_NIC_BYTES * i; }
36/* Whether an interface name (len bytes, not NUL terminated) starts with one of NET_VIRTUAL's prefixes. */
37bool mesh_nic_virtual(const uint8_t *name, size_t len);
3839/* The Rust const asserts that only involve this package. */
40_Static_assert((MESH_S_NICS % 8 == 0), "S_NICS.is_multiple_of(8)");
41_Static_assert((MESH_NIC_BYTES % 8 == 0), "NIC_BYTES.is_multiple_of(8)");
4243#endif