1 // Copyright 2016 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef NET_BASE_SOCKADDR_STORAGE_H_ 6 #define NET_BASE_SOCKADDR_STORAGE_H_ 7 8 #include "base/memory/raw_ptr_exclusion.h" 9 #include "build/build_config.h" 10 11 #if BUILDFLAG(IS_WIN) 12 #include <winsock2.h> 13 #include <ws2tcpip.h> 14 #elif BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA) 15 #include <sys/socket.h> 16 #include <sys/types.h> 17 #endif 18 19 #include "net/base/net_export.h" 20 21 namespace net { 22 23 // Convenience struct for when you need a |struct sockaddr|. 24 struct NET_EXPORT SockaddrStorage { 25 SockaddrStorage(); 26 SockaddrStorage(const SockaddrStorage& other); 27 void operator=(const SockaddrStorage& other); 28 29 struct sockaddr_storage addr_storage; 30 socklen_t addr_len; 31 // This field is not a raw_ptr<> because of a rewriter issue not adding .get() 32 // in reinterpret_cast. 33 RAW_PTR_EXCLUSION struct sockaddr* const addr; 34 }; 35 36 } // namespace net 37 38 #endif // NET_BASE_SOCKADDR_STORAGE_H_ 39