summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
authorBen Longbons <b.r.longbons@gmail.com>2015-01-08 14:36:40 -0800
committerBen Longbons <b.r.longbons@gmail.com>2015-01-23 01:44:26 -0800
commit35b95e24ea1915acf0ef13047209f76bce6d9b7b (patch)
tree650cc854b324b0b6f3e269075a394914d0834b26 /src/net
parentfc07b1e9c72e795e18f9d212e7a72bdb31904c5b (diff)
downloadtmwa-35b95e24ea1915acf0ef13047209f76bce6d9b7b.tar.gz
tmwa-35b95e24ea1915acf0ef13047209f76bce6d9b7b.tar.bz2
tmwa-35b95e24ea1915acf0ef13047209f76bce6d9b7b.tar.xz
tmwa-35b95e24ea1915acf0ef13047209f76bce6d9b7b.zip
Use generated config for login
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