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 | */ |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 16 | package org.onlab.onos.net.flow; |
| 17 | |
| 18 | import java.util.List; |
| 19 | |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 20 | import org.onlab.onos.net.PortNumber; |
alshabib | 55a55d9 | 2014-09-16 11:59:31 -0700 | [diff] [blame] | 21 | import org.onlab.onos.net.flow.instructions.Instruction; |
Pavlin Radoslavov | 855ea2d | 2014-10-30 15:32:39 -0700 | [diff] [blame] | 22 | import org.onlab.packet.IpAddress; |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 23 | import org.onlab.packet.MacAddress; |
| 24 | import org.onlab.packet.VlanId; |
alshabib | 55a55d9 | 2014-09-16 11:59:31 -0700 | [diff] [blame] | 25 | |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 26 | /** |
| 27 | * Abstraction of network traffic treatment. |
| 28 | */ |
| 29 | public interface TrafficTreatment { |
| 30 | |
| 31 | /** |
| 32 | * Returns list of instructions on how to treat traffic. |
| 33 | * |
| 34 | * @return list of treatment instructions |
| 35 | */ |
| 36 | List<Instruction> instructions(); |
| 37 | |
| 38 | /** |
| 39 | * Builder of traffic treatment entities. |
| 40 | */ |
| 41 | public interface Builder { |
| 42 | |
| 43 | /** |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 44 | * Adds an instruction to the builder. |
Sho SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 45 | * |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 46 | * @param instruction an instruction |
| 47 | * @return a treatment builder |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 48 | */ |
alshabib | 369d294 | 2014-09-12 17:59:35 -0700 | [diff] [blame] | 49 | Builder add(Instruction instruction); |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 50 | |
| 51 | /** |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 52 | * Adds a drop instruction and does not return a builder. |
| 53 | */ |
| 54 | public void drop(); |
| 55 | |
| 56 | /** |
| 57 | * Set the output port. |
Sho SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 58 | * |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 59 | * @param number the out port |
| 60 | * @return a treatment builder |
| 61 | */ |
| 62 | public Builder setOutput(PortNumber number); |
| 63 | |
| 64 | /** |
| 65 | * Sets the src l2 address. |
Sho SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 66 | * |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 67 | * @param addr a macaddress |
| 68 | * @return a treatment builder |
| 69 | */ |
| 70 | public Builder setEthSrc(MacAddress addr); |
| 71 | |
| 72 | /** |
| 73 | * Sets the dst l2 address. |
Sho SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 74 | * |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 75 | * @param addr a macaddress |
| 76 | * @return a treatment builder |
| 77 | */ |
| 78 | public Builder setEthDst(MacAddress addr); |
| 79 | |
| 80 | /** |
| 81 | * Sets the vlan id. |
Sho SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 82 | * |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 83 | * @param id a vlanid |
| 84 | * @return a treatment builder |
| 85 | */ |
| 86 | public Builder setVlanId(VlanId id); |
| 87 | |
| 88 | /** |
| 89 | * Sets the vlan priority. |
Sho SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 90 | * |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 91 | * @param pcp a vlan priority |
| 92 | * @return a treatment builder |
| 93 | */ |
| 94 | public Builder setVlanPcp(Byte pcp); |
| 95 | |
| 96 | /** |
| 97 | * Sets the src l3 address. |
Sho SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 98 | * |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 99 | * @param addr an ip |
| 100 | * @return a treatment builder |
| 101 | */ |
Pavlin Radoslavov | 855ea2d | 2014-10-30 15:32:39 -0700 | [diff] [blame] | 102 | public Builder setIpSrc(IpAddress addr); |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 103 | |
| 104 | /** |
| 105 | * Sets the dst l3 address. |
Sho SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 106 | * |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 107 | * @param addr an ip |
| 108 | * @return a treatment builder |
| 109 | */ |
Pavlin Radoslavov | 855ea2d | 2014-10-30 15:32:39 -0700 | [diff] [blame] | 110 | public Builder setIpDst(IpAddress addr); |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 111 | |
| 112 | /** |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 113 | * Push MPLS ether type. |
| 114 | * @return a treatment builder. |
| 115 | */ |
| 116 | public Builder pushMpls(); |
| 117 | |
| 118 | /** |
| 119 | * Pops MPLS ether type. |
| 120 | * @return a treatment builder. |
| 121 | */ |
| 122 | public Builder popMpls(); |
| 123 | |
| 124 | /** |
| 125 | * Sets the mpls label. |
| 126 | * @param mplsLabel MPLS label. |
| 127 | * @return a treatment builder. |
| 128 | */ |
| 129 | public Builder setMpls(Integer mplsLabel); |
| 130 | |
| 131 | /** |
Marc De Leenheer | 4908775 | 2014-10-23 13:54:09 -0700 | [diff] [blame] | 132 | * Sets the optical channel ID or lambda. |
Sho SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 133 | * |
Marc De Leenheer | 4908775 | 2014-10-23 13:54:09 -0700 | [diff] [blame] | 134 | * @param lambda optical channel ID |
| 135 | * @return a treatment builder |
| 136 | */ |
| 137 | public Builder setLambda(short lambda); |
| 138 | |
| 139 | /** |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 140 | * Builds an immutable traffic treatment descriptor. |
| 141 | * |
| 142 | * @return traffic treatment |
| 143 | */ |
| 144 | TrafficTreatment build(); |
| 145 | } |
| 146 | |
| 147 | } |