From 35b95e24ea1915acf0ef13047209f76bce6d9b7b Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Thu, 8 Jan 2015 14:36:40 -0800 Subject: Use generated config for login --- src/net/ip.cpp | 27 +++++++++++++++++++++++++++ src/net/ip.hpp | 4 +++- 2 files changed, 30 insertions(+), 1 deletion(-) (limited to 'src/net') 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 *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 #include +#include + 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 *iv); } // namespace tmwa -- cgit v1.2.3-70-g09d2