Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 1 | /* |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 2 | * Copyright 2014 Open Networking Laboratory |
Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 3 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 4 | * 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 Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 7 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 8 | * 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 Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 15 | */ |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.net.flow; |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 17 | |
| 18 | import java.util.List; |
| 19 | |
sangho | 8995ac5 | 2015-02-04 11:29:03 -0800 | [diff] [blame] | 20 | import org.onosproject.core.GroupId; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 21 | import org.onosproject.net.PortNumber; |
Michele Santuari | 4b6019e | 2014-12-19 11:31:45 +0100 | [diff] [blame] | 22 | import org.onosproject.net.flow.DefaultTrafficTreatment.Builder; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 23 | import org.onosproject.net.flow.instructions.Instruction; |
Pavlin Radoslavov | 855ea2d | 2014-10-30 15:32:39 -0700 | [diff] [blame] | 24 | import org.onlab.packet.IpAddress; |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 25 | import org.onlab.packet.MacAddress; |
Michele Santuari | 4b6019e | 2014-12-19 11:31:45 +0100 | [diff] [blame] | 26 | import org.onlab.packet.MplsLabel; |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 27 | import org.onlab.packet.VlanId; |
alshabib | 55a55d9 | 2014-09-16 11:59:31 -0700 | [diff] [blame] | 28 | |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 29 | /** |
| 30 | * Abstraction of network traffic treatment. |
| 31 | */ |
| 32 | public 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 | /** |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 47 | * Adds an instruction to the builder. |
Sho SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 48 | * |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 49 | * @param instruction an instruction |
| 50 | * @return a treatment builder |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 51 | */ |
alshabib | 369d294 | 2014-09-12 17:59:35 -0700 | [diff] [blame] | 52 | Builder add(Instruction instruction); |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 53 | |
| 54 | /** |
Thomas Vachuska | f4df005 | 2015-01-06 12:30:11 -0800 | [diff] [blame] | 55 | * Adds a drop instruction. |
| 56 | * |
| 57 | * @return a treatment builder |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 58 | */ |
Thomas Vachuska | f4df005 | 2015-01-06 12:30:11 -0800 | [diff] [blame] | 59 | public Builder drop(); |
| 60 | |
| 61 | /** |
| 62 | * Adds a punt-to-controller instruction. |
| 63 | * |
| 64 | * @return a treatment builder |
| 65 | */ |
| 66 | public Builder punt(); |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 67 | |
| 68 | /** |
| 69 | * Set the output port. |
Sho SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 70 | * |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 71 | * @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 SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 78 | * |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 79 | * @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 SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 86 | * |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 87 | * @param addr a macaddress |
| 88 | * @return a treatment builder |
| 89 | */ |
| 90 | public Builder setEthDst(MacAddress addr); |
| 91 | |
| 92 | /** |
| 93 | * Sets the vlan id. |
Sho SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 94 | * |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 95 | * @param id a vlanid |
| 96 | * @return a treatment builder |
| 97 | */ |
| 98 | public Builder setVlanId(VlanId id); |
| 99 | |
| 100 | /** |
| 101 | * Sets the vlan priority. |
Sho SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 102 | * |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 103 | * @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 SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 110 | * |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 111 | * @param addr an ip |
| 112 | * @return a treatment builder |
| 113 | */ |
Pavlin Radoslavov | 855ea2d | 2014-10-30 15:32:39 -0700 | [diff] [blame] | 114 | public Builder setIpSrc(IpAddress addr); |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 115 | |
| 116 | /** |
| 117 | * Sets the dst l3 address. |
Sho SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 118 | * |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 119 | * @param addr an ip |
| 120 | * @return a treatment builder |
| 121 | */ |
Pavlin Radoslavov | 855ea2d | 2014-10-30 15:32:39 -0700 | [diff] [blame] | 122 | public Builder setIpDst(IpAddress addr); |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 123 | |
| 124 | /** |
Pavlin Radoslavov | febe82c | 2015-02-11 19:08:15 -0800 | [diff] [blame] | 125 | * Decrement the TTL in IP header by one. |
sangho | 3f97a17d | 2015-01-29 22:56:29 -0800 | [diff] [blame] | 126 | * |
| 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 Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 146 | * Push MPLS ether type. |
Thomas Vachuska | f4df005 | 2015-01-06 12:30:11 -0800 | [diff] [blame] | 147 | * |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 148 | * @return a treatment builder. |
| 149 | */ |
| 150 | public Builder pushMpls(); |
| 151 | |
| 152 | /** |
| 153 | * Pops MPLS ether type. |
Thomas Vachuska | f4df005 | 2015-01-06 12:30:11 -0800 | [diff] [blame] | 154 | * |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 155 | * @return a treatment builder. |
| 156 | */ |
| 157 | public Builder popMpls(); |
| 158 | |
| 159 | /** |
Michele Santuari | 4b6019e | 2014-12-19 11:31:45 +0100 | [diff] [blame] | 160 | * Pops MPLS ether type and set the new ethertype. |
sangho | 3f97a17d | 2015-01-29 22:56:29 -0800 | [diff] [blame] | 161 | * |
Michele Santuari | 4b6019e | 2014-12-19 11:31:45 +0100 | [diff] [blame] | 162 | * @param etherType an ether type |
sangho | 3f97a17d | 2015-01-29 22:56:29 -0800 | [diff] [blame] | 163 | * @return a treatment builder. |
| 164 | */ |
Michele Santuari | 4b6019e | 2014-12-19 11:31:45 +0100 | [diff] [blame] | 165 | public Builder popMpls(Short etherType); |
sangho | 3f97a17d | 2015-01-29 22:56:29 -0800 | [diff] [blame] | 166 | |
| 167 | /** |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 168 | * Sets the mpls label. |
Thomas Vachuska | f4df005 | 2015-01-06 12:30:11 -0800 | [diff] [blame] | 169 | * |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 170 | * @param mplsLabel MPLS label. |
| 171 | * @return a treatment builder. |
| 172 | */ |
Michele Santuari | 4b6019e | 2014-12-19 11:31:45 +0100 | [diff] [blame] | 173 | public Builder setMpls(MplsLabel mplsLabel); |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 174 | |
| 175 | /** |
sangho | 3f97a17d | 2015-01-29 22:56:29 -0800 | [diff] [blame] | 176 | * Decrement MPLS TTL. |
| 177 | * |
| 178 | * @return a treatment builder |
| 179 | */ |
| 180 | public Builder decMplsTtl(); |
| 181 | |
| 182 | /** |
Marc De Leenheer | 4908775 | 2014-10-23 13:54:09 -0700 | [diff] [blame] | 183 | * Sets the optical channel ID or lambda. |
Sho SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 184 | * |
Marc De Leenheer | 4908775 | 2014-10-23 13:54:09 -0700 | [diff] [blame] | 185 | * @param lambda optical channel ID |
| 186 | * @return a treatment builder |
| 187 | */ |
| 188 | public Builder setLambda(short lambda); |
| 189 | |
| 190 | /** |
sangho | 8995ac5 | 2015-02-04 11:29:03 -0800 | [diff] [blame] | 191 | * Sets the group ID. |
| 192 | * |
| 193 | * @param groupId group ID |
| 194 | * @return a treatment builder |
| 195 | */ |
| 196 | public Builder group(GroupId groupId); |
| 197 | |
alshabib | 9af7007 | 2015-02-09 14:34:16 -0800 | [diff] [blame] | 198 | |
| 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 | |
sangho | 8995ac5 | 2015-02-04 11:29:03 -0800 | [diff] [blame] | 207 | /** |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 208 | * Builds an immutable traffic treatment descriptor. |
| 209 | * |
| 210 | * @return traffic treatment |
| 211 | */ |
| 212 | TrafficTreatment build(); |
Michele Santuari | 4b6019e | 2014-12-19 11:31:45 +0100 | [diff] [blame] | 213 | |
| 214 | |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 215 | } |
| 216 | |
| 217 | } |