blob: e4735302a552443cbad8490e8b53eafb3a0df27c [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
23/**
24 * Represents a route with the next hop MAC address resolved.
25 */
26public class ResolvedRoute {
27
28 private final IpPrefix prefix;
29 private final IpAddress nextHop;
30 private final MacAddress nextHopMac;
31
32 /**
33 * Creates a new resolved route.
34 *
35 * @param route input route
36 * @param nextHopMac next hop MAC address
37 */
38 public ResolvedRoute(Route route, MacAddress nextHopMac) {
39 this.prefix = route.prefix();
40 this.nextHop = route.nextHop();
41 this.nextHopMac = nextHopMac;
42 }
43
44 /**
45 * Creates a new resolved route.
46 *
47 * @param prefix route prefix
48 * @param nextHop route next hop IP address
49 * @param nextHopMac next hop MAC address
50 */
51 public ResolvedRoute(IpPrefix prefix, IpAddress nextHop, MacAddress nextHopMac) {
52 this.prefix = prefix;
53 this.nextHop = nextHop;
54 this.nextHopMac = nextHopMac;
55 }
56
57 /**
58 * Returns the IP prefix.
59 *
60 * @return IP prefix
61 */
62 public IpPrefix prefix() {
63 return prefix;
64 }
65
66 /**
67 * Returns the next hop IP address.
68 *
69 * @return IP address
70 */
71 public IpAddress nextHop() {
72 return nextHop;
73 }
74
75 /**
76 * Returns the next hop MAC address.
77 *
78 * @return MAC address
79 */
80 public MacAddress nextHopMac() {
81 return nextHopMac;
82 }
83}