blob: 7c69887b606160d7e5ccc064f912970784a7f341 [file] [log] [blame]
Thomas Vachuska83e090e2014-10-22 14:25:35 -07001/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
Brian O'Connorb876bf12014-10-02 14:59:37 -070019package org.onlab.onos.net.intent;
20
toma1d16b62014-10-02 23:45:11 -070021import com.google.common.base.MoreObjects;
Thomas Vachuskae0f804a2014-10-27 23:40:48 -070022import org.onlab.onos.core.ApplicationId;
Brian O'Connorb876bf12014-10-02 14:59:37 -070023import org.onlab.onos.net.ConnectPoint;
24import org.onlab.onos.net.flow.TrafficSelector;
25import org.onlab.onos.net.flow.TrafficTreatment;
26
toma1d16b62014-10-02 23:45:11 -070027import static com.google.common.base.Preconditions.checkNotNull;
Brian O'Connorb876bf12014-10-02 14:59:37 -070028
29/**
30 * Abstraction of point-to-point connectivity.
31 */
32public class PointToPointIntent extends ConnectivityIntent {
33
tom85258ee2014-10-07 00:10:02 -070034 private final ConnectPoint ingressPoint;
35 private final ConnectPoint egressPoint;
Brian O'Connorb876bf12014-10-02 14:59:37 -070036
37 /**
38 * Creates a new point-to-point intent with the supplied ingress/egress
39 * ports.
40 *
Thomas Vachuskac96058a2014-10-20 23:00:16 -070041 * @param appId application identifier
tom85258ee2014-10-07 00:10:02 -070042 * @param selector traffic selector
43 * @param treatment treatment
44 * @param ingressPoint ingress port
45 * @param egressPoint egress port
46 * @throws NullPointerException if {@code ingressPoint} or {@code egressPoints} is null.
Brian O'Connorb876bf12014-10-02 14:59:37 -070047 */
Thomas Vachuskac96058a2014-10-20 23:00:16 -070048 public PointToPointIntent(ApplicationId appId, TrafficSelector selector,
toma1d16b62014-10-02 23:45:11 -070049 TrafficTreatment treatment,
tom85258ee2014-10-07 00:10:02 -070050 ConnectPoint ingressPoint,
51 ConnectPoint egressPoint) {
Thomas Vachuskac96058a2014-10-20 23:00:16 -070052 super(id(PointToPointIntent.class, selector, treatment, ingressPoint, egressPoint),
53 appId, null, selector, treatment);
tom85258ee2014-10-07 00:10:02 -070054 this.ingressPoint = checkNotNull(ingressPoint);
55 this.egressPoint = checkNotNull(egressPoint);
Brian O'Connorb876bf12014-10-02 14:59:37 -070056 }
57
58 /**
59 * Constructor for serializer.
60 */
61 protected PointToPointIntent() {
62 super();
tom85258ee2014-10-07 00:10:02 -070063 this.ingressPoint = null;
64 this.egressPoint = null;
Brian O'Connorb876bf12014-10-02 14:59:37 -070065 }
66
67 /**
68 * Returns the port on which the ingress traffic should be connected to
69 * the egress.
70 *
71 * @return ingress port
72 */
tom85258ee2014-10-07 00:10:02 -070073 public ConnectPoint ingressPoint() {
74 return ingressPoint;
Brian O'Connorb876bf12014-10-02 14:59:37 -070075 }
76
77 /**
78 * Returns the port on which the traffic should egress.
79 *
80 * @return egress port
81 */
tom85258ee2014-10-07 00:10:02 -070082 public ConnectPoint egressPoint() {
83 return egressPoint;
Brian O'Connorb876bf12014-10-02 14:59:37 -070084 }
85
86 @Override
Brian O'Connorb876bf12014-10-02 14:59:37 -070087 public String toString() {
88 return MoreObjects.toStringHelper(getClass())
tom85258ee2014-10-07 00:10:02 -070089 .add("id", id())
Thomas Vachuskae291c842014-10-21 02:52:38 -070090 .add("appId", appId())
91 .add("selector", selector())
92 .add("treatment", treatment())
93 .add("ingress", ingressPoint)
94 .add("egress", egressPoint)
Brian O'Connorb876bf12014-10-02 14:59:37 -070095 .toString();
96 }
97
98}