diff options
Diffstat (limited to 'src/net/IPv6Address.hxx')
-rw-r--r-- | src/net/IPv6Address.hxx | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/net/IPv6Address.hxx b/src/net/IPv6Address.hxx index 52606024f..3ef6f7319 100644 --- a/src/net/IPv6Address.hxx +++ b/src/net/IPv6Address.hxx @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 Max Kellermann <max.kellermann@gmail.com> + * Copyright 2012-2020 Max Kellermann <max.kellermann@gmail.com> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -127,6 +127,15 @@ public: } /** + * Cast a #sockaddr_in6 reference to an IPv6Address reference. + */ + static constexpr const IPv6Address &Cast(const struct sockaddr_in6 &src) noexcept { + /* this reinterpret_cast works because this class is + just a wrapper for struct sockaddr_in6 */ + return *(const IPv6Address *)(const void *)&src; + } + + /** * Return a downcasted reference to the address. This call is * only legal after verifying SocketAddress::GetFamily(). */ |