blob: 49815db9c5fd3095ceef9f43fc3bab154b7cddee [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 /**
42 * Builder of traffic selector entities.
43 */
44 public interface Builder {
45
46 /**
47 * Adds a traffic selection criterion. If a same type criterion has
48 * already been added, it will be replaced by this one.
49 *
50 * @param criterion new criterion
alshabib369d2942014-09-12 17:59:35 -070051 * @return self
tom8bb16062014-09-12 14:47:46 -070052 */
alshabib369d2942014-09-12 17:59:35 -070053 Builder add(Criterion criterion);
tom8bb16062014-09-12 14:47:46 -070054
55 /**
alshabib010c31d2014-09-26 10:01:12 -070056 * Matches an inport.
57 * @param port the inport
58 * @return a selection builder
59 */
60 public Builder matchInport(PortNumber port);
61
62 /**
63 * Matches a l2 src address.
64 * @param addr a l2 address
65 * @return a selection builder
66 */
67 public Builder matchEthSrc(MacAddress addr);
68
69 /**
70 * Matches a l2 dst address.
71 * @param addr a l2 address
72 * @return a selection builder
73 */
74 public Builder matchEthDst(MacAddress addr);
75
76 /**
77 * Matches the ethernet type.
78 * @param ethType an ethernet type
79 * @return a selection builder
80 */
81 public Builder matchEthType(short ethType);
82
83 /**
84 * Matches the vlan id.
85 * @param vlanId a vlan id
86 * @return a selection builder
87 */
88 public Builder matchVlanId(VlanId vlanId);
89
90 /**
91 * Matches a vlan priority.
92 * @param vlanPcp a vlan priority
93 * @return a selection builder
94 */
95 public Builder matchVlanPcp(Byte vlanPcp);
96
97 /**
98 * Matches the l3 protocol.
99 * @param proto a l3 protocol
100 * @return a selection builder
101 */
102 public Builder matchIPProtocol(Byte proto);
103
104 /**
105 * Matches a l3 address.
106 * @param ip a l3 address
107 * @return a selection builder
108 */
109 public Builder matchIPSrc(IpPrefix ip);
110
111 /**
112 * Matches a l3 address.
113 * @param ip a l3 address
114 * @return a selection builder
115 */
116 public Builder matchIPDst(IpPrefix ip);
117
118 /**
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700119 * Matches a TCP source port number.
120 * @param tcpPort a TCP source port number
121 * @return a selection builder
122 */
123 public Builder matchTcpSrc(Short tcpPort);
124
125 /**
126 * Matches a TCP destination port number.
127 * @param tcpPort a TCP destination port number
128 * @return a selection builder
129 */
130 public Builder matchTcpDst(Short tcpPort);
131
132 /**
Marc De Leenheer49087752014-10-23 13:54:09 -0700133 * Matches an optical signal ID or lambda.
134 * @param lambda
135 * @return a selection builder
136 */
137 public Builder matchLambda(short lambda);
138
139 /**
tom8bb16062014-09-12 14:47:46 -0700140 * Builds an immutable traffic selector.
141 *
142 * @return traffic selector
143 */
144 TrafficSelector build();
145 }
146
147}