Home | History | Annotate | Download | only in shill
      1 //
      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 //
     16 
     17 #include "shill/socket_info.h"
     18 
     19 namespace shill {
     20 
     21 SocketInfo::SocketInfo(ConnectionState connection_state,
     22                        const IPAddress& local_ip_address,
     23                        uint16_t local_port,
     24                        const IPAddress& remote_ip_address,
     25                        uint16_t remote_port,
     26                        uint64_t transmit_queue_value,
     27                        uint64_t receive_queue_value,
     28                        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 
     39 SocketInfo::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 
     50 SocketInfo::SocketInfo(const SocketInfo& socket_info)
     51     : 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 
     61 SocketInfo::~SocketInfo() {}
     62 
     63 SocketInfo& SocketInfo::operator=(const SocketInfo& socket_info) {
     64   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 
     76 bool SocketInfo::IsSameSocketAs(const SocketInfo& socket_info) const {
     77   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
     84