summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
Diffstat (limited to 'src/net')
-rw-r--r--src/net/ip.cpp27
-rw-r--r--src/net/ip.hpp4
2 files changed, 30 insertions, 1 deletions
diff --git a/src/net/ip.cpp b/src/net/ip.cpp
index 3dc242d..bedbca8 100644
--- a/src/net/ip.cpp
+++ b/src/net/ip.cpp
@@ -105,6 +105,33 @@ bool impl_extract(XString str, IP4Mask *rv)
return true;
}
+bool impl_extract(XString str, std::vector<IP4Mask> *iv)
+{
+ if (str == "all"_s)
+ {
+ iv->clear();
+ iv->push_back(IP4Mask());
+ return true;
+ }
+ if (str == "clear"_s)
+ {
+ iv->clear();
+ return true;
+ }
+ // don't add if already 'all'
+ if (iv->size() == 1 && iv->front().mask() == IP4Address())
+ {
+ return true;
+ }
+ IP4Mask mask;
+ if (extract(str, &mask))
+ {
+ iv->push_back(mask);
+ return true;
+ }
+ return false;
+}
+
VString<15> convert_for_printf(IP4Address a_)
{
const uint8_t *a = a_.bytes();
diff --git a/src/net/ip.hpp b/src/net/ip.hpp
index 82d9430..7508c08 100644
--- a/src/net/ip.hpp
+++ b/src/net/ip.hpp
@@ -25,6 +25,8 @@
#include <cstddef>
#include <cstdint>
+#include <vector>
+
namespace tmwa
{
@@ -159,6 +161,6 @@ VString<15> convert_for_printf(IP4Address a);
VString<31> convert_for_printf(IP4Mask m);
bool impl_extract(XString str, IP4Address *iv);
-
bool impl_extract(XString str, IP4Mask *iv);
+bool impl_extract(XString str, std::vector<IP4Mask> *iv);
} // namespace tmwa