6 #include <glog/logging.h>
9 bool is_private(std::string_view addr
)
11 if (IP4::is_address(addr
))
12 return IP4::is_private(addr
);
13 else if (IP6::is_address(addr
))
14 return IP6::is_private(addr
);
18 bool is_address(std::string_view addr
)
20 return IP4::is_address(addr
) || IP6::is_address(addr
);
23 bool is_address_literal(std::string_view addr
)
25 return IP4::is_address_literal(addr
) || IP6::is_address_literal(addr
);
28 std::string
to_address_literal(std::string_view addr
)
30 if (IP4::is_address(addr
))
31 return IP4::to_address_literal(addr
);
32 if (IP6::is_address(addr
))
33 return IP6::to_address_literal(addr
);
34 LOG(FATAL
) << "not a valid IP address " << addr
;
37 std::string_view
as_address(std::string_view addr
)
39 if (IP4::is_address_literal(addr
))
40 return IP4::as_address(addr
);
41 if (IP6::is_address_literal(addr
))
42 return IP6::as_address(addr
);
43 LOG(FATAL
) << "not a valid IP address literal " << addr
;
46 std::string
reverse(std::string_view addr
)
48 if (IP4::is_address(addr
))
49 return IP4::reverse(addr
);
50 if (IP6::is_address(addr
))
51 return IP6::reverse(addr
);
52 LOG(FATAL
) << "not a valid IP address " << addr
;