diff options
Diffstat (limited to 'src/net/ip.cpp')
-rw-r--r-- | src/net/ip.cpp | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/src/net/ip.cpp b/src/net/ip.cpp index bfc2028..bedbca8 100644 --- a/src/net/ip.cpp +++ b/src/net/ip.cpp @@ -22,15 +22,14 @@ #include "../strings/vstring.hpp" #include "../io/cxxstdio.hpp" - -#include "../mmo/extract.hpp" +#include "../io/extract.hpp" #include "../poison.hpp" namespace tmwa { -bool extract(XString str, IP4Address *rv) +bool impl_extract(XString str, IP4Address *rv) { if (str.endswith('.')) return false; @@ -43,7 +42,7 @@ bool extract(XString str, IP4Address *rv) return false; } -bool extract(XString str, IP4Mask *rv) +bool impl_extract(XString str, IP4Mask *rv) { IP4Address a, m; unsigned b; @@ -106,6 +105,33 @@ bool 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(); |