blob: 91edcbf907c8578930dc1efbd8924e35bca7e21c [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'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.net.flow;
tom8bb16062014-09-12 14:47:46 -070017
18import java.util.List;
19
sangho8995ac52015-02-04 11:29:03 -080020import org.onosproject.core.GroupId;
Brian O'Connorabafb502014-12-02 22:26:20 -080021import org.onosproject.net.PortNumber;
22import org.onosproject.net.flow.instructions.Instruction;
Pavlin Radoslavov855ea2d2014-10-30 15:32:39 -070023import org.onlab.packet.IpAddress;
alshabib010c31d2014-09-26 10:01:12 -070024import org.onlab.packet.MacAddress;
25import org.onlab.packet.VlanId;
alshabib55a55d92014-09-16 11:59:31 -070026
tom8bb16062014-09-12 14:47:46 -070027/**
28 * Abstraction of network traffic treatment.
29 */
30public interface TrafficTreatment {
31
32 /**
33 * Returns list of instructions on how to treat traffic.
34 *
35 * @return list of treatment instructions
36 */
37 List<Instruction> instructions();
38
39 /**
40 * Builder of traffic treatment entities.
41 */
42 public interface Builder {
43
44 /**
alshabib010c31d2014-09-26 10:01:12 -070045 * Adds an instruction to the builder.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -080046 *
alshabib010c31d2014-09-26 10:01:12 -070047 * @param instruction an instruction
48 * @return a treatment builder
tom8bb16062014-09-12 14:47:46 -070049 */
alshabib369d2942014-09-12 17:59:35 -070050 Builder add(Instruction instruction);
tom8bb16062014-09-12 14:47:46 -070051
52 /**
Thomas Vachuskaf4df0052015-01-06 12:30:11 -080053 * Adds a drop instruction.
54 *
55 * @return a treatment builder
alshabib010c31d2014-09-26 10:01:12 -070056 */
Thomas Vachuskaf4df0052015-01-06 12:30:11 -080057 public Builder drop();
58
59 /**
60 * Adds a punt-to-controller instruction.
61 *
62 * @return a treatment builder
63 */
64 public Builder punt();
alshabib010c31d2014-09-26 10:01:12 -070065
66 /**
67 * Set the output port.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -080068 *
alshabib010c31d2014-09-26 10:01:12 -070069 * @param number the out port
70 * @return a treatment builder
71 */
72 public Builder setOutput(PortNumber number);
73
74 /**
75 * Sets the src l2 address.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -080076 *
alshabib010c31d2014-09-26 10:01:12 -070077 * @param addr a macaddress
78 * @return a treatment builder
79 */
80 public Builder setEthSrc(MacAddress addr);
81
82 /**
83 * Sets the dst l2 address.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -080084 *
alshabib010c31d2014-09-26 10:01:12 -070085 * @param addr a macaddress
86 * @return a treatment builder
87 */
88 public Builder setEthDst(MacAddress addr);
89
90 /**
91 * Sets the vlan id.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -080092 *
alshabib010c31d2014-09-26 10:01:12 -070093 * @param id a vlanid
94 * @return a treatment builder
95 */
96 public Builder setVlanId(VlanId id);
97
98 /**
99 * Sets the vlan priority.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800100 *
alshabib010c31d2014-09-26 10:01:12 -0700101 * @param pcp a vlan priority
102 * @return a treatment builder
103 */
104 public Builder setVlanPcp(Byte pcp);
105
106 /**
107 * Sets the src l3 address.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800108 *
alshabib010c31d2014-09-26 10:01:12 -0700109 * @param addr an ip
110 * @return a treatment builder
111 */
Pavlin Radoslavov855ea2d2014-10-30 15:32:39 -0700112 public Builder setIpSrc(IpAddress addr);
alshabib010c31d2014-09-26 10:01:12 -0700113
114 /**
115 * Sets the dst l3 address.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800116 *
alshabib010c31d2014-09-26 10:01:12 -0700117 * @param addr an ip
118 * @return a treatment builder
119 */
Pavlin Radoslavov855ea2d2014-10-30 15:32:39 -0700120 public Builder setIpDst(IpAddress addr);
alshabib010c31d2014-09-26 10:01:12 -0700121
122 /**
sangho3f97a17d2015-01-29 22:56:29 -0800123 * Decrease the TTL in IP header by one.
124 *
125 * @return a treatment builder
126 */
127 public Builder decNwTtl();
128
129 /**
130 * Copy the TTL to outer protocol layer.
131 *
132 * @return a treatment builder
133 */
134 public Builder copyTtlOut();
135
136 /**
137 * Copy the TTL to inner protocol layer.
138 *
139 * @return a treatment builder
140 */
141 public Builder copyTtlIn();
142
143 /**
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800144 * Push MPLS ether type.
Thomas Vachuskaf4df0052015-01-06 12:30:11 -0800145 *
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800146 * @return a treatment builder.
147 */
148 public Builder pushMpls();
149
150 /**
151 * Pops MPLS ether type.
Thomas Vachuskaf4df0052015-01-06 12:30:11 -0800152 *
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800153 * @return a treatment builder.
154 */
155 public Builder popMpls();
156
157 /**
sangho3f97a17d2015-01-29 22:56:29 -0800158 * Pops MPLS ether type.
159 *
160 * @param ethType Ethernet type to set
161 * @return a treatment builder.
162 */
163 public Builder popMpls(short ethType);
164
165 /**
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800166 * Sets the mpls label.
Thomas Vachuskaf4df0052015-01-06 12:30:11 -0800167 *
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800168 * @param mplsLabel MPLS label.
169 * @return a treatment builder.
170 */
171 public Builder setMpls(Integer mplsLabel);
172
173 /**
sangho3f97a17d2015-01-29 22:56:29 -0800174 * Decrement MPLS TTL.
175 *
176 * @return a treatment builder
177 */
178 public Builder decMplsTtl();
179
180 /**
Marc De Leenheer49087752014-10-23 13:54:09 -0700181 * Sets the optical channel ID or lambda.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800182 *
Marc De Leenheer49087752014-10-23 13:54:09 -0700183 * @param lambda optical channel ID
184 * @return a treatment builder
185 */
186 public Builder setLambda(short lambda);
187
188 /**
sangho8995ac52015-02-04 11:29:03 -0800189 * Sets the group ID.
190 *
191 * @param groupId group ID
192 * @return a treatment builder
193 */
194 public Builder group(GroupId groupId);
195
196 /**
tom8bb16062014-09-12 14:47:46 -0700197 * Builds an immutable traffic treatment descriptor.
198 *
199 * @return traffic treatment
200 */
201 TrafficTreatment build();
202 }
203
204}