Public Access
The plan and decisions Q105 to Q116 (docs/milestones/S1.md). lib/net: strict IPv4 parsing, prefix and mask, and the checks a Fixed setting must pass, each refusal with its reason. A Saved Network is Automatic or Fixed (address/prefix and an optional gateway), kept with it in flash. Settings: two DNS servers (9.9.9.9, 1.1.1.1), "Always use my DNS", two NTP servers (pool.ntp.org, time.cloudflare.com). Host-tested: 383 tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EhqxQ49eCju4CzKYNjZzwT
31 lines
989 B
C++
31 lines
989 B
C++
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <string>
|
|
|
|
namespace roro::net {
|
|
|
|
// IPv4 addresses as 32-bit numbers, most significant byte first: 10.39.39.12 is 0x0A27270C.
|
|
bool parseIpv4(const std::string& text, uint32_t& out); // strict: four decimal numbers, 0 to 255
|
|
std::string formatIpv4(uint32_t address);
|
|
uint32_t maskOf(int prefix); // 24 -> 255.255.255.0
|
|
|
|
// A Saved Network's Fixed setting (S1, Q105 to Q107). gateway 0: none.
|
|
struct FixedIp {
|
|
uint32_t address = 0;
|
|
uint8_t prefix = 24;
|
|
uint32_t gateway = 0;
|
|
};
|
|
|
|
// "" when a device can use it, otherwise why not, for a human (Q111).
|
|
std::string checkFixed(const FixedIp& f);
|
|
|
|
// "address/prefix [gateway]", as typed on the console and kept in flash. parseFixed() also checks.
|
|
std::string parseFixed(const std::string& text, FixedIp& out);
|
|
std::string formatFixed(const FixedIp& f);
|
|
|
|
// An IPv4 address or a host name, as an NTP server may be (Q110).
|
|
bool validHost(const std::string& text);
|
|
|
|
} // namespace roro::net
|