blob: d170c2727c927d140521b89c3241881dbc431cd7 [file] [log] [blame]
Brian O'Connorb876bf12014-10-02 14:59:37 -07001package org.onlab.onos.net.intent;
2
toma1d16b62014-10-02 23:45:11 -07003import com.google.common.base.MoreObjects;
Thomas Vachuskac96058a2014-10-20 23:00:16 -07004import org.onlab.onos.ApplicationId;
Brian O'Connorb876bf12014-10-02 14:59:37 -07005import org.onlab.onos.net.ConnectPoint;
6import org.onlab.onos.net.flow.TrafficSelector;
7import org.onlab.onos.net.flow.TrafficTreatment;
8
toma1d16b62014-10-02 23:45:11 -07009import static com.google.common.base.Preconditions.checkNotNull;
Brian O'Connorb876bf12014-10-02 14:59:37 -070010
11/**
12 * Abstraction of point-to-point connectivity.
13 */
14public class PointToPointIntent extends ConnectivityIntent {
15
tom85258ee2014-10-07 00:10:02 -070016 private final ConnectPoint ingressPoint;
17 private final ConnectPoint egressPoint;
Brian O'Connorb876bf12014-10-02 14:59:37 -070018
19 /**
20 * Creates a new point-to-point intent with the supplied ingress/egress
21 * ports.
22 *
Thomas Vachuskac96058a2014-10-20 23:00:16 -070023 * @param appId application identifier
tom85258ee2014-10-07 00:10:02 -070024 * @param selector traffic selector
25 * @param treatment treatment
26 * @param ingressPoint ingress port
27 * @param egressPoint egress port
28 * @throws NullPointerException if {@code ingressPoint} or {@code egressPoints} is null.
Brian O'Connorb876bf12014-10-02 14:59:37 -070029 */
Thomas Vachuskac96058a2014-10-20 23:00:16 -070030 public PointToPointIntent(ApplicationId appId, TrafficSelector selector,
toma1d16b62014-10-02 23:45:11 -070031 TrafficTreatment treatment,
tom85258ee2014-10-07 00:10:02 -070032 ConnectPoint ingressPoint,
33 ConnectPoint egressPoint) {
Thomas Vachuskac96058a2014-10-20 23:00:16 -070034 super(id(PointToPointIntent.class, selector, treatment, ingressPoint, egressPoint),
35 appId, null, selector, treatment);
tom85258ee2014-10-07 00:10:02 -070036 this.ingressPoint = checkNotNull(ingressPoint);
37 this.egressPoint = checkNotNull(egressPoint);
Brian O'Connorb876bf12014-10-02 14:59:37 -070038 }
39
40 /**
41 * Constructor for serializer.
42 */
43 protected PointToPointIntent() {
44 super();
tom85258ee2014-10-07 00:10:02 -070045 this.ingressPoint = null;
46 this.egressPoint = null;
Brian O'Connorb876bf12014-10-02 14:59:37 -070047 }
48
49 /**
50 * Returns the port on which the ingress traffic should be connected to
51 * the egress.
52 *
53 * @return ingress port
54 */
tom85258ee2014-10-07 00:10:02 -070055 public ConnectPoint ingressPoint() {
56 return ingressPoint;
Brian O'Connorb876bf12014-10-02 14:59:37 -070057 }
58
59 /**
60 * Returns the port on which the traffic should egress.
61 *
62 * @return egress port
63 */
tom85258ee2014-10-07 00:10:02 -070064 public ConnectPoint egressPoint() {
65 return egressPoint;
Brian O'Connorb876bf12014-10-02 14:59:37 -070066 }
67
68 @Override
Brian O'Connorb876bf12014-10-02 14:59:37 -070069 public String toString() {
70 return MoreObjects.toStringHelper(getClass())
tom85258ee2014-10-07 00:10:02 -070071 .add("id", id())
Thomas Vachuskae291c842014-10-21 02:52:38 -070072 .add("appId", appId())
73 .add("selector", selector())
74 .add("treatment", treatment())
75 .add("ingress", ingressPoint)
76 .add("egress", egressPoint)
Brian O'Connorb876bf12014-10-02 14:59:37 -070077 .toString();
78 }
79
80}