support 2nd RCPT TO and PRDR
[ghsmtp.git] / IP6.hpp
blob4a852d190da930eb0f90c9d3b3c56e5731974880
1 #ifndef IP6_DOT_HPP
2 #define IP6_DOT_HPP
4 #include <string>
5 #include <string_view>
7 namespace IP6 {
8 auto is_private(std::string_view addr) -> bool;
9 auto is_address(std::string_view addr) -> bool;
10 auto is_address_literal(std::string_view addr) -> bool;
11 auto to_address_literal(std::string_view addr) -> std::string;
12 auto reverse(std::string_view addr) -> std::string;
14 constexpr char lit_pfx[] = "[IPv6:";
15 constexpr auto lit_pfx_sz{sizeof(lit_pfx) - 1};
17 constexpr char lit_sfx[] = "]";
18 constexpr auto lit_sfx_sz{sizeof(lit_sfx) - 1};
20 constexpr auto lit_extra_sz{lit_pfx_sz + lit_sfx_sz};
22 constexpr auto loopback_literal{"[IPv6:::1]"};
24 constexpr auto as_address(std::string_view address_literal) -> std::string_view
26 // CHECK(is_address_literal(address_literal));
27 return std::string_view(begin(address_literal) + lit_pfx_sz,
28 size(address_literal) - lit_extra_sz);
31 } // namespace IP6
33 #endif // IP4_DOT_HPP