blob: bcaf70c45e177595f96c2388acf53fdc4ca007df [file] [log] [blame]
Thomas Vachuska83e090e2014-10-22 14:25:35 -07001/*
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 */
tom8bb16062014-09-12 14:47:46 -070019package org.onlab.onos.net.flow;
20
alshabibba5ac482014-10-02 17:15:20 -070021import java.util.Set;
tom8bb16062014-09-12 14:47:46 -070022
alshabib010c31d2014-09-26 10:01:12 -070023import org.onlab.onos.net.PortNumber;
alshabib7410fea2014-09-16 13:48:39 -070024import org.onlab.onos.net.flow.criteria.Criterion;
alshabib010c31d2014-09-26 10:01:12 -070025import org.onlab.packet.IpPrefix;
26import org.onlab.packet.MacAddress;
27import org.onlab.packet.VlanId;
alshabib7410fea2014-09-16 13:48:39 -070028
tom8bb16062014-09-12 14:47:46 -070029/**
30 * Abstraction of a slice of network traffic.
31 */
32public interface TrafficSelector {
33
34 /**
35 * Returns selection criteria as an ordered list.
36 *
37 * @return list of criteria
38 */
alshabibba5ac482014-10-02 17:15:20 -070039 Set<Criterion> criteria();
tom8bb16062014-09-12 14:47:46 -070040
41 /**
Jonathan Hart936c49d2014-10-23 16:38:59 -070042 * 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 /**
tom8bb16062014-09-12 14:47:46 -070051 * 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
alshabib369d2942014-09-12 17:59:35 -070060 * @return self
tom8bb16062014-09-12 14:47:46 -070061 */
alshabib369d2942014-09-12 17:59:35 -070062 Builder add(Criterion criterion);
tom8bb16062014-09-12 14:47:46 -070063
64 /**
alshabib010c31d2014-09-26 10:01:12 -070065 * 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 Koide9c44c9a2014-10-09 11:44:36 -0700128 * 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 Leenheer49087752014-10-23 13:54:09 -0700142 * Matches an optical signal ID or lambda.
143 * @param lambda
144 * @return a selection builder
145 */
Praseed Balakrishnan64369da2014-10-23 15:55:20 -0700146 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 Leenheer49087752014-10-23 13:54:09 -0700154
155 /**
tom8bb16062014-09-12 14:47:46 -0700156 * Builds an immutable traffic selector.
157 *
158 * @return traffic selector
159 */
160 TrafficSelector build();
161 }
162
163}