blob: 61a1a56ae10ddad874f3c741c114a3418c96321d [file] [log] [blame]
Thomas Vachuska83e090e2014-10-22 14:25:35 -07001/*
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07002 * Copyright 2014 Open Networking Laboratory
Thomas Vachuska83e090e2014-10-22 14:25:35 -07003 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07004 * 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 Vachuska83e090e2014-10-22 14:25:35 -07007 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07008 * 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 Vachuska83e090e2014-10-22 14:25:35 -070015 */
Brian O'Connorb876bf12014-10-02 14:59:37 -070016package org.onlab.onos.net.intent;
17
toma1d16b62014-10-02 23:45:11 -070018import com.google.common.base.MoreObjects;
Thomas Vachuskae0f804a2014-10-27 23:40:48 -070019import org.onlab.onos.core.ApplicationId;
Brian O'Connorb876bf12014-10-02 14:59:37 -070020import org.onlab.onos.net.ConnectPoint;
21import org.onlab.onos.net.flow.TrafficSelector;
22import org.onlab.onos.net.flow.TrafficTreatment;
23
toma1d16b62014-10-02 23:45:11 -070024import static com.google.common.base.Preconditions.checkNotNull;
Brian O'Connorb876bf12014-10-02 14:59:37 -070025
26/**
27 * Abstraction of point-to-point connectivity.
28 */
29public class PointToPointIntent extends ConnectivityIntent {
30
tom85258ee2014-10-07 00:10:02 -070031 private final ConnectPoint ingressPoint;
32 private final ConnectPoint egressPoint;
Brian O'Connorb876bf12014-10-02 14:59:37 -070033
34 /**
35 * Creates a new point-to-point intent with the supplied ingress/egress
36 * ports.
37 *
Thomas Vachuskac96058a2014-10-20 23:00:16 -070038 * @param appId application identifier
tom85258ee2014-10-07 00:10:02 -070039 * @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'Connorb876bf12014-10-02 14:59:37 -070044 */
Thomas Vachuskac96058a2014-10-20 23:00:16 -070045 public PointToPointIntent(ApplicationId appId, TrafficSelector selector,
toma1d16b62014-10-02 23:45:11 -070046 TrafficTreatment treatment,
tom85258ee2014-10-07 00:10:02 -070047 ConnectPoint ingressPoint,
48 ConnectPoint egressPoint) {
Thomas Vachuskac96058a2014-10-20 23:00:16 -070049 super(id(PointToPointIntent.class, selector, treatment, ingressPoint, egressPoint),
50 appId, null, selector, treatment);
tom85258ee2014-10-07 00:10:02 -070051 this.ingressPoint = checkNotNull(ingressPoint);
52 this.egressPoint = checkNotNull(egressPoint);
Brian O'Connorb876bf12014-10-02 14:59:37 -070053 }
54
55 /**
56 * Constructor for serializer.
57 */
58 protected PointToPointIntent() {
59 super();
tom85258ee2014-10-07 00:10:02 -070060 this.ingressPoint = null;
61 this.egressPoint = null;
Brian O'Connorb876bf12014-10-02 14:59:37 -070062 }
63
64 /**
65 * Returns the port on which the ingress traffic should be connected to
66 * the egress.
67 *
68 * @return ingress port
69 */
tom85258ee2014-10-07 00:10:02 -070070 public ConnectPoint ingressPoint() {
71 return ingressPoint;
Brian O'Connorb876bf12014-10-02 14:59:37 -070072 }
73
74 /**
75 * Returns the port on which the traffic should egress.
76 *
77 * @return egress port
78 */
tom85258ee2014-10-07 00:10:02 -070079 public ConnectPoint egressPoint() {
80 return egressPoint;
Brian O'Connorb876bf12014-10-02 14:59:37 -070081 }
82
83 @Override
Brian O'Connorb876bf12014-10-02 14:59:37 -070084 public String toString() {
85 return MoreObjects.toStringHelper(getClass())
tom85258ee2014-10-07 00:10:02 -070086 .add("id", id())
Thomas Vachuskae291c842014-10-21 02:52:38 -070087 .add("appId", appId())
88 .add("selector", selector())
89 .add("treatment", treatment())
90 .add("ingress", ingressPoint)
91 .add("egress", egressPoint)
Brian O'Connorb876bf12014-10-02 14:59:37 -070092 .toString();
93 }
94
95}