net/addr/subnet: Add class for representing a network subnet
This makes it possible to represent and IPv4/IPv6 CIDR network segment
via a class. Provides useful functions to compute base address and
determine if addresses are inside the subnet.
Change-Id: Ib9d01e28b6c8a28ccb622fef87b217fc96daf905
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/src/net/addr/subnet.cpp b/src/net/addr/subnet.cpp
new file mode 100644
index 0000000..36d6049
--- /dev/null
+++ b/src/net/addr/subnet.cpp
@@ -0,0 +1,18 @@
+#include <fmt/format.h>
+
+#include <stdplus/net/addr/subnet.hpp>
+
+#include <stdexcept>
+
+namespace stdplus::detail
+{
+
+void invalidSubnetPfx(std::size_t pfx)
+{
+ throw std::invalid_argument(fmt::format("Invalid subnet prefix {}", pfx));
+}
+
+template class Subnet46<In4Addr, uint8_t>;
+template class Subnet46<In6Addr, uint8_t>;
+
+} // namespace stdplus::detail