blob: 477fd42c0cdb79261f858cf66c1e263b4cf008f4 [file] [log] [blame]
Peter Qiuc0beca52015-09-03 11:25:46 -07001//
2// Copyright (C) 2013 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
Ben Chan086d9802013-04-02 16:39:48 -070016
17#include "shill/socket_info.h"
18
19namespace shill {
20
21SocketInfo::SocketInfo(ConnectionState connection_state,
Paul Stewart1a212a62015-06-16 13:13:10 -070022 const IPAddress& local_ip_address,
Ben Chan7fab8972014-08-10 17:14:46 -070023 uint16_t local_port,
Paul Stewart1a212a62015-06-16 13:13:10 -070024 const IPAddress& remote_ip_address,
Ben Chan7fab8972014-08-10 17:14:46 -070025 uint16_t remote_port,
26 uint64_t transmit_queue_value,
27 uint64_t receive_queue_value,
Ben Chan086d9802013-04-02 16:39:48 -070028 TimerState timer_state)
29 : connection_state_(connection_state),
30 local_ip_address_(local_ip_address),
31 local_port_(local_port),
32 remote_ip_address_(remote_ip_address),
33 remote_port_(remote_port),
34 transmit_queue_value_(transmit_queue_value),
35 receive_queue_value_(receive_queue_value),
36 timer_state_(timer_state) {
37}
38
39SocketInfo::SocketInfo()
40 : connection_state_(kConnectionStateUnknown),
41 local_ip_address_(IPAddress::kFamilyUnknown),
42 local_port_(0),
43 remote_ip_address_(IPAddress::kFamilyUnknown),
44 remote_port_(0),
45 transmit_queue_value_(0),
46 receive_queue_value_(0),
47 timer_state_(kTimerStateUnknown) {
48}
49
Paul Stewart1a212a62015-06-16 13:13:10 -070050SocketInfo::SocketInfo(const SocketInfo& socket_info)
Ben Chan086d9802013-04-02 16:39:48 -070051 : connection_state_(socket_info.connection_state_),
52 local_ip_address_(socket_info.local_ip_address_),
53 local_port_(socket_info.local_port_),
54 remote_ip_address_(socket_info.remote_ip_address_),
55 remote_port_(socket_info.remote_port_),
56 transmit_queue_value_(socket_info.transmit_queue_value_),
57 receive_queue_value_(socket_info.receive_queue_value_),
58 timer_state_(socket_info.timer_state_) {
59}
60
61SocketInfo::~SocketInfo() {}
62
Paul Stewart1a212a62015-06-16 13:13:10 -070063SocketInfo& SocketInfo::operator=(const SocketInfo& socket_info) {
Ben Chan086d9802013-04-02 16:39:48 -070064 connection_state_ = socket_info.connection_state_;
65 local_ip_address_ = socket_info.local_ip_address_;
66 local_port_ = socket_info.local_port_;
67 remote_ip_address_ = socket_info.remote_ip_address_;
68 remote_port_ = socket_info.remote_port_;
69 transmit_queue_value_ = socket_info.transmit_queue_value_;
70 receive_queue_value_ = socket_info.receive_queue_value_;
71 timer_state_ = socket_info.timer_state_;
72
73 return *this;
74}
75
Paul Stewart1a212a62015-06-16 13:13:10 -070076bool SocketInfo::IsSameSocketAs(const SocketInfo& socket_info) const {
Ben Chan086d9802013-04-02 16:39:48 -070077 return (local_ip_address_.Equals(socket_info.local_ip_address_) &&
78 local_port_ == socket_info.local_port_ &&
79 remote_ip_address_.Equals(socket_info.remote_ip_address_) &&
80 remote_port_ == socket_info.remote_port_);
81}
82
83} // namespace shill