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 | |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 18 | import java.util.Set; |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 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.criteria.Criterion; |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 22 | import org.onlab.packet.IpPrefix; |
| 23 | import org.onlab.packet.MacAddress; |
| 24 | import org.onlab.packet.VlanId; |
alshabib | 7410fea | 2014-09-16 13:48:39 -0700 | [diff] [blame] | 25 | |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 26 | /** |
| 27 | * Abstraction of a slice of network traffic. |
| 28 | */ |
| 29 | public interface TrafficSelector { |
| 30 | |
| 31 | /** |
| 32 | * Returns selection criteria as an ordered list. |
| 33 | * |
| 34 | * @return list of criteria |
| 35 | */ |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 36 | Set<Criterion> criteria(); |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 37 | |
| 38 | /** |
Jonathan Hart | 936c49d | 2014-10-23 16:38:59 -0700 | [diff] [blame] | 39 | * Returns the selection criterion for a particular type, if it exists in |
| 40 | * this traffic selector. |
| 41 | * |
| 42 | * @param type criterion type to look up |
| 43 | * @return the criterion of the specified type if one exists, otherwise null |
| 44 | */ |
| 45 | Criterion getCriterion(Criterion.Type type); |
| 46 | |
| 47 | /** |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 48 | * Builder of traffic selector entities. |
| 49 | */ |
| 50 | public interface Builder { |
| 51 | |
| 52 | /** |
| 53 | * Adds a traffic selection criterion. If a same type criterion has |
| 54 | * already been added, it will be replaced by this one. |
| 55 | * |
| 56 | * @param criterion new criterion |
alshabib | 369d294 | 2014-09-12 17:59:35 -0700 | [diff] [blame] | 57 | * @return self |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 58 | */ |
alshabib | 369d294 | 2014-09-12 17:59:35 -0700 | [diff] [blame] | 59 | Builder add(Criterion criterion); |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 60 | |
| 61 | /** |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 62 | * Matches an inport. |
Sho SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 63 | * |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 64 | * @param port the inport |
| 65 | * @return a selection builder |
| 66 | */ |
| 67 | public Builder matchInport(PortNumber port); |
| 68 | |
| 69 | /** |
| 70 | * Matches a l2 src address. |
Sho SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 71 | * |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 72 | * @param addr a l2 address |
| 73 | * @return a selection builder |
| 74 | */ |
| 75 | public Builder matchEthSrc(MacAddress addr); |
| 76 | |
| 77 | /** |
| 78 | * Matches a l2 dst address. |
Sho SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 79 | * |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 80 | * @param addr a l2 address |
| 81 | * @return a selection builder |
| 82 | */ |
| 83 | public Builder matchEthDst(MacAddress addr); |
| 84 | |
| 85 | /** |
| 86 | * Matches the ethernet type. |
Sho SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 87 | * |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 88 | * @param ethType an ethernet type |
| 89 | * @return a selection builder |
| 90 | */ |
| 91 | public Builder matchEthType(short ethType); |
| 92 | |
| 93 | /** |
| 94 | * Matches the vlan id. |
Sho SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 95 | * |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 96 | * @param vlanId a vlan id |
| 97 | * @return a selection builder |
| 98 | */ |
| 99 | public Builder matchVlanId(VlanId vlanId); |
| 100 | |
| 101 | /** |
| 102 | * Matches a vlan priority. |
Sho SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 103 | * |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 104 | * @param vlanPcp a vlan priority |
| 105 | * @return a selection builder |
| 106 | */ |
| 107 | public Builder matchVlanPcp(Byte vlanPcp); |
| 108 | |
| 109 | /** |
| 110 | * Matches the l3 protocol. |
Sho SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 111 | * |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 112 | * @param proto a l3 protocol |
| 113 | * @return a selection builder |
| 114 | */ |
| 115 | public Builder matchIPProtocol(Byte proto); |
| 116 | |
| 117 | /** |
Charles M.C. Chan | 52fae7d | 2015-01-17 00:35:53 +0800 | [diff] [blame] | 118 | * Matches a l3 IPv4 address. |
Sho SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 119 | * |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 120 | * @param ip a l3 address |
| 121 | * @return a selection builder |
| 122 | */ |
| 123 | public Builder matchIPSrc(IpPrefix ip); |
| 124 | |
| 125 | /** |
Charles M.C. Chan | 52fae7d | 2015-01-17 00:35:53 +0800 | [diff] [blame] | 126 | * Matches a l3 IPv4 address. |
Sho SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 127 | * |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 128 | * @param ip a l3 address |
| 129 | * @return a selection builder |
| 130 | */ |
| 131 | public Builder matchIPDst(IpPrefix ip); |
| 132 | |
| 133 | /** |
Toshio Koide | 9c44c9a | 2014-10-09 11:44:36 -0700 | [diff] [blame] | 134 | * Matches a TCP source port number. |
Sho SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 135 | * |
Toshio Koide | 9c44c9a | 2014-10-09 11:44:36 -0700 | [diff] [blame] | 136 | * @param tcpPort a TCP source port number |
| 137 | * @return a selection builder |
| 138 | */ |
| 139 | public Builder matchTcpSrc(Short tcpPort); |
| 140 | |
| 141 | /** |
| 142 | * Matches a TCP destination port number. |
Sho SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 143 | * |
Toshio Koide | 9c44c9a | 2014-10-09 11:44:36 -0700 | [diff] [blame] | 144 | * @param tcpPort a TCP destination port number |
| 145 | * @return a selection builder |
| 146 | */ |
| 147 | public Builder matchTcpDst(Short tcpPort); |
| 148 | |
Charles M.C. Chan | 52fae7d | 2015-01-17 00:35:53 +0800 | [diff] [blame] | 149 | /** |
| 150 | * Matches a l3 IPv6 address. |
| 151 | * |
| 152 | * @param ip a l3 IPv6 address |
| 153 | * @return a selection builder |
| 154 | */ |
| 155 | public Builder matchIPv6Src(IpPrefix ip); |
| 156 | |
| 157 | /** |
| 158 | * Matches a l3 IPv6 address. |
| 159 | * |
| 160 | * @param ip a l3 IPv6 address |
| 161 | * @return a selection builder |
| 162 | */ |
| 163 | public Builder matchIPv6Dst(IpPrefix ip); |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 164 | |
| 165 | /** |
Kunihiro Ishiguro | 0f9aba8 | 2015-01-15 17:14:17 -0800 | [diff] [blame] | 166 | * Matches a ICMPv6 type. |
| 167 | * |
| 168 | * @param icmpv6Type a ICMPv6 type |
| 169 | * @return a selection builder |
| 170 | */ |
| 171 | public Builder matchIcmpv6Type(Byte icmpv6Type); |
| 172 | |
| 173 | /** |
| 174 | * Matches a ICMPv6 code. |
| 175 | * |
| 176 | * @param icmpv6Code a ICMPv6 code |
| 177 | * @return a selection builder |
| 178 | */ |
| 179 | public Builder matchIcmpv6Code(Byte icmpv6Code); |
| 180 | |
| 181 | /** |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 182 | * Matches on a MPLS label . |
| 183 | * @param mplsLabel a MPLS label. |
| 184 | * @return a selection builder |
| 185 | */ |
| 186 | public Builder matchMplsLabel(Integer mplsLabel); |
| 187 | |
Toshio Koide | 9c44c9a | 2014-10-09 11:44:36 -0700 | [diff] [blame] | 188 | /** |
Marc De Leenheer | 4908775 | 2014-10-23 13:54:09 -0700 | [diff] [blame] | 189 | * Matches an optical signal ID or lambda. |
Sho SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 190 | * |
Yuta HIGUCHI | 5c94727 | 2014-11-03 21:39:21 -0800 | [diff] [blame] | 191 | * @param lambda lamda |
Marc De Leenheer | 4908775 | 2014-10-23 13:54:09 -0700 | [diff] [blame] | 192 | * @return a selection builder |
| 193 | */ |
Praseed Balakrishnan | 64369da | 2014-10-23 15:55:20 -0700 | [diff] [blame] | 194 | public Builder matchLambda(Short lambda); |
| 195 | |
| 196 | /** |
| 197 | * Matches an optical Signal Type. |
Sho SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 198 | * |
Yuta HIGUCHI | 5c94727 | 2014-11-03 21:39:21 -0800 | [diff] [blame] | 199 | * @param signalType signalType |
Praseed Balakrishnan | 64369da | 2014-10-23 15:55:20 -0700 | [diff] [blame] | 200 | * @return a selection builder |
| 201 | */ |
Praseed Balakrishnan | 2dd5abd | 2014-11-03 14:56:28 -0800 | [diff] [blame] | 202 | public Builder matchOpticalSignalType(Short signalType); |
Marc De Leenheer | 4908775 | 2014-10-23 13:54:09 -0700 | [diff] [blame] | 203 | |
| 204 | /** |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 205 | * Builds an immutable traffic selector. |
| 206 | * |
| 207 | * @return traffic selector |
| 208 | */ |
| 209 | TrafficSelector build(); |
| 210 | } |
| 211 | |
| 212 | } |