blob: 83e9218b525e87eea8dcf009956b5c5b30eda469 [file] [log] [blame]
Michele Santuari4b6019e2014-12-19 11:31:45 +01001package org.onosproject.net.intent;
2
3import static com.google.common.base.Preconditions.checkNotNull;
4
5import java.util.Collections;
6import java.util.List;
7import java.util.Optional;
8
9
10import org.onlab.packet.MplsLabel;
11import org.onosproject.core.ApplicationId;
12import org.onosproject.net.Path;
13import org.onosproject.net.flow.TrafficSelector;
14import org.onosproject.net.flow.TrafficTreatment;
15
16
17/**
18 * Abstraction of explicit MPLS label-switched path.
19 */
20
Ray Milkeybd4f0112015-03-02 17:07:09 -080021public final class MplsPathIntent extends PathIntent {
Michele Santuari4b6019e2014-12-19 11:31:45 +010022
Ray Milkeybd4f0112015-03-02 17:07:09 -080023 private final Optional<MplsLabel> ingressLabel;
24 private final Optional<MplsLabel> egressLabel;
Michele Santuari4b6019e2014-12-19 11:31:45 +010025
26 /**
27 * Creates a new point-to-point intent with the supplied ingress/egress
28 * ports and using the specified explicit path.
29 *
30 * @param appId application identifier
31 * @param selector traffic selector
32 * @param treatment treatment
33 * @param path traversed links
34 * @param ingressLabel MPLS egress label
35 * @param egressLabel MPLS ingress label
36 * @throws NullPointerException {@code path} is null
37 */
38 public MplsPathIntent(ApplicationId appId, TrafficSelector selector,
39 TrafficTreatment treatment, Path path, Optional<MplsLabel> ingressLabel,
40 Optional<MplsLabel> egressLabel) {
41 this(appId, selector, treatment, path, ingressLabel, egressLabel,
Ray Milkey50a9b722015-03-12 10:38:55 -070042 Collections.emptyList(), DEFAULT_INTENT_PRIORITY);
Michele Santuari4b6019e2014-12-19 11:31:45 +010043
44 }
45
46 /**
47 * Creates a new point-to-point intent with the supplied ingress/egress
48 * ports and using the specified explicit path.
49 *
50 * @param appId application identifier
51 * @param selector traffic selector
52 * @param treatment treatment
53 * @param path traversed links
54 * @param ingressLabel MPLS egress label
55 * @param egressLabel MPLS ingress label
56 * @param constraints optional list of constraints
Ray Milkey50a9b722015-03-12 10:38:55 -070057 * @param priority priority to use for flows generated by this intent
Michele Santuari4b6019e2014-12-19 11:31:45 +010058 * @throws NullPointerException {@code path} is null
59 */
60 public MplsPathIntent(ApplicationId appId, TrafficSelector selector,
61 TrafficTreatment treatment, Path path, Optional<MplsLabel> ingressLabel,
Ray Milkey50a9b722015-03-12 10:38:55 -070062 Optional<MplsLabel> egressLabel, List<Constraint> constraints,
63 int priority) {
Ray Milkeyc24cde32015-03-10 18:20:18 -070064 super(appId, selector, treatment, path, constraints,
Ray Milkey50a9b722015-03-12 10:38:55 -070065 priority);
Michele Santuari4b6019e2014-12-19 11:31:45 +010066
67 checkNotNull(ingressLabel);
68 checkNotNull(egressLabel);
69 this.ingressLabel = ingressLabel;
70 this.egressLabel = egressLabel;
71 }
72
73 /**
74 * Returns the MPLS label which the ingress traffic should tagged.
75 *
76 * @return ingress MPLS label
77 */
78 public Optional<MplsLabel> ingressLabel() {
79 return ingressLabel;
80 }
81
82 /**
83 * Returns the MPLS label which the egress traffic should tagged.
84 *
85 * @return egress MPLS label
86 */
87 public Optional<MplsLabel> egressLabel() {
88 return egressLabel;
89 }
90
91}