Jonathan Hart | 7d7e2f5 | 2016-03-29 16:22:49 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Laboratory |
Jonathan Hart | 7d7e2f5 | 2016-03-29 16:22:49 -0700 | [diff] [blame] | 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 | package org.onosproject.incubator.net.routing; |
| 18 | |
| 19 | import org.onlab.packet.IpAddress; |
| 20 | import org.onlab.packet.IpPrefix; |
| 21 | import org.onlab.packet.MacAddress; |
| 22 | |
| 23 | /** |
| 24 | * Represents a route with the next hop MAC address resolved. |
| 25 | */ |
| 26 | public 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 | } |