blob: e890e62f3252fefd29b886a230f4f4aaa52069e4 [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;
Michele Santuari4b6019e2014-12-19 11:31:45 +010022import org.onosproject.net.flow.DefaultTrafficTreatment.Builder;
Brian O'Connorabafb502014-12-02 22:26:20 -080023import org.onosproject.net.flow.instructions.Instruction;
Pavlin Radoslavov855ea2d2014-10-30 15:32:39 -070024import org.onlab.packet.IpAddress;
alshabib010c31d2014-09-26 10:01:12 -070025import org.onlab.packet.MacAddress;
Michele Santuari4b6019e2014-12-19 11:31:45 +010026import org.onlab.packet.MplsLabel;
alshabib010c31d2014-09-26 10:01:12 -070027import org.onlab.packet.VlanId;
alshabib55a55d92014-09-16 11:59:31 -070028
tom8bb16062014-09-12 14:47:46 -070029/**
30 * Abstraction of network traffic treatment.
31 */
32public interface TrafficTreatment {
33
34 /**
35 * Returns list of instructions on how to treat traffic.
36 *
37 * @return list of treatment instructions
38 */
39 List<Instruction> instructions();
40
41 /**
42 * Builder of traffic treatment entities.
43 */
44 public interface Builder {
45
46 /**
alshabib010c31d2014-09-26 10:01:12 -070047 * Adds an instruction to the builder.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -080048 *
alshabib010c31d2014-09-26 10:01:12 -070049 * @param instruction an instruction
50 * @return a treatment builder
tom8bb16062014-09-12 14:47:46 -070051 */
alshabib369d2942014-09-12 17:59:35 -070052 Builder add(Instruction instruction);
tom8bb16062014-09-12 14:47:46 -070053
54 /**
Thomas Vachuskaf4df0052015-01-06 12:30:11 -080055 * Adds a drop instruction.
56 *
57 * @return a treatment builder
alshabib010c31d2014-09-26 10:01:12 -070058 */
Thomas Vachuskaf4df0052015-01-06 12:30:11 -080059 public Builder drop();
60
61 /**
62 * Adds a punt-to-controller instruction.
63 *
64 * @return a treatment builder
65 */
66 public Builder punt();
alshabib010c31d2014-09-26 10:01:12 -070067
68 /**
69 * Set the output port.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -080070 *
alshabib010c31d2014-09-26 10:01:12 -070071 * @param number the out port
72 * @return a treatment builder
73 */
74 public Builder setOutput(PortNumber number);
75
76 /**
77 * Sets the src l2 address.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -080078 *
alshabib010c31d2014-09-26 10:01:12 -070079 * @param addr a macaddress
80 * @return a treatment builder
81 */
82 public Builder setEthSrc(MacAddress addr);
83
84 /**
85 * Sets the dst l2 address.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -080086 *
alshabib010c31d2014-09-26 10:01:12 -070087 * @param addr a macaddress
88 * @return a treatment builder
89 */
90 public Builder setEthDst(MacAddress addr);
91
92 /**
93 * Sets the vlan id.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -080094 *
alshabib010c31d2014-09-26 10:01:12 -070095 * @param id a vlanid
96 * @return a treatment builder
97 */
98 public Builder setVlanId(VlanId id);
99
100 /**
101 * Sets the vlan priority.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800102 *
alshabib010c31d2014-09-26 10:01:12 -0700103 * @param pcp a vlan priority
104 * @return a treatment builder
105 */
106 public Builder setVlanPcp(Byte pcp);
107
108 /**
109 * Sets the src l3 address.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800110 *
alshabib010c31d2014-09-26 10:01:12 -0700111 * @param addr an ip
112 * @return a treatment builder
113 */
Pavlin Radoslavov855ea2d2014-10-30 15:32:39 -0700114 public Builder setIpSrc(IpAddress addr);
alshabib010c31d2014-09-26 10:01:12 -0700115
116 /**
117 * Sets the dst l3 address.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800118 *
alshabib010c31d2014-09-26 10:01:12 -0700119 * @param addr an ip
120 * @return a treatment builder
121 */
Pavlin Radoslavov855ea2d2014-10-30 15:32:39 -0700122 public Builder setIpDst(IpAddress addr);
alshabib010c31d2014-09-26 10:01:12 -0700123
124 /**
Pavlin Radoslavovfebe82c2015-02-11 19:08:15 -0800125 * Decrement the TTL in IP header by one.
sangho3f97a17d2015-01-29 22:56:29 -0800126 *
127 * @return a treatment builder
128 */
129 public Builder decNwTtl();
130
131 /**
132 * Copy the TTL to outer protocol layer.
133 *
134 * @return a treatment builder
135 */
136 public Builder copyTtlOut();
137
138 /**
139 * Copy the TTL to inner protocol layer.
140 *
141 * @return a treatment builder
142 */
143 public Builder copyTtlIn();
144
145 /**
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800146 * Push MPLS ether type.
Thomas Vachuskaf4df0052015-01-06 12:30:11 -0800147 *
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800148 * @return a treatment builder.
149 */
150 public Builder pushMpls();
151
152 /**
153 * Pops MPLS ether type.
Thomas Vachuskaf4df0052015-01-06 12:30:11 -0800154 *
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800155 * @return a treatment builder.
156 */
157 public Builder popMpls();
158
159 /**
Michele Santuari4b6019e2014-12-19 11:31:45 +0100160 * Pops MPLS ether type and set the new ethertype.
sangho3f97a17d2015-01-29 22:56:29 -0800161 *
Michele Santuari4b6019e2014-12-19 11:31:45 +0100162 * @param etherType an ether type
sangho3f97a17d2015-01-29 22:56:29 -0800163 * @return a treatment builder.
164 */
Michele Santuari4b6019e2014-12-19 11:31:45 +0100165 public Builder popMpls(Short etherType);
sangho3f97a17d2015-01-29 22:56:29 -0800166
167 /**
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800168 * Sets the mpls label.
Thomas Vachuskaf4df0052015-01-06 12:30:11 -0800169 *
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800170 * @param mplsLabel MPLS label.
171 * @return a treatment builder.
172 */
Michele Santuari4b6019e2014-12-19 11:31:45 +0100173 public Builder setMpls(MplsLabel mplsLabel);
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800174
175 /**
sangho3f97a17d2015-01-29 22:56:29 -0800176 * Decrement MPLS TTL.
177 *
178 * @return a treatment builder
179 */
180 public Builder decMplsTtl();
181
182 /**
Marc De Leenheer49087752014-10-23 13:54:09 -0700183 * Sets the optical channel ID or lambda.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800184 *
Marc De Leenheer49087752014-10-23 13:54:09 -0700185 * @param lambda optical channel ID
186 * @return a treatment builder
187 */
188 public Builder setLambda(short lambda);
189
190 /**
sangho8995ac52015-02-04 11:29:03 -0800191 * Sets the group ID.
192 *
193 * @param groupId group ID
194 * @return a treatment builder
195 */
196 public Builder group(GroupId groupId);
197
alshabib9af70072015-02-09 14:34:16 -0800198
199 /**
200 * Sets the next table type to transition to.
201 *
202 * @param type the table type
203 * @return a treatement builder
204 */
205 public Builder transition(FlowRule.Type type);
206
sangho8995ac52015-02-04 11:29:03 -0800207 /**
tom8bb16062014-09-12 14:47:46 -0700208 * Builds an immutable traffic treatment descriptor.
209 *
210 * @return traffic treatment
211 */
212 TrafficTreatment build();
Michele Santuari4b6019e2014-12-19 11:31:45 +0100213
214
tom8bb16062014-09-12 14:47:46 -0700215 }
216
217}