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 | |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 20 | import org.onosproject.net.PortNumber; |
| 21 | import org.onosproject.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 | /** |
Thomas Vachuska | f4df005 | 2015-01-06 12:30:11 -0800 | [diff] [blame] | 52 | * Adds a drop instruction. |
| 53 | * |
| 54 | * @return a treatment builder |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 55 | */ |
Thomas Vachuska | f4df005 | 2015-01-06 12:30:11 -0800 | [diff] [blame] | 56 | public Builder drop(); |
| 57 | |
| 58 | /** |
| 59 | * Adds a punt-to-controller instruction. |
| 60 | * |
| 61 | * @return a treatment builder |
| 62 | */ |
| 63 | public Builder punt(); |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 64 | |
| 65 | /** |
| 66 | * Set the output port. |
Sho SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 67 | * |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 68 | * @param number the out port |
| 69 | * @return a treatment builder |
| 70 | */ |
| 71 | public Builder setOutput(PortNumber number); |
| 72 | |
| 73 | /** |
| 74 | * Sets the src l2 address. |
Sho SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 75 | * |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 76 | * @param addr a macaddress |
| 77 | * @return a treatment builder |
| 78 | */ |
| 79 | public Builder setEthSrc(MacAddress addr); |
| 80 | |
| 81 | /** |
| 82 | * Sets the dst l2 address. |
Sho SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 83 | * |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 84 | * @param addr a macaddress |
| 85 | * @return a treatment builder |
| 86 | */ |
| 87 | public Builder setEthDst(MacAddress addr); |
| 88 | |
| 89 | /** |
| 90 | * Sets the vlan id. |
Sho SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 91 | * |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 92 | * @param id a vlanid |
| 93 | * @return a treatment builder |
| 94 | */ |
| 95 | public Builder setVlanId(VlanId id); |
| 96 | |
| 97 | /** |
| 98 | * Sets the vlan priority. |
Sho SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 99 | * |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 100 | * @param pcp a vlan priority |
| 101 | * @return a treatment builder |
| 102 | */ |
| 103 | public Builder setVlanPcp(Byte pcp); |
| 104 | |
| 105 | /** |
| 106 | * Sets the src l3 address. |
Sho SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 107 | * |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 108 | * @param addr an ip |
| 109 | * @return a treatment builder |
| 110 | */ |
Pavlin Radoslavov | 855ea2d | 2014-10-30 15:32:39 -0700 | [diff] [blame] | 111 | public Builder setIpSrc(IpAddress addr); |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 112 | |
| 113 | /** |
| 114 | * Sets the dst l3 address. |
Sho SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 115 | * |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 116 | * @param addr an ip |
| 117 | * @return a treatment builder |
| 118 | */ |
Pavlin Radoslavov | 855ea2d | 2014-10-30 15:32:39 -0700 | [diff] [blame] | 119 | public Builder setIpDst(IpAddress addr); |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 120 | |
| 121 | /** |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 122 | * Push MPLS ether type. |
Thomas Vachuska | f4df005 | 2015-01-06 12:30:11 -0800 | [diff] [blame] | 123 | * |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 124 | * @return a treatment builder. |
| 125 | */ |
| 126 | public Builder pushMpls(); |
| 127 | |
| 128 | /** |
| 129 | * Pops MPLS ether type. |
Thomas Vachuska | f4df005 | 2015-01-06 12:30:11 -0800 | [diff] [blame] | 130 | * |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 131 | * @return a treatment builder. |
| 132 | */ |
| 133 | public Builder popMpls(); |
| 134 | |
| 135 | /** |
| 136 | * Sets the mpls label. |
Thomas Vachuska | f4df005 | 2015-01-06 12:30:11 -0800 | [diff] [blame] | 137 | * |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 138 | * @param mplsLabel MPLS label. |
| 139 | * @return a treatment builder. |
| 140 | */ |
| 141 | public Builder setMpls(Integer mplsLabel); |
| 142 | |
| 143 | /** |
Marc De Leenheer | 4908775 | 2014-10-23 13:54:09 -0700 | [diff] [blame] | 144 | * Sets the optical channel ID or lambda. |
Sho SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 145 | * |
Marc De Leenheer | 4908775 | 2014-10-23 13:54:09 -0700 | [diff] [blame] | 146 | * @param lambda optical channel ID |
| 147 | * @return a treatment builder |
| 148 | */ |
| 149 | public Builder setLambda(short lambda); |
| 150 | |
| 151 | /** |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 152 | * Builds an immutable traffic treatment descriptor. |
| 153 | * |
| 154 | * @return traffic treatment |
| 155 | */ |
| 156 | TrafficTreatment build(); |
| 157 | } |
| 158 | |
| 159 | } |