test allow
[ghsmtp.git] / IP4.hpp
blobf9f5f8cab02a6948fa598d03905c011e23223a65
1 #ifndef IP4_DOT_HPP
2 #define IP4_DOT_HPP
4 #include <string>
5 #include <string_view>
6 #include <vector>
8 namespace IP4 {
9 auto is_private(std::string_view addr) -> bool;
10 auto is_address(std::string_view addr) -> bool;
11 auto is_address_literal(std::string_view addr) -> bool;
12 auto to_address_literal(std::string_view addr) -> std::string;
13 auto reverse(std::string_view addr) -> std::string;
14 auto fcrdns(std::string_view addr) -> std::vector<std::string>;
16 constexpr char lit_pfx[] = "[";
17 constexpr auto lit_pfx_sz{sizeof(lit_pfx) - 1};
19 constexpr char lit_sfx[] = "]";
20 constexpr auto lit_sfx_sz{sizeof(lit_sfx) - 1};
22 constexpr auto lit_extra_sz{lit_pfx_sz + lit_sfx_sz};
24 constexpr auto loopback_literal{"[127.0.0.1]"};
26 constexpr auto as_address(std::string_view address_literal) -> std::string_view
28 // CHECK(is_address_literal(address_literal));
29 return std::string_view(begin(address_literal) + lit_pfx_sz,
30 size(address_literal) - lit_extra_sz);
33 } // namespace IP4
35 #endif // IP4_DOT_HPP