blob: 7a47ead35aa5e95450573bb48370e6ef78071469 [file] [log] [blame]
Jonathan Hart7d7e2f52016-03-29 16:22:49 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2016-present Open Networking Laboratory
Jonathan Hart7d7e2f52016-03-29 16:22:49 -07003 *
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
17package org.onosproject.incubator.net.routing;
18
19import org.onlab.packet.IpAddress;
20import org.onlab.packet.IpPrefix;
21import org.onlab.packet.MacAddress;
22
Jonathan Hartfd176612016-04-11 10:42:10 -070023import static com.google.common.base.MoreObjects.toStringHelper;
24
Jonathan Hart7d7e2f52016-03-29 16:22:49 -070025/**
26 * Represents a route with the next hop MAC address resolved.
27 */
28public class ResolvedRoute {
29
30 private final IpPrefix prefix;
31 private final IpAddress nextHop;
32 private final MacAddress nextHopMac;
33
34 /**
35 * Creates a new resolved route.
36 *
37 * @param route input route
38 * @param nextHopMac next hop MAC address
39 */
40 public ResolvedRoute(Route route, MacAddress nextHopMac) {
41 this.prefix = route.prefix();
42 this.nextHop = route.nextHop();
43 this.nextHopMac = nextHopMac;
44 }
45
46 /**
47 * Creates a new resolved route.
48 *
49 * @param prefix route prefix
50 * @param nextHop route next hop IP address
51 * @param nextHopMac next hop MAC address
52 */
53 public ResolvedRoute(IpPrefix prefix, IpAddress nextHop, MacAddress nextHopMac) {
54 this.prefix = prefix;
55 this.nextHop = nextHop;
56 this.nextHopMac = nextHopMac;
57 }
58
59 /**
60 * Returns the IP prefix.
61 *
62 * @return IP prefix
63 */
64 public IpPrefix prefix() {
65 return prefix;
66 }
67
68 /**
69 * Returns the next hop IP address.
70 *
71 * @return IP address
72 */
73 public IpAddress nextHop() {
74 return nextHop;
75 }
76
77 /**
78 * Returns the next hop MAC address.
79 *
80 * @return MAC address
81 */
82 public MacAddress nextHopMac() {
83 return nextHopMac;
84 }
Jonathan Hartfd176612016-04-11 10:42:10 -070085
86 @Override
87 public String toString() {
88 return toStringHelper(this)
89 .add("prefix", prefix)
90 .add("nextHop", nextHop)
91 .add("nextHopMac", nextHopMac)
92 .toString();
93 }
Jonathan Hart7d7e2f52016-03-29 16:22:49 -070094}