1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "net/base/sockaddr_storage.h"
6 
7 #include <string.h>
8 
9 namespace net {
10 
SockaddrStorage()11 SockaddrStorage::SockaddrStorage()
12     : addr_len(sizeof(addr_storage)),
13       addr(reinterpret_cast<struct sockaddr*>(&addr_storage)) {}
14 
SockaddrStorage(const SockaddrStorage & other)15 SockaddrStorage::SockaddrStorage(const SockaddrStorage& other)
16     : addr_len(other.addr_len),
17       addr(reinterpret_cast<struct sockaddr*>(&addr_storage)) {
18   memcpy(addr, other.addr, addr_len);
19 }
20 
operator =(const SockaddrStorage & other)21 void SockaddrStorage::operator=(const SockaddrStorage& other) {
22   addr_len = other.addr_len;
23   // addr is already set to &this->addr_storage by default ctor.
24   memcpy(addr, other.addr, addr_len);
25 }
26 
27 }  // namespace net
28