summaryrefslogtreecommitdiffstats
path: root/comm/third_party/botan/src/lib/utils/socket/uri.h
diff options
context:
space:
mode:
Diffstat (limited to 'comm/third_party/botan/src/lib/utils/socket/uri.h')
-rw-r--r--comm/third_party/botan/src/lib/utils/socket/uri.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/comm/third_party/botan/src/lib/utils/socket/uri.h b/comm/third_party/botan/src/lib/utils/socket/uri.h
new file mode 100644
index 0000000000..346f9f4f63
--- /dev/null
+++ b/comm/third_party/botan/src/lib/utils/socket/uri.h
@@ -0,0 +1,49 @@
+/*
+* (C) 2019 Nuno Goncalves <nunojpg@gmail.com>
+*
+* Botan is released under the Simplified BSD License (see license.txt)
+*/
+
+#ifndef BOTAN_URI_H_
+#define BOTAN_URI_H_
+
+#include <cstdint>
+#include <string>
+
+#include <botan/build.h>
+
+namespace Botan {
+
+struct BOTAN_TEST_API URI
+ {
+ enum class Type : uint8_t
+ {
+ NotSet,
+ IPv4,
+ IPv6,
+ Domain,
+ };
+ static URI fromAny(const std::string& uri);
+ static URI fromIPv4(const std::string& uri);
+ static URI fromIPv6(const std::string& uri);
+ static URI fromDomain(const std::string& uri);
+ URI() = default;
+ URI(Type xtype, const std::string& xhost, unsigned short xport)
+ : type { xtype }
+ , host { xhost }
+ , port { xport }
+ {}
+ bool operator==(const URI& a) const
+ {
+ return type == a.type && host == a.host && port == a.port;
+ }
+ std::string to_string() const;
+
+ const Type type{Type::NotSet};
+ const std::string host{};
+ const uint16_t port{};
+ };
+
+}
+
+#endif