aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/ipmath/ipmath.h
diff options
context:
space:
mode:
authorAlexSm <alex@ydb.tech>2023-12-27 23:31:58 +0100
committerGitHub <noreply@github.com>2023-12-27 23:31:58 +0100
commitd67bfb4b4b7549081543e87a31bc6cb5c46ac973 (patch)
tree8674f2f1570877cb653e7ddcff37ba00288de15a /library/cpp/ipmath/ipmath.h
parent1f6bef05ed441c3aa2d565ac792b26cded704ac7 (diff)
downloadydb-d67bfb4b4b7549081543e87a31bc6cb5c46ac973.tar.gz
Import libs 4 (#758)
Diffstat (limited to 'library/cpp/ipmath/ipmath.h')
-rw-r--r--library/cpp/ipmath/ipmath.h16
1 files changed, 15 insertions, 1 deletions
diff --git a/library/cpp/ipmath/ipmath.h b/library/cpp/ipmath/ipmath.h
index f1c15e341e..8c24bd471c 100644
--- a/library/cpp/ipmath/ipmath.h
+++ b/library/cpp/ipmath/ipmath.h
@@ -26,7 +26,7 @@ public:
static TIpAddressRangeBuilder From(const TStringBuf from);
/**
- * Parses a string tormatted in Classless Iter-Domain Routing (CIDR) notation.
+ * Parses a string formatted in Classless Inter-Domain Routing (CIDR) notation.
* @param str a CIDR-formatted string, e.g. "192.168.0.0/16"
* @return a new TIpAddressRange
* @throws TInvalidIpRangeException if the string cannot be parsed.
@@ -35,6 +35,15 @@ public:
static TMaybe<TIpAddressRange> TryFromCidrString(const TStringBuf str);
/**
+ * Parses a string formatted in compact Classless Inter-Domain Routing (CIDR) notation with node address.
+ * @param str a CIDR-formatted string with node address, e.g. "192.168.1.24/16"
+ * @return a new TIpAddressRange
+ * @throws TInvalidIpRangeException if the string cannot be parsed.
+ */
+ static TIpAddressRange FromCompactString(const TStringBuf str);
+ static TMaybe<TIpAddressRange> TryFromCompactString(const TStringBuf str);
+
+ /**
* Parses a string formatted as two dash-separated addresses.
* @param str a CIDR-formatted string, e.g. "192.168.0.0-192.168.0.2"
* @return a new TIpAddressRange
@@ -99,6 +108,8 @@ public:
private:
void Init(TIpv6Address, TIpv6Address);
+ static TMaybe<TIpAddressRange> TryFromCidrStringImpl(const TStringBuf str, bool compact);
+
TIpv6Address Start_;
TIpv6Address End_;
};
@@ -129,8 +140,11 @@ public:
TIpAddressRangeBuilder& To(TIpv6Address);
TIpAddressRangeBuilder& WithPrefix(ui8 len);
+ TIpAddressRangeBuilder& WithMaskedPrefix(ui8 len);
private:
+ TIpAddressRangeBuilder& WithPrefixImpl(ui8 len, bool checkLowerBound);
+
TIpv6Address Start_;
TIpv6Address End_;
};