• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/connection_info.h"
18 
19 #include <netinet/in.h>
20 
21 namespace shill {
22 
ConnectionInfo()23 ConnectionInfo::ConnectionInfo()
24     : protocol_(IPPROTO_MAX),
25       time_to_expire_seconds_(0),
26       is_unreplied_(false),
27       original_source_ip_address_(IPAddress::kFamilyUnknown),
28       original_source_port_(0),
29       original_destination_ip_address_(IPAddress::kFamilyUnknown),
30       original_destination_port_(0),
31       reply_source_ip_address_(IPAddress::kFamilyUnknown),
32       reply_source_port_(0),
33       reply_destination_ip_address_(IPAddress::kFamilyUnknown),
34       reply_destination_port_(0) {
35 }
36 
ConnectionInfo(int protocol,int64_t time_to_expire_seconds,bool is_unreplied,IPAddress original_source_ip_address,uint16_t original_source_port,IPAddress original_destination_ip_address,uint16_t original_destination_port,IPAddress reply_source_ip_address,uint16_t reply_source_port,IPAddress reply_destination_ip_address,uint16_t reply_destination_port)37 ConnectionInfo::ConnectionInfo(int protocol,
38                                int64_t time_to_expire_seconds,
39                                bool is_unreplied,
40                                IPAddress original_source_ip_address,
41                                uint16_t original_source_port,
42                                IPAddress original_destination_ip_address,
43                                uint16_t original_destination_port,
44                                IPAddress reply_source_ip_address,
45                                uint16_t reply_source_port,
46                                IPAddress reply_destination_ip_address,
47                                uint16_t reply_destination_port)
48     : protocol_(protocol),
49       time_to_expire_seconds_(time_to_expire_seconds),
50       is_unreplied_(is_unreplied),
51       original_source_ip_address_(original_source_ip_address),
52       original_source_port_(original_source_port),
53       original_destination_ip_address_(original_destination_ip_address),
54       original_destination_port_(original_destination_port),
55       reply_source_ip_address_(reply_source_ip_address),
56       reply_source_port_(reply_source_port),
57       reply_destination_ip_address_(reply_destination_ip_address),
58       reply_destination_port_(reply_destination_port) {
59 }
60 
ConnectionInfo(const ConnectionInfo & info)61 ConnectionInfo::ConnectionInfo(const ConnectionInfo& info)
62     : protocol_(info.protocol_),
63       time_to_expire_seconds_(info.time_to_expire_seconds_),
64       is_unreplied_(info.is_unreplied_),
65       original_source_ip_address_(info.original_source_ip_address_),
66       original_source_port_(info.original_source_port_),
67       original_destination_ip_address_(
68           info.original_destination_ip_address_),
69       original_destination_port_(info.original_destination_port_),
70       reply_source_ip_address_(info.reply_source_ip_address_),
71       reply_source_port_(info.reply_source_port_),
72       reply_destination_ip_address_(
73           info.reply_destination_ip_address_),
74       reply_destination_port_(info.reply_destination_port_) {
75 }
76 
~ConnectionInfo()77 ConnectionInfo::~ConnectionInfo() {}
78 
operator =(const ConnectionInfo & info)79 ConnectionInfo& ConnectionInfo::operator=(const ConnectionInfo& info) {
80   protocol_ = info.protocol_;
81   time_to_expire_seconds_ = info.time_to_expire_seconds_;
82   is_unreplied_ = info.is_unreplied_;
83   original_source_ip_address_ = info.original_source_ip_address_;
84   original_source_port_ = info.original_source_port_;
85   original_destination_ip_address_ =
86       info.original_destination_ip_address_;
87   original_destination_port_ = info.original_destination_port_;
88   reply_source_ip_address_ = info.reply_source_ip_address_;
89   reply_source_port_ = info.reply_source_port_;
90   reply_destination_ip_address_ = info.reply_destination_ip_address_;
91   reply_destination_port_ = info.reply_destination_port_;
92 
93   return *this;
94 }
95 
96 }  // namespace shill
97