Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | * or more contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. The ASF licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 19 | package org.onlab.onos.net.flow; |
| 20 | |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 21 | import java.util.Set; |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 22 | |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 23 | import org.onlab.onos.net.PortNumber; |
alshabib | 7410fea | 2014-09-16 13:48:39 -0700 | [diff] [blame] | 24 | import org.onlab.onos.net.flow.criteria.Criterion; |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 25 | import org.onlab.packet.IpPrefix; |
| 26 | import org.onlab.packet.MacAddress; |
| 27 | import org.onlab.packet.VlanId; |
alshabib | 7410fea | 2014-09-16 13:48:39 -0700 | [diff] [blame] | 28 | |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 29 | /** |
| 30 | * Abstraction of a slice of network traffic. |
| 31 | */ |
| 32 | public interface TrafficSelector { |
| 33 | |
| 34 | /** |
| 35 | * Returns selection criteria as an ordered list. |
| 36 | * |
| 37 | * @return list of criteria |
| 38 | */ |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 39 | Set<Criterion> criteria(); |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 40 | |
| 41 | /** |
Jonathan Hart | 936c49d | 2014-10-23 16:38:59 -0700 | [diff] [blame] | 42 | * Returns the selection criterion for a particular type, if it exists in |
| 43 | * this traffic selector. |
| 44 | * |
| 45 | * @param type criterion type to look up |
| 46 | * @return the criterion of the specified type if one exists, otherwise null |
| 47 | */ |
| 48 | Criterion getCriterion(Criterion.Type type); |
| 49 | |
| 50 | /** |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 51 | * Builder of traffic selector entities. |
| 52 | */ |
| 53 | public interface Builder { |
| 54 | |
| 55 | /** |
| 56 | * Adds a traffic selection criterion. If a same type criterion has |
| 57 | * already been added, it will be replaced by this one. |
| 58 | * |
| 59 | * @param criterion new criterion |
alshabib | 369d294 | 2014-09-12 17:59:35 -0700 | [diff] [blame] | 60 | * @return self |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 61 | */ |
alshabib | 369d294 | 2014-09-12 17:59:35 -0700 | [diff] [blame] | 62 | Builder add(Criterion criterion); |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 63 | |
| 64 | /** |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 65 | * Matches an inport. |
| 66 | * @param port the inport |
| 67 | * @return a selection builder |
| 68 | */ |
| 69 | public Builder matchInport(PortNumber port); |
| 70 | |
| 71 | /** |
| 72 | * Matches a l2 src address. |
| 73 | * @param addr a l2 address |
| 74 | * @return a selection builder |
| 75 | */ |
| 76 | public Builder matchEthSrc(MacAddress addr); |
| 77 | |
| 78 | /** |
| 79 | * Matches a l2 dst address. |
| 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. |
| 87 | * @param ethType an ethernet type |
| 88 | * @return a selection builder |
| 89 | */ |
| 90 | public Builder matchEthType(short ethType); |
| 91 | |
| 92 | /** |
| 93 | * Matches the vlan id. |
| 94 | * @param vlanId a vlan id |
| 95 | * @return a selection builder |
| 96 | */ |
| 97 | public Builder matchVlanId(VlanId vlanId); |
| 98 | |
| 99 | /** |
| 100 | * Matches a vlan priority. |
| 101 | * @param vlanPcp a vlan priority |
| 102 | * @return a selection builder |
| 103 | */ |
| 104 | public Builder matchVlanPcp(Byte vlanPcp); |
| 105 | |
| 106 | /** |
| 107 | * Matches the l3 protocol. |
| 108 | * @param proto a l3 protocol |
| 109 | * @return a selection builder |
| 110 | */ |
| 111 | public Builder matchIPProtocol(Byte proto); |
| 112 | |
| 113 | /** |
| 114 | * Matches a l3 address. |
| 115 | * @param ip a l3 address |
| 116 | * @return a selection builder |
| 117 | */ |
| 118 | public Builder matchIPSrc(IpPrefix ip); |
| 119 | |
| 120 | /** |
| 121 | * Matches a l3 address. |
| 122 | * @param ip a l3 address |
| 123 | * @return a selection builder |
| 124 | */ |
| 125 | public Builder matchIPDst(IpPrefix ip); |
| 126 | |
| 127 | /** |
Toshio Koide | 9c44c9a | 2014-10-09 11:44:36 -0700 | [diff] [blame] | 128 | * Matches a TCP source port number. |
| 129 | * @param tcpPort a TCP source port number |
| 130 | * @return a selection builder |
| 131 | */ |
| 132 | public Builder matchTcpSrc(Short tcpPort); |
| 133 | |
| 134 | /** |
| 135 | * Matches a TCP destination port number. |
| 136 | * @param tcpPort a TCP destination port number |
| 137 | * @return a selection builder |
| 138 | */ |
| 139 | public Builder matchTcpDst(Short tcpPort); |
| 140 | |
| 141 | /** |
Marc De Leenheer | 4908775 | 2014-10-23 13:54:09 -0700 | [diff] [blame] | 142 | * Matches an optical signal ID or lambda. |
| 143 | * @param lambda |
| 144 | * @return a selection builder |
| 145 | */ |
Praseed Balakrishnan | 64369da | 2014-10-23 15:55:20 -0700 | [diff] [blame] | 146 | public Builder matchLambda(Short lambda); |
| 147 | |
| 148 | /** |
| 149 | * Matches an optical Signal Type. |
| 150 | * @param signalType |
| 151 | * @return a selection builder |
| 152 | */ |
| 153 | public Builder matchOpticalSignalType(Byte signalType); |
Marc De Leenheer | 4908775 | 2014-10-23 13:54:09 -0700 | [diff] [blame] | 154 | |
| 155 | /** |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 156 | * Builds an immutable traffic selector. |
| 157 | * |
| 158 | * @return traffic selector |
| 159 | */ |
| 160 | TrafficSelector build(); |
| 161 | } |
| 162 | |
| 163 | } |