BAN: Add types for IPv4 and MAC addresses

This commit is contained in:
2024-02-02 13:48:07 +02:00
parent 4b332b5d42
commit 7b287a1d5b
2 changed files with 90 additions and 0 deletions

36
BAN/include/BAN/MAC.h Normal file
View File

@@ -0,0 +1,36 @@
#pragma once
#include <BAN/Formatter.h>
namespace BAN
{
struct MACAddress
{
uint8_t address[6];
};
}
namespace BAN::Formatter
{
template<typename F>
void print_argument(F putc, const MACAddress& mac, const ValueFormat&)
{
ValueFormat format {
.base = 16,
.percision = 0,
.fill = 2,
.upper = true,
};
print_argument(putc, mac.address[0], format);
for (size_t i = 1; i < 6; i++)
{
putc(':');
print_argument(putc, mac.address[i], format);
}
}
}