blob: 9cf41de69086e74dfc745f2691d36834a9ca2cc1 [file] [log] [blame]
Paul Stewart75e89d22011-08-01 10:00:02 -07001// Copyright (c) 2011 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#ifndef SHILL_ROUTING_TABLE_ENTRY_
6#define SHILL_ROUTING_TABLE_ENTRY_
7
8#include <base/basictypes.h>
9
10#include "shill/ip_address.h"
11
12namespace shill {
13
14// Holds table entries for routing. These are held in an STL vector
15// in the RoutingTable object, hence the need for copy contructor and
16// operator=.
17struct RoutingTableEntry {
18 public:
19 RoutingTableEntry()
Paul Stewart7355ce12011-09-02 10:47:01 -070020 : dst(IPAddress::kFamilyUnknown),
21 src(IPAddress::kFamilyUnknown),
22 gateway(IPAddress::kFamilyUnknown),
Paul Stewart75e89d22011-08-01 10:00:02 -070023 metric(0),
24 scope(0),
25 from_rtnl(false) {}
26
27 RoutingTableEntry(const IPAddress &dst_in,
Paul Stewart75e89d22011-08-01 10:00:02 -070028 const IPAddress &src_in,
Paul Stewart75e89d22011-08-01 10:00:02 -070029 const IPAddress &gateway_in,
30 uint32 metric_in,
31 unsigned char scope_in,
32 bool from_rtnl_in)
Paul Stewart9e3fcd72011-08-26 15:46:16 -070033 : dst(dst_in),
34 src(src_in),
35 gateway(gateway_in),
Paul Stewart75e89d22011-08-01 10:00:02 -070036 metric(metric_in),
37 scope(scope_in),
38 from_rtnl(from_rtnl_in) {}
39
40 RoutingTableEntry(const RoutingTableEntry &b)
Paul Stewart9e3fcd72011-08-26 15:46:16 -070041 : dst(b.dst),
42 src(b.src),
43 gateway(b.gateway),
Paul Stewart75e89d22011-08-01 10:00:02 -070044 metric(b.metric),
45 scope(b.scope),
46 from_rtnl(b.from_rtnl) {}
47
48 RoutingTableEntry &operator=(const RoutingTableEntry &b) {
Paul Stewart9e3fcd72011-08-26 15:46:16 -070049 dst = b.dst;
50 src = b.src;
51 gateway = b.gateway;
Paul Stewart75e89d22011-08-01 10:00:02 -070052 metric = b.metric;
53 scope = b.scope;
54 from_rtnl = b.from_rtnl;
55
56 return *this;
57 }
58
59 ~RoutingTableEntry() {}
60
61 bool Equals(const RoutingTableEntry &b) {
62 return (dst.Equals(b.dst) &&
Paul Stewart75e89d22011-08-01 10:00:02 -070063 src.Equals(b.src) &&
Paul Stewart75e89d22011-08-01 10:00:02 -070064 gateway.Equals(b.gateway) &&
65 metric == b.metric &&
66 scope == b.scope &&
67 from_rtnl == b.from_rtnl);
68 }
69
70 IPAddress dst;
Paul Stewart75e89d22011-08-01 10:00:02 -070071 IPAddress src;
Paul Stewart75e89d22011-08-01 10:00:02 -070072 IPAddress gateway;
73 uint32 metric;
74 unsigned char scope;
75 bool from_rtnl;
76};
77
78} // namespace shill
79
80
81#endif // SHILL_ROUTING_TABLE_ENTRY_