blob: aaf0ecec315b0a57332a0a6faf4376240cfc98f2 [file] [log] [blame]
Thomas Vachuska83e090e2014-10-22 14:25:35 -07001/*
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07002 * Copyright 2014 Open Networking Laboratory
Thomas Vachuska83e090e2014-10-22 14:25:35 -07003 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07004 * 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 Vachuska83e090e2014-10-22 14:25:35 -07007 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07008 * 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 Vachuska83e090e2014-10-22 14:25:35 -070015 */
tom8bb16062014-09-12 14:47:46 -070016package org.onlab.onos.net.flow;
17
alshabibba5ac482014-10-02 17:15:20 -070018import java.util.Set;
tom8bb16062014-09-12 14:47:46 -070019
alshabib010c31d2014-09-26 10:01:12 -070020import org.onlab.onos.net.PortNumber;
alshabib7410fea2014-09-16 13:48:39 -070021import org.onlab.onos.net.flow.criteria.Criterion;
alshabib010c31d2014-09-26 10:01:12 -070022import org.onlab.packet.IpPrefix;
23import org.onlab.packet.MacAddress;
24import org.onlab.packet.VlanId;
alshabib7410fea2014-09-16 13:48:39 -070025
tom8bb16062014-09-12 14:47:46 -070026/**
27 * Abstraction of a slice of network traffic.
28 */
29public interface TrafficSelector {
30
31 /**
32 * Returns selection criteria as an ordered list.
33 *
34 * @return list of criteria
35 */
alshabibba5ac482014-10-02 17:15:20 -070036 Set<Criterion> criteria();
tom8bb16062014-09-12 14:47:46 -070037
38 /**
Jonathan Hart936c49d2014-10-23 16:38:59 -070039 * 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 /**
tom8bb16062014-09-12 14:47:46 -070048 * 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
alshabib369d2942014-09-12 17:59:35 -070057 * @return self
tom8bb16062014-09-12 14:47:46 -070058 */
alshabib369d2942014-09-12 17:59:35 -070059 Builder add(Criterion criterion);
tom8bb16062014-09-12 14:47:46 -070060
61 /**
alshabib010c31d2014-09-26 10:01:12 -070062 * Matches an inport.
63 * @param port the inport
64 * @return a selection builder
65 */
66 public Builder matchInport(PortNumber port);
67
68 /**
69 * Matches a l2 src address.
70 * @param addr a l2 address
71 * @return a selection builder
72 */
73 public Builder matchEthSrc(MacAddress addr);
74
75 /**
76 * Matches a l2 dst address.
77 * @param addr a l2 address
78 * @return a selection builder
79 */
80 public Builder matchEthDst(MacAddress addr);
81
82 /**
83 * Matches the ethernet type.
84 * @param ethType an ethernet type
85 * @return a selection builder
86 */
87 public Builder matchEthType(short ethType);
88
89 /**
90 * Matches the vlan id.
91 * @param vlanId a vlan id
92 * @return a selection builder
93 */
94 public Builder matchVlanId(VlanId vlanId);
95
96 /**
97 * Matches a vlan priority.
98 * @param vlanPcp a vlan priority
99 * @return a selection builder
100 */
101 public Builder matchVlanPcp(Byte vlanPcp);
102
103 /**
104 * Matches the l3 protocol.
105 * @param proto a l3 protocol
106 * @return a selection builder
107 */
108 public Builder matchIPProtocol(Byte proto);
109
110 /**
111 * Matches a l3 address.
112 * @param ip a l3 address
113 * @return a selection builder
114 */
115 public Builder matchIPSrc(IpPrefix ip);
116
117 /**
118 * Matches a l3 address.
119 * @param ip a l3 address
120 * @return a selection builder
121 */
122 public Builder matchIPDst(IpPrefix ip);
123
124 /**
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700125 * Matches a TCP source port number.
126 * @param tcpPort a TCP source port number
127 * @return a selection builder
128 */
129 public Builder matchTcpSrc(Short tcpPort);
130
131 /**
132 * Matches a TCP destination port number.
133 * @param tcpPort a TCP destination port number
134 * @return a selection builder
135 */
136 public Builder matchTcpDst(Short tcpPort);
137
138 /**
Marc De Leenheer49087752014-10-23 13:54:09 -0700139 * Matches an optical signal ID or lambda.
140 * @param lambda
141 * @return a selection builder
142 */
Praseed Balakrishnan64369da2014-10-23 15:55:20 -0700143 public Builder matchLambda(Short lambda);
144
145 /**
146 * Matches an optical Signal Type.
147 * @param signalType
148 * @return a selection builder
149 */
150 public Builder matchOpticalSignalType(Byte signalType);
Marc De Leenheer49087752014-10-23 13:54:09 -0700151
152 /**
tom8bb16062014-09-12 14:47:46 -0700153 * Builds an immutable traffic selector.
154 *
155 * @return traffic selector
156 */
157 TrafficSelector build();
158 }
159
160}