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; |
| 22 | import org.onosproject.net.flow.instructions.Instruction; |
Pavlin Radoslavov | 855ea2d | 2014-10-30 15:32:39 -0700 | [diff] [blame] | 23 | import org.onlab.packet.IpAddress; |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 24 | import org.onlab.packet.MacAddress; |
| 25 | import org.onlab.packet.VlanId; |
alshabib | 55a55d9 | 2014-09-16 11:59:31 -0700 | [diff] [blame] | 26 | |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 27 | /** |
| 28 | * Abstraction of network traffic treatment. |
| 29 | */ |
| 30 | public 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 | /** |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 45 | * Adds an instruction to the builder. |
Sho SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 46 | * |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 47 | * @param instruction an instruction |
| 48 | * @return a treatment builder |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 49 | */ |
alshabib | 369d294 | 2014-09-12 17:59:35 -0700 | [diff] [blame] | 50 | Builder add(Instruction instruction); |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 51 | |
| 52 | /** |
Thomas Vachuska | f4df005 | 2015-01-06 12:30:11 -0800 | [diff] [blame] | 53 | * Adds a drop instruction. |
| 54 | * |
| 55 | * @return a treatment builder |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 56 | */ |
Thomas Vachuska | f4df005 | 2015-01-06 12:30:11 -0800 | [diff] [blame] | 57 | public Builder drop(); |
| 58 | |
| 59 | /** |
| 60 | * Adds a punt-to-controller instruction. |
| 61 | * |
| 62 | * @return a treatment builder |
| 63 | */ |
| 64 | public Builder punt(); |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 65 | |
| 66 | /** |
| 67 | * Set the output port. |
Sho SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 68 | * |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 69 | * @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 SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 76 | * |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 77 | * @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 SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 84 | * |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 85 | * @param addr a macaddress |
| 86 | * @return a treatment builder |
| 87 | */ |
| 88 | public Builder setEthDst(MacAddress addr); |
| 89 | |
| 90 | /** |
| 91 | * Sets the vlan id. |
Sho SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 92 | * |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 93 | * @param id a vlanid |
| 94 | * @return a treatment builder |
| 95 | */ |
| 96 | public Builder setVlanId(VlanId id); |
| 97 | |
| 98 | /** |
| 99 | * Sets the vlan priority. |
Sho SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 100 | * |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 101 | * @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 SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 108 | * |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 109 | * @param addr an ip |
| 110 | * @return a treatment builder |
| 111 | */ |
Pavlin Radoslavov | 855ea2d | 2014-10-30 15:32:39 -0700 | [diff] [blame] | 112 | public Builder setIpSrc(IpAddress addr); |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 113 | |
| 114 | /** |
| 115 | * Sets the dst l3 address. |
Sho SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 116 | * |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 117 | * @param addr an ip |
| 118 | * @return a treatment builder |
| 119 | */ |
Pavlin Radoslavov | 855ea2d | 2014-10-30 15:32:39 -0700 | [diff] [blame] | 120 | public Builder setIpDst(IpAddress addr); |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 121 | |
| 122 | /** |
sangho | 3f97a17d | 2015-01-29 22:56:29 -0800 | [diff] [blame] | 123 | * 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 Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 144 | * Push MPLS ether type. |
Thomas Vachuska | f4df005 | 2015-01-06 12:30:11 -0800 | [diff] [blame] | 145 | * |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 146 | * @return a treatment builder. |
| 147 | */ |
| 148 | public Builder pushMpls(); |
| 149 | |
| 150 | /** |
| 151 | * Pops MPLS ether type. |
Thomas Vachuska | f4df005 | 2015-01-06 12:30:11 -0800 | [diff] [blame] | 152 | * |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 153 | * @return a treatment builder. |
| 154 | */ |
| 155 | public Builder popMpls(); |
| 156 | |
| 157 | /** |
sangho | 3f97a17d | 2015-01-29 22:56:29 -0800 | [diff] [blame] | 158 | * 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 Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 166 | * Sets the mpls label. |
Thomas Vachuska | f4df005 | 2015-01-06 12:30:11 -0800 | [diff] [blame] | 167 | * |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 168 | * @param mplsLabel MPLS label. |
| 169 | * @return a treatment builder. |
| 170 | */ |
| 171 | public Builder setMpls(Integer mplsLabel); |
| 172 | |
| 173 | /** |
sangho | 3f97a17d | 2015-01-29 22:56:29 -0800 | [diff] [blame] | 174 | * Decrement MPLS TTL. |
| 175 | * |
| 176 | * @return a treatment builder |
| 177 | */ |
| 178 | public Builder decMplsTtl(); |
| 179 | |
| 180 | /** |
Marc De Leenheer | 4908775 | 2014-10-23 13:54:09 -0700 | [diff] [blame] | 181 | * Sets the optical channel ID or lambda. |
Sho SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 182 | * |
Marc De Leenheer | 4908775 | 2014-10-23 13:54:09 -0700 | [diff] [blame] | 183 | * @param lambda optical channel ID |
| 184 | * @return a treatment builder |
| 185 | */ |
| 186 | public Builder setLambda(short lambda); |
| 187 | |
| 188 | /** |
sangho | 8995ac5 | 2015-02-04 11:29:03 -0800 | [diff] [blame] | 189 | * Sets the group ID. |
| 190 | * |
| 191 | * @param groupId group ID |
| 192 | * @return a treatment builder |
| 193 | */ |
| 194 | public Builder group(GroupId groupId); |
| 195 | |
| 196 | /** |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 197 | * Builds an immutable traffic treatment descriptor. |
| 198 | * |
| 199 | * @return traffic treatment |
| 200 | */ |
| 201 | TrafficTreatment build(); |
| 202 | } |
| 203 | |
| 204 | } |