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 #ifndef SHILL_CONNECTION_INFO_H_
     18 #define SHILL_CONNECTION_INFO_H_
     19 
     20 #include <base/macros.h>
     21 
     22 #include "shill/net/ip_address.h"
     23 
     24 namespace shill {
     25 
     26 class ConnectionInfo {
     27  public:
     28   ConnectionInfo();
     29   ConnectionInfo(int protocol,
     30                  int64_t time_to_expire_seconds,
     31                  bool is_unreplied,
     32                  IPAddress original_source_ip_address,
     33                  uint16_t original_source_port,
     34                  IPAddress original_destination_ip_address,
     35                  uint16_t original_destination_port,
     36                  IPAddress reply_source_ip_address,
     37                  uint16_t reply_source_port,
     38                  IPAddress reply_destination_ip_address,
     39                  uint16_t reply_destination_port);
     40   ConnectionInfo(const ConnectionInfo& info);
     41   ~ConnectionInfo();
     42 
     43   ConnectionInfo& operator=(const ConnectionInfo& info);
     44 
     45   int protocol() const { return protocol_; }
     46   void set_protocol(int protocol) { protocol_ = protocol; }
     47 
     48   int64_t time_to_expire_seconds() const { return time_to_expire_seconds_; }
     49   void set_time_to_expire_seconds(int64_t time_to_expire_seconds) {
     50     time_to_expire_seconds_ = time_to_expire_seconds;
     51   }
     52 
     53   bool is_unreplied() const { return is_unreplied_; }
     54   void set_is_unreplied(bool is_unreplied) { is_unreplied_ = is_unreplied; }
     55 
     56   const IPAddress& original_source_ip_address() const {
     57     return original_source_ip_address_;
     58   }
     59   void set_original_source_ip_address(
     60       const IPAddress& original_source_ip_address) {
     61     original_source_ip_address_ = original_source_ip_address;
     62   }
     63 
     64   uint16_t original_source_port() const { return original_source_port_; }
     65   void set_original_source_port(uint16_t original_source_port) {
     66     original_source_port_ = original_source_port;
     67   }
     68 
     69   const IPAddress& original_destination_ip_address() const {
     70     return original_destination_ip_address_;
     71   }
     72   void set_original_destination_ip_address(
     73       const IPAddress& original_destination_ip_address) {
     74     original_destination_ip_address_ = original_destination_ip_address;
     75   }
     76 
     77   uint16_t original_destination_port() const {
     78     return original_destination_port_;
     79   }
     80   void set_original_destination_port(uint16_t original_destination_port) {
     81     original_destination_port_ = original_destination_port;
     82   }
     83 
     84   const IPAddress& reply_source_ip_address() const {
     85     return reply_source_ip_address_;
     86   }
     87   void set_reply_source_ip_address(
     88       const IPAddress& reply_source_ip_address) {
     89     reply_source_ip_address_ = reply_source_ip_address;
     90   }
     91 
     92   uint16_t reply_source_port() const { return reply_source_port_; }
     93   void set_reply_source_port(uint16_t reply_source_port) {
     94     reply_source_port_ = reply_source_port;
     95   }
     96 
     97   const IPAddress& reply_destination_ip_address() const {
     98     return reply_destination_ip_address_;
     99   }
    100   void set_reply_destination_ip_address(
    101       const IPAddress& reply_destination_ip_address) {
    102     reply_destination_ip_address_ = reply_destination_ip_address;
    103   }
    104 
    105   uint16_t reply_destination_port() const { return reply_destination_port_; }
    106   void set_reply_destination_port(uint16_t reply_destination_port) {
    107     reply_destination_port_ = reply_destination_port;
    108   }
    109 
    110  private:
    111   int protocol_;
    112   int64_t time_to_expire_seconds_;
    113   bool is_unreplied_;
    114 
    115   IPAddress original_source_ip_address_;
    116   uint16_t original_source_port_;
    117   IPAddress original_destination_ip_address_;
    118   uint16_t original_destination_port_;
    119 
    120   IPAddress reply_source_ip_address_;
    121   uint16_t reply_source_port_;
    122   IPAddress reply_destination_ip_address_;
    123   uint16_t reply_destination_port_;
    124 
    125   // No DISALLOW_COPY_AND_ASSIGN(ConnectionInfo) as ConnectionInfo needs to be
    126   // kept in STL containers.
    127 };
    128 
    129 }  // namespace shill
    130 
    131 #endif  // SHILL_CONNECTION_INFO_H_
    132