blob: 08063f079f35b0c81f7692a43a570396a3571b12 [file] [log] [blame]
Brian O'Connor66630c82014-10-02 21:08:19 -07001package org.onlab.onos.net.intent;
2
toma1d16b62014-10-02 23:45:11 -07003import com.google.common.base.MoreObjects;
Brian O'Connor66630c82014-10-02 21:08:19 -07004import org.onlab.onos.net.HostId;
5import org.onlab.onos.net.flow.TrafficSelector;
6import org.onlab.onos.net.flow.TrafficTreatment;
7
toma1d16b62014-10-02 23:45:11 -07008import java.util.Objects;
9
10import static com.google.common.base.Preconditions.checkNotNull;
Brian O'Connor66630c82014-10-02 21:08:19 -070011
12/**
toma1d16b62014-10-02 23:45:11 -070013 * Abstraction of end-station to end-station connectivity.
Brian O'Connor66630c82014-10-02 21:08:19 -070014 */
15public class HostToHostIntent extends ConnectivityIntent {
16
17 private final HostId src;
18 private final HostId dst;
19
20 /**
21 * Creates a new point-to-point intent with the supplied ingress/egress
22 * ports.
23 *
toma1d16b62014-10-02 23:45:11 -070024 * @param intentId intent identifier
25 * @param selector action
26 * @param treatment ingress port
Brian O'Connor66630c82014-10-02 21:08:19 -070027 * @throws NullPointerException if {@code ingressPort} or {@code egressPort}
toma1d16b62014-10-02 23:45:11 -070028 * is null.
Brian O'Connor66630c82014-10-02 21:08:19 -070029 */
toma1d16b62014-10-02 23:45:11 -070030 public HostToHostIntent(IntentId intentId, HostId src, HostId dst,
31 TrafficSelector selector, TrafficTreatment treatment) {
32 super(intentId, selector, treatment);
Brian O'Connor66630c82014-10-02 21:08:19 -070033 this.src = checkNotNull(src);
34 this.dst = checkNotNull(dst);
35 }
36
37 /**
38 * Returns the port on which the ingress traffic should be connected to the
39 * egress.
40 *
41 * @return ingress port
42 */
43 public HostId getSrc() {
44 return src;
45 }
46
47 /**
48 * Returns the port on which the traffic should egress.
49 *
50 * @return egress port
51 */
52 public HostId getDst() {
53 return dst;
54 }
55
56 @Override
57 public boolean equals(Object o) {
58 if (this == o) {
59 return true;
60 }
61 if (o == null || getClass() != o.getClass()) {
62 return false;
63 }
64 if (!super.equals(o)) {
65 return false;
66 }
67
68 HostToHostIntent that = (HostToHostIntent) o;
69 return Objects.equals(this.src, that.src)
70 && Objects.equals(this.dst, that.dst);
71 }
72
73 @Override
74 public int hashCode() {
75 return Objects.hash(super.hashCode(), src, dst);
76 }
77
78 @Override
79 public String toString() {
80 return MoreObjects.toStringHelper(getClass())
81 .add("id", getId())
82 .add("selector", getTrafficSelector())
83 .add("treatmetn", getTrafficTreatment())
84 .add("src", src)
85 .add("dst", dst)
86 .toString();
87 }
88
89}