blob: 3c5d5506ec69114eed28890eee13ab3a39356923 [file] [log] [blame]
Jonathan Hart552e31f2015-02-06 11:11:59 -08001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Jonathan Hart552e31f2015-02-06 11:11:59 -08003 *
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 */
Jonathan Hart2da1e602015-02-18 19:09:24 -080016package org.onosproject.routing;
Jonathan Hart552e31f2015-02-06 11:11:59 -080017
Jonathan Hart41349e92015-02-09 14:14:02 -080018import com.google.common.base.MoreObjects;
Jonathan Hart552e31f2015-02-06 11:11:59 -080019import org.onlab.packet.IpAddress;
20import org.onlab.packet.IpPrefix;
21import org.onlab.packet.MacAddress;
22
Jonathan Hart41349e92015-02-09 14:14:02 -080023import java.util.Objects;
24
Jonathan Hart552e31f2015-02-06 11:11:59 -080025/**
26 * An entry in the Forwarding Information Base (FIB).
Jonathan Hart888eaa02016-06-22 15:56:21 -070027 *
28 * @deprecated use RouteService instead
Jonathan Hart552e31f2015-02-06 11:11:59 -080029 */
Jonathan Hart888eaa02016-06-22 15:56:21 -070030@Deprecated
Jonathan Hart552e31f2015-02-06 11:11:59 -080031public class FibEntry {
32
33 private final IpPrefix prefix;
34 private final IpAddress nextHopIp;
35 private final MacAddress nextHopMac;
36
37 /**
38 * Creates a new FIB entry.
39 *
40 * @param prefix IP prefix of the FIB entry
41 * @param nextHopIp IP address of the next hop
42 * @param nextHopMac MAC address of the next hop
43 */
44 public FibEntry(IpPrefix prefix, IpAddress nextHopIp, MacAddress nextHopMac) {
45 this.prefix = prefix;
46 this.nextHopIp = nextHopIp;
47 this.nextHopMac = nextHopMac;
48 }
49
50 /**
51 * Returns the IP prefix of the FIB entry.
52 *
53 * @return the IP prefix
54 */
55 public IpPrefix prefix() {
56 return prefix;
57 }
58
59 /**
60 * Returns the IP address of the next hop.
61 *
62 * @return the IP address
63 */
64 public IpAddress nextHopIp() {
65 return nextHopIp;
66 }
67
68 /**
69 * Returns the MAC address of the next hop.
70 *
71 * @return the MAC address
72 */
73 public MacAddress nextHopMac() {
74 return nextHopMac;
75 }
Jonathan Hart41349e92015-02-09 14:14:02 -080076
77 @Override
78 public boolean equals(Object o) {
79 if (!(o instanceof FibEntry)) {
80 return false;
81 }
82
83 FibEntry that = (FibEntry) o;
84
85 return Objects.equals(this.prefix, that.prefix) &&
86 Objects.equals(this.nextHopIp, that.nextHopIp) &&
87 Objects.equals(this.nextHopMac, that.nextHopMac);
88 }
89
90 @Override
91 public int hashCode() {
92 return Objects.hash(prefix, nextHopIp, nextHopMac);
93 }
94
95 @Override
96 public String toString() {
97 return MoreObjects.toStringHelper(getClass())
98 .add("prefix", prefix)
99 .add("nextHopIp", nextHopIp)
100 .add("nextHopMac", nextHopMac)
101 .toString();
102 }
Jonathan Hart552e31f2015-02-06 11:11:59 -0800103}