Ben Chan | 086d980 | 2013-04-02 16:39:48 -0700 | [diff] [blame] | 1 | // Copyright (c) 2013 The Chromium OS 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 "shill/socket_info.h" |
| 6 | |
| 7 | namespace shill { |
| 8 | |
| 9 | SocketInfo::SocketInfo(ConnectionState connection_state, |
| 10 | const IPAddress &local_ip_address, |
| 11 | uint16 local_port, |
| 12 | const IPAddress &remote_ip_address, |
| 13 | uint16 remote_port, |
| 14 | uint64 transmit_queue_value, |
| 15 | uint64 receive_queue_value, |
| 16 | TimerState timer_state) |
| 17 | : connection_state_(connection_state), |
| 18 | local_ip_address_(local_ip_address), |
| 19 | local_port_(local_port), |
| 20 | remote_ip_address_(remote_ip_address), |
| 21 | remote_port_(remote_port), |
| 22 | transmit_queue_value_(transmit_queue_value), |
| 23 | receive_queue_value_(receive_queue_value), |
| 24 | timer_state_(timer_state) { |
| 25 | } |
| 26 | |
| 27 | SocketInfo::SocketInfo() |
| 28 | : connection_state_(kConnectionStateUnknown), |
| 29 | local_ip_address_(IPAddress::kFamilyUnknown), |
| 30 | local_port_(0), |
| 31 | remote_ip_address_(IPAddress::kFamilyUnknown), |
| 32 | remote_port_(0), |
| 33 | transmit_queue_value_(0), |
| 34 | receive_queue_value_(0), |
| 35 | timer_state_(kTimerStateUnknown) { |
| 36 | } |
| 37 | |
| 38 | SocketInfo::SocketInfo(const SocketInfo &socket_info) |
| 39 | : connection_state_(socket_info.connection_state_), |
| 40 | local_ip_address_(socket_info.local_ip_address_), |
| 41 | local_port_(socket_info.local_port_), |
| 42 | remote_ip_address_(socket_info.remote_ip_address_), |
| 43 | remote_port_(socket_info.remote_port_), |
| 44 | transmit_queue_value_(socket_info.transmit_queue_value_), |
| 45 | receive_queue_value_(socket_info.receive_queue_value_), |
| 46 | timer_state_(socket_info.timer_state_) { |
| 47 | } |
| 48 | |
| 49 | SocketInfo::~SocketInfo() {} |
| 50 | |
| 51 | SocketInfo &SocketInfo::operator=(const SocketInfo &socket_info) { |
| 52 | connection_state_ = socket_info.connection_state_; |
| 53 | local_ip_address_ = socket_info.local_ip_address_; |
| 54 | local_port_ = socket_info.local_port_; |
| 55 | remote_ip_address_ = socket_info.remote_ip_address_; |
| 56 | remote_port_ = socket_info.remote_port_; |
| 57 | transmit_queue_value_ = socket_info.transmit_queue_value_; |
| 58 | receive_queue_value_ = socket_info.receive_queue_value_; |
| 59 | timer_state_ = socket_info.timer_state_; |
| 60 | |
| 61 | return *this; |
| 62 | } |
| 63 | |
| 64 | bool SocketInfo::IsSameSocketAs(const SocketInfo &socket_info) const { |
| 65 | return (local_ip_address_.Equals(socket_info.local_ip_address_) && |
| 66 | local_port_ == socket_info.local_port_ && |
| 67 | remote_ip_address_.Equals(socket_info.remote_ip_address_) && |
| 68 | remote_port_ == socket_info.remote_port_); |
| 69 | } |
| 70 | |
| 71 | } // namespace shill |