aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/utils/socket/uri.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/utils/socket/uri.h')
-rw-r--r--src/lib/utils/socket/uri.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/lib/utils/socket/uri.h b/src/lib/utils/socket/uri.h
new file mode 100644
index 000000000..a9f68ac41
--- /dev/null
+++ b/src/lib/utils/socket/uri.h
@@ -0,0 +1,49 @@
+/*
+* (C) 2019 Nuno Goncalves <[email protected]>
+*
+* 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 type, const std::string& host, unsigned short port)
+ : type { type }
+ , host { host }
+ , port { port }
+ {}
+ 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