Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 1 | /* |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame^] | 2 | * Copyright 2014 Open Networking Laboratory |
Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 3 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame^] | 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 |
Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 7 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame^] | 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. |
Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 15 | */ |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 16 | package org.onlab.onos.net.intent; |
| 17 | |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame] | 18 | import com.google.common.base.MoreObjects; |
Thomas Vachuska | e0f804a | 2014-10-27 23:40:48 -0700 | [diff] [blame] | 19 | import org.onlab.onos.core.ApplicationId; |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 20 | import org.onlab.onos.net.ConnectPoint; |
| 21 | import org.onlab.onos.net.flow.TrafficSelector; |
| 22 | import org.onlab.onos.net.flow.TrafficTreatment; |
| 23 | |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame] | 24 | import static com.google.common.base.Preconditions.checkNotNull; |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 25 | |
| 26 | /** |
| 27 | * Abstraction of point-to-point connectivity. |
| 28 | */ |
| 29 | public class PointToPointIntent extends ConnectivityIntent { |
| 30 | |
tom | 85258ee | 2014-10-07 00:10:02 -0700 | [diff] [blame] | 31 | private final ConnectPoint ingressPoint; |
| 32 | private final ConnectPoint egressPoint; |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 33 | |
| 34 | /** |
| 35 | * Creates a new point-to-point intent with the supplied ingress/egress |
| 36 | * ports. |
| 37 | * |
Thomas Vachuska | c96058a | 2014-10-20 23:00:16 -0700 | [diff] [blame] | 38 | * @param appId application identifier |
tom | 85258ee | 2014-10-07 00:10:02 -0700 | [diff] [blame] | 39 | * @param selector traffic selector |
| 40 | * @param treatment treatment |
| 41 | * @param ingressPoint ingress port |
| 42 | * @param egressPoint egress port |
| 43 | * @throws NullPointerException if {@code ingressPoint} or {@code egressPoints} is null. |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 44 | */ |
Thomas Vachuska | c96058a | 2014-10-20 23:00:16 -0700 | [diff] [blame] | 45 | public PointToPointIntent(ApplicationId appId, TrafficSelector selector, |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame] | 46 | TrafficTreatment treatment, |
tom | 85258ee | 2014-10-07 00:10:02 -0700 | [diff] [blame] | 47 | ConnectPoint ingressPoint, |
| 48 | ConnectPoint egressPoint) { |
Thomas Vachuska | c96058a | 2014-10-20 23:00:16 -0700 | [diff] [blame] | 49 | super(id(PointToPointIntent.class, selector, treatment, ingressPoint, egressPoint), |
| 50 | appId, null, selector, treatment); |
tom | 85258ee | 2014-10-07 00:10:02 -0700 | [diff] [blame] | 51 | this.ingressPoint = checkNotNull(ingressPoint); |
| 52 | this.egressPoint = checkNotNull(egressPoint); |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Constructor for serializer. |
| 57 | */ |
| 58 | protected PointToPointIntent() { |
| 59 | super(); |
tom | 85258ee | 2014-10-07 00:10:02 -0700 | [diff] [blame] | 60 | this.ingressPoint = null; |
| 61 | this.egressPoint = null; |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | /** |
| 65 | * Returns the port on which the ingress traffic should be connected to |
| 66 | * the egress. |
| 67 | * |
| 68 | * @return ingress port |
| 69 | */ |
tom | 85258ee | 2014-10-07 00:10:02 -0700 | [diff] [blame] | 70 | public ConnectPoint ingressPoint() { |
| 71 | return ingressPoint; |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 72 | } |
| 73 | |
| 74 | /** |
| 75 | * Returns the port on which the traffic should egress. |
| 76 | * |
| 77 | * @return egress port |
| 78 | */ |
tom | 85258ee | 2014-10-07 00:10:02 -0700 | [diff] [blame] | 79 | public ConnectPoint egressPoint() { |
| 80 | return egressPoint; |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 81 | } |
| 82 | |
| 83 | @Override |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 84 | public String toString() { |
| 85 | return MoreObjects.toStringHelper(getClass()) |
tom | 85258ee | 2014-10-07 00:10:02 -0700 | [diff] [blame] | 86 | .add("id", id()) |
Thomas Vachuska | e291c84 | 2014-10-21 02:52:38 -0700 | [diff] [blame] | 87 | .add("appId", appId()) |
| 88 | .add("selector", selector()) |
| 89 | .add("treatment", treatment()) |
| 90 | .add("ingress", ingressPoint) |
| 91 | .add("egress", egressPoint) |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 92 | .toString(); |
| 93 | } |
| 94 | |
| 95 | } |